index-C7KLL0cs.js 4.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684
  1. function mse(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 s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{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 s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var Gw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var cE={exports:{}},zx={};var pU;function pse(){if(pU)return zx;pU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var l in i)l!=="key"&&(s[l]=i[l])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return zx.Fragment=e,zx.jsx=n,zx.jsxs=n,zx}var gU;function gse(){return gU||(gU=1,cE.exports=pse()),cE.exports}var a=gse(),uE={exports:{}},Nn={};var bU;function bse(){if(bU)return Nn;bU=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"),s=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"),h=Symbol.for("react.activity"),p=Symbol.iterator;function m(V){return V===null||typeof V!="object"?null:(V=p&&V[p]||V["@@iterator"],typeof V=="function"?V:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function v(V,W,ie){this.props=V,this.context=W,this.refs=b,this.updater=ie||x}v.prototype.isReactComponent={},v.prototype.setState=function(V,W){if(typeof V!="object"&&typeof V!="function"&&V!=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,V,W,"setState")},v.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function S(){}S.prototype=v.prototype;function k(V,W,ie){this.props=V,this.context=W,this.refs=b,this.updater=ie||x}var E=k.prototype=new S;E.constructor=k,y(E,v.prototype),E.isPureReactComponent=!0;var N=Array.isArray;function A(){}var M={H:null,A:null,T:null,S:null},P=Object.prototype.hasOwnProperty;function T(V,W,ie){var J=ie.ref;return{$$typeof:t,type:V,key:W,ref:J!==void 0?J:null,props:ie}}function j(V,W){return T(V.type,W,V.props)}function z(V){return typeof V=="object"&&V!==null&&V.$$typeof===t}function F(V){var W={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(ie){return W[ie]})}var $=/\/+/g;function D(V,W){return typeof V=="object"&&V!==null&&V.key!=null?F(""+V.key):W.toString(36)}function H(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(A,A):(V.status="pending",V.then(function(W){V.status==="pending"&&(V.status="fulfilled",V.value=W)},function(W){V.status==="pending"&&(V.status="rejected",V.reason=W)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function q(V,W,ie,J,pe){var fe=typeof V;(fe==="undefined"||fe==="boolean")&&(V=null);var ve=!1;if(V===null)ve=!0;else switch(fe){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(V.$$typeof){case t:case e:ve=!0;break;case d:return ve=V._init,q(ve(V._payload),W,ie,J,pe)}}if(ve)return pe=pe(V),ve=J===""?"."+D(V,0):J,N(pe)?(ie="",ve!=null&&(ie=ve.replace($,"$&/")+"/"),q(pe,W,ie,"",function(ce){return ce})):pe!=null&&(z(pe)&&(pe=j(pe,ie+(pe.key==null||V&&V.key===pe.key?"":(""+pe.key).replace($,"$&/")+"/")+ve)),W.push(pe)),1;ve=0;var Le=J===""?".":J+":";if(N(V))for(var de=0;de<V.length;de++)J=V[de],fe=Le+D(J,de),ve+=q(J,W,ie,fe,pe);else if(de=m(V),typeof de=="function")for(V=de.call(V),de=0;!(J=V.next()).done;)J=J.value,fe=Le+D(J,de++),ve+=q(J,W,ie,fe,pe);else if(fe==="object"){if(typeof V.then=="function")return q(H(V),W,ie,J,pe);throw W=String(V),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return ve}function I(V,W,ie){if(V==null)return V;var J=[],pe=0;return q(V,J,"","",function(fe){return W.call(ie,fe,pe++)}),J}function K(V){if(V._status===-1){var W=V._result;W=W(),W.then(function(ie){(V._status===0||V._status===-1)&&(V._status=1,V._result=ie)},function(ie){(V._status===0||V._status===-1)&&(V._status=2,V._result=ie)}),V._status===-1&&(V._status=0,V._result=W)}if(V._status===1)return V._result.default;throw V._result}var Z=typeof reportError=="function"?reportError:function(V){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof V=="object"&&V!==null&&typeof V.message=="string"?String(V.message):String(V),error:V});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",V);return}console.error(V)},se={map:I,forEach:function(V,W,ie){I(V,function(){W.apply(this,arguments)},ie)},count:function(V){var W=0;return I(V,function(){W++}),W},toArray:function(V){return I(V,function(W){return W})||[]},only:function(V){if(!z(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return Nn.Activity=h,Nn.Children=se,Nn.Component=v,Nn.Fragment=n,Nn.Profiler=i,Nn.PureComponent=k,Nn.StrictMode=r,Nn.Suspense=c,Nn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=M,Nn.__COMPILER_RUNTIME={__proto__:null,c:function(V){return M.H.useMemoCache(V)}},Nn.cache=function(V){return function(){return V.apply(null,arguments)}},Nn.cacheSignal=function(){return null},Nn.cloneElement=function(V,W,ie){if(V==null)throw Error("The argument must be a React element, but you passed "+V+".");var J=y({},V.props),pe=V.key;if(W!=null)for(fe in W.key!==void 0&&(pe=""+W.key),W)!P.call(W,fe)||fe==="key"||fe==="__self"||fe==="__source"||fe==="ref"&&W.ref===void 0||(J[fe]=W[fe]);var fe=arguments.length-2;if(fe===1)J.children=ie;else if(1<fe){for(var ve=Array(fe),Le=0;Le<fe;Le++)ve[Le]=arguments[Le+2];J.children=ve}return T(V.type,pe,J)},Nn.createContext=function(V){return V={$$typeof:o,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null},V.Provider=V,V.Consumer={$$typeof:s,_context:V},V},Nn.createElement=function(V,W,ie){var J,pe={},fe=null;if(W!=null)for(J in W.key!==void 0&&(fe=""+W.key),W)P.call(W,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(pe[J]=W[J]);var ve=arguments.length-2;if(ve===1)pe.children=ie;else if(1<ve){for(var Le=Array(ve),de=0;de<ve;de++)Le[de]=arguments[de+2];pe.children=Le}if(V&&V.defaultProps)for(J in ve=V.defaultProps,ve)pe[J]===void 0&&(pe[J]=ve[J]);return T(V,fe,pe)},Nn.createRef=function(){return{current:null}},Nn.forwardRef=function(V){return{$$typeof:l,render:V}},Nn.isValidElement=z,Nn.lazy=function(V){return{$$typeof:d,_payload:{_status:-1,_result:V},_init:K}},Nn.memo=function(V,W){return{$$typeof:u,type:V,compare:W===void 0?null:W}},Nn.startTransition=function(V){var W=M.T,ie={};M.T=ie;try{var J=V(),pe=M.S;pe!==null&&pe(ie,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(A,Z)}catch(fe){Z(fe)}finally{W!==null&&ie.types!==null&&(W.types=ie.types),M.T=W}},Nn.unstable_useCacheRefresh=function(){return M.H.useCacheRefresh()},Nn.use=function(V){return M.H.use(V)},Nn.useActionState=function(V,W,ie){return M.H.useActionState(V,W,ie)},Nn.useCallback=function(V,W){return M.H.useCallback(V,W)},Nn.useContext=function(V){return M.H.useContext(V)},Nn.useDebugValue=function(){},Nn.useDeferredValue=function(V,W){return M.H.useDeferredValue(V,W)},Nn.useEffect=function(V,W){return M.H.useEffect(V,W)},Nn.useEffectEvent=function(V){return M.H.useEffectEvent(V)},Nn.useId=function(){return M.H.useId()},Nn.useImperativeHandle=function(V,W,ie){return M.H.useImperativeHandle(V,W,ie)},Nn.useInsertionEffect=function(V,W){return M.H.useInsertionEffect(V,W)},Nn.useLayoutEffect=function(V,W){return M.H.useLayoutEffect(V,W)},Nn.useMemo=function(V,W){return M.H.useMemo(V,W)},Nn.useOptimistic=function(V,W){return M.H.useOptimistic(V,W)},Nn.useReducer=function(V,W,ie){return M.H.useReducer(V,W,ie)},Nn.useRef=function(V){return M.H.useRef(V)},Nn.useState=function(V){return M.H.useState(V)},Nn.useSyncExternalStore=function(V,W,ie){return M.H.useSyncExternalStore(V,W,ie)},Nn.useTransition=function(){return M.H.useTransition()},Nn.version="19.2.0",Nn}var xU;function Cb(){return xU||(xU=1,uE.exports=bse()),uE.exports}var w=Cb();const ci=wl(w),xse=mse({__proto__:null,default:ci},[w]);var dE={exports:{}},Ux={},hE={exports:{}},fE={};var yU;function yse(){return yU||(yU=1,(function(t){function e(q,I){var K=q.length;q.push(I);e:for(;0<K;){var Z=K-1>>>1,se=q[Z];if(0<i(se,I))q[Z]=I,q[K]=se,K=Z;else break e}}function n(q){return q.length===0?null:q[0]}function r(q){if(q.length===0)return null;var I=q[0],K=q.pop();if(K!==I){q[0]=K;e:for(var Z=0,se=q.length,V=se>>>1;Z<V;){var W=2*(Z+1)-1,ie=q[W],J=W+1,pe=q[J];if(0>i(ie,K))J<se&&0>i(pe,ie)?(q[Z]=pe,q[J]=K,Z=J):(q[Z]=ie,q[W]=K,Z=W);else if(J<se&&0>i(pe,K))q[Z]=pe,q[J]=K,Z=J;else break e}}return I}function i(q,I){var K=q.sortIndex-I.sortIndex;return K!==0?K:q.id-I.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,h=null,p=3,m=!1,x=!1,y=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function E(q){for(var I=n(u);I!==null;){if(I.callback===null)r(u);else if(I.startTime<=q)r(u),I.sortIndex=I.expirationTime,e(c,I);else break;I=n(u)}}function N(q){if(y=!1,E(q),!x)if(n(c)!==null)x=!0,A||(A=!0,F());else{var I=n(u);I!==null&&H(N,I.startTime-q)}}var A=!1,M=-1,P=5,T=-1;function j(){return b?!0:!(t.unstable_now()-T<P)}function z(){if(b=!1,A){var q=t.unstable_now();T=q;var I=!0;try{e:{x=!1,y&&(y=!1,S(M),M=-1),m=!0;var K=p;try{t:{for(E(q),h=n(c);h!==null&&!(h.expirationTime>q&&j());){var Z=h.callback;if(typeof Z=="function"){h.callback=null,p=h.priorityLevel;var se=Z(h.expirationTime<=q);if(q=t.unstable_now(),typeof se=="function"){h.callback=se,E(q),I=!0;break t}h===n(c)&&r(c),E(q)}else r(c);h=n(c)}if(h!==null)I=!0;else{var V=n(u);V!==null&&H(N,V.startTime-q),I=!1}}break e}finally{h=null,p=K,m=!1}I=void 0}}finally{I?F():A=!1}}}var F;if(typeof k=="function")F=function(){k(z)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,D=$.port2;$.port1.onmessage=z,F=function(){D.postMessage(null)}}else F=function(){v(z,0)};function H(q,I){M=v(function(){q(t.unstable_now())},I)}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(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<q?Math.floor(1e3/q):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(q){switch(p){case 1:case 2:case 3:var I=3;break;default:I=p}var K=p;p=I;try{return q()}finally{p=K}},t.unstable_requestPaint=function(){b=!0},t.unstable_runWithPriority=function(q,I){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var K=p;p=q;try{return I()}finally{p=K}},t.unstable_scheduleCallback=function(q,I,K){var Z=t.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?Z+K:Z):K=Z,q){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=K+se,q={id:d++,callback:I,priorityLevel:q,startTime:K,expirationTime:se,sortIndex:-1},K>Z?(q.sortIndex=K,e(u,q),n(c)===null&&q===n(u)&&(y?(S(M),M=-1):y=!0,H(N,K-Z))):(q.sortIndex=se,e(c,q),x||m||(x=!0,A||(A=!0,F()))),q},t.unstable_shouldYield=j,t.unstable_wrapCallback=function(q){var I=p;return function(){var K=p;p=I;try{return q.apply(this,arguments)}finally{p=K}}}})(fE)),fE}var vU;function vse(){return vU||(vU=1,hE.exports=yse()),hE.exports}var mE={exports:{}},ns={};var wU;function wse(){if(wU)return ns;wU=1;var t=Cb();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 s(c,u,d){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,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 ns.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ns.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 s(c,u,null,d)},ns.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()}},ns.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))},ns.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ns.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,h=l(d,u.crossOrigin),p=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:h,integrity:p,fetchPriority:m}):d==="script"&&r.d.X(c,{crossOrigin:h,integrity:p,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ns.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)},ns.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,h=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:h,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})}},ns.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)},ns.requestFormReset=function(c){r.d.r(c)},ns.unstable_batchedUpdates=function(c,u){return c(u)},ns.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},ns.useFormStatus=function(){return o.H.useHostTransitionStatus()},ns.version="19.2.0",ns}var _U;function nW(){if(_U)return mE.exports;_U=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(),mE.exports=wse(),mE.exports}var SU;function _se(){if(SU)return Ux;SU=1;var t=vse(),e=Cb(),n=nW();function r(f){var g="https://react.dev/errors/"+f;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)g+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+f+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(f){return!(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)}function s(f){var g=f,_=f;if(f.alternate)for(;g.return;)g=g.return;else{f=g;do g=f,(g.flags&4098)!==0&&(_=g.return),f=g.return;while(f)}return g.tag===3?_:null}function o(f){if(f.tag===13){var g=f.memoizedState;if(g===null&&(f=f.alternate,f!==null&&(g=f.memoizedState)),g!==null)return g.dehydrated}return null}function l(f){if(f.tag===31){var g=f.memoizedState;if(g===null&&(f=f.alternate,f!==null&&(g=f.memoizedState)),g!==null)return g.dehydrated}return null}function c(f){if(s(f)!==f)throw Error(r(188))}function u(f){var g=f.alternate;if(!g){if(g=s(f),g===null)throw Error(r(188));return g!==f?null:f}for(var _=f,C=g;;){var R=_.return;if(R===null)break;var O=R.alternate;if(O===null){if(C=R.return,C!==null){_=C;continue}break}if(R.child===O.child){for(O=R.child;O;){if(O===_)return c(R),f;if(O===C)return c(R),g;O=O.sibling}throw Error(r(188))}if(_.return!==C.return)_=R,C=O;else{for(var ne=!1,Se=R.child;Se;){if(Se===_){ne=!0,_=R,C=O;break}if(Se===C){ne=!0,C=R,_=O;break}Se=Se.sibling}if(!ne){for(Se=O.child;Se;){if(Se===_){ne=!0,_=O,C=R;break}if(Se===C){ne=!0,C=O,_=R;break}Se=Se.sibling}if(!ne)throw Error(r(189))}}if(_.alternate!==C)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?f:g}function d(f){var g=f.tag;if(g===5||g===26||g===27||g===6)return f;for(f=f.child;f!==null;){if(g=d(f),g!==null)return g;f=f.sibling}return null}var h=Object.assign,p=Symbol.for("react.element"),m=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"),S=Symbol.for("react.consumer"),k=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),j=Symbol.for("react.memo_cache_sentinel"),z=Symbol.iterator;function F(f){return f===null||typeof f!="object"?null:(f=z&&f[z]||f["@@iterator"],typeof f=="function"?f:null)}var $=Symbol.for("react.client.reference");function D(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===$?null:f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case y:return"Fragment";case v:return"Profiler";case b:return"StrictMode";case N:return"Suspense";case A:return"SuspenseList";case T:return"Activity"}if(typeof f=="object")switch(f.$$typeof){case x:return"Portal";case k:return f.displayName||"Context";case S:return(f._context.displayName||"Context")+".Consumer";case E:var g=f.render;return f=f.displayName,f||(f=g.displayName||g.name||"",f=f!==""?"ForwardRef("+f+")":"ForwardRef"),f;case M:return g=f.displayName||null,g!==null?g:D(f.type)||"Memo";case P:g=f._payload,f=f._init;try{return D(f(g))}catch{}}return null}var H=Array.isArray,q=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},Z=[],se=-1;function V(f){return{current:f}}function W(f){0>se||(f.current=Z[se],Z[se]=null,se--)}function ie(f,g){se++,Z[se]=f.current,f.current=g}var J=V(null),pe=V(null),fe=V(null),ve=V(null);function Le(f,g){switch(ie(fe,g),ie(pe,f),ie(J,null),g.nodeType){case 9:case 11:f=(f=g.documentElement)&&(f=f.namespaceURI)?Iz(f):0;break;default:if(f=g.tagName,g=g.namespaceURI)g=Iz(g),f=zz(g,f);else switch(f){case"svg":f=1;break;case"math":f=2;break;default:f=0}}W(J),ie(J,f)}function de(){W(J),W(pe),W(fe)}function ce(f){f.memoizedState!==null&&ie(ve,f);var g=J.current,_=zz(g,f.type);g!==_&&(ie(pe,f),ie(J,_))}function Ae(f){pe.current===f&&(W(J),W(pe)),ve.current===f&&(W(ve),Lx._currentValue=K)}var re,Ie;function G(f){if(re===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);re=g&&g[1]||"",Ie=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+re+f+Ie}var Y=!1;function ue(f,g){if(!f||Y)return"";Y=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var C={DetermineComponentFrameRoot:function(){try{if(g){var kt=function(){throw Error()};if(Object.defineProperty(kt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(kt,[])}catch(xt){var ft=xt}Reflect.construct(f,[],kt)}else{try{kt.call()}catch(xt){ft=xt}f.call(kt.prototype)}}else{try{throw Error()}catch(xt){ft=xt}(kt=f())&&typeof kt.catch=="function"&&kt.catch(function(){})}}catch(xt){if(xt&&ft&&typeof xt.stack=="string")return[xt.stack,ft.stack]}return[null,null]}};C.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var R=Object.getOwnPropertyDescriptor(C.DetermineComponentFrameRoot,"name");R&&R.configurable&&Object.defineProperty(C.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=C.DetermineComponentFrameRoot(),ne=O[0],Se=O[1];if(ne&&Se){var Be=ne.split(`
  4. `),ut=Se.split(`
  5. `);for(R=C=0;C<Be.length&&!Be[C].includes("DetermineComponentFrameRoot");)C++;for(;R<ut.length&&!ut[R].includes("DetermineComponentFrameRoot");)R++;if(C===Be.length||R===ut.length)for(C=Be.length-1,R=ut.length-1;1<=C&&0<=R&&Be[C]!==ut[R];)R--;for(;1<=C&&0<=R;C--,R--)if(Be[C]!==ut[R]){if(C!==1||R!==1)do if(C--,R--,0>R||Be[C]!==ut[R]){var vt=`
  6. `+Be[C].replace(" at new "," at ");return f.displayName&&vt.includes("<anonymous>")&&(vt=vt.replace("<anonymous>",f.displayName)),vt}while(1<=C&&0<=R);break}}}finally{Y=!1,Error.prepareStackTrace=_}return(_=f?f.displayName||f.name:"")?G(_):""}function B(f,g){switch(f.tag){case 26:case 27:case 5:return G(f.type);case 16:return G("Lazy");case 13:return f.child!==g&&g!==null?G("Suspense Fallback"):G("Suspense");case 19:return G("SuspenseList");case 0:case 15:return ue(f.type,!1);case 11:return ue(f.type.render,!1);case 1:return ue(f.type,!0);case 31:return G("Activity");default:return""}}function ee(f){try{var g="",_=null;do g+=B(f,_),_=f,f=f.return;while(f);return g}catch(C){return`
  7. Error generating stack: `+C.message+`
  8. `+C.stack}}var Q=Object.prototype.hasOwnProperty,le=t.unstable_scheduleCallback,he=t.unstable_cancelCallback,te=t.unstable_shouldYield,U=t.unstable_requestPaint,L=t.unstable_now,X=t.unstable_getCurrentPriorityLevel,ge=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,Ee=t.unstable_NormalPriority,$e=t.unstable_LowPriority,Ce=t.unstable_IdlePriority,He=t.log,Qe=t.unstable_setDisableYieldValue,xe=null,ye=null;function we(f){if(typeof He=="function"&&Qe(f),ye&&typeof ye.setStrictMode=="function")try{ye.setStrictMode(xe,f)}catch{}}var Ue=Math.clz32?Math.clz32:ke,Pe=Math.log,Ve=Math.LN2;function ke(f){return f>>>=0,f===0?32:31-(Pe(f)/Ve|0)|0}var Ze=256,je=262144,Xe=4194304;function Re(f){var g=f&42;if(g!==0)return g;switch(f&-f){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 f&261888;case 262144:case 524288:case 1048576:case 2097152:return f&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return f&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return f}}function Oe(f,g,_){var C=f.pendingLanes;if(C===0)return 0;var R=0,O=f.suspendedLanes,ne=f.pingedLanes;f=f.warmLanes;var Se=C&134217727;return Se!==0?(C=Se&~O,C!==0?R=Re(C):(ne&=Se,ne!==0?R=Re(ne):_||(_=Se&~f,_!==0&&(R=Re(_))))):(Se=C&~O,Se!==0?R=Re(Se):ne!==0?R=Re(ne):_||(_=C&~f,_!==0&&(R=Re(_)))),R===0?0:g!==0&&g!==R&&(g&O)===0&&(O=R&-R,_=g&-g,O>=_||O===32&&(_&4194048)!==0)?g:R}function Ne(f,g){return(f.pendingLanes&~(f.suspendedLanes&~f.pingedLanes)&g)===0}function Je(f,g){switch(f){case 1:case 2:case 4:case 8:case 64:return g+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return g+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function yt(){var f=Xe;return Xe<<=1,(Xe&62914560)===0&&(Xe=4194304),f}function Et(f){for(var g=[],_=0;31>_;_++)g.push(f);return g}function an(f,g){f.pendingLanes|=g,g!==268435456&&(f.suspendedLanes=0,f.pingedLanes=0,f.warmLanes=0)}function jt(f,g,_,C,R,O){var ne=f.pendingLanes;f.pendingLanes=_,f.suspendedLanes=0,f.pingedLanes=0,f.warmLanes=0,f.expiredLanes&=_,f.entangledLanes&=_,f.errorRecoveryDisabledLanes&=_,f.shellSuspendCounter=0;var Se=f.entanglements,Be=f.expirationTimes,ut=f.hiddenUpdates;for(_=ne&~_;0<_;){var vt=31-Ue(_),kt=1<<vt;Se[vt]=0,Be[vt]=-1;var ft=ut[vt];if(ft!==null)for(ut[vt]=null,vt=0;vt<ft.length;vt++){var xt=ft[vt];xt!==null&&(xt.lane&=-536870913)}_&=~kt}C!==0&&Fe(f,C,0),O!==0&&R===0&&f.tag!==0&&(f.suspendedLanes|=O&~(ne&~g))}function Fe(f,g,_){f.pendingLanes|=g,f.suspendedLanes&=~g;var C=31-Ue(g);f.entangledLanes|=g,f.entanglements[C]=f.entanglements[C]|1073741824|_&261930}function gt(f,g){var _=f.entangledLanes|=g;for(f=f.entanglements;_;){var C=31-Ue(_),R=1<<C;R&g|f[C]&g&&(f[C]|=g),_&=~R}}function Qt(f,g){var _=g&-g;return _=(_&42)!==0?1:tn(_),(_&(f.suspendedLanes|g))!==0?0:_}function tn(f){switch(f){case 2:f=1;break;case 8:f=4;break;case 32:f=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:f=128;break;case 268435456:f=134217728;break;default:f=0}return f}function un(f){return f&=-f,2<f?8<f?(f&134217727)!==0?32:268435456:8:2}function dr(){var f=I.p;return f!==0?f:(f=window.event,f===void 0?32:lU(f.type))}function gr(f,g){var _=I.p;try{return I.p=f,g()}finally{I.p=_}}var ar=Math.random().toString(36).slice(2),Xt="__reactFiber$"+ar,sr="__reactProps$"+ar,vi="__reactContainer$"+ar,Fa="__reactEvents$"+ar,De="__reactListeners$"+ar,nt="__reactHandles$"+ar,dt="__reactResources$"+ar,pt="__reactMarker$"+ar;function ot(f){delete f[Xt],delete f[sr],delete f[Fa],delete f[De],delete f[nt]}function Lt(f){var g=f[Xt];if(g)return g;for(var _=f.parentNode;_;){if(g=_[vi]||_[Xt]){if(_=g.alternate,g.child!==null||_!==null&&_.child!==null)for(f=qz(f);f!==null;){if(_=f[Xt])return _;f=qz(f)}return g}f=_,_=f.parentNode}return null}function me(f){if(f=f[Xt]||f[vi]){var g=f.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return f}return null}function ze(f){var g=f.tag;if(g===5||g===26||g===27||g===6)return f.stateNode;throw Error(r(33))}function Ke(f){var g=f[dt];return g||(g=f[dt]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function Ge(f){f[pt]=!0}var be=new Set,at={};function ht(f,g){rt(f,g),rt(f+"Capture",g)}function rt(f,g){for(at[f]=g,f=0;f<g.length;f++)be.add(g[f])}var Ct=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]*$"),Vt={},Dt={};function Tt(f){return Q.call(Dt,f)?!0:Q.call(Vt,f)?!1:Ct.test(f)?Dt[f]=!0:(Vt[f]=!0,!1)}function Jt(f,g,_){if(Tt(g))if(_===null)f.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":f.removeAttribute(g);return;case"boolean":var C=g.toLowerCase().slice(0,5);if(C!=="data-"&&C!=="aria-"){f.removeAttribute(g);return}}f.setAttribute(g,""+_)}}function Kt(f,g,_){if(_===null)f.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":f.removeAttribute(g);return}f.setAttribute(g,""+_)}}function fn(f,g,_,C){if(C===null)f.removeAttribute(_);else{switch(typeof C){case"undefined":case"function":case"symbol":case"boolean":f.removeAttribute(_);return}f.setAttributeNS(g,_,""+C)}}function Cn(f){switch(typeof f){case"bigint":case"boolean":case"number":case"string":case"undefined":return f;case"object":return f;default:return""}}function gn(f){var g=f.type;return(f=f.nodeName)&&f.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Gt(f,g,_){var C=Object.getOwnPropertyDescriptor(f.constructor.prototype,g);if(!f.hasOwnProperty(g)&&typeof C<"u"&&typeof C.get=="function"&&typeof C.set=="function"){var R=C.get,O=C.set;return Object.defineProperty(f,g,{configurable:!0,get:function(){return R.call(this)},set:function(ne){_=""+ne,O.call(this,ne)}}),Object.defineProperty(f,g,{enumerable:C.enumerable}),{getValue:function(){return _},setValue:function(ne){_=""+ne},stopTracking:function(){f._valueTracker=null,delete f[g]}}}}function mn(f){if(!f._valueTracker){var g=gn(f)?"checked":"value";f._valueTracker=Gt(f,g,""+f[g])}}function pn(f){if(!f)return!1;var g=f._valueTracker;if(!g)return!0;var _=g.getValue(),C="";return f&&(C=gn(f)?f.checked?"true":"false":f.value),f=C,f!==_?(g.setValue(f),!0):!1}function Hr(f){if(f=f||(typeof document<"u"?document:void 0),typeof f>"u")return null;try{return f.activeElement||f.body}catch{return f.body}}var Vr=/[\n"\\]/g;function Tn(f){return f.replace(Vr,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function _n(f,g,_,C,R,O,ne,Se){f.name="",ne!=null&&typeof ne!="function"&&typeof ne!="symbol"&&typeof ne!="boolean"?f.type=ne:f.removeAttribute("type"),g!=null?ne==="number"?(g===0&&f.value===""||f.value!=g)&&(f.value=""+Cn(g)):f.value!==""+Cn(g)&&(f.value=""+Cn(g)):ne!=="submit"&&ne!=="reset"||f.removeAttribute("value"),g!=null?mi(f,ne,Cn(g)):_!=null?mi(f,ne,Cn(_)):C!=null&&f.removeAttribute("value"),R==null&&O!=null&&(f.defaultChecked=!!O),R!=null&&(f.checked=R&&typeof R!="function"&&typeof R!="symbol"),Se!=null&&typeof Se!="function"&&typeof Se!="symbol"&&typeof Se!="boolean"?f.name=""+Cn(Se):f.removeAttribute("name")}function $n(f,g,_,C,R,O,ne,Se){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(f.type=O),g!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||g!=null)){mn(f);return}_=_!=null?""+Cn(_):"",g=g!=null?""+Cn(g):_,Se||g===f.value||(f.value=g),f.defaultValue=g}C=C??R,C=typeof C!="function"&&typeof C!="symbol"&&!!C,f.checked=Se?f.checked:!!C,f.defaultChecked=!!C,ne!=null&&typeof ne!="function"&&typeof ne!="symbol"&&typeof ne!="boolean"&&(f.name=ne),mn(f)}function mi(f,g,_){g==="number"&&Hr(f.ownerDocument)===f||f.defaultValue===""+_||(f.defaultValue=""+_)}function hr(f,g,_,C){if(f=f.options,g){g={};for(var R=0;R<_.length;R++)g["$"+_[R]]=!0;for(_=0;_<f.length;_++)R=g.hasOwnProperty("$"+f[_].value),f[_].selected!==R&&(f[_].selected=R),R&&C&&(f[_].defaultSelected=!0)}else{for(_=""+Cn(_),g=null,R=0;R<f.length;R++){if(f[R].value===_){f[R].selected=!0,C&&(f[R].defaultSelected=!0);return}g!==null||f[R].disabled||(g=f[R])}g!==null&&(g.selected=!0)}}function wi(f,g,_){if(g!=null&&(g=""+Cn(g),g!==f.value&&(f.value=g),_==null)){f.defaultValue!==g&&(f.defaultValue=g);return}f.defaultValue=_!=null?""+Cn(_):""}function bt(f,g,_,C){if(g==null){if(C!=null){if(_!=null)throw Error(r(92));if(H(C)){if(1<C.length)throw Error(r(93));C=C[0]}_=C}_==null&&(_=""),g=_}_=Cn(g),f.defaultValue=_,C=f.textContent,C===_&&C!==""&&C!==null&&(f.value=C),mn(f)}function Ft(f,g){if(g){var _=f.firstChild;if(_&&_===f.lastChild&&_.nodeType===3){_.nodeValue=g;return}}f.textContent=g}var Kn=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 wt(f,g,_){var C=g.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?C?f.setProperty(g,""):g==="float"?f.cssFloat="":f[g]="":C?f.setProperty(g,_):typeof _!="number"||_===0||Kn.has(g)?g==="float"?f.cssFloat=_:f[g]=(""+_).trim():f[g]=_+"px"}function rr(f,g,_){if(g!=null&&typeof g!="object")throw Error(r(62));if(f=f.style,_!=null){for(var C in _)!_.hasOwnProperty(C)||g!=null&&g.hasOwnProperty(C)||(C.indexOf("--")===0?f.setProperty(C,""):C==="float"?f.cssFloat="":f[C]="");for(var R in g)C=g[R],g.hasOwnProperty(R)&&_[R]!==C&&wt(f,R,C)}else for(var O in g)g.hasOwnProperty(O)&&wt(f,O,g[O])}function Yr(f){if(f.indexOf("-")===-1)return!1;switch(f){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 ai=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"]]),_i=/^[\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 wa(f){return _i.test(""+f)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":f}function $t(){}var bn=null;function _a(f){return f=f.target||f.srcElement||window,f.correspondingUseElement&&(f=f.correspondingUseElement),f.nodeType===3?f.parentNode:f}var si=null,Qr=null;function nc(f){var g=me(f);if(g&&(f=g.stateNode)){var _=f[sr]||null;e:switch(f=g.stateNode,g.type){case"input":if(_n(f,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),g=_.name,_.type==="radio"&&g!=null){for(_=f;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Tn(""+g)+'"][type="radio"]'),g=0;g<_.length;g++){var C=_[g];if(C!==f&&C.form===f.form){var R=C[sr]||null;if(!R)throw Error(r(90));_n(C,R.value,R.defaultValue,R.defaultValue,R.checked,R.defaultChecked,R.type,R.name)}}for(g=0;g<_.length;g++)C=_[g],C.form===f.form&&pn(C)}break e;case"textarea":wi(f,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&hr(f,!!_.multiple,g,!1)}}}var Or=!1;function Nl(f,g,_){if(Or)return f(g,_);Or=!0;try{var C=f(g);return C}finally{if(Or=!1,(si!==null||Qr!==null)&&(Sw(),si&&(g=si,f=Qr,Qr=si=null,nc(g),f)))for(g=0;g<f.length;g++)nc(f[g])}}function Oo(f,g){var _=f.stateNode;if(_===null)return null;var C=_[sr]||null;if(C===null)return null;_=C[g];e:switch(g){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(C=!C.disabled)||(f=f.type,C=!(f==="button"||f==="input"||f==="select"||f==="textarea")),f=!C;break e;default:f=!1}if(f)return null;if(_&&typeof _!="function")throw Error(r(231,g,typeof _));return _}var Sa=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),kl=!1;if(Sa)try{var Ml={};Object.defineProperty(Ml,"passive",{get:function(){kl=!0}}),window.addEventListener("test",Ml,Ml),window.removeEventListener("test",Ml,Ml)}catch{kl=!1}var Ia=null,Si=null,rc=null;function Gr(){if(rc)return rc;var f,g=Si,_=g.length,C,R="value"in Ia?Ia.value:Ia.textContent,O=R.length;for(f=0;f<_&&g[f]===R[f];f++);var ne=_-f;for(C=1;C<=ne&&g[_-C]===R[O-C];C++);return rc=R.slice(f,1<C?1-C:void 0)}function Ni(f){var g=f.keyCode;return"charCode"in f?(f=f.charCode,f===0&&g===13&&(f=13)):f=g,f===10&&(f=13),32<=f||f===13?f:0}function so(){return!0}function br(){return!1}function Xn(f){function g(_,C,R,O,ne){this._reactName=_,this._targetInst=R,this.type=C,this.nativeEvent=O,this.target=ne,this.currentTarget=null;for(var Se in f)f.hasOwnProperty(Se)&&(_=f[Se],this[Se]=_?_(O):O[Se]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?so:br,this.isPropagationStopped=br,this}return h(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=so)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=so)},persist:function(){},isPersistent:so}),g}var Cl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(f){return f.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rf=Xn(Cl),Vc=h({},Cl,{view:0,detail:0}),pd=Xn(Vc),af,sf,El,ic=h({},Vc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zn,button:0,buttons:0,relatedTarget:function(f){return f.relatedTarget===void 0?f.fromElement===f.srcElement?f.toElement:f.fromElement:f.relatedTarget},movementX:function(f){return"movementX"in f?f.movementX:(f!==El&&(El&&f.type==="mousemove"?(af=f.screenX-El.screenX,sf=f.screenY-El.screenY):sf=af=0,El=f),af)},movementY:function(f){return"movementY"in f?f.movementY:sf}}),of=Xn(ic),Lv=h({},ic,{dataTransfer:0}),Ov=Xn(Lv),Fv=h({},Vc,{relatedTarget:0}),xn=Xn(Fv),fC=h({},Cl,{animationName:0,elapsedTime:0,pseudoElement:0}),ex=Xn(fC),Iv=h({},Cl,{clipboardData:function(f){return"clipboardData"in f?f.clipboardData:window.clipboardData}}),tx=Xn(Iv),zv=h({},Cl,{data:0}),Uv=Xn(zv),Bv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},oe={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"},Mt={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zn(f){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(f):(f=Mt[f])?!!g[f]:!1}function Zn(){return zn}var Fo=h({},Vc,{key:function(f){if(f.key){var g=Bv[f.key]||f.key;if(g!=="Unidentified")return g}return f.type==="keypress"?(f=Ni(f),f===13?"Enter":String.fromCharCode(f)):f.type==="keydown"||f.type==="keyup"?oe[f.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zn,charCode:function(f){return f.type==="keypress"?Ni(f):0},keyCode:function(f){return f.type==="keydown"||f.type==="keyup"?f.keyCode:0},which:function(f){return f.type==="keypress"?Ni(f):f.type==="keydown"||f.type==="keyup"?f.keyCode:0}}),gd=Xn(Fo),vs=h({},ic,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ts=Xn(vs),mC=h({},Vc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zn}),HF=Xn(mC),Tie=h({},Cl,{propertyName:0,elapsedTime:0,pseudoElement:0}),jie=Xn(Tie),Pie=h({},ic,{deltaX:function(f){return"deltaX"in f?f.deltaX:"wheelDeltaX"in f?-f.wheelDeltaX:0},deltaY:function(f){return"deltaY"in f?f.deltaY:"wheelDeltaY"in f?-f.wheelDeltaY:"wheelDelta"in f?-f.wheelDelta:0},deltaZ:0,deltaMode:0}),Die=Xn(Pie),Rie=h({},Cl,{newState:0,oldState:0}),Lie=Xn(Rie),Oie=[9,13,27,32],pC=Sa&&"CompositionEvent"in window,nx=null;Sa&&"documentMode"in document&&(nx=document.documentMode);var Fie=Sa&&"TextEvent"in window&&!nx,VF=Sa&&(!pC||nx&&8<nx&&11>=nx),GF=" ",qF=!1;function WF(f,g){switch(f){case"keyup":return Oie.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function KF(f){return f=f.detail,typeof f=="object"&&"data"in f?f.data:null}var Zm=!1;function Iie(f,g){switch(f){case"compositionend":return KF(g);case"keypress":return g.which!==32?null:(qF=!0,GF);case"textInput":return f=g.data,f===GF&&qF?null:f;default:return null}}function zie(f,g){if(Zm)return f==="compositionend"||!pC&&WF(f,g)?(f=Gr(),rc=Si=Ia=null,Zm=!1,f):null;switch(f){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1<g.char.length)return g.char;if(g.which)return String.fromCharCode(g.which)}return null;case"compositionend":return VF&&g.locale!=="ko"?null:g.data;default:return null}}var Uie={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 XF(f){var g=f&&f.nodeName&&f.nodeName.toLowerCase();return g==="input"?!!Uie[f.type]:g==="textarea"}function YF(f,g,_,C){si?Qr?Qr.push(C):Qr=[C]:si=C,g=Tw(g,"onChange"),0<g.length&&(_=new rf("onChange","change",null,_,C),f.push({event:_,listeners:g}))}var rx=null,ix=null;function Bie(f){Pz(f,0)}function $v(f){var g=ze(f);if(pn(g))return f}function QF(f,g){if(f==="change")return g}var ZF=!1;if(Sa){var gC;if(Sa){var bC="oninput"in document;if(!bC){var JF=document.createElement("div");JF.setAttribute("oninput","return;"),bC=typeof JF.oninput=="function"}gC=bC}else gC=!1;ZF=gC&&(!document.documentMode||9<document.documentMode)}function eI(){rx&&(rx.detachEvent("onpropertychange",tI),ix=rx=null)}function tI(f){if(f.propertyName==="value"&&$v(ix)){var g=[];YF(g,ix,f,_a(f)),Nl(Bie,g)}}function $ie(f,g,_){f==="focusin"?(eI(),rx=g,ix=_,rx.attachEvent("onpropertychange",tI)):f==="focusout"&&eI()}function Hie(f){if(f==="selectionchange"||f==="keyup"||f==="keydown")return $v(ix)}function Vie(f,g){if(f==="click")return $v(g)}function Gie(f,g){if(f==="input"||f==="change")return $v(g)}function qie(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var oo=typeof Object.is=="function"?Object.is:qie;function ax(f,g){if(oo(f,g))return!0;if(typeof f!="object"||f===null||typeof g!="object"||g===null)return!1;var _=Object.keys(f),C=Object.keys(g);if(_.length!==C.length)return!1;for(C=0;C<_.length;C++){var R=_[C];if(!Q.call(g,R)||!oo(f[R],g[R]))return!1}return!0}function nI(f){for(;f&&f.firstChild;)f=f.firstChild;return f}function rI(f,g){var _=nI(f);f=0;for(var C;_;){if(_.nodeType===3){if(C=f+_.textContent.length,f<=g&&C>=g)return{node:_,offset:g-f};f=C}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=nI(_)}}function iI(f,g){return f&&g?f===g?!0:f&&f.nodeType===3?!1:g&&g.nodeType===3?iI(f,g.parentNode):"contains"in f?f.contains(g):f.compareDocumentPosition?!!(f.compareDocumentPosition(g)&16):!1:!1}function aI(f){f=f!=null&&f.ownerDocument!=null&&f.ownerDocument.defaultView!=null?f.ownerDocument.defaultView:window;for(var g=Hr(f.document);g instanceof f.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)f=g.contentWindow;else break;g=Hr(f.document)}return g}function xC(f){var g=f&&f.nodeName&&f.nodeName.toLowerCase();return g&&(g==="input"&&(f.type==="text"||f.type==="search"||f.type==="tel"||f.type==="url"||f.type==="password")||g==="textarea"||f.contentEditable==="true")}var Wie=Sa&&"documentMode"in document&&11>=document.documentMode,Jm=null,yC=null,sx=null,vC=!1;function sI(f,g,_){var C=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;vC||Jm==null||Jm!==Hr(C)||(C=Jm,"selectionStart"in C&&xC(C)?C={start:C.selectionStart,end:C.selectionEnd}:(C=(C.ownerDocument&&C.ownerDocument.defaultView||window).getSelection(),C={anchorNode:C.anchorNode,anchorOffset:C.anchorOffset,focusNode:C.focusNode,focusOffset:C.focusOffset}),sx&&ax(sx,C)||(sx=C,C=Tw(yC,"onSelect"),0<C.length&&(g=new rf("onSelect","select",null,g,_),f.push({event:g,listeners:C}),g.target=Jm)))}function lf(f,g){var _={};return _[f.toLowerCase()]=g.toLowerCase(),_["Webkit"+f]="webkit"+g,_["Moz"+f]="moz"+g,_}var ep={animationend:lf("Animation","AnimationEnd"),animationiteration:lf("Animation","AnimationIteration"),animationstart:lf("Animation","AnimationStart"),transitionrun:lf("Transition","TransitionRun"),transitionstart:lf("Transition","TransitionStart"),transitioncancel:lf("Transition","TransitionCancel"),transitionend:lf("Transition","TransitionEnd")},wC={},oI={};Sa&&(oI=document.createElement("div").style,"AnimationEvent"in window||(delete ep.animationend.animation,delete ep.animationiteration.animation,delete ep.animationstart.animation),"TransitionEvent"in window||delete ep.transitionend.transition);function cf(f){if(wC[f])return wC[f];if(!ep[f])return f;var g=ep[f],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in oI)return wC[f]=g[_];return f}var lI=cf("animationend"),cI=cf("animationiteration"),uI=cf("animationstart"),Kie=cf("transitionrun"),Xie=cf("transitionstart"),Yie=cf("transitioncancel"),dI=cf("transitionend"),hI=new Map,_C="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(" ");_C.push("scrollEnd");function Al(f,g){hI.set(f,g),ht(g,[f])}var Hv=typeof reportError=="function"?reportError:function(f){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=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(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",f);return}console.error(f)},Io=[],tp=0,SC=0;function Vv(){for(var f=tp,g=SC=tp=0;g<f;){var _=Io[g];Io[g++]=null;var C=Io[g];Io[g++]=null;var R=Io[g];Io[g++]=null;var O=Io[g];if(Io[g++]=null,C!==null&&R!==null){var ne=C.pending;ne===null?R.next=R:(R.next=ne.next,ne.next=R),C.pending=R}O!==0&&fI(_,R,O)}}function Gv(f,g,_,C){Io[tp++]=f,Io[tp++]=g,Io[tp++]=_,Io[tp++]=C,SC|=C,f.lanes|=C,f=f.alternate,f!==null&&(f.lanes|=C)}function NC(f,g,_,C){return Gv(f,g,_,C),qv(f)}function uf(f,g){return Gv(f,null,null,g),qv(f)}function fI(f,g,_){f.lanes|=_;var C=f.alternate;C!==null&&(C.lanes|=_);for(var R=!1,O=f.return;O!==null;)O.childLanes|=_,C=O.alternate,C!==null&&(C.childLanes|=_),O.tag===22&&(f=O.stateNode,f===null||f._visibility&1||(R=!0)),f=O,O=O.return;return f.tag===3?(O=f.stateNode,R&&g!==null&&(R=31-Ue(_),f=O.hiddenUpdates,C=f[R],C===null?f[R]=[g]:C.push(g),g.lane=_|536870912),O):null}function qv(f){if(50<Ex)throw Ex=0,D2=null,Error(r(185));for(var g=f.return;g!==null;)f=g,g=f.return;return f.tag===3?f.stateNode:null}var np={};function Qie(f,g,_,C){this.tag=f,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=C,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lo(f,g,_,C){return new Qie(f,g,_,C)}function kC(f){return f=f.prototype,!(!f||!f.isReactComponent)}function Gc(f,g){var _=f.alternate;return _===null?(_=lo(f.tag,g,f.key,f.mode),_.elementType=f.elementType,_.type=f.type,_.stateNode=f.stateNode,_.alternate=f,f.alternate=_):(_.pendingProps=g,_.type=f.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=f.flags&65011712,_.childLanes=f.childLanes,_.lanes=f.lanes,_.child=f.child,_.memoizedProps=f.memoizedProps,_.memoizedState=f.memoizedState,_.updateQueue=f.updateQueue,g=f.dependencies,_.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},_.sibling=f.sibling,_.index=f.index,_.ref=f.ref,_.refCleanup=f.refCleanup,_}function mI(f,g){f.flags&=65011714;var _=f.alternate;return _===null?(f.childLanes=0,f.lanes=g,f.child=null,f.subtreeFlags=0,f.memoizedProps=null,f.memoizedState=null,f.updateQueue=null,f.dependencies=null,f.stateNode=null):(f.childLanes=_.childLanes,f.lanes=_.lanes,f.child=_.child,f.subtreeFlags=0,f.deletions=null,f.memoizedProps=_.memoizedProps,f.memoizedState=_.memoizedState,f.updateQueue=_.updateQueue,f.type=_.type,g=_.dependencies,f.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),f}function Wv(f,g,_,C,R,O){var ne=0;if(C=f,typeof f=="function")kC(f)&&(ne=1);else if(typeof f=="string")ne=nse(f,_,J.current)?26:f==="html"||f==="head"||f==="body"?27:5;else e:switch(f){case T:return f=lo(31,_,g,R),f.elementType=T,f.lanes=O,f;case y:return df(_.children,R,O,g);case b:ne=8,R|=24;break;case v:return f=lo(12,_,g,R|2),f.elementType=v,f.lanes=O,f;case N:return f=lo(13,_,g,R),f.elementType=N,f.lanes=O,f;case A:return f=lo(19,_,g,R),f.elementType=A,f.lanes=O,f;default:if(typeof f=="object"&&f!==null)switch(f.$$typeof){case k:ne=10;break e;case S:ne=9;break e;case E:ne=11;break e;case M:ne=14;break e;case P:ne=16,C=null;break e}ne=29,_=Error(r(130,f===null?"null":typeof f,"")),C=null}return g=lo(ne,_,g,R),g.elementType=f,g.type=C,g.lanes=O,g}function df(f,g,_,C){return f=lo(7,f,C,g),f.lanes=_,f}function MC(f,g,_){return f=lo(6,f,null,g),f.lanes=_,f}function pI(f){var g=lo(18,null,null,0);return g.stateNode=f,g}function CC(f,g,_){return g=lo(4,f.children!==null?f.children:[],f.key,g),g.lanes=_,g.stateNode={containerInfo:f.containerInfo,pendingChildren:null,implementation:f.implementation},g}var gI=new WeakMap;function zo(f,g){if(typeof f=="object"&&f!==null){var _=gI.get(f);return _!==void 0?_:(g={value:f,source:g,stack:ee(g)},gI.set(f,g),g)}return{value:f,source:g,stack:ee(g)}}var rp=[],ip=0,Kv=null,ox=0,Uo=[],Bo=0,bd=null,ac=1,sc="";function qc(f,g){rp[ip++]=ox,rp[ip++]=Kv,Kv=f,ox=g}function bI(f,g,_){Uo[Bo++]=ac,Uo[Bo++]=sc,Uo[Bo++]=bd,bd=f;var C=ac;f=sc;var R=32-Ue(C)-1;C&=~(1<<R),_+=1;var O=32-Ue(g)+R;if(30<O){var ne=R-R%5;O=(C&(1<<ne)-1).toString(32),C>>=ne,R-=ne,ac=1<<32-Ue(g)+R|_<<R|C,sc=O+f}else ac=1<<O|_<<R|C,sc=f}function EC(f){f.return!==null&&(qc(f,1),bI(f,1,0))}function AC(f){for(;f===Kv;)Kv=rp[--ip],rp[ip]=null,ox=rp[--ip],rp[ip]=null;for(;f===bd;)bd=Uo[--Bo],Uo[Bo]=null,sc=Uo[--Bo],Uo[Bo]=null,ac=Uo[--Bo],Uo[Bo]=null}function xI(f,g){Uo[Bo++]=ac,Uo[Bo++]=sc,Uo[Bo++]=bd,ac=g.id,sc=g.overflow,bd=f}var za=null,Zr=null,Jn=!1,xd=null,$o=!1,TC=Error(r(519));function yd(f){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw lx(zo(g,f)),TC}function yI(f){var g=f.stateNode,_=f.type,C=f.memoizedProps;switch(g[Xt]=f,g[sr]=C,_){case"dialog":Vn("cancel",g),Vn("close",g);break;case"iframe":case"object":case"embed":Vn("load",g);break;case"video":case"audio":for(_=0;_<Tx.length;_++)Vn(Tx[_],g);break;case"source":Vn("error",g);break;case"img":case"image":case"link":Vn("error",g),Vn("load",g);break;case"details":Vn("toggle",g);break;case"input":Vn("invalid",g),$n(g,C.value,C.defaultValue,C.checked,C.defaultChecked,C.type,C.name,!0);break;case"select":Vn("invalid",g);break;case"textarea":Vn("invalid",g),bt(g,C.value,C.defaultValue,C.children)}_=C.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||C.suppressHydrationWarning===!0||Oz(g.textContent,_)?(C.popover!=null&&(Vn("beforetoggle",g),Vn("toggle",g)),C.onScroll!=null&&Vn("scroll",g),C.onScrollEnd!=null&&Vn("scrollend",g),C.onClick!=null&&(g.onclick=$t),g=!0):g=!1,g||yd(f,!0)}function vI(f){for(za=f.return;za;)switch(za.tag){case 5:case 31:case 13:$o=!1;return;case 27:case 3:$o=!0;return;default:za=za.return}}function ap(f){if(f!==za)return!1;if(!Jn)return vI(f),Jn=!0,!1;var g=f.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=f.type,_=!(_!=="form"&&_!=="button")||K2(f.type,f.memoizedProps)),_=!_),_&&Zr&&yd(f),vI(f),g===13){if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));Zr=Gz(f)}else if(g===31){if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));Zr=Gz(f)}else g===27?(g=Zr,Dd(f.type)?(f=J2,J2=null,Zr=f):Zr=g):Zr=za?Vo(f.stateNode.nextSibling):null;return!0}function hf(){Zr=za=null,Jn=!1}function jC(){var f=xd;return f!==null&&(Bs===null?Bs=f:Bs.push.apply(Bs,f),xd=null),f}function lx(f){xd===null?xd=[f]:xd.push(f)}var PC=V(null),ff=null,Wc=null;function vd(f,g,_){ie(PC,g._currentValue),g._currentValue=_}function Kc(f){f._currentValue=PC.current,W(PC)}function DC(f,g,_){for(;f!==null;){var C=f.alternate;if((f.childLanes&g)!==g?(f.childLanes|=g,C!==null&&(C.childLanes|=g)):C!==null&&(C.childLanes&g)!==g&&(C.childLanes|=g),f===_)break;f=f.return}}function RC(f,g,_,C){var R=f.child;for(R!==null&&(R.return=f);R!==null;){var O=R.dependencies;if(O!==null){var ne=R.child;O=O.firstContext;e:for(;O!==null;){var Se=O;O=R;for(var Be=0;Be<g.length;Be++)if(Se.context===g[Be]){O.lanes|=_,Se=O.alternate,Se!==null&&(Se.lanes|=_),DC(O.return,_,f),C||(ne=null);break e}O=Se.next}}else if(R.tag===18){if(ne=R.return,ne===null)throw Error(r(341));ne.lanes|=_,O=ne.alternate,O!==null&&(O.lanes|=_),DC(ne,_,f),ne=null}else ne=R.child;if(ne!==null)ne.return=R;else for(ne=R;ne!==null;){if(ne===f){ne=null;break}if(R=ne.sibling,R!==null){R.return=ne.return,ne=R;break}ne=ne.return}R=ne}}function sp(f,g,_,C){f=null;for(var R=g,O=!1;R!==null;){if(!O){if((R.flags&524288)!==0)O=!0;else if((R.flags&262144)!==0)break}if(R.tag===10){var ne=R.alternate;if(ne===null)throw Error(r(387));if(ne=ne.memoizedProps,ne!==null){var Se=R.type;oo(R.pendingProps.value,ne.value)||(f!==null?f.push(Se):f=[Se])}}else if(R===ve.current){if(ne=R.alternate,ne===null)throw Error(r(387));ne.memoizedState.memoizedState!==R.memoizedState.memoizedState&&(f!==null?f.push(Lx):f=[Lx])}R=R.return}f!==null&&RC(g,f,_,C),g.flags|=262144}function Xv(f){for(f=f.firstContext;f!==null;){if(!oo(f.context._currentValue,f.memoizedValue))return!0;f=f.next}return!1}function mf(f){ff=f,Wc=null,f=f.dependencies,f!==null&&(f.firstContext=null)}function Ua(f){return wI(ff,f)}function Yv(f,g){return ff===null&&mf(f),wI(f,g)}function wI(f,g){var _=g._currentValue;if(g={context:g,memoizedValue:_,next:null},Wc===null){if(f===null)throw Error(r(308));Wc=g,f.dependencies={lanes:0,firstContext:g},f.flags|=524288}else Wc=Wc.next=g;return _}var Zie=typeof AbortController<"u"?AbortController:function(){var f=[],g=this.signal={aborted:!1,addEventListener:function(_,C){f.push(C)}};this.abort=function(){g.aborted=!0,f.forEach(function(_){return _()})}},Jie=t.unstable_scheduleCallback,eae=t.unstable_NormalPriority,Hi={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function LC(){return{controller:new Zie,data:new Map,refCount:0}}function cx(f){f.refCount--,f.refCount===0&&Jie(eae,function(){f.controller.abort()})}var ux=null,OC=0,op=0,lp=null;function tae(f,g){if(ux===null){var _=ux=[];OC=0,op=z2(),lp={status:"pending",value:void 0,then:function(C){_.push(C)}}}return OC++,g.then(_I,_I),g}function _I(){if(--OC===0&&ux!==null){lp!==null&&(lp.status="fulfilled");var f=ux;ux=null,op=0,lp=null;for(var g=0;g<f.length;g++)(0,f[g])()}}function nae(f,g){var _=[],C={status:"pending",value:null,reason:null,then:function(R){_.push(R)}};return f.then(function(){C.status="fulfilled",C.value=g;for(var R=0;R<_.length;R++)(0,_[R])(g)},function(R){for(C.status="rejected",C.reason=R,R=0;R<_.length;R++)(0,_[R])(void 0)}),C}var SI=q.S;q.S=function(f,g){sz=L(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&tae(f,g),SI!==null&&SI(f,g)};var pf=V(null);function FC(){var f=pf.current;return f!==null?f:Fr.pooledCache}function Qv(f,g){g===null?ie(pf,pf.current):ie(pf,g.pool)}function NI(){var f=FC();return f===null?null:{parent:Hi._currentValue,pool:f}}var cp=Error(r(460)),IC=Error(r(474)),Zv=Error(r(542)),Jv={then:function(){}};function kI(f){return f=f.status,f==="fulfilled"||f==="rejected"}function MI(f,g,_){switch(_=f[_],_===void 0?f.push(g):_!==g&&(g.then($t,$t),g=_),g.status){case"fulfilled":return g.value;case"rejected":throw f=g.reason,EI(f),f;default:if(typeof g.status=="string")g.then($t,$t);else{if(f=Fr,f!==null&&100<f.shellSuspendCounter)throw Error(r(482));f=g,f.status="pending",f.then(function(C){if(g.status==="pending"){var R=g;R.status="fulfilled",R.value=C}},function(C){if(g.status==="pending"){var R=g;R.status="rejected",R.reason=C}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw f=g.reason,EI(f),f}throw bf=g,cp}}function gf(f){try{var g=f._init;return g(f._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(bf=_,cp):_}}var bf=null;function CI(){if(bf===null)throw Error(r(459));var f=bf;return bf=null,f}function EI(f){if(f===cp||f===Zv)throw Error(r(483))}var up=null,dx=0;function ew(f){var g=dx;return dx+=1,up===null&&(up=[]),MI(up,f,g)}function hx(f,g){g=g.props.ref,f.ref=g!==void 0?g:null}function tw(f,g){throw g.$$typeof===p?Error(r(525)):(f=Object.prototype.toString.call(g),Error(r(31,f==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":f)))}function AI(f){function g(tt,qe){if(f){var ct=tt.deletions;ct===null?(tt.deletions=[qe],tt.flags|=16):ct.push(qe)}}function _(tt,qe){if(!f)return null;for(;qe!==null;)g(tt,qe),qe=qe.sibling;return null}function C(tt){for(var qe=new Map;tt!==null;)tt.key!==null?qe.set(tt.key,tt):qe.set(tt.index,tt),tt=tt.sibling;return qe}function R(tt,qe){return tt=Gc(tt,qe),tt.index=0,tt.sibling=null,tt}function O(tt,qe,ct){return tt.index=ct,f?(ct=tt.alternate,ct!==null?(ct=ct.index,ct<qe?(tt.flags|=67108866,qe):ct):(tt.flags|=67108866,qe)):(tt.flags|=1048576,qe)}function ne(tt){return f&&tt.alternate===null&&(tt.flags|=67108866),tt}function Se(tt,qe,ct,St){return qe===null||qe.tag!==6?(qe=MC(ct,tt.mode,St),qe.return=tt,qe):(qe=R(qe,ct),qe.return=tt,qe)}function Be(tt,qe,ct,St){var nn=ct.type;return nn===y?vt(tt,qe,ct.props.children,St,ct.key):qe!==null&&(qe.elementType===nn||typeof nn=="object"&&nn!==null&&nn.$$typeof===P&&gf(nn)===qe.type)?(qe=R(qe,ct.props),hx(qe,ct),qe.return=tt,qe):(qe=Wv(ct.type,ct.key,ct.props,null,tt.mode,St),hx(qe,ct),qe.return=tt,qe)}function ut(tt,qe,ct,St){return qe===null||qe.tag!==4||qe.stateNode.containerInfo!==ct.containerInfo||qe.stateNode.implementation!==ct.implementation?(qe=CC(ct,tt.mode,St),qe.return=tt,qe):(qe=R(qe,ct.children||[]),qe.return=tt,qe)}function vt(tt,qe,ct,St,nn){return qe===null||qe.tag!==7?(qe=df(ct,tt.mode,St,nn),qe.return=tt,qe):(qe=R(qe,ct),qe.return=tt,qe)}function kt(tt,qe,ct){if(typeof qe=="string"&&qe!==""||typeof qe=="number"||typeof qe=="bigint")return qe=MC(""+qe,tt.mode,ct),qe.return=tt,qe;if(typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case m:return ct=Wv(qe.type,qe.key,qe.props,null,tt.mode,ct),hx(ct,qe),ct.return=tt,ct;case x:return qe=CC(qe,tt.mode,ct),qe.return=tt,qe;case P:return qe=gf(qe),kt(tt,qe,ct)}if(H(qe)||F(qe))return qe=df(qe,tt.mode,ct,null),qe.return=tt,qe;if(typeof qe.then=="function")return kt(tt,ew(qe),ct);if(qe.$$typeof===k)return kt(tt,Yv(tt,qe),ct);tw(tt,qe)}return null}function ft(tt,qe,ct,St){var nn=qe!==null?qe.key:null;if(typeof ct=="string"&&ct!==""||typeof ct=="number"||typeof ct=="bigint")return nn!==null?null:Se(tt,qe,""+ct,St);if(typeof ct=="object"&&ct!==null){switch(ct.$$typeof){case m:return ct.key===nn?Be(tt,qe,ct,St):null;case x:return ct.key===nn?ut(tt,qe,ct,St):null;case P:return ct=gf(ct),ft(tt,qe,ct,St)}if(H(ct)||F(ct))return nn!==null?null:vt(tt,qe,ct,St,null);if(typeof ct.then=="function")return ft(tt,qe,ew(ct),St);if(ct.$$typeof===k)return ft(tt,qe,Yv(tt,ct),St);tw(tt,ct)}return null}function xt(tt,qe,ct,St,nn){if(typeof St=="string"&&St!==""||typeof St=="number"||typeof St=="bigint")return tt=tt.get(ct)||null,Se(qe,tt,""+St,nn);if(typeof St=="object"&&St!==null){switch(St.$$typeof){case m:return tt=tt.get(St.key===null?ct:St.key)||null,Be(qe,tt,St,nn);case x:return tt=tt.get(St.key===null?ct:St.key)||null,ut(qe,tt,St,nn);case P:return St=gf(St),xt(tt,qe,ct,St,nn)}if(H(St)||F(St))return tt=tt.get(ct)||null,vt(qe,tt,St,nn,null);if(typeof St.then=="function")return xt(tt,qe,ct,ew(St),nn);if(St.$$typeof===k)return xt(tt,qe,ct,Yv(qe,St),nn);tw(qe,St)}return null}function Wt(tt,qe,ct,St){for(var nn=null,or=null,Yt=qe,An=qe=0,Qn=null;Yt!==null&&An<ct.length;An++){Yt.index>An?(Qn=Yt,Yt=null):Qn=Yt.sibling;var lr=ft(tt,Yt,ct[An],St);if(lr===null){Yt===null&&(Yt=Qn);break}f&&Yt&&lr.alternate===null&&g(tt,Yt),qe=O(lr,qe,An),or===null?nn=lr:or.sibling=lr,or=lr,Yt=Qn}if(An===ct.length)return _(tt,Yt),Jn&&qc(tt,An),nn;if(Yt===null){for(;An<ct.length;An++)Yt=kt(tt,ct[An],St),Yt!==null&&(qe=O(Yt,qe,An),or===null?nn=Yt:or.sibling=Yt,or=Yt);return Jn&&qc(tt,An),nn}for(Yt=C(Yt);An<ct.length;An++)Qn=xt(Yt,tt,An,ct[An],St),Qn!==null&&(f&&Qn.alternate!==null&&Yt.delete(Qn.key===null?An:Qn.key),qe=O(Qn,qe,An),or===null?nn=Qn:or.sibling=Qn,or=Qn);return f&&Yt.forEach(function(Id){return g(tt,Id)}),Jn&&qc(tt,An),nn}function dn(tt,qe,ct,St){if(ct==null)throw Error(r(151));for(var nn=null,or=null,Yt=qe,An=qe=0,Qn=null,lr=ct.next();Yt!==null&&!lr.done;An++,lr=ct.next()){Yt.index>An?(Qn=Yt,Yt=null):Qn=Yt.sibling;var Id=ft(tt,Yt,lr.value,St);if(Id===null){Yt===null&&(Yt=Qn);break}f&&Yt&&Id.alternate===null&&g(tt,Yt),qe=O(Id,qe,An),or===null?nn=Id:or.sibling=Id,or=Id,Yt=Qn}if(lr.done)return _(tt,Yt),Jn&&qc(tt,An),nn;if(Yt===null){for(;!lr.done;An++,lr=ct.next())lr=kt(tt,lr.value,St),lr!==null&&(qe=O(lr,qe,An),or===null?nn=lr:or.sibling=lr,or=lr);return Jn&&qc(tt,An),nn}for(Yt=C(Yt);!lr.done;An++,lr=ct.next())lr=xt(Yt,tt,An,lr.value,St),lr!==null&&(f&&lr.alternate!==null&&Yt.delete(lr.key===null?An:lr.key),qe=O(lr,qe,An),or===null?nn=lr:or.sibling=lr,or=lr);return f&&Yt.forEach(function(fse){return g(tt,fse)}),Jn&&qc(tt,An),nn}function Cr(tt,qe,ct,St){if(typeof ct=="object"&&ct!==null&&ct.type===y&&ct.key===null&&(ct=ct.props.children),typeof ct=="object"&&ct!==null){switch(ct.$$typeof){case m:e:{for(var nn=ct.key;qe!==null;){if(qe.key===nn){if(nn=ct.type,nn===y){if(qe.tag===7){_(tt,qe.sibling),St=R(qe,ct.props.children),St.return=tt,tt=St;break e}}else if(qe.elementType===nn||typeof nn=="object"&&nn!==null&&nn.$$typeof===P&&gf(nn)===qe.type){_(tt,qe.sibling),St=R(qe,ct.props),hx(St,ct),St.return=tt,tt=St;break e}_(tt,qe);break}else g(tt,qe);qe=qe.sibling}ct.type===y?(St=df(ct.props.children,tt.mode,St,ct.key),St.return=tt,tt=St):(St=Wv(ct.type,ct.key,ct.props,null,tt.mode,St),hx(St,ct),St.return=tt,tt=St)}return ne(tt);case x:e:{for(nn=ct.key;qe!==null;){if(qe.key===nn)if(qe.tag===4&&qe.stateNode.containerInfo===ct.containerInfo&&qe.stateNode.implementation===ct.implementation){_(tt,qe.sibling),St=R(qe,ct.children||[]),St.return=tt,tt=St;break e}else{_(tt,qe);break}else g(tt,qe);qe=qe.sibling}St=CC(ct,tt.mode,St),St.return=tt,tt=St}return ne(tt);case P:return ct=gf(ct),Cr(tt,qe,ct,St)}if(H(ct))return Wt(tt,qe,ct,St);if(F(ct)){if(nn=F(ct),typeof nn!="function")throw Error(r(150));return ct=nn.call(ct),dn(tt,qe,ct,St)}if(typeof ct.then=="function")return Cr(tt,qe,ew(ct),St);if(ct.$$typeof===k)return Cr(tt,qe,Yv(tt,ct),St);tw(tt,ct)}return typeof ct=="string"&&ct!==""||typeof ct=="number"||typeof ct=="bigint"?(ct=""+ct,qe!==null&&qe.tag===6?(_(tt,qe.sibling),St=R(qe,ct),St.return=tt,tt=St):(_(tt,qe),St=MC(ct,tt.mode,St),St.return=tt,tt=St),ne(tt)):_(tt,qe)}return function(tt,qe,ct,St){try{dx=0;var nn=Cr(tt,qe,ct,St);return up=null,nn}catch(Yt){if(Yt===cp||Yt===Zv)throw Yt;var or=lo(29,Yt,null,tt.mode);return or.lanes=St,or.return=tt,or}finally{}}}var xf=AI(!0),TI=AI(!1),wd=!1;function zC(f){f.updateQueue={baseState:f.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function UC(f,g){f=f.updateQueue,g.updateQueue===f&&(g.updateQueue={baseState:f.baseState,firstBaseUpdate:f.firstBaseUpdate,lastBaseUpdate:f.lastBaseUpdate,shared:f.shared,callbacks:null})}function _d(f){return{lane:f,tag:0,payload:null,callback:null,next:null}}function Sd(f,g,_){var C=f.updateQueue;if(C===null)return null;if(C=C.shared,(fr&2)!==0){var R=C.pending;return R===null?g.next=g:(g.next=R.next,R.next=g),C.pending=g,g=qv(f),fI(f,null,_),g}return Gv(f,C,g,_),qv(f)}function fx(f,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var C=g.lanes;C&=f.pendingLanes,_|=C,g.lanes=_,gt(f,_)}}function BC(f,g){var _=f.updateQueue,C=f.alternate;if(C!==null&&(C=C.updateQueue,_===C)){var R=null,O=null;if(_=_.firstBaseUpdate,_!==null){do{var ne={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};O===null?R=O=ne:O=O.next=ne,_=_.next}while(_!==null);O===null?R=O=g:O=O.next=g}else R=O=g;_={baseState:C.baseState,firstBaseUpdate:R,lastBaseUpdate:O,shared:C.shared,callbacks:C.callbacks},f.updateQueue=_;return}f=_.lastBaseUpdate,f===null?_.firstBaseUpdate=g:f.next=g,_.lastBaseUpdate=g}var $C=!1;function mx(){if($C){var f=lp;if(f!==null)throw f}}function px(f,g,_,C){$C=!1;var R=f.updateQueue;wd=!1;var O=R.firstBaseUpdate,ne=R.lastBaseUpdate,Se=R.shared.pending;if(Se!==null){R.shared.pending=null;var Be=Se,ut=Be.next;Be.next=null,ne===null?O=ut:ne.next=ut,ne=Be;var vt=f.alternate;vt!==null&&(vt=vt.updateQueue,Se=vt.lastBaseUpdate,Se!==ne&&(Se===null?vt.firstBaseUpdate=ut:Se.next=ut,vt.lastBaseUpdate=Be))}if(O!==null){var kt=R.baseState;ne=0,vt=ut=Be=null,Se=O;do{var ft=Se.lane&-536870913,xt=ft!==Se.lane;if(xt?(Yn&ft)===ft:(C&ft)===ft){ft!==0&&ft===op&&($C=!0),vt!==null&&(vt=vt.next={lane:0,tag:Se.tag,payload:Se.payload,callback:null,next:null});e:{var Wt=f,dn=Se;ft=g;var Cr=_;switch(dn.tag){case 1:if(Wt=dn.payload,typeof Wt=="function"){kt=Wt.call(Cr,kt,ft);break e}kt=Wt;break e;case 3:Wt.flags=Wt.flags&-65537|128;case 0:if(Wt=dn.payload,ft=typeof Wt=="function"?Wt.call(Cr,kt,ft):Wt,ft==null)break e;kt=h({},kt,ft);break e;case 2:wd=!0}}ft=Se.callback,ft!==null&&(f.flags|=64,xt&&(f.flags|=8192),xt=R.callbacks,xt===null?R.callbacks=[ft]:xt.push(ft))}else xt={lane:ft,tag:Se.tag,payload:Se.payload,callback:Se.callback,next:null},vt===null?(ut=vt=xt,Be=kt):vt=vt.next=xt,ne|=ft;if(Se=Se.next,Se===null){if(Se=R.shared.pending,Se===null)break;xt=Se,Se=xt.next,xt.next=null,R.lastBaseUpdate=xt,R.shared.pending=null}}while(!0);vt===null&&(Be=kt),R.baseState=Be,R.firstBaseUpdate=ut,R.lastBaseUpdate=vt,O===null&&(R.shared.lanes=0),Ed|=ne,f.lanes=ne,f.memoizedState=kt}}function jI(f,g){if(typeof f!="function")throw Error(r(191,f));f.call(g)}function PI(f,g){var _=f.callbacks;if(_!==null)for(f.callbacks=null,f=0;f<_.length;f++)jI(_[f],g)}var dp=V(null),nw=V(0);function DI(f,g){f=ru,ie(nw,f),ie(dp,g),ru=f|g.baseLanes}function HC(){ie(nw,ru),ie(dp,dp.current)}function VC(){ru=nw.current,W(dp),W(nw)}var co=V(null),Ho=null;function Nd(f){var g=f.alternate;ie(Li,Li.current&1),ie(co,f),Ho===null&&(g===null||dp.current!==null||g.memoizedState!==null)&&(Ho=f)}function GC(f){ie(Li,Li.current),ie(co,f),Ho===null&&(Ho=f)}function RI(f){f.tag===22?(ie(Li,Li.current),ie(co,f),Ho===null&&(Ho=f)):kd()}function kd(){ie(Li,Li.current),ie(co,co.current)}function uo(f){W(co),Ho===f&&(Ho=null),W(Li)}var Li=V(0);function rw(f){for(var g=f;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||Q2(_)||Z2(_)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===f)break;for(;g.sibling===null;){if(g.return===null||g.return===f)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var Xc=0,En=null,kr=null,Vi=null,iw=!1,hp=!1,yf=!1,aw=0,gx=0,fp=null,rae=0;function ki(){throw Error(r(321))}function qC(f,g){if(g===null)return!1;for(var _=0;_<g.length&&_<f.length;_++)if(!oo(f[_],g[_]))return!1;return!0}function WC(f,g,_,C,R,O){return Xc=O,En=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,q.H=f===null||f.memoizedState===null?b5:l2,yf=!1,O=_(C,R),yf=!1,hp&&(O=OI(g,_,C,R)),LI(f),O}function LI(f){q.H=yx;var g=kr!==null&&kr.next!==null;if(Xc=0,Vi=kr=En=null,iw=!1,gx=0,fp=null,g)throw Error(r(300));f===null||Gi||(f=f.dependencies,f!==null&&Xv(f)&&(Gi=!0))}function OI(f,g,_,C){En=f;var R=0;do{if(hp&&(fp=null),gx=0,hp=!1,25<=R)throw Error(r(301));if(R+=1,Vi=kr=null,f.updateQueue!=null){var O=f.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}q.H=x5,O=g(_,C)}while(hp);return O}function iae(){var f=q.H,g=f.useState()[0];return g=typeof g.then=="function"?bx(g):g,f=f.useState()[0],(kr!==null?kr.memoizedState:null)!==f&&(En.flags|=1024),g}function KC(){var f=aw!==0;return aw=0,f}function XC(f,g,_){g.updateQueue=f.updateQueue,g.flags&=-2053,f.lanes&=~_}function YC(f){if(iw){for(f=f.memoizedState;f!==null;){var g=f.queue;g!==null&&(g.pending=null),f=f.next}iw=!1}Xc=0,Vi=kr=En=null,hp=!1,gx=aw=0,fp=null}function ws(){var f={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Vi===null?En.memoizedState=Vi=f:Vi=Vi.next=f,Vi}function Oi(){if(kr===null){var f=En.alternate;f=f!==null?f.memoizedState:null}else f=kr.next;var g=Vi===null?En.memoizedState:Vi.next;if(g!==null)Vi=g,kr=f;else{if(f===null)throw En.alternate===null?Error(r(467)):Error(r(310));kr=f,f={memoizedState:kr.memoizedState,baseState:kr.baseState,baseQueue:kr.baseQueue,queue:kr.queue,next:null},Vi===null?En.memoizedState=Vi=f:Vi=Vi.next=f}return Vi}function sw(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function bx(f){var g=gx;return gx+=1,fp===null&&(fp=[]),f=MI(fp,f,g),g=En,(Vi===null?g.memoizedState:Vi.next)===null&&(g=g.alternate,q.H=g===null||g.memoizedState===null?b5:l2),f}function ow(f){if(f!==null&&typeof f=="object"){if(typeof f.then=="function")return bx(f);if(f.$$typeof===k)return Ua(f)}throw Error(r(438,String(f)))}function QC(f){var g=null,_=En.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var C=En.alternate;C!==null&&(C=C.updateQueue,C!==null&&(C=C.memoCache,C!=null&&(g={data:C.data.map(function(R){return R.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),_===null&&(_=sw(),En.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(f),C=0;C<f;C++)_[C]=j;return g.index++,_}function Yc(f,g){return typeof g=="function"?g(f):g}function lw(f){var g=Oi();return ZC(g,kr,f)}function ZC(f,g,_){var C=f.queue;if(C===null)throw Error(r(311));C.lastRenderedReducer=_;var R=f.baseQueue,O=C.pending;if(O!==null){if(R!==null){var ne=R.next;R.next=O.next,O.next=ne}g.baseQueue=R=O,C.pending=null}if(O=f.baseState,R===null)f.memoizedState=O;else{g=R.next;var Se=ne=null,Be=null,ut=g,vt=!1;do{var kt=ut.lane&-536870913;if(kt!==ut.lane?(Yn&kt)===kt:(Xc&kt)===kt){var ft=ut.revertLane;if(ft===0)Be!==null&&(Be=Be.next={lane:0,revertLane:0,gesture:null,action:ut.action,hasEagerState:ut.hasEagerState,eagerState:ut.eagerState,next:null}),kt===op&&(vt=!0);else if((Xc&ft)===ft){ut=ut.next,ft===op&&(vt=!0);continue}else kt={lane:0,revertLane:ut.revertLane,gesture:null,action:ut.action,hasEagerState:ut.hasEagerState,eagerState:ut.eagerState,next:null},Be===null?(Se=Be=kt,ne=O):Be=Be.next=kt,En.lanes|=ft,Ed|=ft;kt=ut.action,yf&&_(O,kt),O=ut.hasEagerState?ut.eagerState:_(O,kt)}else ft={lane:kt,revertLane:ut.revertLane,gesture:ut.gesture,action:ut.action,hasEagerState:ut.hasEagerState,eagerState:ut.eagerState,next:null},Be===null?(Se=Be=ft,ne=O):Be=Be.next=ft,En.lanes|=kt,Ed|=kt;ut=ut.next}while(ut!==null&&ut!==g);if(Be===null?ne=O:Be.next=Se,!oo(O,f.memoizedState)&&(Gi=!0,vt&&(_=lp,_!==null)))throw _;f.memoizedState=O,f.baseState=ne,f.baseQueue=Be,C.lastRenderedState=O}return R===null&&(C.lanes=0),[f.memoizedState,C.dispatch]}function JC(f){var g=Oi(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=f;var C=_.dispatch,R=_.pending,O=g.memoizedState;if(R!==null){_.pending=null;var ne=R=R.next;do O=f(O,ne.action),ne=ne.next;while(ne!==R);oo(O,g.memoizedState)||(Gi=!0),g.memoizedState=O,g.baseQueue===null&&(g.baseState=O),_.lastRenderedState=O}return[O,C]}function FI(f,g,_){var C=En,R=Oi(),O=Jn;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=g();var ne=!oo((kr||R).memoizedState,_);if(ne&&(R.memoizedState=_,Gi=!0),R=R.queue,n2(UI.bind(null,C,R,f),[f]),R.getSnapshot!==g||ne||Vi!==null&&Vi.memoizedState.tag&1){if(C.flags|=2048,mp(9,{destroy:void 0},zI.bind(null,C,R,_,g),null),Fr===null)throw Error(r(349));O||(Xc&127)!==0||II(C,g,_)}return _}function II(f,g,_){f.flags|=16384,f={getSnapshot:g,value:_},g=En.updateQueue,g===null?(g=sw(),En.updateQueue=g,g.stores=[f]):(_=g.stores,_===null?g.stores=[f]:_.push(f))}function zI(f,g,_,C){g.value=_,g.getSnapshot=C,BI(g)&&$I(f)}function UI(f,g,_){return _(function(){BI(g)&&$I(f)})}function BI(f){var g=f.getSnapshot;f=f.value;try{var _=g();return!oo(f,_)}catch{return!0}}function $I(f){var g=uf(f,2);g!==null&&$s(g,f,2)}function e2(f){var g=ws();if(typeof f=="function"){var _=f;if(f=_(),yf){we(!0);try{_()}finally{we(!1)}}}return g.memoizedState=g.baseState=f,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yc,lastRenderedState:f},g}function HI(f,g,_,C){return f.baseState=_,ZC(f,kr,typeof C=="function"?C:Yc)}function aae(f,g,_,C,R){if(dw(f))throw Error(r(485));if(f=g.action,f!==null){var O={payload:R,action:f,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(ne){O.listeners.push(ne)}};q.T!==null?_(!0):O.isTransition=!1,C(O),_=g.pending,_===null?(O.next=g.pending=O,VI(g,O)):(O.next=_.next,g.pending=_.next=O)}}function VI(f,g){var _=g.action,C=g.payload,R=f.state;if(g.isTransition){var O=q.T,ne={};q.T=ne;try{var Se=_(R,C),Be=q.S;Be!==null&&Be(ne,Se),GI(f,g,Se)}catch(ut){t2(f,g,ut)}finally{O!==null&&ne.types!==null&&(O.types=ne.types),q.T=O}}else try{O=_(R,C),GI(f,g,O)}catch(ut){t2(f,g,ut)}}function GI(f,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(C){qI(f,g,C)},function(C){return t2(f,g,C)}):qI(f,g,_)}function qI(f,g,_){g.status="fulfilled",g.value=_,WI(g),f.state=_,g=f.pending,g!==null&&(_=g.next,_===g?f.pending=null:(_=_.next,g.next=_,VI(f,_)))}function t2(f,g,_){var C=f.pending;if(f.pending=null,C!==null){C=C.next;do g.status="rejected",g.reason=_,WI(g),g=g.next;while(g!==C)}f.action=null}function WI(f){f=f.listeners;for(var g=0;g<f.length;g++)(0,f[g])()}function KI(f,g){return g}function XI(f,g){if(Jn){var _=Fr.formState;if(_!==null){e:{var C=En;if(Jn){if(Zr){t:{for(var R=Zr,O=$o;R.nodeType!==8;){if(!O){R=null;break t}if(R=Vo(R.nextSibling),R===null){R=null;break t}}O=R.data,R=O==="F!"||O==="F"?R:null}if(R){Zr=Vo(R.nextSibling),C=R.data==="F!";break e}}yd(C)}C=!1}C&&(g=_[0])}}return _=ws(),_.memoizedState=_.baseState=g,C={pending:null,lanes:0,dispatch:null,lastRenderedReducer:KI,lastRenderedState:g},_.queue=C,_=m5.bind(null,En,C),C.dispatch=_,C=e2(!1),O=o2.bind(null,En,!1,C.queue),C=ws(),R={state:g,dispatch:null,action:f,pending:null},C.queue=R,_=aae.bind(null,En,R,O,_),R.dispatch=_,C.memoizedState=f,[g,_,!1]}function YI(f){var g=Oi();return QI(g,kr,f)}function QI(f,g,_){if(g=ZC(f,g,KI)[0],f=lw(Yc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var C=bx(g)}catch(ne){throw ne===cp?Zv:ne}else C=g;g=Oi();var R=g.queue,O=R.dispatch;return _!==g.memoizedState&&(En.flags|=2048,mp(9,{destroy:void 0},sae.bind(null,R,_),null)),[C,O,f]}function sae(f,g){f.action=g}function ZI(f){var g=Oi(),_=kr;if(_!==null)return QI(g,_,f);Oi(),g=g.memoizedState,_=Oi();var C=_.queue.dispatch;return _.memoizedState=f,[g,C,!1]}function mp(f,g,_,C){return f={tag:f,create:_,deps:C,inst:g,next:null},g=En.updateQueue,g===null&&(g=sw(),En.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=f.next=f:(C=_.next,_.next=f,f.next=C,g.lastEffect=f),f}function JI(){return Oi().memoizedState}function cw(f,g,_,C){var R=ws();En.flags|=f,R.memoizedState=mp(1|g,{destroy:void 0},_,C===void 0?null:C)}function uw(f,g,_,C){var R=Oi();C=C===void 0?null:C;var O=R.memoizedState.inst;kr!==null&&C!==null&&qC(C,kr.memoizedState.deps)?R.memoizedState=mp(g,O,_,C):(En.flags|=f,R.memoizedState=mp(1|g,O,_,C))}function e5(f,g){cw(8390656,8,f,g)}function n2(f,g){uw(2048,8,f,g)}function oae(f){En.flags|=4;var g=En.updateQueue;if(g===null)g=sw(),En.updateQueue=g,g.events=[f];else{var _=g.events;_===null?g.events=[f]:_.push(f)}}function t5(f){var g=Oi().memoizedState;return oae({ref:g,nextImpl:f}),function(){if((fr&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function n5(f,g){return uw(4,2,f,g)}function r5(f,g){return uw(4,4,f,g)}function i5(f,g){if(typeof g=="function"){f=f();var _=g(f);return function(){typeof _=="function"?_():g(null)}}if(g!=null)return f=f(),g.current=f,function(){g.current=null}}function a5(f,g,_){_=_!=null?_.concat([f]):null,uw(4,4,i5.bind(null,g,f),_)}function r2(){}function s5(f,g){var _=Oi();g=g===void 0?null:g;var C=_.memoizedState;return g!==null&&qC(g,C[1])?C[0]:(_.memoizedState=[f,g],f)}function o5(f,g){var _=Oi();g=g===void 0?null:g;var C=_.memoizedState;if(g!==null&&qC(g,C[1]))return C[0];if(C=f(),yf){we(!0);try{f()}finally{we(!1)}}return _.memoizedState=[C,g],C}function i2(f,g,_){return _===void 0||(Xc&1073741824)!==0&&(Yn&261930)===0?f.memoizedState=g:(f.memoizedState=_,f=lz(),En.lanes|=f,Ed|=f,_)}function l5(f,g,_,C){return oo(_,g)?_:dp.current!==null?(f=i2(f,_,C),oo(f,g)||(Gi=!0),f):(Xc&42)===0||(Xc&1073741824)!==0&&(Yn&261930)===0?(Gi=!0,f.memoizedState=_):(f=lz(),En.lanes|=f,Ed|=f,g)}function c5(f,g,_,C,R){var O=I.p;I.p=O!==0&&8>O?O:8;var ne=q.T,Se={};q.T=Se,o2(f,!1,g,_);try{var Be=R(),ut=q.S;if(ut!==null&&ut(Se,Be),Be!==null&&typeof Be=="object"&&typeof Be.then=="function"){var vt=nae(Be,C);xx(f,g,vt,mo(f))}else xx(f,g,C,mo(f))}catch(kt){xx(f,g,{then:function(){},status:"rejected",reason:kt},mo())}finally{I.p=O,ne!==null&&Se.types!==null&&(ne.types=Se.types),q.T=ne}}function lae(){}function a2(f,g,_,C){if(f.tag!==5)throw Error(r(476));var R=u5(f).queue;c5(f,R,g,K,_===null?lae:function(){return d5(f),_(C)})}function u5(f){var g=f.memoizedState;if(g!==null)return g;g={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yc,lastRenderedState:K},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yc,lastRenderedState:_},next:null},f.memoizedState=g,f=f.alternate,f!==null&&(f.memoizedState=g),g}function d5(f){var g=u5(f);g.next===null&&(g=f.alternate.memoizedState),xx(f,g.next.queue,{},mo())}function s2(){return Ua(Lx)}function h5(){return Oi().memoizedState}function f5(){return Oi().memoizedState}function cae(f){for(var g=f.return;g!==null;){switch(g.tag){case 24:case 3:var _=mo();f=_d(_);var C=Sd(g,f,_);C!==null&&($s(C,g,_),fx(C,g,_)),g={cache:LC()},f.payload=g;return}g=g.return}}function uae(f,g,_){var C=mo();_={lane:C,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},dw(f)?p5(g,_):(_=NC(f,g,_,C),_!==null&&($s(_,f,C),g5(_,g,C)))}function m5(f,g,_){var C=mo();xx(f,g,_,C)}function xx(f,g,_,C){var R={lane:C,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(dw(f))p5(g,R);else{var O=f.alternate;if(f.lanes===0&&(O===null||O.lanes===0)&&(O=g.lastRenderedReducer,O!==null))try{var ne=g.lastRenderedState,Se=O(ne,_);if(R.hasEagerState=!0,R.eagerState=Se,oo(Se,ne))return Gv(f,g,R,0),Fr===null&&Vv(),!1}catch{}finally{}if(_=NC(f,g,R,C),_!==null)return $s(_,f,C),g5(_,g,C),!0}return!1}function o2(f,g,_,C){if(C={lane:2,revertLane:z2(),gesture:null,action:C,hasEagerState:!1,eagerState:null,next:null},dw(f)){if(g)throw Error(r(479))}else g=NC(f,_,C,2),g!==null&&$s(g,f,2)}function dw(f){var g=f.alternate;return f===En||g!==null&&g===En}function p5(f,g){hp=iw=!0;var _=f.pending;_===null?g.next=g:(g.next=_.next,_.next=g),f.pending=g}function g5(f,g,_){if((_&4194048)!==0){var C=g.lanes;C&=f.pendingLanes,_|=C,g.lanes=_,gt(f,_)}}var yx={readContext:Ua,use:ow,useCallback:ki,useContext:ki,useEffect:ki,useImperativeHandle:ki,useLayoutEffect:ki,useInsertionEffect:ki,useMemo:ki,useReducer:ki,useRef:ki,useState:ki,useDebugValue:ki,useDeferredValue:ki,useTransition:ki,useSyncExternalStore:ki,useId:ki,useHostTransitionStatus:ki,useFormState:ki,useActionState:ki,useOptimistic:ki,useMemoCache:ki,useCacheRefresh:ki};yx.useEffectEvent=ki;var b5={readContext:Ua,use:ow,useCallback:function(f,g){return ws().memoizedState=[f,g===void 0?null:g],f},useContext:Ua,useEffect:e5,useImperativeHandle:function(f,g,_){_=_!=null?_.concat([f]):null,cw(4194308,4,i5.bind(null,g,f),_)},useLayoutEffect:function(f,g){return cw(4194308,4,f,g)},useInsertionEffect:function(f,g){cw(4,2,f,g)},useMemo:function(f,g){var _=ws();g=g===void 0?null:g;var C=f();if(yf){we(!0);try{f()}finally{we(!1)}}return _.memoizedState=[C,g],C},useReducer:function(f,g,_){var C=ws();if(_!==void 0){var R=_(g);if(yf){we(!0);try{_(g)}finally{we(!1)}}}else R=g;return C.memoizedState=C.baseState=R,f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:f,lastRenderedState:R},C.queue=f,f=f.dispatch=uae.bind(null,En,f),[C.memoizedState,f]},useRef:function(f){var g=ws();return f={current:f},g.memoizedState=f},useState:function(f){f=e2(f);var g=f.queue,_=m5.bind(null,En,g);return g.dispatch=_,[f.memoizedState,_]},useDebugValue:r2,useDeferredValue:function(f,g){var _=ws();return i2(_,f,g)},useTransition:function(){var f=e2(!1);return f=c5.bind(null,En,f.queue,!0,!1),ws().memoizedState=f,[!1,f]},useSyncExternalStore:function(f,g,_){var C=En,R=ws();if(Jn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),Fr===null)throw Error(r(349));(Yn&127)!==0||II(C,g,_)}R.memoizedState=_;var O={value:_,getSnapshot:g};return R.queue=O,e5(UI.bind(null,C,O,f),[f]),C.flags|=2048,mp(9,{destroy:void 0},zI.bind(null,C,O,_,g),null),_},useId:function(){var f=ws(),g=Fr.identifierPrefix;if(Jn){var _=sc,C=ac;_=(C&~(1<<32-Ue(C)-1)).toString(32)+_,g="_"+g+"R_"+_,_=aw++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=rae++,g="_"+g+"r_"+_.toString(32)+"_";return f.memoizedState=g},useHostTransitionStatus:s2,useFormState:XI,useActionState:XI,useOptimistic:function(f){var g=ws();g.memoizedState=g.baseState=f;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=o2.bind(null,En,!0,_),_.dispatch=g,[f,g]},useMemoCache:QC,useCacheRefresh:function(){return ws().memoizedState=cae.bind(null,En)},useEffectEvent:function(f){var g=ws(),_={impl:f};return g.memoizedState=_,function(){if((fr&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},l2={readContext:Ua,use:ow,useCallback:s5,useContext:Ua,useEffect:n2,useImperativeHandle:a5,useInsertionEffect:n5,useLayoutEffect:r5,useMemo:o5,useReducer:lw,useRef:JI,useState:function(){return lw(Yc)},useDebugValue:r2,useDeferredValue:function(f,g){var _=Oi();return l5(_,kr.memoizedState,f,g)},useTransition:function(){var f=lw(Yc)[0],g=Oi().memoizedState;return[typeof f=="boolean"?f:bx(f),g]},useSyncExternalStore:FI,useId:h5,useHostTransitionStatus:s2,useFormState:YI,useActionState:YI,useOptimistic:function(f,g){var _=Oi();return HI(_,kr,f,g)},useMemoCache:QC,useCacheRefresh:f5};l2.useEffectEvent=t5;var x5={readContext:Ua,use:ow,useCallback:s5,useContext:Ua,useEffect:n2,useImperativeHandle:a5,useInsertionEffect:n5,useLayoutEffect:r5,useMemo:o5,useReducer:JC,useRef:JI,useState:function(){return JC(Yc)},useDebugValue:r2,useDeferredValue:function(f,g){var _=Oi();return kr===null?i2(_,f,g):l5(_,kr.memoizedState,f,g)},useTransition:function(){var f=JC(Yc)[0],g=Oi().memoizedState;return[typeof f=="boolean"?f:bx(f),g]},useSyncExternalStore:FI,useId:h5,useHostTransitionStatus:s2,useFormState:ZI,useActionState:ZI,useOptimistic:function(f,g){var _=Oi();return kr!==null?HI(_,kr,f,g):(_.baseState=f,[f,_.queue.dispatch])},useMemoCache:QC,useCacheRefresh:f5};x5.useEffectEvent=t5;function c2(f,g,_,C){g=f.memoizedState,_=_(C,g),_=_==null?g:h({},g,_),f.memoizedState=_,f.lanes===0&&(f.updateQueue.baseState=_)}var u2={enqueueSetState:function(f,g,_){f=f._reactInternals;var C=mo(),R=_d(C);R.payload=g,_!=null&&(R.callback=_),g=Sd(f,R,C),g!==null&&($s(g,f,C),fx(g,f,C))},enqueueReplaceState:function(f,g,_){f=f._reactInternals;var C=mo(),R=_d(C);R.tag=1,R.payload=g,_!=null&&(R.callback=_),g=Sd(f,R,C),g!==null&&($s(g,f,C),fx(g,f,C))},enqueueForceUpdate:function(f,g){f=f._reactInternals;var _=mo(),C=_d(_);C.tag=2,g!=null&&(C.callback=g),g=Sd(f,C,_),g!==null&&($s(g,f,_),fx(g,f,_))}};function y5(f,g,_,C,R,O,ne){return f=f.stateNode,typeof f.shouldComponentUpdate=="function"?f.shouldComponentUpdate(C,O,ne):g.prototype&&g.prototype.isPureReactComponent?!ax(_,C)||!ax(R,O):!0}function v5(f,g,_,C){f=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,C),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,C),g.state!==f&&u2.enqueueReplaceState(g,g.state,null)}function vf(f,g){var _=g;if("ref"in g){_={};for(var C in g)C!=="ref"&&(_[C]=g[C])}if(f=f.defaultProps){_===g&&(_=h({},_));for(var R in f)_[R]===void 0&&(_[R]=f[R])}return _}function w5(f){Hv(f)}function _5(f){console.error(f)}function S5(f){Hv(f)}function hw(f,g){try{var _=f.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(C){setTimeout(function(){throw C})}}function N5(f,g,_){try{var C=f.onCaughtError;C(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(R){setTimeout(function(){throw R})}}function d2(f,g,_){return _=_d(_),_.tag=3,_.payload={element:null},_.callback=function(){hw(f,g)},_}function k5(f){return f=_d(f),f.tag=3,f}function M5(f,g,_,C){var R=_.type.getDerivedStateFromError;if(typeof R=="function"){var O=C.value;f.payload=function(){return R(O)},f.callback=function(){N5(g,_,C)}}var ne=_.stateNode;ne!==null&&typeof ne.componentDidCatch=="function"&&(f.callback=function(){N5(g,_,C),typeof R!="function"&&(Ad===null?Ad=new Set([this]):Ad.add(this));var Se=C.stack;this.componentDidCatch(C.value,{componentStack:Se!==null?Se:""})})}function dae(f,g,_,C,R){if(_.flags|=32768,C!==null&&typeof C=="object"&&typeof C.then=="function"){if(g=_.alternate,g!==null&&sp(g,_,R,!0),_=co.current,_!==null){switch(_.tag){case 31:case 13:return Ho===null?Nw():_.alternate===null&&Mi===0&&(Mi=3),_.flags&=-257,_.flags|=65536,_.lanes=R,C===Jv?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([C]):g.add(C),O2(f,C,R)),!1;case 22:return _.flags|=65536,C===Jv?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([C])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([C]):_.add(C)),O2(f,C,R)),!1}throw Error(r(435,_.tag))}return O2(f,C,R),Nw(),!1}if(Jn)return g=co.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=R,C!==TC&&(f=Error(r(422),{cause:C}),lx(zo(f,_)))):(C!==TC&&(g=Error(r(423),{cause:C}),lx(zo(g,_))),f=f.current.alternate,f.flags|=65536,R&=-R,f.lanes|=R,C=zo(C,_),R=d2(f.stateNode,C,R),BC(f,R),Mi!==4&&(Mi=2)),!1;var O=Error(r(520),{cause:C});if(O=zo(O,_),Cx===null?Cx=[O]:Cx.push(O),Mi!==4&&(Mi=2),g===null)return!0;C=zo(C,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,f=R&-R,_.lanes|=f,f=d2(_.stateNode,C,f),BC(_,f),!1;case 1:if(g=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Ad===null||!Ad.has(O))))return _.flags|=65536,R&=-R,_.lanes|=R,R=k5(R),M5(R,f,_,C),BC(_,R),!1}_=_.return}while(_!==null);return!1}var h2=Error(r(461)),Gi=!1;function Ba(f,g,_,C){g.child=f===null?TI(g,null,_,C):xf(g,f.child,_,C)}function C5(f,g,_,C,R){_=_.render;var O=g.ref;if("ref"in C){var ne={};for(var Se in C)Se!=="ref"&&(ne[Se]=C[Se])}else ne=C;return mf(g),C=WC(f,g,_,ne,O,R),Se=KC(),f!==null&&!Gi?(XC(f,g,R),Qc(f,g,R)):(Jn&&Se&&EC(g),g.flags|=1,Ba(f,g,C,R),g.child)}function E5(f,g,_,C,R){if(f===null){var O=_.type;return typeof O=="function"&&!kC(O)&&O.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=O,A5(f,g,O,C,R)):(f=Wv(_.type,null,C,g,g.mode,R),f.ref=g.ref,f.return=g,g.child=f)}if(O=f.child,!v2(f,R)){var ne=O.memoizedProps;if(_=_.compare,_=_!==null?_:ax,_(ne,C)&&f.ref===g.ref)return Qc(f,g,R)}return g.flags|=1,f=Gc(O,C),f.ref=g.ref,f.return=g,g.child=f}function A5(f,g,_,C,R){if(f!==null){var O=f.memoizedProps;if(ax(O,C)&&f.ref===g.ref)if(Gi=!1,g.pendingProps=C=O,v2(f,R))(f.flags&131072)!==0&&(Gi=!0);else return g.lanes=f.lanes,Qc(f,g,R)}return f2(f,g,_,C,R)}function T5(f,g,_,C){var R=C.children,O=f!==null?f.memoizedState:null;if(f===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),C.mode==="hidden"){if((g.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,f!==null){for(C=g.child=f.child,R=0;C!==null;)R=R|C.lanes|C.childLanes,C=C.sibling;C=R&~O}else C=0,g.child=null;return j5(f,g,O,_,C)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},f!==null&&Qv(g,O!==null?O.cachePool:null),O!==null?DI(g,O):HC(),RI(g);else return C=g.lanes=536870912,j5(f,g,O!==null?O.baseLanes|_:_,_,C)}else O!==null?(Qv(g,O.cachePool),DI(g,O),kd(),g.memoizedState=null):(f!==null&&Qv(g,null),HC(),kd());return Ba(f,g,R,_),g.child}function vx(f,g){return f!==null&&f.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function j5(f,g,_,C,R){var O=FC();return O=O===null?null:{parent:Hi._currentValue,pool:O},g.memoizedState={baseLanes:_,cachePool:O},f!==null&&Qv(g,null),HC(),RI(g),f!==null&&sp(f,g,C,!0),g.childLanes=R,null}function fw(f,g){return g=pw({mode:g.mode,children:g.children},f.mode),g.ref=f.ref,f.child=g,g.return=f,g}function P5(f,g,_){return xf(g,f.child,null,_),f=fw(g,g.pendingProps),f.flags|=2,uo(g),g.memoizedState=null,f}function hae(f,g,_){var C=g.pendingProps,R=(g.flags&128)!==0;if(g.flags&=-129,f===null){if(Jn){if(C.mode==="hidden")return f=fw(g,C),g.lanes=536870912,vx(null,f);if(GC(g),(f=Zr)?(f=Vz(f,$o),f=f!==null&&f.data==="&"?f:null,f!==null&&(g.memoizedState={dehydrated:f,treeContext:bd!==null?{id:ac,overflow:sc}:null,retryLane:536870912,hydrationErrors:null},_=pI(f),_.return=g,g.child=_,za=g,Zr=null)):f=null,f===null)throw yd(g);return g.lanes=536870912,null}return fw(g,C)}var O=f.memoizedState;if(O!==null){var ne=O.dehydrated;if(GC(g),R)if(g.flags&256)g.flags&=-257,g=P5(f,g,_);else if(g.memoizedState!==null)g.child=f.child,g.flags|=128,g=null;else throw Error(r(558));else if(Gi||sp(f,g,_,!1),R=(_&f.childLanes)!==0,Gi||R){if(C=Fr,C!==null&&(ne=Qt(C,_),ne!==0&&ne!==O.retryLane))throw O.retryLane=ne,uf(f,ne),$s(C,f,ne),h2;Nw(),g=P5(f,g,_)}else f=O.treeContext,Zr=Vo(ne.nextSibling),za=g,Jn=!0,xd=null,$o=!1,f!==null&&xI(g,f),g=fw(g,C),g.flags|=4096;return g}return f=Gc(f.child,{mode:C.mode,children:C.children}),f.ref=g.ref,g.child=f,f.return=g,f}function mw(f,g){var _=g.ref;if(_===null)f!==null&&f.ref!==null&&(g.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(f===null||f.ref!==_)&&(g.flags|=4194816)}}function f2(f,g,_,C,R){return mf(g),_=WC(f,g,_,C,void 0,R),C=KC(),f!==null&&!Gi?(XC(f,g,R),Qc(f,g,R)):(Jn&&C&&EC(g),g.flags|=1,Ba(f,g,_,R),g.child)}function D5(f,g,_,C,R,O){return mf(g),g.updateQueue=null,_=OI(g,C,_,R),LI(f),C=KC(),f!==null&&!Gi?(XC(f,g,O),Qc(f,g,O)):(Jn&&C&&EC(g),g.flags|=1,Ba(f,g,_,O),g.child)}function R5(f,g,_,C,R){if(mf(g),g.stateNode===null){var O=np,ne=_.contextType;typeof ne=="object"&&ne!==null&&(O=Ua(ne)),O=new _(C,O),g.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=u2,g.stateNode=O,O._reactInternals=g,O=g.stateNode,O.props=C,O.state=g.memoizedState,O.refs={},zC(g),ne=_.contextType,O.context=typeof ne=="object"&&ne!==null?Ua(ne):np,O.state=g.memoizedState,ne=_.getDerivedStateFromProps,typeof ne=="function"&&(c2(g,_,ne,C),O.state=g.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(ne=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),ne!==O.state&&u2.enqueueReplaceState(O,O.state,null),px(g,C,O,R),mx(),O.state=g.memoizedState),typeof O.componentDidMount=="function"&&(g.flags|=4194308),C=!0}else if(f===null){O=g.stateNode;var Se=g.memoizedProps,Be=vf(_,Se);O.props=Be;var ut=O.context,vt=_.contextType;ne=np,typeof vt=="object"&&vt!==null&&(ne=Ua(vt));var kt=_.getDerivedStateFromProps;vt=typeof kt=="function"||typeof O.getSnapshotBeforeUpdate=="function",Se=g.pendingProps!==Se,vt||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(Se||ut!==ne)&&v5(g,O,C,ne),wd=!1;var ft=g.memoizedState;O.state=ft,px(g,C,O,R),mx(),ut=g.memoizedState,Se||ft!==ut||wd?(typeof kt=="function"&&(c2(g,_,kt,C),ut=g.memoizedState),(Be=wd||y5(g,_,Be,C,ft,ut,ne))?(vt||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(g.flags|=4194308)):(typeof O.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=C,g.memoizedState=ut),O.props=C,O.state=ut,O.context=ne,C=Be):(typeof O.componentDidMount=="function"&&(g.flags|=4194308),C=!1)}else{O=g.stateNode,UC(f,g),ne=g.memoizedProps,vt=vf(_,ne),O.props=vt,kt=g.pendingProps,ft=O.context,ut=_.contextType,Be=np,typeof ut=="object"&&ut!==null&&(Be=Ua(ut)),Se=_.getDerivedStateFromProps,(ut=typeof Se=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(ne!==kt||ft!==Be)&&v5(g,O,C,Be),wd=!1,ft=g.memoizedState,O.state=ft,px(g,C,O,R),mx();var xt=g.memoizedState;ne!==kt||ft!==xt||wd||f!==null&&f.dependencies!==null&&Xv(f.dependencies)?(typeof Se=="function"&&(c2(g,_,Se,C),xt=g.memoizedState),(vt=wd||y5(g,_,vt,C,ft,xt,Be)||f!==null&&f.dependencies!==null&&Xv(f.dependencies))?(ut||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(C,xt,Be),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(C,xt,Be)),typeof O.componentDidUpdate=="function"&&(g.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof O.componentDidUpdate!="function"||ne===f.memoizedProps&&ft===f.memoizedState||(g.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||ne===f.memoizedProps&&ft===f.memoizedState||(g.flags|=1024),g.memoizedProps=C,g.memoizedState=xt),O.props=C,O.state=xt,O.context=Be,C=vt):(typeof O.componentDidUpdate!="function"||ne===f.memoizedProps&&ft===f.memoizedState||(g.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||ne===f.memoizedProps&&ft===f.memoizedState||(g.flags|=1024),C=!1)}return O=C,mw(f,g),C=(g.flags&128)!==0,O||C?(O=g.stateNode,_=C&&typeof _.getDerivedStateFromError!="function"?null:O.render(),g.flags|=1,f!==null&&C?(g.child=xf(g,f.child,null,R),g.child=xf(g,null,_,R)):Ba(f,g,_,R),g.memoizedState=O.state,f=g.child):f=Qc(f,g,R),f}function L5(f,g,_,C){return hf(),g.flags|=256,Ba(f,g,_,C),g.child}var m2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function p2(f){return{baseLanes:f,cachePool:NI()}}function g2(f,g,_){return f=f!==null?f.childLanes&~_:0,g&&(f|=fo),f}function O5(f,g,_){var C=g.pendingProps,R=!1,O=(g.flags&128)!==0,ne;if((ne=O)||(ne=f!==null&&f.memoizedState===null?!1:(Li.current&2)!==0),ne&&(R=!0,g.flags&=-129),ne=(g.flags&32)!==0,g.flags&=-33,f===null){if(Jn){if(R?Nd(g):kd(),(f=Zr)?(f=Vz(f,$o),f=f!==null&&f.data!=="&"?f:null,f!==null&&(g.memoizedState={dehydrated:f,treeContext:bd!==null?{id:ac,overflow:sc}:null,retryLane:536870912,hydrationErrors:null},_=pI(f),_.return=g,g.child=_,za=g,Zr=null)):f=null,f===null)throw yd(g);return Z2(f)?g.lanes=32:g.lanes=536870912,null}var Se=C.children;return C=C.fallback,R?(kd(),R=g.mode,Se=pw({mode:"hidden",children:Se},R),C=df(C,R,_,null),Se.return=g,C.return=g,Se.sibling=C,g.child=Se,C=g.child,C.memoizedState=p2(_),C.childLanes=g2(f,ne,_),g.memoizedState=m2,vx(null,C)):(Nd(g),b2(g,Se))}var Be=f.memoizedState;if(Be!==null&&(Se=Be.dehydrated,Se!==null)){if(O)g.flags&256?(Nd(g),g.flags&=-257,g=x2(f,g,_)):g.memoizedState!==null?(kd(),g.child=f.child,g.flags|=128,g=null):(kd(),Se=C.fallback,R=g.mode,C=pw({mode:"visible",children:C.children},R),Se=df(Se,R,_,null),Se.flags|=2,C.return=g,Se.return=g,C.sibling=Se,g.child=C,xf(g,f.child,null,_),C=g.child,C.memoizedState=p2(_),C.childLanes=g2(f,ne,_),g.memoizedState=m2,g=vx(null,C));else if(Nd(g),Z2(Se)){if(ne=Se.nextSibling&&Se.nextSibling.dataset,ne)var ut=ne.dgst;ne=ut,C=Error(r(419)),C.stack="",C.digest=ne,lx({value:C,source:null,stack:null}),g=x2(f,g,_)}else if(Gi||sp(f,g,_,!1),ne=(_&f.childLanes)!==0,Gi||ne){if(ne=Fr,ne!==null&&(C=Qt(ne,_),C!==0&&C!==Be.retryLane))throw Be.retryLane=C,uf(f,C),$s(ne,f,C),h2;Q2(Se)||Nw(),g=x2(f,g,_)}else Q2(Se)?(g.flags|=192,g.child=f.child,g=null):(f=Be.treeContext,Zr=Vo(Se.nextSibling),za=g,Jn=!0,xd=null,$o=!1,f!==null&&xI(g,f),g=b2(g,C.children),g.flags|=4096);return g}return R?(kd(),Se=C.fallback,R=g.mode,Be=f.child,ut=Be.sibling,C=Gc(Be,{mode:"hidden",children:C.children}),C.subtreeFlags=Be.subtreeFlags&65011712,ut!==null?Se=Gc(ut,Se):(Se=df(Se,R,_,null),Se.flags|=2),Se.return=g,C.return=g,C.sibling=Se,g.child=C,vx(null,C),C=g.child,Se=f.child.memoizedState,Se===null?Se=p2(_):(R=Se.cachePool,R!==null?(Be=Hi._currentValue,R=R.parent!==Be?{parent:Be,pool:Be}:R):R=NI(),Se={baseLanes:Se.baseLanes|_,cachePool:R}),C.memoizedState=Se,C.childLanes=g2(f,ne,_),g.memoizedState=m2,vx(f.child,C)):(Nd(g),_=f.child,f=_.sibling,_=Gc(_,{mode:"visible",children:C.children}),_.return=g,_.sibling=null,f!==null&&(ne=g.deletions,ne===null?(g.deletions=[f],g.flags|=16):ne.push(f)),g.child=_,g.memoizedState=null,_)}function b2(f,g){return g=pw({mode:"visible",children:g},f.mode),g.return=f,f.child=g}function pw(f,g){return f=lo(22,f,null,g),f.lanes=0,f}function x2(f,g,_){return xf(g,f.child,null,_),f=b2(g,g.pendingProps.children),f.flags|=2,g.memoizedState=null,f}function F5(f,g,_){f.lanes|=g;var C=f.alternate;C!==null&&(C.lanes|=g),DC(f.return,g,_)}function y2(f,g,_,C,R,O){var ne=f.memoizedState;ne===null?f.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:C,tail:_,tailMode:R,treeForkCount:O}:(ne.isBackwards=g,ne.rendering=null,ne.renderingStartTime=0,ne.last=C,ne.tail=_,ne.tailMode=R,ne.treeForkCount=O)}function I5(f,g,_){var C=g.pendingProps,R=C.revealOrder,O=C.tail;C=C.children;var ne=Li.current,Se=(ne&2)!==0;if(Se?(ne=ne&1|2,g.flags|=128):ne&=1,ie(Li,ne),Ba(f,g,C,_),C=Jn?ox:0,!Se&&f!==null&&(f.flags&128)!==0)e:for(f=g.child;f!==null;){if(f.tag===13)f.memoizedState!==null&&F5(f,_,g);else if(f.tag===19)F5(f,_,g);else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===g)break e;for(;f.sibling===null;){if(f.return===null||f.return===g)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}switch(R){case"forwards":for(_=g.child,R=null;_!==null;)f=_.alternate,f!==null&&rw(f)===null&&(R=_),_=_.sibling;_=R,_===null?(R=g.child,g.child=null):(R=_.sibling,_.sibling=null),y2(g,!1,R,_,O,C);break;case"backwards":case"unstable_legacy-backwards":for(_=null,R=g.child,g.child=null;R!==null;){if(f=R.alternate,f!==null&&rw(f)===null){g.child=R;break}f=R.sibling,R.sibling=_,_=R,R=f}y2(g,!0,_,null,O,C);break;case"together":y2(g,!1,null,null,void 0,C);break;default:g.memoizedState=null}return g.child}function Qc(f,g,_){if(f!==null&&(g.dependencies=f.dependencies),Ed|=g.lanes,(_&g.childLanes)===0)if(f!==null){if(sp(f,g,_,!1),(_&g.childLanes)===0)return null}else return null;if(f!==null&&g.child!==f.child)throw Error(r(153));if(g.child!==null){for(f=g.child,_=Gc(f,f.pendingProps),g.child=_,_.return=g;f.sibling!==null;)f=f.sibling,_=_.sibling=Gc(f,f.pendingProps),_.return=g;_.sibling=null}return g.child}function v2(f,g){return(f.lanes&g)!==0?!0:(f=f.dependencies,!!(f!==null&&Xv(f)))}function fae(f,g,_){switch(g.tag){case 3:Le(g,g.stateNode.containerInfo),vd(g,Hi,f.memoizedState.cache),hf();break;case 27:case 5:ce(g);break;case 4:Le(g,g.stateNode.containerInfo);break;case 10:vd(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,GC(g),null;break;case 13:var C=g.memoizedState;if(C!==null)return C.dehydrated!==null?(Nd(g),g.flags|=128,null):(_&g.child.childLanes)!==0?O5(f,g,_):(Nd(g),f=Qc(f,g,_),f!==null?f.sibling:null);Nd(g);break;case 19:var R=(f.flags&128)!==0;if(C=(_&g.childLanes)!==0,C||(sp(f,g,_,!1),C=(_&g.childLanes)!==0),R){if(C)return I5(f,g,_);g.flags|=128}if(R=g.memoizedState,R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),ie(Li,Li.current),C)break;return null;case 22:return g.lanes=0,T5(f,g,_,g.pendingProps);case 24:vd(g,Hi,f.memoizedState.cache)}return Qc(f,g,_)}function z5(f,g,_){if(f!==null)if(f.memoizedProps!==g.pendingProps)Gi=!0;else{if(!v2(f,_)&&(g.flags&128)===0)return Gi=!1,fae(f,g,_);Gi=(f.flags&131072)!==0}else Gi=!1,Jn&&(g.flags&1048576)!==0&&bI(g,ox,g.index);switch(g.lanes=0,g.tag){case 16:e:{var C=g.pendingProps;if(f=gf(g.elementType),g.type=f,typeof f=="function")kC(f)?(C=vf(f,C),g.tag=1,g=R5(null,g,f,C,_)):(g.tag=0,g=f2(null,g,f,C,_));else{if(f!=null){var R=f.$$typeof;if(R===E){g.tag=11,g=C5(null,g,f,C,_);break e}else if(R===M){g.tag=14,g=E5(null,g,f,C,_);break e}}throw g=D(f)||f,Error(r(306,g,""))}}return g;case 0:return f2(f,g,g.type,g.pendingProps,_);case 1:return C=g.type,R=vf(C,g.pendingProps),R5(f,g,C,R,_);case 3:e:{if(Le(g,g.stateNode.containerInfo),f===null)throw Error(r(387));C=g.pendingProps;var O=g.memoizedState;R=O.element,UC(f,g),px(g,C,null,_);var ne=g.memoizedState;if(C=ne.cache,vd(g,Hi,C),C!==O.cache&&RC(g,[Hi],_,!0),mx(),C=ne.element,O.isDehydrated)if(O={element:C,isDehydrated:!1,cache:ne.cache},g.updateQueue.baseState=O,g.memoizedState=O,g.flags&256){g=L5(f,g,C,_);break e}else if(C!==R){R=zo(Error(r(424)),g),lx(R),g=L5(f,g,C,_);break e}else{switch(f=g.stateNode.containerInfo,f.nodeType){case 9:f=f.body;break;default:f=f.nodeName==="HTML"?f.ownerDocument.body:f}for(Zr=Vo(f.firstChild),za=g,Jn=!0,xd=null,$o=!0,_=TI(g,null,C,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(hf(),C===R){g=Qc(f,g,_);break e}Ba(f,g,C,_)}g=g.child}return g;case 26:return mw(f,g),f===null?(_=Yz(g.type,null,g.pendingProps,null))?g.memoizedState=_:Jn||(_=g.type,f=g.pendingProps,C=jw(fe.current).createElement(_),C[Xt]=g,C[sr]=f,$a(C,_,f),Ge(C),g.stateNode=C):g.memoizedState=Yz(g.type,f.memoizedProps,g.pendingProps,f.memoizedState),null;case 27:return ce(g),f===null&&Jn&&(C=g.stateNode=Wz(g.type,g.pendingProps,fe.current),za=g,$o=!0,R=Zr,Dd(g.type)?(J2=R,Zr=Vo(C.firstChild)):Zr=R),Ba(f,g,g.pendingProps.children,_),mw(f,g),f===null&&(g.flags|=4194304),g.child;case 5:return f===null&&Jn&&((R=C=Zr)&&(C=Hae(C,g.type,g.pendingProps,$o),C!==null?(g.stateNode=C,za=g,Zr=Vo(C.firstChild),$o=!1,R=!0):R=!1),R||yd(g)),ce(g),R=g.type,O=g.pendingProps,ne=f!==null?f.memoizedProps:null,C=O.children,K2(R,O)?C=null:ne!==null&&K2(R,ne)&&(g.flags|=32),g.memoizedState!==null&&(R=WC(f,g,iae,null,null,_),Lx._currentValue=R),mw(f,g),Ba(f,g,C,_),g.child;case 6:return f===null&&Jn&&((f=_=Zr)&&(_=Vae(_,g.pendingProps,$o),_!==null?(g.stateNode=_,za=g,Zr=null,f=!0):f=!1),f||yd(g)),null;case 13:return O5(f,g,_);case 4:return Le(g,g.stateNode.containerInfo),C=g.pendingProps,f===null?g.child=xf(g,null,C,_):Ba(f,g,C,_),g.child;case 11:return C5(f,g,g.type,g.pendingProps,_);case 7:return Ba(f,g,g.pendingProps,_),g.child;case 8:return Ba(f,g,g.pendingProps.children,_),g.child;case 12:return Ba(f,g,g.pendingProps.children,_),g.child;case 10:return C=g.pendingProps,vd(g,g.type,C.value),Ba(f,g,C.children,_),g.child;case 9:return R=g.type._context,C=g.pendingProps.children,mf(g),R=Ua(R),C=C(R),g.flags|=1,Ba(f,g,C,_),g.child;case 14:return E5(f,g,g.type,g.pendingProps,_);case 15:return A5(f,g,g.type,g.pendingProps,_);case 19:return I5(f,g,_);case 31:return hae(f,g,_);case 22:return T5(f,g,_,g.pendingProps);case 24:return mf(g),C=Ua(Hi),f===null?(R=FC(),R===null&&(R=Fr,O=LC(),R.pooledCache=O,O.refCount++,O!==null&&(R.pooledCacheLanes|=_),R=O),g.memoizedState={parent:C,cache:R},zC(g),vd(g,Hi,R)):((f.lanes&_)!==0&&(UC(f,g),px(g,null,null,_),mx()),R=f.memoizedState,O=g.memoizedState,R.parent!==C?(R={parent:C,cache:C},g.memoizedState=R,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=R),vd(g,Hi,C)):(C=O.cache,vd(g,Hi,C),C!==R.cache&&RC(g,[Hi],_,!0))),Ba(f,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function Zc(f){f.flags|=4}function w2(f,g,_,C,R){if((g=(f.mode&32)!==0)&&(g=!1),g){if(f.flags|=16777216,(R&335544128)===R)if(f.stateNode.complete)f.flags|=8192;else if(hz())f.flags|=8192;else throw bf=Jv,IC}else f.flags&=-16777217}function U5(f,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)f.flags&=-16777217;else if(f.flags|=16777216,!tU(g))if(hz())f.flags|=8192;else throw bf=Jv,IC}function gw(f,g){g!==null&&(f.flags|=4),f.flags&16384&&(g=f.tag!==22?yt():536870912,f.lanes|=g,xp|=g)}function wx(f,g){if(!Jn)switch(f.tailMode){case"hidden":g=f.tail;for(var _=null;g!==null;)g.alternate!==null&&(_=g),g=g.sibling;_===null?f.tail=null:_.sibling=null;break;case"collapsed":_=f.tail;for(var C=null;_!==null;)_.alternate!==null&&(C=_),_=_.sibling;C===null?g||f.tail===null?f.tail=null:f.tail.sibling=null:C.sibling=null}}function Jr(f){var g=f.alternate!==null&&f.alternate.child===f.child,_=0,C=0;if(g)for(var R=f.child;R!==null;)_|=R.lanes|R.childLanes,C|=R.subtreeFlags&65011712,C|=R.flags&65011712,R.return=f,R=R.sibling;else for(R=f.child;R!==null;)_|=R.lanes|R.childLanes,C|=R.subtreeFlags,C|=R.flags,R.return=f,R=R.sibling;return f.subtreeFlags|=C,f.childLanes=_,g}function mae(f,g,_){var C=g.pendingProps;switch(AC(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Jr(g),null;case 1:return Jr(g),null;case 3:return _=g.stateNode,C=null,f!==null&&(C=f.memoizedState.cache),g.memoizedState.cache!==C&&(g.flags|=2048),Kc(Hi),de(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(f===null||f.child===null)&&(ap(g)?Zc(g):f===null||f.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,jC())),Jr(g),null;case 26:var R=g.type,O=g.memoizedState;return f===null?(Zc(g),O!==null?(Jr(g),U5(g,O)):(Jr(g),w2(g,R,null,C,_))):O?O!==f.memoizedState?(Zc(g),Jr(g),U5(g,O)):(Jr(g),g.flags&=-16777217):(f=f.memoizedProps,f!==C&&Zc(g),Jr(g),w2(g,R,f,C,_)),null;case 27:if(Ae(g),_=fe.current,R=g.type,f!==null&&g.stateNode!=null)f.memoizedProps!==C&&Zc(g);else{if(!C){if(g.stateNode===null)throw Error(r(166));return Jr(g),null}f=J.current,ap(g)?yI(g):(f=Wz(R,C,_),g.stateNode=f,Zc(g))}return Jr(g),null;case 5:if(Ae(g),R=g.type,f!==null&&g.stateNode!=null)f.memoizedProps!==C&&Zc(g);else{if(!C){if(g.stateNode===null)throw Error(r(166));return Jr(g),null}if(O=J.current,ap(g))yI(g);else{var ne=jw(fe.current);switch(O){case 1:O=ne.createElementNS("http://www.w3.org/2000/svg",R);break;case 2:O=ne.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;default:switch(R){case"svg":O=ne.createElementNS("http://www.w3.org/2000/svg",R);break;case"math":O=ne.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;case"script":O=ne.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof C.is=="string"?ne.createElement("select",{is:C.is}):ne.createElement("select"),C.multiple?O.multiple=!0:C.size&&(O.size=C.size);break;default:O=typeof C.is=="string"?ne.createElement(R,{is:C.is}):ne.createElement(R)}}O[Xt]=g,O[sr]=C;e:for(ne=g.child;ne!==null;){if(ne.tag===5||ne.tag===6)O.appendChild(ne.stateNode);else if(ne.tag!==4&&ne.tag!==27&&ne.child!==null){ne.child.return=ne,ne=ne.child;continue}if(ne===g)break e;for(;ne.sibling===null;){if(ne.return===null||ne.return===g)break e;ne=ne.return}ne.sibling.return=ne.return,ne=ne.sibling}g.stateNode=O;e:switch($a(O,R,C),R){case"button":case"input":case"select":case"textarea":C=!!C.autoFocus;break e;case"img":C=!0;break e;default:C=!1}C&&Zc(g)}}return Jr(g),w2(g,g.type,f===null?null:f.memoizedProps,g.pendingProps,_),null;case 6:if(f&&g.stateNode!=null)f.memoizedProps!==C&&Zc(g);else{if(typeof C!="string"&&g.stateNode===null)throw Error(r(166));if(f=fe.current,ap(g)){if(f=g.stateNode,_=g.memoizedProps,C=null,R=za,R!==null)switch(R.tag){case 27:case 5:C=R.memoizedProps}f[Xt]=g,f=!!(f.nodeValue===_||C!==null&&C.suppressHydrationWarning===!0||Oz(f.nodeValue,_)),f||yd(g,!0)}else f=jw(f).createTextNode(C),f[Xt]=g,g.stateNode=f}return Jr(g),null;case 31:if(_=g.memoizedState,f===null||f.memoizedState!==null){if(C=ap(g),_!==null){if(f===null){if(!C)throw Error(r(318));if(f=g.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(557));f[Xt]=g}else hf(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Jr(g),f=!1}else _=jC(),f!==null&&f.memoizedState!==null&&(f.memoizedState.hydrationErrors=_),f=!0;if(!f)return g.flags&256?(uo(g),g):(uo(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Jr(g),null;case 13:if(C=g.memoizedState,f===null||f.memoizedState!==null&&f.memoizedState.dehydrated!==null){if(R=ap(g),C!==null&&C.dehydrated!==null){if(f===null){if(!R)throw Error(r(318));if(R=g.memoizedState,R=R!==null?R.dehydrated:null,!R)throw Error(r(317));R[Xt]=g}else hf(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Jr(g),R=!1}else R=jC(),f!==null&&f.memoizedState!==null&&(f.memoizedState.hydrationErrors=R),R=!0;if(!R)return g.flags&256?(uo(g),g):(uo(g),null)}return uo(g),(g.flags&128)!==0?(g.lanes=_,g):(_=C!==null,f=f!==null&&f.memoizedState!==null,_&&(C=g.child,R=null,C.alternate!==null&&C.alternate.memoizedState!==null&&C.alternate.memoizedState.cachePool!==null&&(R=C.alternate.memoizedState.cachePool.pool),O=null,C.memoizedState!==null&&C.memoizedState.cachePool!==null&&(O=C.memoizedState.cachePool.pool),O!==R&&(C.flags|=2048)),_!==f&&_&&(g.child.flags|=8192),gw(g,g.updateQueue),Jr(g),null);case 4:return de(),f===null&&H2(g.stateNode.containerInfo),Jr(g),null;case 10:return Kc(g.type),Jr(g),null;case 19:if(W(Li),C=g.memoizedState,C===null)return Jr(g),null;if(R=(g.flags&128)!==0,O=C.rendering,O===null)if(R)wx(C,!1);else{if(Mi!==0||f!==null&&(f.flags&128)!==0)for(f=g.child;f!==null;){if(O=rw(f),O!==null){for(g.flags|=128,wx(C,!1),f=O.updateQueue,g.updateQueue=f,gw(g,f),g.subtreeFlags=0,f=_,_=g.child;_!==null;)mI(_,f),_=_.sibling;return ie(Li,Li.current&1|2),Jn&&qc(g,C.treeForkCount),g.child}f=f.sibling}C.tail!==null&&L()>ww&&(g.flags|=128,R=!0,wx(C,!1),g.lanes=4194304)}else{if(!R)if(f=rw(O),f!==null){if(g.flags|=128,R=!0,f=f.updateQueue,g.updateQueue=f,gw(g,f),wx(C,!0),C.tail===null&&C.tailMode==="hidden"&&!O.alternate&&!Jn)return Jr(g),null}else 2*L()-C.renderingStartTime>ww&&_!==536870912&&(g.flags|=128,R=!0,wx(C,!1),g.lanes=4194304);C.isBackwards?(O.sibling=g.child,g.child=O):(f=C.last,f!==null?f.sibling=O:g.child=O,C.last=O)}return C.tail!==null?(f=C.tail,C.rendering=f,C.tail=f.sibling,C.renderingStartTime=L(),f.sibling=null,_=Li.current,ie(Li,R?_&1|2:_&1),Jn&&qc(g,C.treeForkCount),f):(Jr(g),null);case 22:case 23:return uo(g),VC(),C=g.memoizedState!==null,f!==null?f.memoizedState!==null!==C&&(g.flags|=8192):C&&(g.flags|=8192),C?(_&536870912)!==0&&(g.flags&128)===0&&(Jr(g),g.subtreeFlags&6&&(g.flags|=8192)):Jr(g),_=g.updateQueue,_!==null&&gw(g,_.retryQueue),_=null,f!==null&&f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(_=f.memoizedState.cachePool.pool),C=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(C=g.memoizedState.cachePool.pool),C!==_&&(g.flags|=2048),f!==null&&W(pf),null;case 24:return _=null,f!==null&&(_=f.memoizedState.cache),g.memoizedState.cache!==_&&(g.flags|=2048),Kc(Hi),Jr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function pae(f,g){switch(AC(g),g.tag){case 1:return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 3:return Kc(Hi),de(),f=g.flags,(f&65536)!==0&&(f&128)===0?(g.flags=f&-65537|128,g):null;case 26:case 27:case 5:return Ae(g),null;case 31:if(g.memoizedState!==null){if(uo(g),g.alternate===null)throw Error(r(340));hf()}return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 13:if(uo(g),f=g.memoizedState,f!==null&&f.dehydrated!==null){if(g.alternate===null)throw Error(r(340));hf()}return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 19:return W(Li),null;case 4:return de(),null;case 10:return Kc(g.type),null;case 22:case 23:return uo(g),VC(),f!==null&&W(pf),f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 24:return Kc(Hi),null;case 25:return null;default:return null}}function B5(f,g){switch(AC(g),g.tag){case 3:Kc(Hi),de();break;case 26:case 27:case 5:Ae(g);break;case 4:de();break;case 31:g.memoizedState!==null&&uo(g);break;case 13:uo(g);break;case 19:W(Li);break;case 10:Kc(g.type);break;case 22:case 23:uo(g),VC(),f!==null&&W(pf);break;case 24:Kc(Hi)}}function _x(f,g){try{var _=g.updateQueue,C=_!==null?_.lastEffect:null;if(C!==null){var R=C.next;_=R;do{if((_.tag&f)===f){C=void 0;var O=_.create,ne=_.inst;C=O(),ne.destroy=C}_=_.next}while(_!==R)}}catch(Se){yr(g,g.return,Se)}}function Md(f,g,_){try{var C=g.updateQueue,R=C!==null?C.lastEffect:null;if(R!==null){var O=R.next;C=O;do{if((C.tag&f)===f){var ne=C.inst,Se=ne.destroy;if(Se!==void 0){ne.destroy=void 0,R=g;var Be=_,ut=Se;try{ut()}catch(vt){yr(R,Be,vt)}}}C=C.next}while(C!==O)}}catch(vt){yr(g,g.return,vt)}}function $5(f){var g=f.updateQueue;if(g!==null){var _=f.stateNode;try{PI(g,_)}catch(C){yr(f,f.return,C)}}}function H5(f,g,_){_.props=vf(f.type,f.memoizedProps),_.state=f.memoizedState;try{_.componentWillUnmount()}catch(C){yr(f,g,C)}}function Sx(f,g){try{var _=f.ref;if(_!==null){switch(f.tag){case 26:case 27:case 5:var C=f.stateNode;break;case 30:C=f.stateNode;break;default:C=f.stateNode}typeof _=="function"?f.refCleanup=_(C):_.current=C}}catch(R){yr(f,g,R)}}function oc(f,g){var _=f.ref,C=f.refCleanup;if(_!==null)if(typeof C=="function")try{C()}catch(R){yr(f,g,R)}finally{f.refCleanup=null,f=f.alternate,f!=null&&(f.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(R){yr(f,g,R)}else _.current=null}function V5(f){var g=f.type,_=f.memoizedProps,C=f.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":_.autoFocus&&C.focus();break e;case"img":_.src?C.src=_.src:_.srcSet&&(C.srcset=_.srcSet)}}catch(R){yr(f,f.return,R)}}function _2(f,g,_){try{var C=f.stateNode;Fae(C,f.type,_,g),C[sr]=g}catch(R){yr(f,f.return,R)}}function G5(f){return f.tag===5||f.tag===3||f.tag===26||f.tag===27&&Dd(f.type)||f.tag===4}function S2(f){e:for(;;){for(;f.sibling===null;){if(f.return===null||G5(f.return))return null;f=f.return}for(f.sibling.return=f.return,f=f.sibling;f.tag!==5&&f.tag!==6&&f.tag!==18;){if(f.tag===27&&Dd(f.type)||f.flags&2||f.child===null||f.tag===4)continue e;f.child.return=f,f=f.child}if(!(f.flags&2))return f.stateNode}}function N2(f,g,_){var C=f.tag;if(C===5||C===6)f=f.stateNode,g?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(f,g):(g=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,g.appendChild(f),_=_._reactRootContainer,_!=null||g.onclick!==null||(g.onclick=$t));else if(C!==4&&(C===27&&Dd(f.type)&&(_=f.stateNode,g=null),f=f.child,f!==null))for(N2(f,g,_),f=f.sibling;f!==null;)N2(f,g,_),f=f.sibling}function bw(f,g,_){var C=f.tag;if(C===5||C===6)f=f.stateNode,g?_.insertBefore(f,g):_.appendChild(f);else if(C!==4&&(C===27&&Dd(f.type)&&(_=f.stateNode),f=f.child,f!==null))for(bw(f,g,_),f=f.sibling;f!==null;)bw(f,g,_),f=f.sibling}function q5(f){var g=f.stateNode,_=f.memoizedProps;try{for(var C=f.type,R=g.attributes;R.length;)g.removeAttributeNode(R[0]);$a(g,C,_),g[Xt]=f,g[sr]=_}catch(O){yr(f,f.return,O)}}var Jc=!1,qi=!1,k2=!1,W5=typeof WeakSet=="function"?WeakSet:Set,Na=null;function gae(f,g){if(f=f.containerInfo,q2=Iw,f=aI(f),xC(f)){if("selectionStart"in f)var _={start:f.selectionStart,end:f.selectionEnd};else e:{_=(_=f.ownerDocument)&&_.defaultView||window;var C=_.getSelection&&_.getSelection();if(C&&C.rangeCount!==0){_=C.anchorNode;var R=C.anchorOffset,O=C.focusNode;C=C.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var ne=0,Se=-1,Be=-1,ut=0,vt=0,kt=f,ft=null;t:for(;;){for(var xt;kt!==_||R!==0&&kt.nodeType!==3||(Se=ne+R),kt!==O||C!==0&&kt.nodeType!==3||(Be=ne+C),kt.nodeType===3&&(ne+=kt.nodeValue.length),(xt=kt.firstChild)!==null;)ft=kt,kt=xt;for(;;){if(kt===f)break t;if(ft===_&&++ut===R&&(Se=ne),ft===O&&++vt===C&&(Be=ne),(xt=kt.nextSibling)!==null)break;kt=ft,ft=kt.parentNode}kt=xt}_=Se===-1||Be===-1?null:{start:Se,end:Be}}else _=null}_=_||{start:0,end:0}}else _=null;for(W2={focusedElem:f,selectionRange:_},Iw=!1,Na=g;Na!==null;)if(g=Na,f=g.child,(g.subtreeFlags&1028)!==0&&f!==null)f.return=g,Na=f;else for(;Na!==null;){switch(g=Na,O=g.alternate,f=g.flags,g.tag){case 0:if((f&4)!==0&&(f=g.updateQueue,f=f!==null?f.events:null,f!==null))for(_=0;_<f.length;_++)R=f[_],R.ref.impl=R.nextImpl;break;case 11:case 15:break;case 1:if((f&1024)!==0&&O!==null){f=void 0,_=g,R=O.memoizedProps,O=O.memoizedState,C=_.stateNode;try{var Wt=vf(_.type,R);f=C.getSnapshotBeforeUpdate(Wt,O),C.__reactInternalSnapshotBeforeUpdate=f}catch(dn){yr(_,_.return,dn)}}break;case 3:if((f&1024)!==0){if(f=g.stateNode.containerInfo,_=f.nodeType,_===9)Y2(f);else if(_===1)switch(f.nodeName){case"HEAD":case"HTML":case"BODY":Y2(f);break;default:f.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((f&1024)!==0)throw Error(r(163))}if(f=g.sibling,f!==null){f.return=g.return,Na=f;break}Na=g.return}}function K5(f,g,_){var C=_.flags;switch(_.tag){case 0:case 11:case 15:tu(f,_),C&4&&_x(5,_);break;case 1:if(tu(f,_),C&4)if(f=_.stateNode,g===null)try{f.componentDidMount()}catch(ne){yr(_,_.return,ne)}else{var R=vf(_.type,g.memoizedProps);g=g.memoizedState;try{f.componentDidUpdate(R,g,f.__reactInternalSnapshotBeforeUpdate)}catch(ne){yr(_,_.return,ne)}}C&64&&$5(_),C&512&&Sx(_,_.return);break;case 3:if(tu(f,_),C&64&&(f=_.updateQueue,f!==null)){if(g=null,_.child!==null)switch(_.child.tag){case 27:case 5:g=_.child.stateNode;break;case 1:g=_.child.stateNode}try{PI(f,g)}catch(ne){yr(_,_.return,ne)}}break;case 27:g===null&&C&4&&q5(_);case 26:case 5:tu(f,_),g===null&&C&4&&V5(_),C&512&&Sx(_,_.return);break;case 12:tu(f,_);break;case 31:tu(f,_),C&4&&Q5(f,_);break;case 13:tu(f,_),C&4&&Z5(f,_),C&64&&(f=_.memoizedState,f!==null&&(f=f.dehydrated,f!==null&&(_=kae.bind(null,_),Gae(f,_))));break;case 22:if(C=_.memoizedState!==null||Jc,!C){g=g!==null&&g.memoizedState!==null||qi,R=Jc;var O=qi;Jc=C,(qi=g)&&!O?nu(f,_,(_.subtreeFlags&8772)!==0):tu(f,_),Jc=R,qi=O}break;case 30:break;default:tu(f,_)}}function X5(f){var g=f.alternate;g!==null&&(f.alternate=null,X5(g)),f.child=null,f.deletions=null,f.sibling=null,f.tag===5&&(g=f.stateNode,g!==null&&ot(g)),f.stateNode=null,f.return=null,f.dependencies=null,f.memoizedProps=null,f.memoizedState=null,f.pendingProps=null,f.stateNode=null,f.updateQueue=null}var oi=null,Is=!1;function eu(f,g,_){for(_=_.child;_!==null;)Y5(f,g,_),_=_.sibling}function Y5(f,g,_){if(ye&&typeof ye.onCommitFiberUnmount=="function")try{ye.onCommitFiberUnmount(xe,_)}catch{}switch(_.tag){case 26:qi||oc(_,g),eu(f,g,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:qi||oc(_,g);var C=oi,R=Is;Dd(_.type)&&(oi=_.stateNode,Is=!1),eu(f,g,_),Px(_.stateNode),oi=C,Is=R;break;case 5:qi||oc(_,g);case 6:if(C=oi,R=Is,oi=null,eu(f,g,_),oi=C,Is=R,oi!==null)if(Is)try{(oi.nodeType===9?oi.body:oi.nodeName==="HTML"?oi.ownerDocument.body:oi).removeChild(_.stateNode)}catch(O){yr(_,g,O)}else try{oi.removeChild(_.stateNode)}catch(O){yr(_,g,O)}break;case 18:oi!==null&&(Is?(f=oi,$z(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,_.stateNode),Mp(f)):$z(oi,_.stateNode));break;case 4:C=oi,R=Is,oi=_.stateNode.containerInfo,Is=!0,eu(f,g,_),oi=C,Is=R;break;case 0:case 11:case 14:case 15:Md(2,_,g),qi||Md(4,_,g),eu(f,g,_);break;case 1:qi||(oc(_,g),C=_.stateNode,typeof C.componentWillUnmount=="function"&&H5(_,g,C)),eu(f,g,_);break;case 21:eu(f,g,_);break;case 22:qi=(C=qi)||_.memoizedState!==null,eu(f,g,_),qi=C;break;default:eu(f,g,_)}}function Q5(f,g){if(g.memoizedState===null&&(f=g.alternate,f!==null&&(f=f.memoizedState,f!==null))){f=f.dehydrated;try{Mp(f)}catch(_){yr(g,g.return,_)}}}function Z5(f,g){if(g.memoizedState===null&&(f=g.alternate,f!==null&&(f=f.memoizedState,f!==null&&(f=f.dehydrated,f!==null))))try{Mp(f)}catch(_){yr(g,g.return,_)}}function bae(f){switch(f.tag){case 31:case 13:case 19:var g=f.stateNode;return g===null&&(g=f.stateNode=new W5),g;case 22:return f=f.stateNode,g=f._retryCache,g===null&&(g=f._retryCache=new W5),g;default:throw Error(r(435,f.tag))}}function xw(f,g){var _=bae(f);g.forEach(function(C){if(!_.has(C)){_.add(C);var R=Mae.bind(null,f,C);C.then(R,R)}})}function zs(f,g){var _=g.deletions;if(_!==null)for(var C=0;C<_.length;C++){var R=_[C],O=f,ne=g,Se=ne;e:for(;Se!==null;){switch(Se.tag){case 27:if(Dd(Se.type)){oi=Se.stateNode,Is=!1;break e}break;case 5:oi=Se.stateNode,Is=!1;break e;case 3:case 4:oi=Se.stateNode.containerInfo,Is=!0;break e}Se=Se.return}if(oi===null)throw Error(r(160));Y5(O,ne,R),oi=null,Is=!1,O=R.alternate,O!==null&&(O.return=null),R.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)J5(g,f),g=g.sibling}var Tl=null;function J5(f,g){var _=f.alternate,C=f.flags;switch(f.tag){case 0:case 11:case 14:case 15:zs(g,f),Us(f),C&4&&(Md(3,f,f.return),_x(3,f),Md(5,f,f.return));break;case 1:zs(g,f),Us(f),C&512&&(qi||_===null||oc(_,_.return)),C&64&&Jc&&(f=f.updateQueue,f!==null&&(C=f.callbacks,C!==null&&(_=f.shared.hiddenCallbacks,f.shared.hiddenCallbacks=_===null?C:_.concat(C))));break;case 26:var R=Tl;if(zs(g,f),Us(f),C&512&&(qi||_===null||oc(_,_.return)),C&4){var O=_!==null?_.memoizedState:null;if(C=f.memoizedState,_===null)if(C===null)if(f.stateNode===null){e:{C=f.type,_=f.memoizedProps,R=R.ownerDocument||R;t:switch(C){case"title":O=R.getElementsByTagName("title")[0],(!O||O[pt]||O[Xt]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=R.createElement(C),R.head.insertBefore(O,R.querySelector("head > title"))),$a(O,C,_),O[Xt]=f,Ge(O),C=O;break e;case"link":var ne=Jz("link","href",R).get(C+(_.href||""));if(ne){for(var Se=0;Se<ne.length;Se++)if(O=ne[Se],O.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&O.getAttribute("rel")===(_.rel==null?null:_.rel)&&O.getAttribute("title")===(_.title==null?null:_.title)&&O.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){ne.splice(Se,1);break t}}O=R.createElement(C),$a(O,C,_),R.head.appendChild(O);break;case"meta":if(ne=Jz("meta","content",R).get(C+(_.content||""))){for(Se=0;Se<ne.length;Se++)if(O=ne[Se],O.getAttribute("content")===(_.content==null?null:""+_.content)&&O.getAttribute("name")===(_.name==null?null:_.name)&&O.getAttribute("property")===(_.property==null?null:_.property)&&O.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&O.getAttribute("charset")===(_.charSet==null?null:_.charSet)){ne.splice(Se,1);break t}}O=R.createElement(C),$a(O,C,_),R.head.appendChild(O);break;default:throw Error(r(468,C))}O[Xt]=f,Ge(O),C=O}f.stateNode=C}else eU(R,f.type,f.stateNode);else f.stateNode=Zz(R,C,f.memoizedProps);else O!==C?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,C===null?eU(R,f.type,f.stateNode):Zz(R,C,f.memoizedProps)):C===null&&f.stateNode!==null&&_2(f,f.memoizedProps,_.memoizedProps)}break;case 27:zs(g,f),Us(f),C&512&&(qi||_===null||oc(_,_.return)),_!==null&&C&4&&_2(f,f.memoizedProps,_.memoizedProps);break;case 5:if(zs(g,f),Us(f),C&512&&(qi||_===null||oc(_,_.return)),f.flags&32){R=f.stateNode;try{Ft(R,"")}catch(Wt){yr(f,f.return,Wt)}}C&4&&f.stateNode!=null&&(R=f.memoizedProps,_2(f,R,_!==null?_.memoizedProps:R)),C&1024&&(k2=!0);break;case 6:if(zs(g,f),Us(f),C&4){if(f.stateNode===null)throw Error(r(162));C=f.memoizedProps,_=f.stateNode;try{_.nodeValue=C}catch(Wt){yr(f,f.return,Wt)}}break;case 3:if(Rw=null,R=Tl,Tl=Pw(g.containerInfo),zs(g,f),Tl=R,Us(f),C&4&&_!==null&&_.memoizedState.isDehydrated)try{Mp(g.containerInfo)}catch(Wt){yr(f,f.return,Wt)}k2&&(k2=!1,ez(f));break;case 4:C=Tl,Tl=Pw(f.stateNode.containerInfo),zs(g,f),Us(f),Tl=C;break;case 12:zs(g,f),Us(f);break;case 31:zs(g,f),Us(f),C&4&&(C=f.updateQueue,C!==null&&(f.updateQueue=null,xw(f,C)));break;case 13:zs(g,f),Us(f),f.child.flags&8192&&f.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(vw=L()),C&4&&(C=f.updateQueue,C!==null&&(f.updateQueue=null,xw(f,C)));break;case 22:R=f.memoizedState!==null;var Be=_!==null&&_.memoizedState!==null,ut=Jc,vt=qi;if(Jc=ut||R,qi=vt||Be,zs(g,f),qi=vt,Jc=ut,Us(f),C&8192)e:for(g=f.stateNode,g._visibility=R?g._visibility&-2:g._visibility|1,R&&(_===null||Be||Jc||qi||wf(f)),_=null,g=f;;){if(g.tag===5||g.tag===26){if(_===null){Be=_=g;try{if(O=Be.stateNode,R)ne=O.style,typeof ne.setProperty=="function"?ne.setProperty("display","none","important"):ne.display="none";else{Se=Be.stateNode;var kt=Be.memoizedProps.style,ft=kt!=null&&kt.hasOwnProperty("display")?kt.display:null;Se.style.display=ft==null||typeof ft=="boolean"?"":(""+ft).trim()}}catch(Wt){yr(Be,Be.return,Wt)}}}else if(g.tag===6){if(_===null){Be=g;try{Be.stateNode.nodeValue=R?"":Be.memoizedProps}catch(Wt){yr(Be,Be.return,Wt)}}}else if(g.tag===18){if(_===null){Be=g;try{var xt=Be.stateNode;R?Hz(xt,!0):Hz(Be.stateNode,!1)}catch(Wt){yr(Be,Be.return,Wt)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===f)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===f)break e;for(;g.sibling===null;){if(g.return===null||g.return===f)break e;_===g&&(_=null),g=g.return}_===g&&(_=null),g.sibling.return=g.return,g=g.sibling}C&4&&(C=f.updateQueue,C!==null&&(_=C.retryQueue,_!==null&&(C.retryQueue=null,xw(f,_))));break;case 19:zs(g,f),Us(f),C&4&&(C=f.updateQueue,C!==null&&(f.updateQueue=null,xw(f,C)));break;case 30:break;case 21:break;default:zs(g,f),Us(f)}}function Us(f){var g=f.flags;if(g&2){try{for(var _,C=f.return;C!==null;){if(G5(C)){_=C;break}C=C.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var R=_.stateNode,O=S2(f);bw(f,O,R);break;case 5:var ne=_.stateNode;_.flags&32&&(Ft(ne,""),_.flags&=-33);var Se=S2(f);bw(f,Se,ne);break;case 3:case 4:var Be=_.stateNode.containerInfo,ut=S2(f);N2(f,ut,Be);break;default:throw Error(r(161))}}catch(vt){yr(f,f.return,vt)}f.flags&=-3}g&4096&&(f.flags&=-4097)}function ez(f){if(f.subtreeFlags&1024)for(f=f.child;f!==null;){var g=f;ez(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),f=f.sibling}}function tu(f,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)K5(f,g.alternate,g),g=g.sibling}function wf(f){for(f=f.child;f!==null;){var g=f;switch(g.tag){case 0:case 11:case 14:case 15:Md(4,g,g.return),wf(g);break;case 1:oc(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&H5(g,g.return,_),wf(g);break;case 27:Px(g.stateNode);case 26:case 5:oc(g,g.return),wf(g);break;case 22:g.memoizedState===null&&wf(g);break;case 30:wf(g);break;default:wf(g)}f=f.sibling}}function nu(f,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var C=g.alternate,R=f,O=g,ne=O.flags;switch(O.tag){case 0:case 11:case 15:nu(R,O,_),_x(4,O);break;case 1:if(nu(R,O,_),C=O,R=C.stateNode,typeof R.componentDidMount=="function")try{R.componentDidMount()}catch(ut){yr(C,C.return,ut)}if(C=O,R=C.updateQueue,R!==null){var Se=C.stateNode;try{var Be=R.shared.hiddenCallbacks;if(Be!==null)for(R.shared.hiddenCallbacks=null,R=0;R<Be.length;R++)jI(Be[R],Se)}catch(ut){yr(C,C.return,ut)}}_&&ne&64&&$5(O),Sx(O,O.return);break;case 27:q5(O);case 26:case 5:nu(R,O,_),_&&C===null&&ne&4&&V5(O),Sx(O,O.return);break;case 12:nu(R,O,_);break;case 31:nu(R,O,_),_&&ne&4&&Q5(R,O);break;case 13:nu(R,O,_),_&&ne&4&&Z5(R,O);break;case 22:O.memoizedState===null&&nu(R,O,_),Sx(O,O.return);break;case 30:break;default:nu(R,O,_)}g=g.sibling}}function M2(f,g){var _=null;f!==null&&f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(_=f.memoizedState.cachePool.pool),f=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(f=g.memoizedState.cachePool.pool),f!==_&&(f!=null&&f.refCount++,_!=null&&cx(_))}function C2(f,g){f=null,g.alternate!==null&&(f=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==f&&(g.refCount++,f!=null&&cx(f))}function jl(f,g,_,C){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)tz(f,g,_,C),g=g.sibling}function tz(f,g,_,C){var R=g.flags;switch(g.tag){case 0:case 11:case 15:jl(f,g,_,C),R&2048&&_x(9,g);break;case 1:jl(f,g,_,C);break;case 3:jl(f,g,_,C),R&2048&&(f=null,g.alternate!==null&&(f=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==f&&(g.refCount++,f!=null&&cx(f)));break;case 12:if(R&2048){jl(f,g,_,C),f=g.stateNode;try{var O=g.memoizedProps,ne=O.id,Se=O.onPostCommit;typeof Se=="function"&&Se(ne,g.alternate===null?"mount":"update",f.passiveEffectDuration,-0)}catch(Be){yr(g,g.return,Be)}}else jl(f,g,_,C);break;case 31:jl(f,g,_,C);break;case 13:jl(f,g,_,C);break;case 23:break;case 22:O=g.stateNode,ne=g.alternate,g.memoizedState!==null?O._visibility&2?jl(f,g,_,C):Nx(f,g):O._visibility&2?jl(f,g,_,C):(O._visibility|=2,pp(f,g,_,C,(g.subtreeFlags&10256)!==0||!1)),R&2048&&M2(ne,g);break;case 24:jl(f,g,_,C),R&2048&&C2(g.alternate,g);break;default:jl(f,g,_,C)}}function pp(f,g,_,C,R){for(R=R&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var O=f,ne=g,Se=_,Be=C,ut=ne.flags;switch(ne.tag){case 0:case 11:case 15:pp(O,ne,Se,Be,R),_x(8,ne);break;case 23:break;case 22:var vt=ne.stateNode;ne.memoizedState!==null?vt._visibility&2?pp(O,ne,Se,Be,R):Nx(O,ne):(vt._visibility|=2,pp(O,ne,Se,Be,R)),R&&ut&2048&&M2(ne.alternate,ne);break;case 24:pp(O,ne,Se,Be,R),R&&ut&2048&&C2(ne.alternate,ne);break;default:pp(O,ne,Se,Be,R)}g=g.sibling}}function Nx(f,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=f,C=g,R=C.flags;switch(C.tag){case 22:Nx(_,C),R&2048&&M2(C.alternate,C);break;case 24:Nx(_,C),R&2048&&C2(C.alternate,C);break;default:Nx(_,C)}g=g.sibling}}var kx=8192;function gp(f,g,_){if(f.subtreeFlags&kx)for(f=f.child;f!==null;)nz(f,g,_),f=f.sibling}function nz(f,g,_){switch(f.tag){case 26:gp(f,g,_),f.flags&kx&&f.memoizedState!==null&&rse(_,Tl,f.memoizedState,f.memoizedProps);break;case 5:gp(f,g,_);break;case 3:case 4:var C=Tl;Tl=Pw(f.stateNode.containerInfo),gp(f,g,_),Tl=C;break;case 22:f.memoizedState===null&&(C=f.alternate,C!==null&&C.memoizedState!==null?(C=kx,kx=16777216,gp(f,g,_),kx=C):gp(f,g,_));break;default:gp(f,g,_)}}function rz(f){var g=f.alternate;if(g!==null&&(f=g.child,f!==null)){g.child=null;do g=f.sibling,f.sibling=null,f=g;while(f!==null)}}function Mx(f){var g=f.deletions;if((f.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var C=g[_];Na=C,az(C,f)}rz(f)}if(f.subtreeFlags&10256)for(f=f.child;f!==null;)iz(f),f=f.sibling}function iz(f){switch(f.tag){case 0:case 11:case 15:Mx(f),f.flags&2048&&Md(9,f,f.return);break;case 3:Mx(f);break;case 12:Mx(f);break;case 22:var g=f.stateNode;f.memoizedState!==null&&g._visibility&2&&(f.return===null||f.return.tag!==13)?(g._visibility&=-3,yw(f)):Mx(f);break;default:Mx(f)}}function yw(f){var g=f.deletions;if((f.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var C=g[_];Na=C,az(C,f)}rz(f)}for(f=f.child;f!==null;){switch(g=f,g.tag){case 0:case 11:case 15:Md(8,g,g.return),yw(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,yw(g));break;default:yw(g)}f=f.sibling}}function az(f,g){for(;Na!==null;){var _=Na;switch(_.tag){case 0:case 11:case 15:Md(8,_,g);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var C=_.memoizedState.cachePool.pool;C!=null&&C.refCount++}break;case 24:cx(_.memoizedState.cache)}if(C=_.child,C!==null)C.return=_,Na=C;else e:for(_=f;Na!==null;){C=Na;var R=C.sibling,O=C.return;if(X5(C),C===_){Na=null;break e}if(R!==null){R.return=O,Na=R;break e}Na=O}}}var xae={getCacheForType:function(f){var g=Ua(Hi),_=g.data.get(f);return _===void 0&&(_=f(),g.data.set(f,_)),_},cacheSignal:function(){return Ua(Hi).controller.signal}},yae=typeof WeakMap=="function"?WeakMap:Map,fr=0,Fr=null,Hn=null,Yn=0,xr=0,ho=null,Cd=!1,bp=!1,E2=!1,ru=0,Mi=0,Ed=0,_f=0,A2=0,fo=0,xp=0,Cx=null,Bs=null,T2=!1,vw=0,sz=0,ww=1/0,_w=null,Ad=null,sa=0,Td=null,yp=null,iu=0,j2=0,P2=null,oz=null,Ex=0,D2=null;function mo(){return(fr&2)!==0&&Yn!==0?Yn&-Yn:q.T!==null?z2():dr()}function lz(){if(fo===0)if((Yn&536870912)===0||Jn){var f=je;je<<=1,(je&3932160)===0&&(je=262144),fo=f}else fo=536870912;return f=co.current,f!==null&&(f.flags|=32),fo}function $s(f,g,_){(f===Fr&&(xr===2||xr===9)||f.cancelPendingCommit!==null)&&(vp(f,0),jd(f,Yn,fo,!1)),an(f,_),((fr&2)===0||f!==Fr)&&(f===Fr&&((fr&2)===0&&(_f|=_),Mi===4&&jd(f,Yn,fo,!1)),lc(f))}function cz(f,g,_){if((fr&6)!==0)throw Error(r(327));var C=!_&&(g&127)===0&&(g&f.expiredLanes)===0||Ne(f,g),R=C?_ae(f,g):L2(f,g,!0),O=C;do{if(R===0){bp&&!C&&jd(f,g,0,!1);break}else{if(_=f.current.alternate,O&&!vae(_)){R=L2(f,g,!1),O=!1;continue}if(R===2){if(O=g,f.errorRecoveryDisabledLanes&O)var ne=0;else ne=f.pendingLanes&-536870913,ne=ne!==0?ne:ne&536870912?536870912:0;if(ne!==0){g=ne;e:{var Se=f;R=Cx;var Be=Se.current.memoizedState.isDehydrated;if(Be&&(vp(Se,ne).flags|=256),ne=L2(Se,ne,!1),ne!==2){if(E2&&!Be){Se.errorRecoveryDisabledLanes|=O,_f|=O,R=4;break e}O=Bs,Bs=R,O!==null&&(Bs===null?Bs=O:Bs.push.apply(Bs,O))}R=ne}if(O=!1,R!==2)continue}}if(R===1){vp(f,0),jd(f,g,0,!0);break}e:{switch(C=f,O=R,O){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:jd(C,g,fo,!Cd);break e;case 2:Bs=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(R=vw+300-L(),10<R)){if(jd(C,g,fo,!Cd),Oe(C,0,!0)!==0)break e;iu=g,C.timeoutHandle=Uz(uz.bind(null,C,_,Bs,_w,T2,g,fo,_f,xp,Cd,O,"Throttled",-0,0),R);break e}uz(C,_,Bs,_w,T2,g,fo,_f,xp,Cd,O,null,-0,0)}}break}while(!0);lc(f)}function uz(f,g,_,C,R,O,ne,Se,Be,ut,vt,kt,ft,xt){if(f.timeoutHandle=-1,kt=g.subtreeFlags,kt&8192||(kt&16785408)===16785408){kt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:$t},nz(g,O,kt);var Wt=(O&62914560)===O?vw-L():(O&4194048)===O?sz-L():0;if(Wt=ise(kt,Wt),Wt!==null){iu=O,f.cancelPendingCommit=Wt(xz.bind(null,f,g,O,_,C,R,ne,Se,Be,vt,kt,null,ft,xt)),jd(f,O,ne,!ut);return}}xz(f,g,O,_,C,R,ne,Se,Be)}function vae(f){for(var g=f;;){var _=g.tag;if((_===0||_===11||_===15)&&g.flags&16384&&(_=g.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var C=0;C<_.length;C++){var R=_[C],O=R.getSnapshot;R=R.value;try{if(!oo(O(),R))return!1}catch{return!1}}if(_=g.child,g.subtreeFlags&16384&&_!==null)_.return=g,g=_;else{if(g===f)break;for(;g.sibling===null;){if(g.return===null||g.return===f)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function jd(f,g,_,C){g&=~A2,g&=~_f,f.suspendedLanes|=g,f.pingedLanes&=~g,C&&(f.warmLanes|=g),C=f.expirationTimes;for(var R=g;0<R;){var O=31-Ue(R),ne=1<<O;C[O]=-1,R&=~ne}_!==0&&Fe(f,_,g)}function Sw(){return(fr&6)===0?(Ax(0),!1):!0}function R2(){if(Hn!==null){if(xr===0)var f=Hn.return;else f=Hn,Wc=ff=null,YC(f),up=null,dx=0,f=Hn;for(;f!==null;)B5(f.alternate,f),f=f.return;Hn=null}}function vp(f,g){var _=f.timeoutHandle;_!==-1&&(f.timeoutHandle=-1,Uae(_)),_=f.cancelPendingCommit,_!==null&&(f.cancelPendingCommit=null,_()),iu=0,R2(),Fr=f,Hn=_=Gc(f.current,null),Yn=g,xr=0,ho=null,Cd=!1,bp=Ne(f,g),E2=!1,xp=fo=A2=_f=Ed=Mi=0,Bs=Cx=null,T2=!1,(g&8)!==0&&(g|=g&32);var C=f.entangledLanes;if(C!==0)for(f=f.entanglements,C&=g;0<C;){var R=31-Ue(C),O=1<<R;g|=f[R],C&=~O}return ru=g,Vv(),_}function dz(f,g){En=null,q.H=yx,g===cp||g===Zv?(g=CI(),xr=3):g===IC?(g=CI(),xr=4):xr=g===h2?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,ho=g,Hn===null&&(Mi=1,hw(f,zo(g,f.current)))}function hz(){var f=co.current;return f===null?!0:(Yn&4194048)===Yn?Ho===null:(Yn&62914560)===Yn||(Yn&536870912)!==0?f===Ho:!1}function fz(){var f=q.H;return q.H=yx,f===null?yx:f}function mz(){var f=q.A;return q.A=xae,f}function Nw(){Mi=4,Cd||(Yn&4194048)!==Yn&&co.current!==null||(bp=!0),(Ed&134217727)===0&&(_f&134217727)===0||Fr===null||jd(Fr,Yn,fo,!1)}function L2(f,g,_){var C=fr;fr|=2;var R=fz(),O=mz();(Fr!==f||Yn!==g)&&(_w=null,vp(f,g)),g=!1;var ne=Mi;e:do try{if(xr!==0&&Hn!==null){var Se=Hn,Be=ho;switch(xr){case 8:R2(),ne=6;break e;case 3:case 2:case 9:case 6:co.current===null&&(g=!0);var ut=xr;if(xr=0,ho=null,wp(f,Se,Be,ut),_&&bp){ne=0;break e}break;default:ut=xr,xr=0,ho=null,wp(f,Se,Be,ut)}}wae(),ne=Mi;break}catch(vt){dz(f,vt)}while(!0);return g&&f.shellSuspendCounter++,Wc=ff=null,fr=C,q.H=R,q.A=O,Hn===null&&(Fr=null,Yn=0,Vv()),ne}function wae(){for(;Hn!==null;)pz(Hn)}function _ae(f,g){var _=fr;fr|=2;var C=fz(),R=mz();Fr!==f||Yn!==g?(_w=null,ww=L()+500,vp(f,g)):bp=Ne(f,g);e:do try{if(xr!==0&&Hn!==null){g=Hn;var O=ho;t:switch(xr){case 1:xr=0,ho=null,wp(f,g,O,1);break;case 2:case 9:if(kI(O)){xr=0,ho=null,gz(g);break}g=function(){xr!==2&&xr!==9||Fr!==f||(xr=7),lc(f)},O.then(g,g);break e;case 3:xr=7;break e;case 4:xr=5;break e;case 7:kI(O)?(xr=0,ho=null,gz(g)):(xr=0,ho=null,wp(f,g,O,7));break;case 5:var ne=null;switch(Hn.tag){case 26:ne=Hn.memoizedState;case 5:case 27:var Se=Hn;if(ne?tU(ne):Se.stateNode.complete){xr=0,ho=null;var Be=Se.sibling;if(Be!==null)Hn=Be;else{var ut=Se.return;ut!==null?(Hn=ut,kw(ut)):Hn=null}break t}}xr=0,ho=null,wp(f,g,O,5);break;case 6:xr=0,ho=null,wp(f,g,O,6);break;case 8:R2(),Mi=6;break e;default:throw Error(r(462))}}Sae();break}catch(vt){dz(f,vt)}while(!0);return Wc=ff=null,q.H=C,q.A=R,fr=_,Hn!==null?0:(Fr=null,Yn=0,Vv(),Mi)}function Sae(){for(;Hn!==null&&!te();)pz(Hn)}function pz(f){var g=z5(f.alternate,f,ru);f.memoizedProps=f.pendingProps,g===null?kw(f):Hn=g}function gz(f){var g=f,_=g.alternate;switch(g.tag){case 15:case 0:g=D5(_,g,g.pendingProps,g.type,void 0,Yn);break;case 11:g=D5(_,g,g.pendingProps,g.type.render,g.ref,Yn);break;case 5:YC(g);default:B5(_,g),g=Hn=mI(g,ru),g=z5(_,g,ru)}f.memoizedProps=f.pendingProps,g===null?kw(f):Hn=g}function wp(f,g,_,C){Wc=ff=null,YC(g),up=null,dx=0;var R=g.return;try{if(dae(f,R,g,_,Yn)){Mi=1,hw(f,zo(_,f.current)),Hn=null;return}}catch(O){if(R!==null)throw Hn=R,O;Mi=1,hw(f,zo(_,f.current)),Hn=null;return}g.flags&32768?(Jn||C===1?f=!0:bp||(Yn&536870912)!==0?f=!1:(Cd=f=!0,(C===2||C===9||C===3||C===6)&&(C=co.current,C!==null&&C.tag===13&&(C.flags|=16384))),bz(g,f)):kw(g)}function kw(f){var g=f;do{if((g.flags&32768)!==0){bz(g,Cd);return}f=g.return;var _=mae(g.alternate,g,ru);if(_!==null){Hn=_;return}if(g=g.sibling,g!==null){Hn=g;return}Hn=g=f}while(g!==null);Mi===0&&(Mi=5)}function bz(f,g){do{var _=pae(f.alternate,f);if(_!==null){_.flags&=32767,Hn=_;return}if(_=f.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!g&&(f=f.sibling,f!==null)){Hn=f;return}Hn=f=_}while(f!==null);Mi=6,Hn=null}function xz(f,g,_,C,R,O,ne,Se,Be){f.cancelPendingCommit=null;do Mw();while(sa!==0);if((fr&6)!==0)throw Error(r(327));if(g!==null){if(g===f.current)throw Error(r(177));if(O=g.lanes|g.childLanes,O|=SC,jt(f,_,O,ne,Se,Be),f===Fr&&(Hn=Fr=null,Yn=0),yp=g,Td=f,iu=_,j2=O,P2=R,oz=C,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(f.callbackNode=null,f.callbackPriority=0,Cae(Ee,function(){return Sz(),null})):(f.callbackNode=null,f.callbackPriority=0),C=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||C){C=q.T,q.T=null,R=I.p,I.p=2,ne=fr,fr|=4;try{gae(f,g,_)}finally{fr=ne,I.p=R,q.T=C}}sa=1,yz(),vz(),wz()}}function yz(){if(sa===1){sa=0;var f=Td,g=yp,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=q.T,q.T=null;var C=I.p;I.p=2;var R=fr;fr|=4;try{J5(g,f);var O=W2,ne=aI(f.containerInfo),Se=O.focusedElem,Be=O.selectionRange;if(ne!==Se&&Se&&Se.ownerDocument&&iI(Se.ownerDocument.documentElement,Se)){if(Be!==null&&xC(Se)){var ut=Be.start,vt=Be.end;if(vt===void 0&&(vt=ut),"selectionStart"in Se)Se.selectionStart=ut,Se.selectionEnd=Math.min(vt,Se.value.length);else{var kt=Se.ownerDocument||document,ft=kt&&kt.defaultView||window;if(ft.getSelection){var xt=ft.getSelection(),Wt=Se.textContent.length,dn=Math.min(Be.start,Wt),Cr=Be.end===void 0?dn:Math.min(Be.end,Wt);!xt.extend&&dn>Cr&&(ne=Cr,Cr=dn,dn=ne);var tt=rI(Se,dn),qe=rI(Se,Cr);if(tt&&qe&&(xt.rangeCount!==1||xt.anchorNode!==tt.node||xt.anchorOffset!==tt.offset||xt.focusNode!==qe.node||xt.focusOffset!==qe.offset)){var ct=kt.createRange();ct.setStart(tt.node,tt.offset),xt.removeAllRanges(),dn>Cr?(xt.addRange(ct),xt.extend(qe.node,qe.offset)):(ct.setEnd(qe.node,qe.offset),xt.addRange(ct))}}}}for(kt=[],xt=Se;xt=xt.parentNode;)xt.nodeType===1&&kt.push({element:xt,left:xt.scrollLeft,top:xt.scrollTop});for(typeof Se.focus=="function"&&Se.focus(),Se=0;Se<kt.length;Se++){var St=kt[Se];St.element.scrollLeft=St.left,St.element.scrollTop=St.top}}Iw=!!q2,W2=q2=null}finally{fr=R,I.p=C,q.T=_}}f.current=g,sa=2}}function vz(){if(sa===2){sa=0;var f=Td,g=yp,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=q.T,q.T=null;var C=I.p;I.p=2;var R=fr;fr|=4;try{K5(f,g.alternate,g)}finally{fr=R,I.p=C,q.T=_}}sa=3}}function wz(){if(sa===4||sa===3){sa=0,U();var f=Td,g=yp,_=iu,C=oz;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?sa=5:(sa=0,yp=Td=null,_z(f,f.pendingLanes));var R=f.pendingLanes;if(R===0&&(Ad=null),un(_),g=g.stateNode,ye&&typeof ye.onCommitFiberRoot=="function")try{ye.onCommitFiberRoot(xe,g,void 0,(g.current.flags&128)===128)}catch{}if(C!==null){g=q.T,R=I.p,I.p=2,q.T=null;try{for(var O=f.onRecoverableError,ne=0;ne<C.length;ne++){var Se=C[ne];O(Se.value,{componentStack:Se.stack})}}finally{q.T=g,I.p=R}}(iu&3)!==0&&Mw(),lc(f),R=f.pendingLanes,(_&261930)!==0&&(R&42)!==0?f===D2?Ex++:(Ex=0,D2=f):Ex=0,Ax(0)}}function _z(f,g){(f.pooledCacheLanes&=g)===0&&(g=f.pooledCache,g!=null&&(f.pooledCache=null,cx(g)))}function Mw(){return yz(),vz(),wz(),Sz()}function Sz(){if(sa!==5)return!1;var f=Td,g=j2;j2=0;var _=un(iu),C=q.T,R=I.p;try{I.p=32>_?32:_,q.T=null,_=P2,P2=null;var O=Td,ne=iu;if(sa=0,yp=Td=null,iu=0,(fr&6)!==0)throw Error(r(331));var Se=fr;if(fr|=4,iz(O.current),tz(O,O.current,ne,_),fr=Se,Ax(0,!1),ye&&typeof ye.onPostCommitFiberRoot=="function")try{ye.onPostCommitFiberRoot(xe,O)}catch{}return!0}finally{I.p=R,q.T=C,_z(f,g)}}function Nz(f,g,_){g=zo(_,g),g=d2(f.stateNode,g,2),f=Sd(f,g,2),f!==null&&(an(f,2),lc(f))}function yr(f,g,_){if(f.tag===3)Nz(f,f,_);else for(;g!==null;){if(g.tag===3){Nz(g,f,_);break}else if(g.tag===1){var C=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof C.componentDidCatch=="function"&&(Ad===null||!Ad.has(C))){f=zo(_,f),_=k5(2),C=Sd(g,_,2),C!==null&&(M5(_,C,g,f),an(C,2),lc(C));break}}g=g.return}}function O2(f,g,_){var C=f.pingCache;if(C===null){C=f.pingCache=new yae;var R=new Set;C.set(g,R)}else R=C.get(g),R===void 0&&(R=new Set,C.set(g,R));R.has(_)||(E2=!0,R.add(_),f=Nae.bind(null,f,g,_),g.then(f,f))}function Nae(f,g,_){var C=f.pingCache;C!==null&&C.delete(g),f.pingedLanes|=f.suspendedLanes&_,f.warmLanes&=~_,Fr===f&&(Yn&_)===_&&(Mi===4||Mi===3&&(Yn&62914560)===Yn&&300>L()-vw?(fr&2)===0&&vp(f,0):A2|=_,xp===Yn&&(xp=0)),lc(f)}function kz(f,g){g===0&&(g=yt()),f=uf(f,g),f!==null&&(an(f,g),lc(f))}function kae(f){var g=f.memoizedState,_=0;g!==null&&(_=g.retryLane),kz(f,_)}function Mae(f,g){var _=0;switch(f.tag){case 31:case 13:var C=f.stateNode,R=f.memoizedState;R!==null&&(_=R.retryLane);break;case 19:C=f.stateNode;break;case 22:C=f.stateNode._retryCache;break;default:throw Error(r(314))}C!==null&&C.delete(g),kz(f,_)}function Cae(f,g){return le(f,g)}var Cw=null,_p=null,F2=!1,Ew=!1,I2=!1,Pd=0;function lc(f){f!==_p&&f.next===null&&(_p===null?Cw=_p=f:_p=_p.next=f),Ew=!0,F2||(F2=!0,Aae())}function Ax(f,g){if(!I2&&Ew){I2=!0;do for(var _=!1,C=Cw;C!==null;){if(f!==0){var R=C.pendingLanes;if(R===0)var O=0;else{var ne=C.suspendedLanes,Se=C.pingedLanes;O=(1<<31-Ue(42|f)+1)-1,O&=R&~(ne&~Se),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,Az(C,O))}else O=Yn,O=Oe(C,C===Fr?O:0,C.cancelPendingCommit!==null||C.timeoutHandle!==-1),(O&3)===0||Ne(C,O)||(_=!0,Az(C,O));C=C.next}while(_);I2=!1}}function Eae(){Mz()}function Mz(){Ew=F2=!1;var f=0;Pd!==0&&zae()&&(f=Pd);for(var g=L(),_=null,C=Cw;C!==null;){var R=C.next,O=Cz(C,g);O===0?(C.next=null,_===null?Cw=R:_.next=R,R===null&&(_p=_)):(_=C,(f!==0||(O&3)!==0)&&(Ew=!0)),C=R}sa!==0&&sa!==5||Ax(f),Pd!==0&&(Pd=0)}function Cz(f,g){for(var _=f.suspendedLanes,C=f.pingedLanes,R=f.expirationTimes,O=f.pendingLanes&-62914561;0<O;){var ne=31-Ue(O),Se=1<<ne,Be=R[ne];Be===-1?((Se&_)===0||(Se&C)!==0)&&(R[ne]=Je(Se,g)):Be<=g&&(f.expiredLanes|=Se),O&=~Se}if(g=Fr,_=Yn,_=Oe(f,f===g?_:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),C=f.callbackNode,_===0||f===g&&(xr===2||xr===9)||f.cancelPendingCommit!==null)return C!==null&&C!==null&&he(C),f.callbackNode=null,f.callbackPriority=0;if((_&3)===0||Ne(f,_)){if(g=_&-_,g===f.callbackPriority)return g;switch(C!==null&&he(C),un(_)){case 2:case 8:_=_e;break;case 32:_=Ee;break;case 268435456:_=Ce;break;default:_=Ee}return C=Ez.bind(null,f),_=le(_,C),f.callbackPriority=g,f.callbackNode=_,g}return C!==null&&C!==null&&he(C),f.callbackPriority=2,f.callbackNode=null,2}function Ez(f,g){if(sa!==0&&sa!==5)return f.callbackNode=null,f.callbackPriority=0,null;var _=f.callbackNode;if(Mw()&&f.callbackNode!==_)return null;var C=Yn;return C=Oe(f,f===Fr?C:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),C===0?null:(cz(f,C,g),Cz(f,L()),f.callbackNode!=null&&f.callbackNode===_?Ez.bind(null,f):null)}function Az(f,g){if(Mw())return null;cz(f,g,!0)}function Aae(){Bae(function(){(fr&6)!==0?le(ge,Eae):Mz()})}function z2(){if(Pd===0){var f=op;f===0&&(f=Ze,Ze<<=1,(Ze&261888)===0&&(Ze=256)),Pd=f}return Pd}function Tz(f){return f==null||typeof f=="symbol"||typeof f=="boolean"?null:typeof f=="function"?f:wa(""+f)}function jz(f,g){var _=g.ownerDocument.createElement("input");return _.name=g.name,_.value=g.value,f.id&&_.setAttribute("form",f.id),g.parentNode.insertBefore(_,g),f=new FormData(f),_.parentNode.removeChild(_),f}function Tae(f,g,_,C,R){if(g==="submit"&&_&&_.stateNode===R){var O=Tz((R[sr]||null).action),ne=C.submitter;ne&&(g=(g=ne[sr]||null)?Tz(g.formAction):ne.getAttribute("formAction"),g!==null&&(O=g,ne=null));var Se=new rf("action","action",null,C,R);f.push({event:Se,listeners:[{instance:null,listener:function(){if(C.defaultPrevented){if(Pd!==0){var Be=ne?jz(R,ne):new FormData(R);a2(_,{pending:!0,data:Be,method:R.method,action:O},null,Be)}}else typeof O=="function"&&(Se.preventDefault(),Be=ne?jz(R,ne):new FormData(R),a2(_,{pending:!0,data:Be,method:R.method,action:O},O,Be))},currentTarget:R}]})}}for(var U2=0;U2<_C.length;U2++){var B2=_C[U2],jae=B2.toLowerCase(),Pae=B2[0].toUpperCase()+B2.slice(1);Al(jae,"on"+Pae)}Al(lI,"onAnimationEnd"),Al(cI,"onAnimationIteration"),Al(uI,"onAnimationStart"),Al("dblclick","onDoubleClick"),Al("focusin","onFocus"),Al("focusout","onBlur"),Al(Kie,"onTransitionRun"),Al(Xie,"onTransitionStart"),Al(Yie,"onTransitionCancel"),Al(dI,"onTransitionEnd"),rt("onMouseEnter",["mouseout","mouseover"]),rt("onMouseLeave",["mouseout","mouseover"]),rt("onPointerEnter",["pointerout","pointerover"]),rt("onPointerLeave",["pointerout","pointerover"]),ht("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ht("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ht("onBeforeInput",["compositionend","keypress","textInput","paste"]),ht("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ht("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ht("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Tx="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(" "),Dae=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Tx));function Pz(f,g){g=(g&4)!==0;for(var _=0;_<f.length;_++){var C=f[_],R=C.event;C=C.listeners;e:{var O=void 0;if(g)for(var ne=C.length-1;0<=ne;ne--){var Se=C[ne],Be=Se.instance,ut=Se.currentTarget;if(Se=Se.listener,Be!==O&&R.isPropagationStopped())break e;O=Se,R.currentTarget=ut;try{O(R)}catch(vt){Hv(vt)}R.currentTarget=null,O=Be}else for(ne=0;ne<C.length;ne++){if(Se=C[ne],Be=Se.instance,ut=Se.currentTarget,Se=Se.listener,Be!==O&&R.isPropagationStopped())break e;O=Se,R.currentTarget=ut;try{O(R)}catch(vt){Hv(vt)}R.currentTarget=null,O=Be}}}}function Vn(f,g){var _=g[Fa];_===void 0&&(_=g[Fa]=new Set);var C=f+"__bubble";_.has(C)||(Dz(g,f,2,!1),_.add(C))}function $2(f,g,_){var C=0;g&&(C|=4),Dz(_,f,C,g)}var Aw="_reactListening"+Math.random().toString(36).slice(2);function H2(f){if(!f[Aw]){f[Aw]=!0,be.forEach(function(_){_!=="selectionchange"&&(Dae.has(_)||$2(_,!1,f),$2(_,!0,f))});var g=f.nodeType===9?f:f.ownerDocument;g===null||g[Aw]||(g[Aw]=!0,$2("selectionchange",!1,g))}}function Dz(f,g,_,C){switch(lU(g)){case 2:var R=ose;break;case 8:R=lse;break;default:R=iE}_=R.bind(null,g,_,f),R=void 0,!kl||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(R=!0),C?R!==void 0?f.addEventListener(g,_,{capture:!0,passive:R}):f.addEventListener(g,_,!0):R!==void 0?f.addEventListener(g,_,{passive:R}):f.addEventListener(g,_,!1)}function V2(f,g,_,C,R){var O=C;if((g&1)===0&&(g&2)===0&&C!==null)e:for(;;){if(C===null)return;var ne=C.tag;if(ne===3||ne===4){var Se=C.stateNode.containerInfo;if(Se===R)break;if(ne===4)for(ne=C.return;ne!==null;){var Be=ne.tag;if((Be===3||Be===4)&&ne.stateNode.containerInfo===R)return;ne=ne.return}for(;Se!==null;){if(ne=Lt(Se),ne===null)return;if(Be=ne.tag,Be===5||Be===6||Be===26||Be===27){C=O=ne;continue e}Se=Se.parentNode}}C=C.return}Nl(function(){var ut=O,vt=_a(_),kt=[];e:{var ft=hI.get(f);if(ft!==void 0){var xt=rf,Wt=f;switch(f){case"keypress":if(Ni(_)===0)break e;case"keydown":case"keyup":xt=gd;break;case"focusin":Wt="focus",xt=xn;break;case"focusout":Wt="blur",xt=xn;break;case"beforeblur":case"afterblur":xt=xn;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":xt=of;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xt=Ov;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xt=HF;break;case lI:case cI:case uI:xt=ex;break;case dI:xt=jie;break;case"scroll":case"scrollend":xt=pd;break;case"wheel":xt=Die;break;case"copy":case"cut":case"paste":xt=tx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xt=ts;break;case"toggle":case"beforetoggle":xt=Lie}var dn=(g&4)!==0,Cr=!dn&&(f==="scroll"||f==="scrollend"),tt=dn?ft!==null?ft+"Capture":null:ft;dn=[];for(var qe=ut,ct;qe!==null;){var St=qe;if(ct=St.stateNode,St=St.tag,St!==5&&St!==26&&St!==27||ct===null||tt===null||(St=Oo(qe,tt),St!=null&&dn.push(jx(qe,St,ct))),Cr)break;qe=qe.return}0<dn.length&&(ft=new xt(ft,Wt,null,_,vt),kt.push({event:ft,listeners:dn}))}}if((g&7)===0){e:{if(ft=f==="mouseover"||f==="pointerover",xt=f==="mouseout"||f==="pointerout",ft&&_!==bn&&(Wt=_.relatedTarget||_.fromElement)&&(Lt(Wt)||Wt[vi]))break e;if((xt||ft)&&(ft=vt.window===vt?vt:(ft=vt.ownerDocument)?ft.defaultView||ft.parentWindow:window,xt?(Wt=_.relatedTarget||_.toElement,xt=ut,Wt=Wt?Lt(Wt):null,Wt!==null&&(Cr=s(Wt),dn=Wt.tag,Wt!==Cr||dn!==5&&dn!==27&&dn!==6)&&(Wt=null)):(xt=null,Wt=ut),xt!==Wt)){if(dn=of,St="onMouseLeave",tt="onMouseEnter",qe="mouse",(f==="pointerout"||f==="pointerover")&&(dn=ts,St="onPointerLeave",tt="onPointerEnter",qe="pointer"),Cr=xt==null?ft:ze(xt),ct=Wt==null?ft:ze(Wt),ft=new dn(St,qe+"leave",xt,_,vt),ft.target=Cr,ft.relatedTarget=ct,St=null,Lt(vt)===ut&&(dn=new dn(tt,qe+"enter",Wt,_,vt),dn.target=ct,dn.relatedTarget=Cr,St=dn),Cr=St,xt&&Wt)t:{for(dn=Rae,tt=xt,qe=Wt,ct=0,St=tt;St;St=dn(St))ct++;St=0;for(var nn=qe;nn;nn=dn(nn))St++;for(;0<ct-St;)tt=dn(tt),ct--;for(;0<St-ct;)qe=dn(qe),St--;for(;ct--;){if(tt===qe||qe!==null&&tt===qe.alternate){dn=tt;break t}tt=dn(tt),qe=dn(qe)}dn=null}else dn=null;xt!==null&&Rz(kt,ft,xt,dn,!1),Wt!==null&&Cr!==null&&Rz(kt,Cr,Wt,dn,!0)}}e:{if(ft=ut?ze(ut):window,xt=ft.nodeName&&ft.nodeName.toLowerCase(),xt==="select"||xt==="input"&&ft.type==="file")var or=QF;else if(XF(ft))if(ZF)or=Gie;else{or=Hie;var Yt=$ie}else xt=ft.nodeName,!xt||xt.toLowerCase()!=="input"||ft.type!=="checkbox"&&ft.type!=="radio"?ut&&Yr(ut.elementType)&&(or=QF):or=Vie;if(or&&(or=or(f,ut))){YF(kt,or,_,vt);break e}Yt&&Yt(f,ft,ut),f==="focusout"&&ut&&ft.type==="number"&&ut.memoizedProps.value!=null&&mi(ft,"number",ft.value)}switch(Yt=ut?ze(ut):window,f){case"focusin":(XF(Yt)||Yt.contentEditable==="true")&&(Jm=Yt,yC=ut,sx=null);break;case"focusout":sx=yC=Jm=null;break;case"mousedown":vC=!0;break;case"contextmenu":case"mouseup":case"dragend":vC=!1,sI(kt,_,vt);break;case"selectionchange":if(Wie)break;case"keydown":case"keyup":sI(kt,_,vt)}var An;if(pC)e:{switch(f){case"compositionstart":var Qn="onCompositionStart";break e;case"compositionend":Qn="onCompositionEnd";break e;case"compositionupdate":Qn="onCompositionUpdate";break e}Qn=void 0}else Zm?WF(f,_)&&(Qn="onCompositionEnd"):f==="keydown"&&_.keyCode===229&&(Qn="onCompositionStart");Qn&&(VF&&_.locale!=="ko"&&(Zm||Qn!=="onCompositionStart"?Qn==="onCompositionEnd"&&Zm&&(An=Gr()):(Ia=vt,Si="value"in Ia?Ia.value:Ia.textContent,Zm=!0)),Yt=Tw(ut,Qn),0<Yt.length&&(Qn=new Uv(Qn,f,null,_,vt),kt.push({event:Qn,listeners:Yt}),An?Qn.data=An:(An=KF(_),An!==null&&(Qn.data=An)))),(An=Fie?Iie(f,_):zie(f,_))&&(Qn=Tw(ut,"onBeforeInput"),0<Qn.length&&(Yt=new Uv("onBeforeInput","beforeinput",null,_,vt),kt.push({event:Yt,listeners:Qn}),Yt.data=An)),Tae(kt,f,ut,_,vt)}Pz(kt,g)})}function jx(f,g,_){return{instance:f,listener:g,currentTarget:_}}function Tw(f,g){for(var _=g+"Capture",C=[];f!==null;){var R=f,O=R.stateNode;if(R=R.tag,R!==5&&R!==26&&R!==27||O===null||(R=Oo(f,_),R!=null&&C.unshift(jx(f,R,O)),R=Oo(f,g),R!=null&&C.push(jx(f,R,O))),f.tag===3)return C;f=f.return}return[]}function Rae(f){if(f===null)return null;do f=f.return;while(f&&f.tag!==5&&f.tag!==27);return f||null}function Rz(f,g,_,C,R){for(var O=g._reactName,ne=[];_!==null&&_!==C;){var Se=_,Be=Se.alternate,ut=Se.stateNode;if(Se=Se.tag,Be!==null&&Be===C)break;Se!==5&&Se!==26&&Se!==27||ut===null||(Be=ut,R?(ut=Oo(_,O),ut!=null&&ne.unshift(jx(_,ut,Be))):R||(ut=Oo(_,O),ut!=null&&ne.push(jx(_,ut,Be)))),_=_.return}ne.length!==0&&f.push({event:g,listeners:ne})}var Lae=/\r\n?/g,Oae=/\u0000|\uFFFD/g;function Lz(f){return(typeof f=="string"?f:""+f).replace(Lae,`
  9. `).replace(Oae,"")}function Oz(f,g){return g=Lz(g),Lz(f)===g}function Mr(f,g,_,C,R,O){switch(_){case"children":typeof C=="string"?g==="body"||g==="textarea"&&C===""||Ft(f,C):(typeof C=="number"||typeof C=="bigint")&&g!=="body"&&Ft(f,""+C);break;case"className":Kt(f,"class",C);break;case"tabIndex":Kt(f,"tabindex",C);break;case"dir":case"role":case"viewBox":case"width":case"height":Kt(f,_,C);break;case"style":rr(f,C,O);break;case"data":if(g!=="object"){Kt(f,"data",C);break}case"src":case"href":if(C===""&&(g!=="a"||_!=="href")){f.removeAttribute(_);break}if(C==null||typeof C=="function"||typeof C=="symbol"||typeof C=="boolean"){f.removeAttribute(_);break}C=wa(""+C),f.setAttribute(_,C);break;case"action":case"formAction":if(typeof C=="function"){f.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 O=="function"&&(_==="formAction"?(g!=="input"&&Mr(f,g,"name",R.name,R,null),Mr(f,g,"formEncType",R.formEncType,R,null),Mr(f,g,"formMethod",R.formMethod,R,null),Mr(f,g,"formTarget",R.formTarget,R,null)):(Mr(f,g,"encType",R.encType,R,null),Mr(f,g,"method",R.method,R,null),Mr(f,g,"target",R.target,R,null)));if(C==null||typeof C=="symbol"||typeof C=="boolean"){f.removeAttribute(_);break}C=wa(""+C),f.setAttribute(_,C);break;case"onClick":C!=null&&(f.onclick=$t);break;case"onScroll":C!=null&&Vn("scroll",f);break;case"onScrollEnd":C!=null&&Vn("scrollend",f);break;case"dangerouslySetInnerHTML":if(C!=null){if(typeof C!="object"||!("__html"in C))throw Error(r(61));if(_=C.__html,_!=null){if(R.children!=null)throw Error(r(60));f.innerHTML=_}}break;case"multiple":f.multiple=C&&typeof C!="function"&&typeof C!="symbol";break;case"muted":f.muted=C&&typeof C!="function"&&typeof C!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(C==null||typeof C=="function"||typeof C=="boolean"||typeof C=="symbol"){f.removeAttribute("xlink:href");break}_=wa(""+C),f.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":C!=null&&typeof C!="function"&&typeof C!="symbol"?f.setAttribute(_,""+C):f.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":C&&typeof C!="function"&&typeof C!="symbol"?f.setAttribute(_,""):f.removeAttribute(_);break;case"capture":case"download":C===!0?f.setAttribute(_,""):C!==!1&&C!=null&&typeof C!="function"&&typeof C!="symbol"?f.setAttribute(_,C):f.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":C!=null&&typeof C!="function"&&typeof C!="symbol"&&!isNaN(C)&&1<=C?f.setAttribute(_,C):f.removeAttribute(_);break;case"rowSpan":case"start":C==null||typeof C=="function"||typeof C=="symbol"||isNaN(C)?f.removeAttribute(_):f.setAttribute(_,C);break;case"popover":Vn("beforetoggle",f),Vn("toggle",f),Jt(f,"popover",C);break;case"xlinkActuate":fn(f,"http://www.w3.org/1999/xlink","xlink:actuate",C);break;case"xlinkArcrole":fn(f,"http://www.w3.org/1999/xlink","xlink:arcrole",C);break;case"xlinkRole":fn(f,"http://www.w3.org/1999/xlink","xlink:role",C);break;case"xlinkShow":fn(f,"http://www.w3.org/1999/xlink","xlink:show",C);break;case"xlinkTitle":fn(f,"http://www.w3.org/1999/xlink","xlink:title",C);break;case"xlinkType":fn(f,"http://www.w3.org/1999/xlink","xlink:type",C);break;case"xmlBase":fn(f,"http://www.w3.org/XML/1998/namespace","xml:base",C);break;case"xmlLang":fn(f,"http://www.w3.org/XML/1998/namespace","xml:lang",C);break;case"xmlSpace":fn(f,"http://www.w3.org/XML/1998/namespace","xml:space",C);break;case"is":Jt(f,"is",C);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=ai.get(_)||_,Jt(f,_,C))}}function G2(f,g,_,C,R,O){switch(_){case"style":rr(f,C,O);break;case"dangerouslySetInnerHTML":if(C!=null){if(typeof C!="object"||!("__html"in C))throw Error(r(61));if(_=C.__html,_!=null){if(R.children!=null)throw Error(r(60));f.innerHTML=_}}break;case"children":typeof C=="string"?Ft(f,C):(typeof C=="number"||typeof C=="bigint")&&Ft(f,""+C);break;case"onScroll":C!=null&&Vn("scroll",f);break;case"onScrollEnd":C!=null&&Vn("scrollend",f);break;case"onClick":C!=null&&(f.onclick=$t);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"&&(R=_.endsWith("Capture"),g=_.slice(2,R?_.length-7:void 0),O=f[sr]||null,O=O!=null?O[_]:null,typeof O=="function"&&f.removeEventListener(g,O,R),typeof C=="function")){typeof O!="function"&&O!==null&&(_ in f?f[_]=null:f.hasAttribute(_)&&f.removeAttribute(_)),f.addEventListener(g,C,R);break e}_ in f?f[_]=C:C===!0?f.setAttribute(_,""):Jt(f,_,C)}}}function $a(f,g,_){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Vn("error",f),Vn("load",f);var C=!1,R=!1,O;for(O in _)if(_.hasOwnProperty(O)){var ne=_[O];if(ne!=null)switch(O){case"src":C=!0;break;case"srcSet":R=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:Mr(f,g,O,ne,_,null)}}R&&Mr(f,g,"srcSet",_.srcSet,_,null),C&&Mr(f,g,"src",_.src,_,null);return;case"input":Vn("invalid",f);var Se=O=ne=R=null,Be=null,ut=null;for(C in _)if(_.hasOwnProperty(C)){var vt=_[C];if(vt!=null)switch(C){case"name":R=vt;break;case"type":ne=vt;break;case"checked":Be=vt;break;case"defaultChecked":ut=vt;break;case"value":O=vt;break;case"defaultValue":Se=vt;break;case"children":case"dangerouslySetInnerHTML":if(vt!=null)throw Error(r(137,g));break;default:Mr(f,g,C,vt,_,null)}}$n(f,O,Se,Be,ut,ne,R,!1);return;case"select":Vn("invalid",f),C=ne=O=null;for(R in _)if(_.hasOwnProperty(R)&&(Se=_[R],Se!=null))switch(R){case"value":O=Se;break;case"defaultValue":ne=Se;break;case"multiple":C=Se;default:Mr(f,g,R,Se,_,null)}g=O,_=ne,f.multiple=!!C,g!=null?hr(f,!!C,g,!1):_!=null&&hr(f,!!C,_,!0);return;case"textarea":Vn("invalid",f),O=R=C=null;for(ne in _)if(_.hasOwnProperty(ne)&&(Se=_[ne],Se!=null))switch(ne){case"value":C=Se;break;case"defaultValue":R=Se;break;case"children":O=Se;break;case"dangerouslySetInnerHTML":if(Se!=null)throw Error(r(91));break;default:Mr(f,g,ne,Se,_,null)}bt(f,C,R,O);return;case"option":for(Be in _)if(_.hasOwnProperty(Be)&&(C=_[Be],C!=null))switch(Be){case"selected":f.selected=C&&typeof C!="function"&&typeof C!="symbol";break;default:Mr(f,g,Be,C,_,null)}return;case"dialog":Vn("beforetoggle",f),Vn("toggle",f),Vn("cancel",f),Vn("close",f);break;case"iframe":case"object":Vn("load",f);break;case"video":case"audio":for(C=0;C<Tx.length;C++)Vn(Tx[C],f);break;case"image":Vn("error",f),Vn("load",f);break;case"details":Vn("toggle",f);break;case"embed":case"source":case"link":Vn("error",f),Vn("load",f);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ut in _)if(_.hasOwnProperty(ut)&&(C=_[ut],C!=null))switch(ut){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:Mr(f,g,ut,C,_,null)}return;default:if(Yr(g)){for(vt in _)_.hasOwnProperty(vt)&&(C=_[vt],C!==void 0&&G2(f,g,vt,C,_,void 0));return}}for(Se in _)_.hasOwnProperty(Se)&&(C=_[Se],C!=null&&Mr(f,g,Se,C,_,null))}function Fae(f,g,_,C){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var R=null,O=null,ne=null,Se=null,Be=null,ut=null,vt=null;for(xt in _){var kt=_[xt];if(_.hasOwnProperty(xt)&&kt!=null)switch(xt){case"checked":break;case"value":break;case"defaultValue":Be=kt;default:C.hasOwnProperty(xt)||Mr(f,g,xt,null,C,kt)}}for(var ft in C){var xt=C[ft];if(kt=_[ft],C.hasOwnProperty(ft)&&(xt!=null||kt!=null))switch(ft){case"type":O=xt;break;case"name":R=xt;break;case"checked":ut=xt;break;case"defaultChecked":vt=xt;break;case"value":ne=xt;break;case"defaultValue":Se=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(r(137,g));break;default:xt!==kt&&Mr(f,g,ft,xt,C,kt)}}_n(f,ne,Se,Be,ut,vt,O,R);return;case"select":xt=ne=Se=ft=null;for(O in _)if(Be=_[O],_.hasOwnProperty(O)&&Be!=null)switch(O){case"value":break;case"multiple":xt=Be;default:C.hasOwnProperty(O)||Mr(f,g,O,null,C,Be)}for(R in C)if(O=C[R],Be=_[R],C.hasOwnProperty(R)&&(O!=null||Be!=null))switch(R){case"value":ft=O;break;case"defaultValue":Se=O;break;case"multiple":ne=O;default:O!==Be&&Mr(f,g,R,O,C,Be)}g=Se,_=ne,C=xt,ft!=null?hr(f,!!_,ft,!1):!!C!=!!_&&(g!=null?hr(f,!!_,g,!0):hr(f,!!_,_?[]:"",!1));return;case"textarea":xt=ft=null;for(Se in _)if(R=_[Se],_.hasOwnProperty(Se)&&R!=null&&!C.hasOwnProperty(Se))switch(Se){case"value":break;case"children":break;default:Mr(f,g,Se,null,C,R)}for(ne in C)if(R=C[ne],O=_[ne],C.hasOwnProperty(ne)&&(R!=null||O!=null))switch(ne){case"value":ft=R;break;case"defaultValue":xt=R;break;case"children":break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(r(91));break;default:R!==O&&Mr(f,g,ne,R,C,O)}wi(f,ft,xt);return;case"option":for(var Wt in _)if(ft=_[Wt],_.hasOwnProperty(Wt)&&ft!=null&&!C.hasOwnProperty(Wt))switch(Wt){case"selected":f.selected=!1;break;default:Mr(f,g,Wt,null,C,ft)}for(Be in C)if(ft=C[Be],xt=_[Be],C.hasOwnProperty(Be)&&ft!==xt&&(ft!=null||xt!=null))switch(Be){case"selected":f.selected=ft&&typeof ft!="function"&&typeof ft!="symbol";break;default:Mr(f,g,Be,ft,C,xt)}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 dn in _)ft=_[dn],_.hasOwnProperty(dn)&&ft!=null&&!C.hasOwnProperty(dn)&&Mr(f,g,dn,null,C,ft);for(ut in C)if(ft=C[ut],xt=_[ut],C.hasOwnProperty(ut)&&ft!==xt&&(ft!=null||xt!=null))switch(ut){case"children":case"dangerouslySetInnerHTML":if(ft!=null)throw Error(r(137,g));break;default:Mr(f,g,ut,ft,C,xt)}return;default:if(Yr(g)){for(var Cr in _)ft=_[Cr],_.hasOwnProperty(Cr)&&ft!==void 0&&!C.hasOwnProperty(Cr)&&G2(f,g,Cr,void 0,C,ft);for(vt in C)ft=C[vt],xt=_[vt],!C.hasOwnProperty(vt)||ft===xt||ft===void 0&&xt===void 0||G2(f,g,vt,ft,C,xt);return}}for(var tt in _)ft=_[tt],_.hasOwnProperty(tt)&&ft!=null&&!C.hasOwnProperty(tt)&&Mr(f,g,tt,null,C,ft);for(kt in C)ft=C[kt],xt=_[kt],!C.hasOwnProperty(kt)||ft===xt||ft==null&&xt==null||Mr(f,g,kt,ft,C,xt)}function Fz(f){switch(f){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Iae(){if(typeof performance.getEntriesByType=="function"){for(var f=0,g=0,_=performance.getEntriesByType("resource"),C=0;C<_.length;C++){var R=_[C],O=R.transferSize,ne=R.initiatorType,Se=R.duration;if(O&&Se&&Fz(ne)){for(ne=0,Se=R.responseEnd,C+=1;C<_.length;C++){var Be=_[C],ut=Be.startTime;if(ut>Se)break;var vt=Be.transferSize,kt=Be.initiatorType;vt&&Fz(kt)&&(Be=Be.responseEnd,ne+=vt*(Be<Se?1:(Se-ut)/(Be-ut)))}if(--C,g+=8*(O+ne)/(R.duration/1e3),f++,10<f)break}}if(0<f)return g/f/1e6}return navigator.connection&&(f=navigator.connection.downlink,typeof f=="number")?f:5}var q2=null,W2=null;function jw(f){return f.nodeType===9?f:f.ownerDocument}function Iz(f){switch(f){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function zz(f,g){if(f===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return f===1&&g==="foreignObject"?0:f}function K2(f,g){return f==="textarea"||f==="noscript"||typeof g.children=="string"||typeof g.children=="number"||typeof g.children=="bigint"||typeof g.dangerouslySetInnerHTML=="object"&&g.dangerouslySetInnerHTML!==null&&g.dangerouslySetInnerHTML.__html!=null}var X2=null;function zae(){var f=window.event;return f&&f.type==="popstate"?f===X2?!1:(X2=f,!0):(X2=null,!1)}var Uz=typeof setTimeout=="function"?setTimeout:void 0,Uae=typeof clearTimeout=="function"?clearTimeout:void 0,Bz=typeof Promise=="function"?Promise:void 0,Bae=typeof queueMicrotask=="function"?queueMicrotask:typeof Bz<"u"?function(f){return Bz.resolve(null).then(f).catch($ae)}:Uz;function $ae(f){setTimeout(function(){throw f})}function Dd(f){return f==="head"}function $z(f,g){var _=g,C=0;do{var R=_.nextSibling;if(f.removeChild(_),R&&R.nodeType===8)if(_=R.data,_==="/$"||_==="/&"){if(C===0){f.removeChild(R),Mp(g);return}C--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")C++;else if(_==="html")Px(f.ownerDocument.documentElement);else if(_==="head"){_=f.ownerDocument.head,Px(_);for(var O=_.firstChild;O;){var ne=O.nextSibling,Se=O.nodeName;O[pt]||Se==="SCRIPT"||Se==="STYLE"||Se==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=ne}}else _==="body"&&Px(f.ownerDocument.body);_=R}while(_);Mp(g)}function Hz(f,g){var _=f;f=0;do{var C=_.nextSibling;if(_.nodeType===1?g?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(g?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),C&&C.nodeType===8)if(_=C.data,_==="/$"){if(f===0)break;f--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||f++;_=C}while(_)}function Y2(f){var g=f.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var _=g;switch(g=g.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":Y2(_),ot(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}f.removeChild(_)}}function Hae(f,g,_,C){for(;f.nodeType===1;){var R=_;if(f.nodeName.toLowerCase()!==g.toLowerCase()){if(!C&&(f.nodeName!=="INPUT"||f.type!=="hidden"))break}else if(C){if(!f[pt])switch(g){case"meta":if(!f.hasAttribute("itemprop"))break;return f;case"link":if(O=f.getAttribute("rel"),O==="stylesheet"&&f.hasAttribute("data-precedence"))break;if(O!==R.rel||f.getAttribute("href")!==(R.href==null||R.href===""?null:R.href)||f.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin)||f.getAttribute("title")!==(R.title==null?null:R.title))break;return f;case"style":if(f.hasAttribute("data-precedence"))break;return f;case"script":if(O=f.getAttribute("src"),(O!==(R.src==null?null:R.src)||f.getAttribute("type")!==(R.type==null?null:R.type)||f.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin))&&O&&f.hasAttribute("async")&&!f.hasAttribute("itemprop"))break;return f;default:return f}}else if(g==="input"&&f.type==="hidden"){var O=R.name==null?null:""+R.name;if(R.type==="hidden"&&f.getAttribute("name")===O)return f}else return f;if(f=Vo(f.nextSibling),f===null)break}return null}function Vae(f,g,_){if(g==="")return null;for(;f.nodeType!==3;)if((f.nodeType!==1||f.nodeName!=="INPUT"||f.type!=="hidden")&&!_||(f=Vo(f.nextSibling),f===null))return null;return f}function Vz(f,g){for(;f.nodeType!==8;)if((f.nodeType!==1||f.nodeName!=="INPUT"||f.type!=="hidden")&&!g||(f=Vo(f.nextSibling),f===null))return null;return f}function Q2(f){return f.data==="$?"||f.data==="$~"}function Z2(f){return f.data==="$!"||f.data==="$?"&&f.ownerDocument.readyState!=="loading"}function Gae(f,g){var _=f.ownerDocument;if(f.data==="$~")f._reactRetry=g;else if(f.data!=="$?"||_.readyState!=="loading")g();else{var C=function(){g(),_.removeEventListener("DOMContentLoaded",C)};_.addEventListener("DOMContentLoaded",C),f._reactRetry=C}}function Vo(f){for(;f!=null;f=f.nextSibling){var g=f.nodeType;if(g===1||g===3)break;if(g===8){if(g=f.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return f}var J2=null;function Gz(f){f=f.nextSibling;for(var g=0;f;){if(f.nodeType===8){var _=f.data;if(_==="/$"||_==="/&"){if(g===0)return Vo(f.nextSibling);g--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||g++}f=f.nextSibling}return null}function qz(f){f=f.previousSibling;for(var g=0;f;){if(f.nodeType===8){var _=f.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(g===0)return f;g--}else _!=="/$"&&_!=="/&"||g++}f=f.previousSibling}return null}function Wz(f,g,_){switch(g=jw(_),f){case"html":if(f=g.documentElement,!f)throw Error(r(452));return f;case"head":if(f=g.head,!f)throw Error(r(453));return f;case"body":if(f=g.body,!f)throw Error(r(454));return f;default:throw Error(r(451))}}function Px(f){for(var g=f.attributes;g.length;)f.removeAttributeNode(g[0]);ot(f)}var Go=new Map,Kz=new Set;function Pw(f){return typeof f.getRootNode=="function"?f.getRootNode():f.nodeType===9?f:f.ownerDocument}var au=I.d;I.d={f:qae,r:Wae,D:Kae,C:Xae,L:Yae,m:Qae,X:Jae,S:Zae,M:ese};function qae(){var f=au.f(),g=Sw();return f||g}function Wae(f){var g=me(f);g!==null&&g.tag===5&&g.type==="form"?d5(g):au.r(f)}var Sp=typeof document>"u"?null:document;function Xz(f,g,_){var C=Sp;if(C&&typeof g=="string"&&g){var R=Tn(g);R='link[rel="'+f+'"][href="'+R+'"]',typeof _=="string"&&(R+='[crossorigin="'+_+'"]'),Kz.has(R)||(Kz.add(R),f={rel:f,crossOrigin:_,href:g},C.querySelector(R)===null&&(g=C.createElement("link"),$a(g,"link",f),Ge(g),C.head.appendChild(g)))}}function Kae(f){au.D(f),Xz("dns-prefetch",f,null)}function Xae(f,g){au.C(f,g),Xz("preconnect",f,g)}function Yae(f,g,_){au.L(f,g,_);var C=Sp;if(C&&f&&g){var R='link[rel="preload"][as="'+Tn(g)+'"]';g==="image"&&_&&_.imageSrcSet?(R+='[imagesrcset="'+Tn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(R+='[imagesizes="'+Tn(_.imageSizes)+'"]')):R+='[href="'+Tn(f)+'"]';var O=R;switch(g){case"style":O=Np(f);break;case"script":O=kp(f)}Go.has(O)||(f=h({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:f,as:g},_),Go.set(O,f),C.querySelector(R)!==null||g==="style"&&C.querySelector(Dx(O))||g==="script"&&C.querySelector(Rx(O))||(g=C.createElement("link"),$a(g,"link",f),Ge(g),C.head.appendChild(g)))}}function Qae(f,g){au.m(f,g);var _=Sp;if(_&&f){var C=g&&typeof g.as=="string"?g.as:"script",R='link[rel="modulepreload"][as="'+Tn(C)+'"][href="'+Tn(f)+'"]',O=R;switch(C){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=kp(f)}if(!Go.has(O)&&(f=h({rel:"modulepreload",href:f},g),Go.set(O,f),_.querySelector(R)===null)){switch(C){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Rx(O)))return}C=_.createElement("link"),$a(C,"link",f),Ge(C),_.head.appendChild(C)}}}function Zae(f,g,_){au.S(f,g,_);var C=Sp;if(C&&f){var R=Ke(C).hoistableStyles,O=Np(f);g=g||"default";var ne=R.get(O);if(!ne){var Se={loading:0,preload:null};if(ne=C.querySelector(Dx(O)))Se.loading=5;else{f=h({rel:"stylesheet",href:f,"data-precedence":g},_),(_=Go.get(O))&&eE(f,_);var Be=ne=C.createElement("link");Ge(Be),$a(Be,"link",f),Be._p=new Promise(function(ut,vt){Be.onload=ut,Be.onerror=vt}),Be.addEventListener("load",function(){Se.loading|=1}),Be.addEventListener("error",function(){Se.loading|=2}),Se.loading|=4,Dw(ne,g,C)}ne={type:"stylesheet",instance:ne,count:1,state:Se},R.set(O,ne)}}}function Jae(f,g){au.X(f,g);var _=Sp;if(_&&f){var C=Ke(_).hoistableScripts,R=kp(f),O=C.get(R);O||(O=_.querySelector(Rx(R)),O||(f=h({src:f,async:!0},g),(g=Go.get(R))&&tE(f,g),O=_.createElement("script"),Ge(O),$a(O,"link",f),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},C.set(R,O))}}function ese(f,g){au.M(f,g);var _=Sp;if(_&&f){var C=Ke(_).hoistableScripts,R=kp(f),O=C.get(R);O||(O=_.querySelector(Rx(R)),O||(f=h({src:f,async:!0,type:"module"},g),(g=Go.get(R))&&tE(f,g),O=_.createElement("script"),Ge(O),$a(O,"link",f),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},C.set(R,O))}}function Yz(f,g,_,C){var R=(R=fe.current)?Pw(R):null;if(!R)throw Error(r(446));switch(f){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(g=Np(_.href),_=Ke(R).hoistableStyles,C=_.get(g),C||(C={type:"style",instance:null,count:0,state:null},_.set(g,C)),C):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){f=Np(_.href);var O=Ke(R).hoistableStyles,ne=O.get(f);if(ne||(R=R.ownerDocument||R,ne={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(f,ne),(O=R.querySelector(Dx(f)))&&!O._p&&(ne.instance=O,ne.state.loading=5),Go.has(f)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Go.set(f,_),O||tse(R,f,_,ne.state))),g&&C===null)throw Error(r(528,""));return ne}if(g&&C!==null)throw Error(r(529,""));return null;case"script":return g=_.async,_=_.src,typeof _=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=kp(_),_=Ke(R).hoistableScripts,C=_.get(g),C||(C={type:"script",instance:null,count:0,state:null},_.set(g,C)),C):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,f))}}function Np(f){return'href="'+Tn(f)+'"'}function Dx(f){return'link[rel="stylesheet"]['+f+"]"}function Qz(f){return h({},f,{"data-precedence":f.precedence,precedence:null})}function tse(f,g,_,C){f.querySelector('link[rel="preload"][as="style"]['+g+"]")?C.loading=1:(g=f.createElement("link"),C.preload=g,g.addEventListener("load",function(){return C.loading|=1}),g.addEventListener("error",function(){return C.loading|=2}),$a(g,"link",_),Ge(g),f.head.appendChild(g))}function kp(f){return'[src="'+Tn(f)+'"]'}function Rx(f){return"script[async]"+f}function Zz(f,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var C=f.querySelector('style[data-href~="'+Tn(_.href)+'"]');if(C)return g.instance=C,Ge(C),C;var R=h({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return C=(f.ownerDocument||f).createElement("style"),Ge(C),$a(C,"style",R),Dw(C,_.precedence,f),g.instance=C;case"stylesheet":R=Np(_.href);var O=f.querySelector(Dx(R));if(O)return g.state.loading|=4,g.instance=O,Ge(O),O;C=Qz(_),(R=Go.get(R))&&eE(C,R),O=(f.ownerDocument||f).createElement("link"),Ge(O);var ne=O;return ne._p=new Promise(function(Se,Be){ne.onload=Se,ne.onerror=Be}),$a(O,"link",C),g.state.loading|=4,Dw(O,_.precedence,f),g.instance=O;case"script":return O=kp(_.src),(R=f.querySelector(Rx(O)))?(g.instance=R,Ge(R),R):(C=_,(R=Go.get(O))&&(C=h({},_),tE(C,R)),f=f.ownerDocument||f,R=f.createElement("script"),Ge(R),$a(R,"link",C),f.head.appendChild(R),g.instance=R);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(C=g.instance,g.state.loading|=4,Dw(C,_.precedence,f));return g.instance}function Dw(f,g,_){for(var C=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),R=C.length?C[C.length-1]:null,O=R,ne=0;ne<C.length;ne++){var Se=C[ne];if(Se.dataset.precedence===g)O=Se;else if(O!==R)break}O?O.parentNode.insertBefore(f,O.nextSibling):(g=_.nodeType===9?_.head:_,g.insertBefore(f,g.firstChild))}function eE(f,g){f.crossOrigin==null&&(f.crossOrigin=g.crossOrigin),f.referrerPolicy==null&&(f.referrerPolicy=g.referrerPolicy),f.title==null&&(f.title=g.title)}function tE(f,g){f.crossOrigin==null&&(f.crossOrigin=g.crossOrigin),f.referrerPolicy==null&&(f.referrerPolicy=g.referrerPolicy),f.integrity==null&&(f.integrity=g.integrity)}var Rw=null;function Jz(f,g,_){if(Rw===null){var C=new Map,R=Rw=new Map;R.set(_,C)}else R=Rw,C=R.get(_),C||(C=new Map,R.set(_,C));if(C.has(f))return C;for(C.set(f,null),_=_.getElementsByTagName(f),R=0;R<_.length;R++){var O=_[R];if(!(O[pt]||O[Xt]||f==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var ne=O.getAttribute(g)||"";ne=f+ne;var Se=C.get(ne);Se?Se.push(O):C.set(ne,[O])}}return C}function eU(f,g,_){f=f.ownerDocument||f,f.head.insertBefore(_,g==="title"?f.querySelector("head > title"):null)}function nse(f,g,_){if(_===1||g.itemProp!=null)return!1;switch(f){case"meta":case"title":return!0;case"style":if(typeof g.precedence!="string"||typeof g.href!="string"||g.href==="")break;return!0;case"link":if(typeof g.rel!="string"||typeof g.href!="string"||g.href===""||g.onLoad||g.onError)break;switch(g.rel){case"stylesheet":return f=g.disabled,typeof g.precedence=="string"&&f==null;default:return!0}case"script":if(g.async&&typeof g.async!="function"&&typeof g.async!="symbol"&&!g.onLoad&&!g.onError&&g.src&&typeof g.src=="string")return!0}return!1}function tU(f){return!(f.type==="stylesheet"&&(f.state.loading&3)===0)}function rse(f,g,_,C){if(_.type==="stylesheet"&&(typeof C.media!="string"||matchMedia(C.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var R=Np(C.href),O=g.querySelector(Dx(R));if(O){g=O._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(f.count++,f=Lw.bind(f),g.then(f,f)),_.state.loading|=4,_.instance=O,Ge(O);return}O=g.ownerDocument||g,C=Qz(C),(R=Go.get(R))&&eE(C,R),O=O.createElement("link"),Ge(O);var ne=O;ne._p=new Promise(function(Se,Be){ne.onload=Se,ne.onerror=Be}),$a(O,"link",C),_.instance=O}f.stylesheets===null&&(f.stylesheets=new Map),f.stylesheets.set(_,g),(g=_.state.preload)&&(_.state.loading&3)===0&&(f.count++,_=Lw.bind(f),g.addEventListener("load",_),g.addEventListener("error",_))}}var nE=0;function ise(f,g){return f.stylesheets&&f.count===0&&Fw(f,f.stylesheets),0<f.count||0<f.imgCount?function(_){var C=setTimeout(function(){if(f.stylesheets&&Fw(f,f.stylesheets),f.unsuspend){var O=f.unsuspend;f.unsuspend=null,O()}},6e4+g);0<f.imgBytes&&nE===0&&(nE=62500*Iae());var R=setTimeout(function(){if(f.waitingForImages=!1,f.count===0&&(f.stylesheets&&Fw(f,f.stylesheets),f.unsuspend)){var O=f.unsuspend;f.unsuspend=null,O()}},(f.imgBytes>nE?50:800)+g);return f.unsuspend=_,function(){f.unsuspend=null,clearTimeout(C),clearTimeout(R)}}:null}function Lw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Fw(this,this.stylesheets);else if(this.unsuspend){var f=this.unsuspend;this.unsuspend=null,f()}}}var Ow=null;function Fw(f,g){f.stylesheets=null,f.unsuspend!==null&&(f.count++,Ow=new Map,g.forEach(ase,f),Ow=null,Lw.call(f))}function ase(f,g){if(!(g.state.loading&4)){var _=Ow.get(f);if(_)var C=_.get(null);else{_=new Map,Ow.set(f,_);for(var R=f.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<R.length;O++){var ne=R[O];(ne.nodeName==="LINK"||ne.getAttribute("media")!=="not all")&&(_.set(ne.dataset.precedence,ne),C=ne)}C&&_.set(null,C)}R=g.instance,ne=R.getAttribute("data-precedence"),O=_.get(ne)||C,O===C&&_.set(null,R),_.set(ne,R),this.count++,C=Lw.bind(this),R.addEventListener("load",C),R.addEventListener("error",C),O?O.parentNode.insertBefore(R,O.nextSibling):(f=f.nodeType===9?f.head:f,f.insertBefore(R,f.firstChild)),g.state.loading|=4}}var Lx={$$typeof:k,Provider:null,Consumer:null,_currentValue:K,_currentValue2:K,_threadCount:0};function sse(f,g,_,C,R,O,ne,Se,Be){this.tag=1,this.containerInfo=f,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=Et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Et(0),this.hiddenUpdates=Et(null),this.identifierPrefix=C,this.onUncaughtError=R,this.onCaughtError=O,this.onRecoverableError=ne,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Be,this.incompleteTransitions=new Map}function nU(f,g,_,C,R,O,ne,Se,Be,ut,vt,kt){return f=new sse(f,g,_,ne,Be,ut,vt,kt,Se),g=1,O===!0&&(g|=24),O=lo(3,null,null,g),f.current=O,O.stateNode=f,g=LC(),g.refCount++,f.pooledCache=g,g.refCount++,O.memoizedState={element:C,isDehydrated:_,cache:g},zC(O),f}function rU(f){return f?(f=np,f):np}function iU(f,g,_,C,R,O){R=rU(R),C.context===null?C.context=R:C.pendingContext=R,C=_d(g),C.payload={element:_},O=O===void 0?null:O,O!==null&&(C.callback=O),_=Sd(f,C,g),_!==null&&($s(_,f,g),fx(_,f,g))}function aU(f,g){if(f=f.memoizedState,f!==null&&f.dehydrated!==null){var _=f.retryLane;f.retryLane=_!==0&&_<g?_:g}}function rE(f,g){aU(f,g),(f=f.alternate)&&aU(f,g)}function sU(f){if(f.tag===13||f.tag===31){var g=uf(f,67108864);g!==null&&$s(g,f,67108864),rE(f,67108864)}}function oU(f){if(f.tag===13||f.tag===31){var g=mo();g=tn(g);var _=uf(f,g);_!==null&&$s(_,f,g),rE(f,g)}}var Iw=!0;function ose(f,g,_,C){var R=q.T;q.T=null;var O=I.p;try{I.p=2,iE(f,g,_,C)}finally{I.p=O,q.T=R}}function lse(f,g,_,C){var R=q.T;q.T=null;var O=I.p;try{I.p=8,iE(f,g,_,C)}finally{I.p=O,q.T=R}}function iE(f,g,_,C){if(Iw){var R=aE(C);if(R===null)V2(f,g,C,zw,_),cU(f,C);else if(use(R,f,g,_,C))C.stopPropagation();else if(cU(f,C),g&4&&-1<cse.indexOf(f)){for(;R!==null;){var O=me(R);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var ne=Re(O.pendingLanes);if(ne!==0){var Se=O;for(Se.pendingLanes|=2,Se.entangledLanes|=2;ne;){var Be=1<<31-Ue(ne);Se.entanglements[1]|=Be,ne&=~Be}lc(O),(fr&6)===0&&(ww=L()+500,Ax(0))}}break;case 31:case 13:Se=uf(O,2),Se!==null&&$s(Se,O,2),Sw(),rE(O,2)}if(O=aE(C),O===null&&V2(f,g,C,zw,_),O===R)break;R=O}R!==null&&C.stopPropagation()}else V2(f,g,C,null,_)}}function aE(f){return f=_a(f),sE(f)}var zw=null;function sE(f){if(zw=null,f=Lt(f),f!==null){var g=s(f);if(g===null)f=null;else{var _=g.tag;if(_===13){if(f=o(g),f!==null)return f;f=null}else if(_===31){if(f=l(g),f!==null)return f;f=null}else if(_===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;f=null}else g!==f&&(f=null)}}return zw=f,null}function lU(f){switch(f){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(X()){case ge:return 2;case _e:return 8;case Ee:case $e:return 32;case Ce:return 268435456;default:return 32}default:return 32}}var oE=!1,Rd=null,Ld=null,Od=null,Ox=new Map,Fx=new Map,Fd=[],cse="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 cU(f,g){switch(f){case"focusin":case"focusout":Rd=null;break;case"dragenter":case"dragleave":Ld=null;break;case"mouseover":case"mouseout":Od=null;break;case"pointerover":case"pointerout":Ox.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fx.delete(g.pointerId)}}function Ix(f,g,_,C,R,O){return f===null||f.nativeEvent!==O?(f={blockedOn:g,domEventName:_,eventSystemFlags:C,nativeEvent:O,targetContainers:[R]},g!==null&&(g=me(g),g!==null&&sU(g)),f):(f.eventSystemFlags|=C,g=f.targetContainers,R!==null&&g.indexOf(R)===-1&&g.push(R),f)}function use(f,g,_,C,R){switch(g){case"focusin":return Rd=Ix(Rd,f,g,_,C,R),!0;case"dragenter":return Ld=Ix(Ld,f,g,_,C,R),!0;case"mouseover":return Od=Ix(Od,f,g,_,C,R),!0;case"pointerover":var O=R.pointerId;return Ox.set(O,Ix(Ox.get(O)||null,f,g,_,C,R)),!0;case"gotpointercapture":return O=R.pointerId,Fx.set(O,Ix(Fx.get(O)||null,f,g,_,C,R)),!0}return!1}function uU(f){var g=Lt(f.target);if(g!==null){var _=s(g);if(_!==null){if(g=_.tag,g===13){if(g=o(_),g!==null){f.blockedOn=g,gr(f.priority,function(){oU(_)});return}}else if(g===31){if(g=l(_),g!==null){f.blockedOn=g,gr(f.priority,function(){oU(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){f.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}f.blockedOn=null}function Uw(f){if(f.blockedOn!==null)return!1;for(var g=f.targetContainers;0<g.length;){var _=aE(f.nativeEvent);if(_===null){_=f.nativeEvent;var C=new _.constructor(_.type,_);bn=C,_.target.dispatchEvent(C),bn=null}else return g=me(_),g!==null&&sU(g),f.blockedOn=_,!1;g.shift()}return!0}function dU(f,g,_){Uw(f)&&_.delete(g)}function dse(){oE=!1,Rd!==null&&Uw(Rd)&&(Rd=null),Ld!==null&&Uw(Ld)&&(Ld=null),Od!==null&&Uw(Od)&&(Od=null),Ox.forEach(dU),Fx.forEach(dU)}function Bw(f,g){f.blockedOn===g&&(f.blockedOn=null,oE||(oE=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,dse)))}var $w=null;function hU(f){$w!==f&&($w=f,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){$w===f&&($w=null);for(var g=0;g<f.length;g+=3){var _=f[g],C=f[g+1],R=f[g+2];if(typeof C!="function"){if(sE(C||_)===null)continue;break}var O=me(_);O!==null&&(f.splice(g,3),g-=3,a2(O,{pending:!0,data:R,method:_.method,action:C},C,R))}}))}function Mp(f){function g(Be){return Bw(Be,f)}Rd!==null&&Bw(Rd,f),Ld!==null&&Bw(Ld,f),Od!==null&&Bw(Od,f),Ox.forEach(g),Fx.forEach(g);for(var _=0;_<Fd.length;_++){var C=Fd[_];C.blockedOn===f&&(C.blockedOn=null)}for(;0<Fd.length&&(_=Fd[0],_.blockedOn===null);)uU(_),_.blockedOn===null&&Fd.shift();if(_=(f.ownerDocument||f).$$reactFormReplay,_!=null)for(C=0;C<_.length;C+=3){var R=_[C],O=_[C+1],ne=R[sr]||null;if(typeof O=="function")ne||hU(_);else if(ne){var Se=null;if(O&&O.hasAttribute("formAction")){if(R=O,ne=O[sr]||null)Se=ne.formAction;else if(sE(R)!==null)continue}else Se=ne.action;typeof Se=="function"?_[C+1]=Se:(_.splice(C,3),C-=3),hU(_)}}}function fU(){function f(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(ne){return R=ne})},focusReset:"manual",scroll:"manual"})}function g(){R!==null&&(R(),R=null),C||setTimeout(_,20)}function _(){if(!C&&!navigation.transition){var O=navigation.currentEntry;O&&O.url!=null&&navigation.navigate(O.url,{state:O.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var C=!1,R=null;return navigation.addEventListener("navigate",f),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(_,100),function(){C=!0,navigation.removeEventListener("navigate",f),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),R!==null&&(R(),R=null)}}}function lE(f){this._internalRoot=f}Hw.prototype.render=lE.prototype.render=function(f){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,C=mo();iU(_,C,f,g,null,null)},Hw.prototype.unmount=lE.prototype.unmount=function(){var f=this._internalRoot;if(f!==null){this._internalRoot=null;var g=f.containerInfo;iU(f.current,2,null,f,null,null),Sw(),g[vi]=null}};function Hw(f){this._internalRoot=f}Hw.prototype.unstable_scheduleHydration=function(f){if(f){var g=dr();f={blockedOn:null,target:f,priority:g};for(var _=0;_<Fd.length&&g!==0&&g<Fd[_].priority;_++);Fd.splice(_,0,f),_===0&&uU(f)}};var mU=e.version;if(mU!=="19.2.0")throw Error(r(527,mU,"19.2.0"));I.findDOMNode=function(f){var g=f._reactInternals;if(g===void 0)throw typeof f.render=="function"?Error(r(188)):(f=Object.keys(f).join(","),Error(r(268,f)));return f=u(g),f=f!==null?d(f):null,f=f===null?null:f.stateNode,f};var hse={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Vw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vw.isDisabled&&Vw.supportsFiber)try{xe=Vw.inject(hse),ye=Vw}catch{}}return Ux.createRoot=function(f,g){if(!i(f))throw Error(r(299));var _=!1,C="",R=w5,O=_5,ne=S5;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(C=g.identifierPrefix),g.onUncaughtError!==void 0&&(R=g.onUncaughtError),g.onCaughtError!==void 0&&(O=g.onCaughtError),g.onRecoverableError!==void 0&&(ne=g.onRecoverableError)),g=nU(f,1,!1,null,null,_,C,null,R,O,ne,fU),f[vi]=g.current,H2(f),new lE(g)},Ux.hydrateRoot=function(f,g,_){if(!i(f))throw Error(r(299));var C=!1,R="",O=w5,ne=_5,Se=S5,Be=null;return _!=null&&(_.unstable_strictMode===!0&&(C=!0),_.identifierPrefix!==void 0&&(R=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(ne=_.onCaughtError),_.onRecoverableError!==void 0&&(Se=_.onRecoverableError),_.formState!==void 0&&(Be=_.formState)),g=nU(f,1,!0,g,_??null,C,R,Be,O,ne,Se,fU),g.context=rU(null),_=g.current,C=mo(),C=tn(C),R=_d(C),R.callback=null,Sd(_,R,C),_=C,g.current.lanes=_,an(g,_),lc(g),f[vi]=g.current,H2(f),new Hw(g)},Ux.version="19.2.0",Ux}var NU;function Sse(){if(NU)return dE.exports;NU=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(),dE.exports=_se(),dE.exports}var Nse=Sse();const yn=t=>typeof t=="string",Bx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},kU=t=>t==null?"":""+t,kse=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Mse=/###/g,MU=t=>t&&t.indexOf("###")>-1?t.replace(Mse,"."):t,CU=t=>!t||yn(t),Ey=(t,e,n)=>{const r=yn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(CU(t))return{};const s=MU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return CU(t)?{}:{obj:t,k:MU(r[i])}},EU=(t,e,n)=>{const{obj:r,k:i}=Ey(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),l=Ey(t,o,Object);for(;l.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),l=Ey(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${s}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${s}`]=n},Cse=(t,e,n,r)=>{const{obj:i,k:s}=Ey(t,e,Object);i[s]=i[s]||[],i[s].push(n)},i1=(t,e)=>{const{obj:n,k:r}=Ey(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Ese=(t,e,n)=>{const r=i1(t,n);return r!==void 0?r:i1(e,n)},rW=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?yn(t[r])||t[r]instanceof String||yn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):rW(t[r],e[r],n):t[r]=e[r]);return t},Cp=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ase={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Tse=t=>yn(t)?t.replace(/[&<>"'\/]/g,e=>Ase[e]):t;class jse{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 Pse=[" ",",","?","!",";"],Dse=new jse(20),Rse=(t,e,n)=>{e=e||"",n=n||"";const r=Pse.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Dse.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},_P=(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 s=0;s<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=s;c<r.length;++c)if(c!==s&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;s+=c-s+1;break}i=o}return i},Zy=t=>t?.replace("_","-"),Lse={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 a1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Lse,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:(yn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new a1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new a1(this.logger,e)}}var wc=new a1;let _k=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,s])=>{for(let o=0;o<s;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i.apply(i,[e,...n])})}};class AU extends _k{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 s=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):yn(r)&&s?l.push(...r.split(s)):l.push(r)));const c=i1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!yn(r)?c:_P(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const o=s.keySeparator!==void 0?s.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),EU(this.data,l,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(yn(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,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=i1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?rW(c,r,s):c={...c,...r},EU(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 iW={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const aW=Symbol("i18next/PATH_KEY");function Ose(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===aW?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function SP(t,e){const{[aW]:n}=t(Ose());return n.join(e?.keySeparator??".")}const TU={},pE=t=>!yn(t)&&typeof t!="boolean"&&typeof t!="number";class s1 extends _k{constructor(e,n={}){super(),kse(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=wc.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 s=pE(i.res);return!(r.returnObjects===!1&&s)}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 s=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Rse(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:yn(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:yn(s)?[s]:s}}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=SP(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=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 h=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return p?s?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:s?{res:l,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const m=this.resolve(e,i);let x=m?.res;const y=m?.usedKey||l,b=m?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,E=i.count!==void 0&&!yn(i.count),N=s1.hasDefaultValue(i),A=E?this.pluralResolver.getSuffix(h,i.count,i):"",M=i.ordinal&&E?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",P=E&&!i.ordinal&&i.count===0,T=P&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${A}`]||i[`defaultValue${M}`]||i.defaultValue;let j=x;k&&!x&&N&&(j=T);const z=pE(j),F=Object.prototype.toString.apply(j);if(k&&j&&z&&v.indexOf(F)<0&&!(yn(S)&&Array.isArray(j))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const $=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,j,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return s?(m.res=$,m.usedParams=this.getUsedParamsDetails(i),m):$}if(o){const $=Array.isArray(j),D=$?[]:{},H=$?b:y;for(const q in j)if(Object.prototype.hasOwnProperty.call(j,q)){const I=`${H}${o}${q}`;N&&!x?D[q]=this.translate(I,{...i,defaultValue:pE(T)?T[q]:void 0,joinArrays:!1,ns:c}):D[q]=this.translate(I,{...i,joinArrays:!1,ns:c}),D[q]===I&&(D[q]=j[q])}x=D}}else if(k&&yn(S)&&Array.isArray(x))x=x.join(S),x&&(x=this.extendTranslation(x,e,i,r));else{let $=!1,D=!1;!this.isValidLookup(x)&&N&&($=!0,x=T),this.isValidLookup(x)||(D=!0,x=l);const q=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&D?void 0:x,I=N&&T!==x&&this.options.updateMissing;if(D||$||I){if(this.logger.log(I?"updateKey":"missingKey",h,u,l,I?T:x),o){const V=this.resolve(l,{...i,keySeparator:!1});V&&V.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 K=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let V=0;V<Z.length;V++)K.push(Z[V]);else this.options.saveMissingTo==="all"?K=this.languageUtils.toResolveHierarchy(i.lng||this.language):K.push(i.lng||this.language);const se=(V,W,ie)=>{const J=N&&ie!==x?ie:q;this.options.missingKeyHandler?this.options.missingKeyHandler(V,u,W,J,I,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(V,u,W,J,I,i),this.emit("missingKey",V,u,W,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&E?K.forEach(V=>{const W=this.pluralResolver.getSuffixes(V,i);P&&i[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(ie=>{se([V],l+ie,i[`defaultValue${ie}`]||T)})}):se(K,l,T))}x=this.extendTranslation(x,e,i,m,r),D&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(D||$)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,$?x:void 0,i))}return s?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):x}extendTranslation(e,n,r,i,s){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=yn(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const h=e.match(this.interpolator.nestingRegexp);u=h&&h.length}let d=r.replace&&!yn(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 h=e.match(this.interpolator.nestingRegexp),p=h&&h.length;u<p&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...h)=>s?.[0]===h[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=yn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=iW.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,s,o,l;return yn(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const p=n.count!==void 0&&!yn(n.count),m=p&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(yn(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(b=>{this.isValidLookup(r)||(l=b,!TU[`${y[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(TU[`${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 S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,v,b,n);else{let E;p&&(E=this.pluralResolver.getSuffix(v,n.count,n));const N=`${this.options.pluralSeparator}zero`,A=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&E.indexOf(A)===0&&S.push(d+E.replace(A,this.options.pluralSeparator)),S.push(d+E),m&&S.push(d+N)),x){const M=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(M),p&&(n.ordinal&&E.indexOf(A)===0&&S.push(M+E.replace(A,this.options.pluralSeparator)),S.push(M+E),m&&S.push(M+N))}}let k;for(;k=S.pop();)this.isValidLookup(r)||(s=k,r=this.getResource(v,b,k,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,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&&!yn(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 s of n)delete i[s]}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 jU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=wc.create("languageUtils")}getScriptPartFromCode(e){if(e=Zy(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=Zy(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(yn(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 s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.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)),yn(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=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return yn(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):yn(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const PU={zero:0,one:1,two:2,few:3,many:4,other:5},DU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Fse{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=wc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=Zy(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];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!"),DU;if(!e.match(/-|_/))return DU;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[s]=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,s)=>PU[i]-PU[s]).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 RU=(t,e,n,r=".",i=!0)=>{let s=Ese(t,e,n);return!s&&i&&yn(n)&&(s=_P(t,n,r),s===void 0&&(s=_P(e,n,r))),s},gE=t=>t.replace(/\$/g,"$$$$");class Ise{constructor(e={}){this.logger=wc.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:s,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:h,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:Tse,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Cp(s):o||"{{",this.suffix=l?Cp(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?Cp(p):m||Cp("$t("),this.nestingSuffix=x?Cp(x):y||Cp(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||1e3,this.alwaysFormat=S!==void 0?S:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const v=RU(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:m}):v}const x=m.split(this.formatSeparator),y=x.shift().trim(),b=x.join(this.formatSeparator).trim();return this.format(RU(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>gE(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?gE(this.escape(m)):gE(m)}].forEach(m=>{for(l=0;s=m.regex.exec(e);){const x=s[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const b=d(e,s,i);o=yn(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!yn(o)&&!this.useRawValueToEscape&&(o=kU(o));const y=m.safeValue(o);if(e=e.replace(s[0],y),h?(m.regex.lastIndex+=o.length,m.regex.lastIndex-=s[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const h=c.split(new RegExp(`${d}[ ]*{`));let p=`{${h[1]}`;c=h[0],p=this.interpolate(p,o);const m=p.match(/'/g),x=p.match(/"/g);((m?.length??0)%2===0&&!x||x.length%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${p}`}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&&!yn(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)),s=n(l.call(this,i[1].trim(),o),o),s&&i[0]===e&&!yn(s))return s;yn(s)||(s=kU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((d,h)=>this.format(d,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const zse=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}},LU=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const o=r+JSON.stringify(s);let l=e[o];return l||(l=t(Zy(r),i),e[o]=l),l(n)}},Use=t=>(e,n,r)=>t(Zy(n),r)(e);class Bse{constructor(e={}){this.logger=wc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?LU:Use;this.formats={number:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s});return l=>o.format(l)}),currency:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s,style:"currency"});return l=>o.format(l)}),datetime:r((i,s)=>{const o=new Intl.DateTimeFormat(i,{...s});return l=>o.format(l)}),relativetime:r((i,s)=>{const o=new Intl.RelativeTimeFormat(i,{...s});return l=>o.format(l,s.range||"day")}),list:r((i,s)=>{const o=new Intl.ListFormat(i,{...s});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=LU(n)}format(e,n,r,i={}){const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(l=>l.indexOf(")")>-1)){const l=s.findIndex(c=>c.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,l)].join(this.formatSeparator)}return s.reduce((l,c)=>{const{formatName:u,formatOptions:d}=zse(c);if(this.formats[u]){let h=l;try{const p=i?.formatParams?.[i.interpolationkey]||{},m=p.locale||p.lng||i.locale||i.lng||r;h=this.formats[u](l,m,{...d,...i,...p})}catch(p){this.logger.warn(p)}return h}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const $se=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Hse extends _k{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=wc.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 s={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(h=>{const p=`${u}|${h}`;!r.reload&&this.store.hasResourceBundle(u,h)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?o[p]===void 0&&(o[p]=!0):(this.state[p]=1,d=!1,o[p]===void 0&&(o[p]=!0),s[p]===void 0&&(s[p]=!0),c[h]===void 0&&(c[h]=!0)))}),d||(l[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,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=>{Cse(c.loaded,[s],o),$se(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(h=>{l[u][h]===void 0&&(l[u][h]=!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,s=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:s,callback:o});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);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();yn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),yn(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.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],s=r[1];this.read(i,s,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,s,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:s},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(h=>l(null,h)).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 OU=()=>({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]),yn(t[1])&&(e.defaultValue=t[1]),yn(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}),FU=t=>(yn(t.ns)&&(t.ns=[t.ns]),yn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),yn(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),qw=()=>{},Vse=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Ay extends _k{constructor(e={},n){if(super(),this.options=FU(e),this.services={},this.logger=wc,this.modules={external:[]},Vse(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&&(yn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=OU();this.options={...r,...this.options,...FU(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?wc.init(i(this.modules.logger),this.options):wc.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Bse;const d=new jU(this.options);this.store=new AU(this.options.resources,this.options);const h=this.services;h.logger=wc,h.resourceStore=this.store,h.languageUtils=d,h.pluralResolver=new Fse(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)&&(h.formatter=i(u),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new Ise(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Hse(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new s1(this.services,this.options),this.translator.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=qw),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=Bx(),c=()=>{const u=(d,h)=>{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(h),n(d,h)};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=qw){let r=n;const i=yn(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 s=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.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(s,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=Bx();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=qw),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),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"&&iW.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=Bx();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},s=(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=yn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(yn(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{s(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=(s,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([s,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(s)?d=s.map(h=>(typeof h=="function"&&(h=SP(h,{...this.options,...o})),`${c.keyPrefix}${u}${h}`)):(typeof s=="function"&&(s=SP(s,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${s}`:s),this.t(d,c)};return yn(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,s=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(s,e)))}loadNamespaces(e,n){const r=Bx();return this.options.ns?(yn(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=Bx();yn(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),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 s=i.getTextInfo();if(s&&s.direction)return s.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 jU(OU());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 Ay(e,n);return r.createInstance=Ay.createInstance,r}cloneInstance(e={},n=qw){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Ay(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(l=>{s[l]=this[l]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},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,h)=>(d[h]={...c[u][h]},d),c[u]),c),{});s.store=new AU(l,i),s.services.resourceStore=s.store}return s.translator=new s1(s.services,i),s.translator.on("*",(l,...c)=>{s.emit(l,...c)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Fs=Ay.createInstance();Fs.createInstance;Fs.dir;Fs.init;Fs.loadResources;Fs.reloadResources;Fs.use;Fs.changeLanguage;Fs.getFixedT;Fs.t;Fs.exists;Fs.setDefaultNamespace;Fs.hasLoadedNamespace;Fs.loadNamespaces;Fs.loadLanguages;const Gse=(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);ym(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},IU={},sW=(t,e,n,r)=>{ym(n)&&IU[n]||(ym(n)&&(IU[n]=new Date),Gse(t,e,n,r))},oW=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},NP=(t,e,n)=>{t.loadNamespaces(e,oW(t,n))},zU=(t,e,n,r)=>{if(ym(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return NP(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,oW(t,r))},qse=(t,e,n={})=>!e.languages||!e.languages.length?(sW(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}}),ym=t=>typeof t=="string",Wse=t=>typeof t=="object"&&t!==null,Kse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Xse={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Yse=t=>Xse[t],Qse=t=>t.replace(Kse,Yse);let kP={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Qse};const Zse=(t={})=>{kP={...kP,...t}},Jse=()=>kP;let lW;const eoe=t=>{lW=t},toe=()=>lW,noe={type:"3rdParty",init(t){Zse(t.options.react),eoe(t)}},roe=w.createContext();class ioe{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var bE={exports:{}},xE={};var UU;function aoe(){if(UU)return xE;UU=1;var t=Cb();function e(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,o=t.useDebugValue;function l(h,p){var m=p(),x=r({inst:{value:m,getSnapshot:p}}),y=x[0].inst,b=x[1];return s(function(){y.value=m,y.getSnapshot=p,c(y)&&b({inst:y})},[h,m,p]),i(function(){return c(y)&&b({inst:y}),h(function(){c(y)&&b({inst:y})})},[h]),o(m),m}function c(h){var p=h.getSnapshot;h=h.value;try{var m=p();return!n(h,m)}catch{return!0}}function u(h,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return xE.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,xE}var BU;function cW(){return BU||(BU=1,bE.exports=aoe()),bE.exports}var $R=cW();const soe=(t,e)=>ym(e)?e:Wse(e)&&ym(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,ooe={t:soe,ready:!1},loe=()=>()=>{},Ut=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(roe)||{},s=n||r||toe();s&&!s.reportNamespaces&&(s.reportNamespaces=new ioe),s||sW(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...Jse(),...s?.options?.react,...e}),[s,e]),{useSuspense:l,keyPrefix:c}=o,u=i||s?.options?.defaultNS,d=ym(u)?[u]:u||["translation"],h=w.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(h);const p=w.useRef(0),m=w.useCallback(T=>{if(!s)return loe;const{bindI18n:j,bindI18nStore:z}=o,F=()=>{p.current+=1,T()};return j&&s.on(j,F),z&&s.store.on(z,F),()=>{j&&j.split(" ").forEach($=>s.off($,F)),z&&z.split(" ").forEach($=>s.store.off($,F))}},[s,o]),x=w.useRef(),y=w.useCallback(()=>{if(!s)return ooe;const T=!!(s.isInitialized||s.initializedStoreOnce)&&h.every(H=>qse(H,s,o)),j=e.lng||s.language,z=p.current,F=x.current;if(F&&F.ready===T&&F.lng===j&&F.keyPrefix===c&&F.revision===z)return F;const D={t:s.getFixedT(j,o.nsMode==="fallback"?h:h[0],c),ready:T,lng:j,keyPrefix:c,revision:z};return x.current=D,D},[s,h,c,o,e.lng]),[b,v]=w.useState(0),{t:S,ready:k}=$R.useSyncExternalStore(m,y,y);w.useEffect(()=>{if(s&&!k&&!l){const T=()=>v(j=>j+1);e.lng?zU(s,e.lng,h,T):NP(s,h,T)}},[s,e.lng,h,k,l,b]);const E=s||{},N=w.useRef(null),A=w.useRef(),M=T=>{const j=Object.getOwnPropertyDescriptors(T);j.__original&&delete j.__original;const z=Object.create(Object.getPrototypeOf(T),j);if(!Object.prototype.hasOwnProperty.call(z,"__original"))try{Object.defineProperty(z,"__original",{value:T,writable:!1,enumerable:!1,configurable:!1})}catch{}return z},P=w.useMemo(()=>{const T=E,j=T?.language;let z=T;T&&(N.current&&N.current.__original===T?A.current!==j?(z=M(T),N.current=z,A.current=j):z=N.current:(z=M(T),N.current=z,A.current=j));const F=[S,z,k];return F.t=S,F.i18n=z,F.ready=k,F},[S,E,k,E.resolvedLanguage,E.language,E.languages]);if(s&&l&&!k)throw new Promise(T=>{const j=()=>T();e.lng?zU(s,e.lng,h,j):NP(s,h,j)});return P},{slice:coe,forEach:uoe}=[];function doe(t){return uoe.call(coe.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function hoe(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 $U=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,foe=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let s=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!$U.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!$U.test(r.path))throw new TypeError("option path is invalid");s+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(s+="; HttpOnly"),r.secure&&(s+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(s+="; Partitioned"),s},HU={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=foe(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 moe={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return HU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&HU.create(n,t,r,i,s)}},poe={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 s=r.substring(1).split("&");for(let o=0;o<s.length;o++){const l=s[o].indexOf("=");l>0&&s[o].substring(0,l)===e&&(n=s[o].substring(l+1))}}return n}},goe={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 s=i.substring(1);if(e){const o=s.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 Ep=null;const VU=()=>{if(Ep!==null)return Ep;try{if(Ep=typeof window<"u"&&window.localStorage!==null,!Ep)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Ep=!1}return Ep};var boe={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&VU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&VU()&&window.localStorage.setItem(n,t)}};let Ap=null;const GU=()=>{if(Ap!==null)return Ap;try{if(Ap=typeof window<"u"&&window.sessionStorage!==null,!Ap)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ap=!1}return Ap};var xoe={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&GU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&GU()&&window.sessionStorage.setItem(n,t)}},yoe={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let s=0;s<n.length;s++)e.push(n[s]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},voe={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}},woe={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}},_oe={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 uW=!1;try{document.cookie,uW=!0}catch{}const dW=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];uW||dW.splice(1,1);const Soe=()=>({order:dW,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class hW{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=doe(n,this.options||{},Soe()),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(moe),this.addDetector(poe),this.addDetector(boe),this.addDetector(xoe),this.addDetector(yoe),this.addDetector(voe),this.addDetector(woe),this.addDetector(_oe),this.addDetector(goe)}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&&!hoe(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)}))}}hW.type="languageDetector";const Noe={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",inventory:"Filament",files:"File Manager",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",updateAvailableBanner:"Version {{version}} is available!",viewUpdate:"View update",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode",smartSwitches:"Smart Switches",logout:"Logout"},common:{save:"Save",saving:"Saving...",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",days:"days",enable:"Enable",disable:"Disable",permissions:"Permissions",noPrinters:"No printers configured",noData:"No data available",linkNotFound:"Link not found",required:"Required",optional:"Optional",dismiss:"Dismiss",apply:"Apply",reset:"Reset",export:"Export",import:"Import",clear:"Clear",selectAll:"Select All",deselectAll:"Deselect All",noChange:"— No change —",unchanged:"Unchanged",unassigned:"Unassigned",unknown:"Unknown",unknownError:"Unknown error",today:"Today",asap:"ASAP",overdue:"Overdue",now:"Now",collapse:"Collapse",expand:"Expand",viewArchive:"View archive",viewInFileManager:"View in File Manager",addedBy:"Added by {{username}}",prints:"prints",more:"+{{count}} more",ascending:"Ascending",descending:"Descending",printer:"Printer",remove:"Remove",type:"Type",print:"Print",rename:"Rename",move:"Move",create:"Create",duplicate:"Duplicate",left:"Left",right:"Right"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address / Hostname",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",sort:{name:"Name",status:"Status",model:"Model",location:"Location",ascending:"Sort ascending",descending:"Sort descending"},cardSize:{small:"Small cards",medium:"Medium cards",large:"Large cards",extraLarge:"Extra large cards"},hideOffline:"Hide offline",powerOn:"Power On",offlinePrintersWithPlugs:"Offline printers with smart plugs",noPrintersConfigured:"No printers configured yet",readyToPrint:"Ready to print",external:"External",deleteArchives:"Delete print archives",noLabel:"No label",printPreview:"Print preview",width:"Width",height:"Height",noObjectsFound:"No objects found",objectsLoadedOnPrintStart:"Objects are loaded when a print starts",willBeSkipped:"Will be skipped",name:"Name",serialCannotBeChanged:"Serial number cannot be changed",locationHelp:"Used to group printers and filter queue jobs",wifiSignal:{veryWeak:"Very weak",weak:"Weak",fair:"Fair",good:"Good",excellent:"Excellent"},maintenanceUpToDate:"All maintenance up to date - Click to view",chamberLightOn:"Turn on chamber light",chamberLightOff:"Turn off chamber light",browseFiles:"Browse printer files",autoOffAfterPrint:"Auto power-off after print",autoOffExecuted:"Auto-off was executed - turn printer on to reset",hmsErrors:"HMS Errors",viewHmsErrors:"View {{count}} HMS error(s)",resume:"Resume",pause:"Pause",stop:"Stop",camera:"Camera",skipObject:"Skip Object",reconnect:"Reconnect",mqttDebug:"MQTT Debug",activeNozzle:"Active: {{nozzle}} nozzle",nozzleRack:"Nozzle Rack",nozzleDocked:"Docked",nozzleMounted:"Mounted",nozzleActive:"Active",nozzleIdle:"Idle",nozzleDiameter:"Diameter",nozzleType:"Type",nozzleStatus:"Status",nozzleFilament:"Filament",nozzleWear:"Wear",nozzleMaxTemp:"Max Temp",nozzleSerial:"Serial",nozzleHardenedSteel:"Hardened Steel",nozzleStainlessSteel:"Stainless Steel",nozzleTungstenCarbide:"Tungsten Carbide",nozzleFlow:"Flow",nozzleHighFlow:"High Flow",nozzleStandardFlow:"Standard",firmwareUpdate:"Firmware Update",firmwareInstructions:"On the printer's touchscreen, go to",firmwareNav:"Navigate to",settings:"Settings",firmware:"Firmware",discoverPrinters:"Discover Printers",searching:"Searching...",manualEntry:"Manual Entry",addFromCloud:"Add from Cloud",toast:{printerDeleted:"Printer deleted",printerAdded:"Printer added",printerUpdated:"Printer updated",failedToDelete:"Failed to delete printer",failedToAdd:"Failed to add printer",failedToUpdate:"Failed to update printer",commandSent:"Command sent",failedToSendCommand:"Failed to send command",turnedOn:"{{name}} turned on",failedToPowerOn:"Failed to power on {{name}}",scriptTriggered:"Script triggered",printStopped:"Print stopped",printPaused:"Print paused",printResumed:"Print resumed",referenceDeleted:"Reference deleted",detectionAreaSaved:"Detection area saved",failedToRunScript:"Failed to run script",failedToStopPrint:"Failed to stop print",failedToPausePrint:"Failed to pause print",failedToResumePrint:"Failed to resume print",failedToControlChamberLight:"Failed to control chamber light",failedToUpdateSetting:"Failed to update setting",failedToSkipObjects:"Failed to skip objects",failedToRereadRfid:"Failed to re-read RFID",failedToCheckPlate:"Failed to check plate",failedToUpdateLabel:"Failed to update label",failedToDeleteReference:"Failed to delete reference",failedToSaveDetectionArea:"Failed to save detection area",plateCheckEnabled:"Plate check enabled",plateCheckDisabled:"Plate check disabled",calibrationSaved:"Calibration saved!",calibrationFailed:"Calibration failed",rfidRereadInitiated:"RFID re-read initiated"},connection:{connected:"Connected",offline:"Offline"},queue:{inQueue:"{{count}} print in queue",inQueue_plural:"{{count}} prints in queue"},controls:"Controls",rfid:{reread:"Re-read RFID"},permission:{noAdd:"You do not have permission to add printers",noEdit:"You do not have permission to edit printers",noDelete:"You do not have permission to delete printers",noControl:"You do not have permission to control printers",noFiles:"You do not have permission to access printer files",noAmsRfid:"You do not have permission to re-read AMS RFID",noSmartPlugControl:"You do not have permission to control smart plugs"},modal:{addTitle:"Add Printer",editTitle:"Edit Printer",myPrinter:"My Printer",selectModel:"Select model...",locationGroup:"Location / Group (optional)",locationPlaceholder:"e.g., Workshop, Office, Basement",autoArchiveLabel:"Auto-archive completed prints",fromPrinterSettings:"From printer settings",modelOptional:"Model (optional)",saveChanges:"Save Changes"},skipObjects:{tooltip:"Skip objects",onlyWhilePrinting:"Skip objects (only while printing)",requiresMultiple:"Skip objects (requires 2+ objects)",title:"Skip Objects",matchIdsInfo:"Match IDs with your printer display",printerShowsIds:"The printer screen shows object IDs on the build plate",skipSelected:"Skip Selected",skipping:"Skipping...",noObjectsSelected:"No objects selected",selectObjectsToSkip:"Select objects you want to skip from the current print",skipped:"skipped",objectsSkipped:"Objects skipped",activeCount:"{{count}} active",waitForLayer:"Wait for layer 2+ to skip objects (currently layer {{layer}})",skip:"Skip",confirmTitle:"Skip Object?",confirmMessage:'Are you sure you want to skip "{{name}}"? This cannot be undone.'},confirm:{deleteTitle:"Delete Printer",deleteMessage:'Are you sure you want to delete "{{name}}"? This will remove all connection settings.',deleteArchivesNote:"All print history for this printer will be permanently deleted.",keepArchivesNote:"Print history will be kept but no longer associated with this printer.",stopTitle:"Stop Print",stopMessage:'Are you sure you want to stop the current print on "{{name}}"? This will cancel the print job.',stopButton:"Stop Print",pauseTitle:"Pause Print",pauseMessage:'Are you sure you want to pause the current print on "{{name}}"?',pauseButton:"Pause Print",resumeTitle:"Resume Print",resumeMessage:'Are you sure you want to resume the print on "{{name}}"?',resumeButton:"Resume Print",powerOnTitle:"Power On Printer",powerOnMessage:'Are you sure you want to turn ON the power for "{{name}}"?',powerOnButton:"Power On",powerOffTitle:"Power Off Printer",powerOffMessage:'Are you sure you want to turn OFF the power for "{{name}}"?',powerOffWarning:'WARNING: "{{name}}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.',powerOffButton:"Power Off"},discovery:{title:"Discover Printers",searching:"Searching...",scanning:"Scanning...",scanProgress:"Scanning... {{scanned}}/{{total}}",foundPrinters:"Found {{count}} printer(s)",noPrintersFound:"No printers found",noPrintersFoundSubnet:"No printers found in the specified subnet.",noPrintersFoundNetwork:"No printers found on the network.",allConfigured:"All discovered printers are already configured.",alreadyAdded:"Already added",select:"Select",manualEntry:"Manual Entry",addFromCloud:"Add from Cloud",subnetToScan:"Subnet to scan",dockerNote:"Docker detected. Enter your printer's subnet in CIDR notation. Requires network_mode: host in docker-compose.yml.",scanSubnet:"Scan Subnet for Printers",discoverNetwork:"Discover Printers on Network",scanningSubnet:"Scanning subnet for Bambu printers...",scanningNetwork:"Scanning network...",serialRequired:"Serial required",unknown:"Unknown",failedToStart:"Failed to start discovery"},filaments:"Filaments",openCameraOverlay:"Open camera overlay",openCameraWindow:"Open camera in new window",firmwareUpdateAvailable:"Firmware update available: {{current}} → {{latest}}",firmwareUpToDate:"Firmware {{version}} — Up to date",firmwareUpdateButton:"Update",plateDetection:{noPermission:"You do not have permission to update printers",enabledClick:"Plate check enabled - Click to disable",disabledClick:"Plate check disabled - Click to enable",manageCalibration:"Manage plate detection calibration",calibrationRequired:"Calibration Required",calibrationInstructions:"Please ensure the build plate is <strong>completely empty</strong>, then click Calibrate.",calibrationDescription:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects.",calibrationTip:"<strong>Tip:</strong> You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking.",plateEmpty:"Plate appears empty",objectsDetected:"Objects detected on plate",confidence:"Confidence",difference:"Difference",analysisPreview:"Analysis preview:",analysisLegend:"Green box = detection area, Red overlay = differences from calibration",savedReferences:"Saved References ({{count}}/{{max}})",deleteReference:"Delete reference",labelPlaceholder:"Label...",clickToEdit:"{{label}} - Click to edit",clickToAddLabel:"Click to add label"},fans:{partCooling:"Part Cooling Fan",auxiliary:"Auxiliary Fan",chamber:"Chamber Fan"},clickToViewHmsErrors:"Click to view HMS errors",estimatedCompletion:"Estimated completion time",slotOptions:"Slot options",firmwareModal:{title:"Firmware Update",titleUpToDate:"Firmware Info",currentVersion:"Current:",latestVersion:"Latest:",releaseNotes:"Release Notes",checkingPrereqs:"Checking prerequisites...",sdCardReady:"SD card ready. Click below to upload firmware.",uploadedSuccess:"Firmware uploaded to SD card!",applyInstructions:"To apply the update on your printer:",step1:"On the printer's touchscreen, go to <strong>Settings</strong>",step2:"Navigate to <strong>Firmware</strong>",step3:"Select <strong>Update from SD card</strong>",step4:"The update will take 10-20 minutes",done:"Done",starting:"Starting...",uploadFirmware:"Upload Firmware",uploadFailed:"Failed to start upload: {{error}}",uploadedToast:"Firmware uploaded! Trigger update from printer screen."},accessCodePlaceholder:"Leave empty to keep current",roi:{title:"Detection Area (ROI)",xStart:"X Start",yStart:"Y Start",width:"Width",height:"Height",instruction:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."}},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",sortLargest:"Largest first",sortSmallest:"Smallest first",sortSize:"Size",noArchives:"No archives found",noArchivesSearch:"No archives match your search",noArchivesYet:"No archives yet",loadingArchives:"Loading archives...",releaseToUpload:"Release to upload",showAll:"Show all",showFavoritesOnly:"Show favorites only",gridView:"Grid view",listView:"List view",calendarView:"Calendar view",manageTags:"Manage Tags",showFailedPrints:"Show failed prints",hideFailedPrints:"Hide failed prints",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"},toast:{source3mfAttached:"Source 3MF attached: {{filename}}",failedUploadSource3mf:"Failed to upload source 3MF",source3mfRemoved:"Source 3MF removed",failedRemoveSource3mf:"Failed to remove source 3MF",f3dAttached:"F3D attached: {{filename}}",failedUploadF3d:"Failed to upload F3D",f3dRemoved:"F3D removed",failedRemoveF3d:"Failed to remove F3D",timelapseAttached:"Timelapse attached: {{filename}}",timelapseAlreadyAttached:"Timelapse already attached",noMatchingTimelapse:"No matching timelapse found",failedScanTimelapse:"Failed to scan for timelapse",failedAttachTimelapse:"Failed to attach timelapse",archiveDeleted:"Archive deleted",failedDeleteArchive:"Failed to delete archive",addedToFavorites:"Added to favorites",removedFromFavorites:"Removed from favorites",projectUpdated:"Project updated",failedUpdateProject:"Failed to update project",linkCopied:"Link copied to clipboard",failedCopyLink:"Failed to copy link",photoDeleted:"Photo deleted",failedDeletePhoto:"Failed to delete photo",failedDeleteArchives:"Failed to delete archives",failedUpdateFavorites:"Failed to update favorites",exportDownloaded:"Export downloaded",exportFailed:"Export failed"},menu:{print:"Print",schedule:"Schedule",openInBambuStudio:"Open in Slicer",slice:"Slice",externalLink:"External Link",viewOnMakerWorld:"View on MakerWorld",preview3d:"3D Preview",viewTimelapse:"View Timelapse",scanForTimelapse:"Scan for Timelapse",downloadSource3mf:"Download Source 3MF",uploadSource3mf:"Upload Source 3MF",replaceSource3mf:"Replace Source 3MF",removeSource3mf:"Remove Source 3MF",uploadF3d:"Upload F3D",replaceF3d:"Replace F3D",downloadF3d:"Download F3D",removeF3d:"Remove F3D",download:"Download",copyDownloadLink:"Copy Download Link",qrCode:"QR Code",viewPhotos:"View Photos",viewPhotosCount:"View Photos ({{count}})",projectPage:"Project Page",addToFavorites:"Add to Favorites",removeFromFavorites:"Remove from Favorites",edit:"Edit",goToProject:"Go to Project: {{name}}",addToProject:"Add to Project",removeFromProject:"Remove from Project",loading:"Loading...",noProjectsAvailable:"No projects available",select:"Select",deselect:"Deselect",delete:"Delete"},permission:{noReprint:"You do not have permission to reprint this archive",noAddToQueue:"You do not have permission to add to queue",noUpdateArchives:"You do not have permission to update archives",noUploadFiles:"You do not have permission to upload files",noDownload:"You do not have permission to download archives",noCopyLink:"You do not have permission to copy download links",noDelete:"You do not have permission to delete this archive",noCreate:"You do not have permission to create archives"},card:{previousPlate:"Previous plate",nextPlate:"Next plate",plateNumber:"Plate {{index}}",moreOptions:"Right-click for more options",addToFavorites:"Add to favorites",removeFromFavorites:"Remove from favorites",cancelled:"cancelled",failed:"failed",duplicate:"duplicate",duplicateTitle:"This model has been printed before",openSource3mf:"Open source 3MF in Bambu Studio (right-click for more options)",downloadF3d:"Download Fusion 360 design file",viewTimelapse:"View timelapse",viewPhoto:"View 1 photo",viewPhotos:"View {{count}} photos",openFolder:"Open folder: {{name}}",slicedFile:"Sliced file - ready to print",sourceFile:"Source file only - no AMS mapping available",gcode:"GCODE",source:"SOURCE",project:"Project: {{name}}",estimated:"Estimated: {{time}}",actual:"Actual: {{time}}",accuracy:"Accuracy: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} layer",layers:"{{count}} layers",object:"{{count}} object",objects:"{{count}} objects",slicedFor:"Sliced for {{model}}",uploadedBy:"Uploaded By",noPermissionReprint:"You do not have permission to reprint",noPermissionEdit:"You do not have permission to edit archives",noPermissionDelete:"You do not have permission to delete archives",reprint:"Reprint",schedulePrint:"Schedule Print",schedule:"Schedule",openInBambuStudio:"Open in Slicer",openInBambuStudioToSlice:"Open in Slicer to slice",slice:"Slice",externalLink:"External Link",makerWorld:"MakerWorld: {{designer}}",viewProject:"View project",noExternalLink:"No external link",preview3d:"3D Preview",download:"Download",edit:"Edit",delete:"Delete"},modal:{deleteArchive:"Delete Archive",deleteConfirm:'Are you sure you want to delete "{{name}}"? This action cannot be undone.',deleteButton:"Delete",removeSource3mf:"Remove Source 3MF",removeSource3mfConfirm:'Are you sure you want to remove the source 3MF file from "{{name}}"? This will delete the original slicer project file.',removeButton:"Remove",removeF3d:"Remove F3D",removeF3dConfirm:'Are you sure you want to remove the Fusion 360 design file from "{{name}}"?',timelapse:"{{name}} - Timelapse",selectTimelapse:"Select Timelapse",selectTimelapseDesc:"No auto-match found. Select the timelapse for this print:",deleteArchives:"Delete Archives",deleteArchivesConfirm:"Are you sure you want to delete {{count}} archive(s)? This action cannot be undone.",deleteCount:"Delete {{count}}"},page:{title:"Archives",printsCount:"{{filtered}} of {{total}} prints",dropFilesHere:"Drop .3mf files here",releaseToUpload:"Release to upload",only3mfSupported:"Only .3mf files are supported",close:"Close",selected:"{{count}} selected",selectAll:"Select All",tags:"Tags",project:"Project",favorite:"Favorite",delete:"Delete",toggledFavorites:"Toggled favorites for {{count}} archive(s)",failedUpdateFavorites:"Failed to update favorites",archivesDeleted:"{{count}} archive(s) deleted",failedDeleteArchives:"Failed to delete archives",photoDeleted:"Photo deleted",failedDeletePhoto:"Failed to delete photo"},list:{name:"Name",printer:"Printer",date:"Date",size:"Size",actions:"Actions",hasTimelapse:"Has timelapse"}},queue:{title:"Print Queue",subtitle:"Schedule and manage your print jobs",addToQueue:"Add to Queue",print:"Print",reprint:"Re-print",schedulePrint:"Schedule Print",editQueueItem:"Edit Queue Item",printToPrinters:"Print to {{count}} Printers",queueToPrinters:"Queue to {{count}} Printers",sending:"Sending...",sendingProgress:"Sending {{current}}/{{total}}...",adding:"Adding...",addingProgress:"Adding {{current}}/{{total}}...",savingProgress:"Saving {{current}}/{{total}}...",clearQueue:"Clear Queue",clearHistory:"Clear History",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",startNow:"Start Now",printingInProgress:"Printing in progress...",viewArchive:"View archive",viewInFileManager:"View in File Manager",itemCount:"{{count}} item",itemCount_plural:"{{count}} items",dragToReorder:"Drag to reorder (ASAP only)",reorderHint:"Position only affects ASAP items. Scheduled items run at their set time.",addedBy:"Added by {{name}}",nextInQueue:"Next in queue",clearPlate:"Clear Plate & Start Next",clearPlateSuccess:"Plate cleared — ready for next print",plateReady:"Plate cleared — ready for next print",sections:{currentlyPrinting:"Currently Printing",queued:"Queued",history:"History"},status:{pending:"Pending",waiting:"Waiting",printing:"Printing",paused:"Paused",completed:"Completed",failed:"Failed",skipped:"Skipped",cancelled:"Cancelled"},summary:{printing:"Printing",queued:"Queued",totalTime:"Total Queue Time",history:"History"},filter:{allPrinters:"All Printers",unassigned:"Unassigned",allStatus:"All Status",allLocations:"All Locations",any:"Any"},sort:{byPosition:"Sort by Position",byName:"Sort by Name",byPrinter:"Sort by Printer",bySchedule:"Sort by Schedule",byDate:"Sort by Date",ascendingOldest:"Ascending (oldest first)",descendingNewest:"Descending (newest first)"},badges:{staged:"Staged",requiresPrevious:"Requires previous success",autoPowerOff:"Auto power off"},empty:{title:"No prints scheduled",description:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'},time:{asap:"ASAP",overdue:"Overdue",now:"Now",lessThanMinute:"In less than a minute",inMinutes:"In {{count}} min",inHours:"In {{count}} hours"},actions:{stopPrint:"Stop Print",startPrint:"Start Print",requeue:"Re-queue"},bulkEdit:{title:"Edit {{count}} Item",title_plural:"Edit {{count}} Items",description:"Only changed settings will be applied to selected items.",printer:"Printer",noChange:"— No change —",queueOptions:"Queue Options",staged:"Staged (manual start)",autoPowerOff:"Auto power off after print",requirePrevious:"Require previous success",printOptions:"Print Options",bedLevelling:"Bed levelling",flowCalibration:"Flow calibration",vibrationCalibration:"Vibration calibration",layerInspection:"First layer inspection",timelapse:"Timelapse",useAms:"Use AMS",applyChanges:"Apply Changes",selectAll:"Select All",deselectAll:"Deselect All",selected:"{{count}} selected",editSelected:"Edit Selected",cancelSelected:"Cancel Selected"},confirm:{cancelTitle:"Cancel Scheduled Print",cancelMessage:'Are you sure you want to cancel "{{name}}"?',stopTitle:"Stop Print",stopMessage:'Are you sure you want to stop the current print "{{name}}"? This will cancel the print job on the printer.',removeTitle:"Remove from History",removeMessage:'Are you sure you want to remove "{{name}}" from the queue history?',clearHistoryTitle:"Clear History",clearHistoryMessage:"Are you sure you want to remove all {{count}} item(s) from the history?",cancelButton:"Cancel Print",stopButton:"Stop Print",thisPrint:"this print",thisItem:"this item"},toast:{cancelled:"Queue item cancelled",cancelFailed:"Failed to cancel item",removed:"Queue item removed",removeFailed:"Failed to remove item",stopped:"Print stopped",stopFailed:"Failed to stop print",released:"Print released to queue",startFailed:"Failed to start print",reorderFailed:"Failed to reorder queue",historyCleared:"Cleared {{count}} history item(s)",clearHistoryFailed:"Failed to clear history",updateFailed:"Failed to update items",bulkCancelled:"Cancelled {{count}} item(s)",bulkCancelFailed:"Failed to cancel items"},permissions:{noStopPrint:"You do not have permission to stop prints",noStartPrint:"You do not have permission to start prints",noEdit:"You do not have permission to edit this queue item",noCancel:"You do not have permission to cancel this queue item",noRequeue:"You do not have permission to re-queue items",noRemove:"You do not have permission to remove this queue item",noClearHistory:"You do not have permission to clear all history",noEditItems:"You do not have permission to edit queue items",noCancelItems:"You do not have permission to cancel queue items"}},stats:{title:"Dashboard",subtitle:"Drag widgets to rearrange. Click the eye icon to hide.",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",printTime:"Print Time",totalFilament:"Total Filament Used",filamentUsed:"Filament Used",filamentCost:"Filament Cost",totalCost:"Total Cost",energyUsed:"Energy Used",energyCost:"Energy Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",printsByPrinter:"Prints by Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time",quickStats:"Quick Stats",printActivity:"Print Activity",filamentTypes:"Filament Types",filamentTrends:"Filament Trends",failureAnalysis:"Failure Analysis",timeAccuracy:"Time Accuracy",successful:"Successful:",failed:"Failed:",perfectEstimate:"100% = perfect estimate",noTimeAccuracyData:"No time accuracy data yet",noFilamentData:"No filament data available",noPrinterData:"No printer data available",noPrintData:"No print data available",noPrintDataLast30Days:"No print data in the last 30 days",failureReasons:"Failure Reasons",topFailureReasons:"Top Failure Reasons",failedPrintsCount:"{{failed}} / {{total}} prints failed",lastWeekRate:"Last week: {{rate}}%",resetLayout:"Reset Layout",recalculateCosts:"Recalculate Costs",recalculateCostsHint:"Recalculate all archive costs using current filament prices",exportStats:"Export Stats",exportAsCsv:"Export as CSV",exportAsExcel:"Export as Excel",hiddenCount:"{{count}} Hidden",exportDownloaded:"Export downloaded",exportFailed:"Export failed",layoutReset:"Layout reset",recalculatedCosts:"Recalculated costs for {{count}} archives",recalculateFailed:"Failed to recalculate costs",loadingStats:"Loading statistics...",noPermissionResetLayout:"You do not have permission to reset layout",noPermissionRecalculate:"You do not have permission to recalculate costs"},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",statusTab:"Status",settingsTab:"Settings",overdueCount:"{{count}} overdue",dueSoonCount:"{{count}} due soon",dueSoon:"Due soon",allGood:"All good",overdueBy:"Overdue by {{duration}}",dueIn:"Due in {{duration}}",timeLeft:"{{duration}} left",day:"1 day",days:"{{count}} days",week:"1 week",weeks:"{{count}} weeks",month:"1 month",months:"{{count}} months",year:"1 year",maintenanceTypes:"Maintenance Types",maintenanceTypesDescription:"System types and your custom maintenance tasks",addCustomType:"Add Custom Type",intervalType:"Interval Type",intervalValue:"Interval ({{type}})",icon:"Icon",documentationLink:"Documentation Link (optional)",assignToPrinters:"Assign to Printers",selectAtLeastOnePrinter:"Select at least one printer",addType:"Add Type",custom:"Custom",printHours:"Print Hours",calendarDays:"Calendar Days",exampleName:"e.g., Replace HEPA Filter",viewDocumentation:"View documentation",timeBasedInterval:"Time-based interval",intervalOverrides:"Interval Overrides",intervalOverridesDescription:"Customize intervals for specific printers",assignedToPrinters:"Assigned to printers:",noPrintersAssigned:"No printers assigned",addPrinterShort:"Add:",printersAssignedClick:"{{count}} printer(s) assigned - click to manage",removeFromPrinter:"Remove from this printer",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",cleanCarbonRods:"Clean Carbon Rods",checkPtfeTube:"Check PTFE Tube",replaceHepaFilter:"Replace HEPA Filter",replaceCarbonFilter:"Replace Carbon Filter",lubricateLeftNozzleRail:"Lubricate Left Nozzle Rail"},maintenanceComplete:"Maintenance marked as complete",typeUpdated:"Maintenance type updated",typeDeleted:"Maintenance type deleted",printHoursUpdated:"Print hours updated",printerAssigned:"Printer assigned",printerRemoved:"Printer removed",deleteTypeConfirm:'Delete "{{name}}"?',noPermissionUpdate:"You do not have permission to update maintenance items",noPermissionPerform:"You do not have permission to perform maintenance",noPermissionEditTypes:"You do not have permission to edit maintenance types",noPermissionDeleteTypes:"You do not have permission to delete maintenance types",noPermissionEditHours:"You do not have permission to edit print hours",noPermissionRemovePrinter:"You do not have permission to remove printer assignments",noPermissionAssignPrinter:"You do not have permission to assign printers",noPermissionEditIntervals:"You do not have permission to edit intervals",configureSettings:"Configure maintenance types and intervals"},settings:{title:"Settings",general:"General",tabs:{general:"General",smartPlugs:"Smart Plugs",notifications:"Notifications",filament:"Filament",network:"Network",apiKeys:"API Keys",virtualPrinter:"Virtual Printer",users:"Authentication",backup:"Backup",emailAuth:"Email Authentication"},email:{smtpSettings:"SMTP Configuration",smtpHost:"SMTP Server",smtpPort:"SMTP Port",security:"Security",authentication:"Authentication",username:"Username",password:"Password",fromEmail:"From Email",fromName:"From Name",testConnection:"Test SMTP Connection",testRecipient:"Test Recipient Email",sendTest:"Send Test Email",sending:"Sending...",save:"Save Settings",saving:"Saving...",advancedAuth:"Advanced Authentication",advancedAuthEnabled:"Advanced Authentication is enabled",advancedAuthEnabledDesc:"Email-based user management features are active. New users will receive auto-generated passwords via email, and users can reset their passwords through the forgot password feature.",advancedAuthDisabled:"Advanced Authentication is disabled",advancedAuthDisabledDesc:"Enable advanced authentication to activate email-based features for user management.",enable:"Enable",disable:"Disable",feature1:"Passwords are auto-generated and emailed to new users",feature2:"Users can login with username or email",feature3:"Forgot password feature is available",feature4:"Admins can reset user passwords via email",errors:{requiredFields:"Please fill in all required fields",usernameRequired:"Username is required when authentication is enabled",enterTestEmail:"Please enter a test email address",smtpServerAndEmail:"Please fill in SMTP Server and From Email before testing",usernamePasswordRequired:"Username and Password are required when authentication is enabled",configureSmtpFirst:"Please configure and test SMTP settings first"},success:{settingsSaved:"SMTP settings saved successfully"},securityOptions:{starttls:"STARTTLS (Port 587)",ssl:"SSL/TLS (Port 465)",none:"None (Port 25)"},authOptions:{enabled:"Enabled",disabled:"Disabled"}},appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},filamentTracking:"Filament Tracking",filamentTrackingDesc:"Choose how to track your filament spools. You can use the built-in inventory or connect an external Spoolman server.",trackingModeBuiltIn:"Built-in Inventory",trackingModeBuiltInDesc:"RFID auto-matching and usage tracking included",trackingModeSpoolmanDesc:"External filament management server",builtInFeatureRfid:"Automatically detects Bambu Lab RFID spools in AMS",builtInFeatureUsage:"Tracks filament consumption per print",builtInFeatureCatalog:"Manage spools, colors, and K-factor profiles",spoolmanUrl:"Spoolman URL",spoolmanUrlHint:"URL of your Spoolman server (e.g., http://localhost:7912)",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected",status:"Status",connect:"Connect",disconnect:"Disconnect",howSyncWorks:"How Sync Works",syncInfoRfidOnly:"Only official Bambu Lab spools with RFID are synced",syncInfoAutoCreate:"New spools are auto-created in Spoolman on first sync",syncInfoThirdPartySkipped:"Non-Bambu Lab spools (third-party, refilled) are skipped",linkingExistingSpools:"Linking Existing Spools",linkingExistingSpoolsDesc:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".',syncMode:"Sync Mode",syncModeAuto:"Automatic",syncModeManual:"Manual Only",syncModeAutoDesc:"AMS data syncs automatically when changes are detected",syncModeManualDesc:"Only sync when manually triggered",syncAmsData:"Sync AMS Data",syncAmsDataDesc:"Manually sync printer AMS data to Spoolman",allPrinters:"All Printers",noDefaultPrinter:"No default (ask each time)",sidebarOrder:"Sidebar order",saveThumbnails:"Save thumbnails",captureFinishPhoto:"Capture finish photo",noPrintersConfigured:"No printers configured",archiveMode:{always:"Always create archive entry",never:"Never create archive entry",ask:"Ask each time"},checkForUpdatesLabel:"Check for updates",checkPrinterFirmware:"Check printer firmware",enableRetry:"Enable retry",homeAssistantDescription:"Control smart plugs via Home Assistant",environmentManagedLabel:"(Environment Managed)",autoEnabledViaEnv:"Automatically enabled via environment variables",urlFromEnvReadOnly:"Value set by HA_URL environment variable (read-only)",tokenFromEnvReadOnly:"Value set by HA_TOKEN environment variable (read-only)",mqttConnectedTo:"Connected to",prometheusDescription:"Expose printer data in Prometheus format",noSmartPlugsTitle:"No smart plugs configured",noSmartPlugsDescription:"Add a Tasmota-based smart plug to track energy usage and automate power control.",noProvidersTitle:"No providers configured",noProvidersDescription:"Add a provider to receive alerts.",noTemplatesAvailable:"No templates available. Restart the backend to seed default templates.",apiPermissionView:"View printer status and queue",apiPermissionEdit:"Add and remove items from print queue",apiKeysEmptyTitle:"No API keys",apiKeysEmptyDescription:"Create an API key to integrate with external services.",noUsersFound:"No users found",noGroupsFound:"No groups found",noGroupsAvailable:"No groups available",passwordsDoNotMatch:"Passwords do not match",systemGroupWarning:"System group names cannot be changed",authDisabledTitle:"Authentication is Disabled",authDisabledFeature1:"Require login to access the system",authDisabledFeature2:"Create multiple users with group-based permissions",authDisabledFeature3:"Control access with 50+ granular permissions",userHasCreated:"This user has created:",userItemsQuestion:"What would you like to do with these items?",deleteUserConfirm:"Are you sure you want to delete this user?",actionCannotBeUndone:"This action cannot be undone.",addFirstSmartPlug:"Add Your First Smart Plug",providers:"Providers",log:"Log",testAll:"Test All",testResults:"Test Results",testPassedCount:"{{count}} passed",testFailedCount:"{{count}} failed",messageTemplates:"Message Templates",messageTemplatesDescription:"Customize notification messages for each event.",apiKeys:"API Keys",apiKeysDescription:"Create API keys for external integrations and webhooks.",createKey:"Create Key",apiKeyCreated:"API Key Created Successfully",apiKeyCopyWarning:"Copy this key now - it won't be shown again!",useInApiBrowser:"Use in API Browser",createNewApiKey:"Create New API Key",keyName:"Key Name",keyNamePlaceholder:"e.g., Home Assistant, OctoPrint",readStatus:"Read Status",readStatusDescription:"View printer status and queue",manageQueue:"Manage Queue",manageQueueDescription:"Add and remove items from print queue",controlPrinter:"Control Printer",controlPrinterDescription:"Pause, resume, and stop prints",unnamedKey:"Unnamed Key",lastUsed:"Last used",read:"Read",control:"Control",createFirstKey:"Create Your First Key",webhookEndpoints:"Webhook Endpoints",webhookApiKeyHint:"Use your API key in the X-API-Key header.",webhook:{getAllStatus:"Get all printer status",getSpecificStatus:"Get specific printer status",addToQueue:"Add to print queue",pausePrint:"Pause print",resumePrint:"Resume print",stopPrint:"Stop print"},apiBrowser:"API Browser",apiBrowserDescription:"Explore and test all available API endpoints.",apiKeyForTesting:"API Key for Testing",apiKeyPlaceholder:"Paste your API key here to test authenticated endpoints...",apiKeyHint:"This key will be sent as X-API-Key header with requests.",deleteApiKeyTitle:"Delete API Key",deleteApiKeyMessage:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",deleteKey:"Delete Key",amsDisplayThresholds:"AMS Display Thresholds",amsThresholdsDescription:"Configure color thresholds for AMS humidity and temperature indicators.",humidity:"Humidity",goodGreen:"Good (green)",fairOrange:"Fair (orange)",aboveFairBad:"Above fair threshold shows as red (bad)",temperature:"Temperature",goodBlue:"Good (blue)",aboveFairHot:"Above fair threshold shows as red (hot)",historyRetention:"History Retention",keepSensorHistory:"Keep sensor history for",historyRetentionDescription:"Older humidity and temperature data will be automatically deleted",printModal:"Print Modal",expandCustomMapping:"Expand custom mapping by default",expandCustomMappingDescription:"When printing to multiple printers, show per-printer AMS mapping expanded",authentication:"Authentication",authEnabledDescription:"Your instance is secured with user authentication",authDisabledDescription:"Enable to require login and manage user access",authDisabledMessage:"Enable authentication to create user accounts, manage permissions, and secure your Bambuddy instance.",enableAuthentication:"Enable Authentication",currentUser:"Current User",changePassword:"Change Password",admin:"Admin",users:"Users",addUser:"Add User",groups:"Groups",addGroup:"Add Group",system:"System",noDescription:"No description",userCount:"{{count}} users",permissionCount:"{{count}} permissions",createUser:"Create User",username:"Username",enterUsername:"Enter username",password:"Password",enterPassword:"Enter password (min 6 characters)",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm password",viewReleaseOnGitHub:"View release on GitHub",turnAllPlugsOn:"Turn all plugs on",turnAllPlugsOff:"Turn all plugs off",clearNotificationLogs:"Clear Notification Logs",clearLogsMessage:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",clearLogs:"Clear Logs",resetUiPreferences:"Reset UI Preferences",resetUiPreferencesMessage:"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.",resetPreferences:"Reset Preferences",deleteGroupTitle:"Delete Group",deleteGroupMessage:"Are you sure you want to delete this group? Users in this group will lose these permissions.",deleteGroup:"Delete Group",disableAuthenticationTitle:"Disable Authentication",disableAuthenticationMessage:"Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.",disableAuthentication:"Disable Authentication",configureBambuddy:"Configure Bambuddy",systemDefault:"System Default",archiveSettings:"Archive Settings",newWindow:"New Window",embeddedOverlay:"Embedded Overlay",preferredSlicer:"Preferred Slicer",preferredSlicerDescription:"Choose which slicer application to open files with",externalCameras:"External Cameras",costTracking:"Cost Tracking",printsOnly:"Prints Only",totalConsumption:"Total Consumption",dataManagement:"Data Management",clearNotificationLogsDescription:"Delete notification logs older than 30 days",resetUiPreferencesDescription:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected.",enableHomeAssistant:"Enable Home Assistant",enableMqtt:"Enable MQTT",useTls:"Use TLS",enableMetricsEndpoint:"Enable Metrics Endpoint",availableMetrics:"Available Metrics",editUser:"Edit User",deleteUserTitle:"Delete User",groupName:"Group Name",leaveEmptyForAnonymous:"Leave empty for anonymous",leaveEmptyForNoAuth:"Leave empty for no authentication",enterNewPassword:"Enter new password",confirmNewPassword:"Confirm new password",enterGroupName:"Enter group name",enterDescriptionOptional:"Enter description (optional)",enterCurrentPassword:"Enter current password",enterNewPasswordMin6:"Enter new password (min 6 characters)",toast:{keyCopied:"Key copied to clipboard",copyFailed:"Failed to copy key",keyAddedToBrowser:"Key added to API Browser",clearLogsFailed:"Failed to clear logs",uiPreferencesReset:"UI preferences reset. Refreshing...",authDisabled:"Authentication disabled successfully",authDisableFailed:"Failed to disable authentication",apiKeyCreated:"API key created",apiKeyDeleted:"API key deleted",userCreated:"User created successfully",userUpdated:"User updated successfully",userDeleted:"User deleted successfully",groupCreated:"Group created successfully",groupUpdated:"Group updated successfully",groupDeleted:"Group deleted successfully",fillRequiredFields:"Please fill in all required fields",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters",enterGroupName:"Please enter a group name",settingsSaved:"Settings saved",cameraSettingsSaved:"Camera settings saved",enterCameraUrl:"Please enter a camera URL",passwordChanged:"Password changed successfully",connectionFailed:"Connection failed",testFailed:"Test failed",cameraConnected:"Camera connected{{resolution}}"},testConnection:"Test Connection",catalog:{spoolCatalog:"Spool Catalog",spoolCatalogDescription:"Empty spool weights by brand/type. Used for automatic weight lookup when adding spools.",searchCatalog:"Search catalog...",addNewEntry:"Add New Entry",namePlaceholder:"Name (e.g., Bambu Lab - Plastic)",weight:"Weight",type:"Type",default:"Default",custom:"Custom",noMatch:"No entries match your search",empty:"No entries in catalog",deleteEntry:"Delete Entry",deleteConfirm:'Are you sure you want to delete "{{name}}"?',resetCatalog:"Reset Catalog",resetConfirm:"Reset catalog to defaults? This will remove all custom entries.",loadFailed:"Failed to load spool catalog",nameWeightRequired:"Name and weight are required",entryAdded:"Entry added",addFailed:"Failed to add entry",entryUpdated:"Entry updated",updateFailed:"Failed to update entry",entryDeleted:"Entry deleted",deleteFailed:"Failed to delete entry",resetSuccess:"Catalog reset to defaults",resetFailed:"Failed to reset catalog",exported:"Exported {{count}} entries",imported:"Imported {{added}} entries ({{skipped}} skipped)",importFailed:"Failed to import: invalid JSON format",exportTooltip:"Export catalog to JSON",importTooltip:"Import catalog from JSON",resetTooltip:"Reset to defaults"},colorCatalog:{title:"Color Catalog",description:"Filament colors by manufacturer/material. Used for automatic color lookup when adding spools.",searchColors:"Search colors...",allManufacturers:"All manufacturers",addNewColor:"Add New Color",manufacturer:"Manufacturer",colorName:"Color Name",hex:"Hex",materialOptional:"Material (optional)",showing:"Showing {{filtered}} of {{total}} colors",noMatch:"No colors match your search",empty:"No colors in catalog",deleteColor:"Delete Color",deleteConfirm:'Are you sure you want to delete "{{name}}"?',resetCatalog:"Reset Color Catalog",resetConfirm:"Reset catalog to defaults? This will remove all custom colors.",sync:"Sync",starting:"Starting...",syncTooltip:"Sync from FilamentColors.xyz (2000+ colors, may take a minute)",loadFailed:"Failed to load color catalog",fieldsRequired:"Manufacturer, color name, and hex color are required",colorAdded:"Color added",addFailed:"Failed to add color",colorUpdated:"Color updated",updateFailed:"Failed to update color",colorDeleted:"Color deleted",deleteFailed:"Failed to delete color",resetSuccess:"Color catalog reset to defaults",resetFailed:"Failed to reset catalog",syncUpToDate:"Already up to date ({{count}} colors checked)",syncComplete:"Added {{added}} new colors ({{skipped}} already existed)",syncError:"Sync error",syncFailed:"Failed to sync from FilamentColors.xyz",exported:"Exported {{count}} colors",imported:"Imported {{added}} colors ({{skipped}} skipped)",importFailed:"Failed to import: invalid JSON format"}},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"},hmsErrors:{title:"Errors - {{name}}",noErrors:"No errors",viewOnWiki:"View on Bambu Lab Wiki",clearInstructions:"Clear errors on the printer to dismiss them here."},mqttDebug:{title:"MQTT Debug Log",searchPlaceholder:"Search topic or payload...",noMessages:"No messages logged yet",startLoggingHint:'Click "Start Logging" to begin capturing MQTT messages',noMessagesMatch:"No messages match your filter",adjustFilterHint:"Try adjusting your search or filter criteria",incoming:"Incoming",outgoing:"Outgoing",loggingStopped:"Logging stopped",loggingActive:"Logging active - messages will auto-refresh",startLogging:"Start Logging",stopLogging:"Stop Logging",clearLog:"Clear Log",topic:"Topic",timestamp:"Timestamp",direction:"Direction",all:"All"},printerFiles:{title:"File Manager",storageUsed:"Used:",storageFree:"Free:",filterPlaceholder:"Filter files...",deleteButton:"Delete",deleteFiles:"Delete {{count}} Files",deleteFileConfirm:'Delete "{{name}}"? This cannot be undone.',deleteFilesConfirm:"Delete {{count}} selected files? This cannot be undone.",noFiles:"No files on printer",loadingFiles:"Loading files...",failedToLoad:"Failed to load files",toast:{filesDeleted:"Deleted {{count}} file(s)",deleteFailed:"Delete failed: {{error}}"}},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?"},login:{title:"Bambuddy Login",subtitle:"Sign in to your account",username:"Username",usernamePlaceholder:"Enter your username",usernameOrEmail:"Username or Email",usernameOrEmailPlaceholder:"Username or @ Email",password:"Password",passwordPlaceholder:"Enter your password",signIn:"Sign in",signingIn:"Logging in...",forgotPassword:"Forgot your password?",loginSuccess:"Logged in successfully",loginFailed:"Login failed",enterCredentials:"Please enter username and password",forgotPasswordTitle:"Forgot Password",forgotPasswordMessage:"If you've forgotten your password, please contact your system administrator to reset it.",forgotPasswordEmailMessage:"Enter your email address and we'll send you a new password.",emailAddress:"Email Address",emailPlaceholder:"your.email@example.com",cancel:"Cancel",sending:"Sending...",sendResetEmail:"Send Reset Email",howToReset:"How to reset your password:",resetStep1:"Contact your Bambuddy administrator",resetStep2:"Ask them to reset your password in User Management",resetStep3:"They can set a new temporary password for you",resetStep4:"Log in with the new password and change it in Settings",gotIt:"Got it"},setup:{title:"Bambuddy Setup",subtitle:"Configure authentication for your Bambuddy instance",enableAuth:"Enable Authentication",adminAccount:"Admin Account",adminAccountDesc:"If admin users already exist, authentication will be enabled using the existing admin accounts. Leave the fields below empty to use existing admins, or enter new credentials to create a new admin user.",adminUsername:"Admin Username",adminPassword:"Admin Password",optionalIfAdminExists:"(optional if admin users exist)",adminUsernamePlaceholder:"Enter admin username (optional)",adminPasswordPlaceholder:"Enter admin password (optional)",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm admin password",settingUp:"Setting up...",completeSetup:"Complete Setup",toast:{authEnabledAdminCreated:"Authentication enabled and admin user created",authEnabledExistingAdmins:"Authentication enabled using existing admin users",setupCompleted:"Setup completed",enterBothCredentials:"Please enter both admin username and password, or leave both empty to use existing admin users",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters"}},changePassword:{title:"Change Password",currentPassword:"Current Password",currentPasswordPlaceholder:"Enter current password",newPassword:"New Password",newPasswordPlaceholder:"Enter new password (min 6 characters)",confirmPassword:"Confirm New Password",confirmPasswordPlaceholder:"Confirm new password",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters",changing:"Changing...",success:"Password changed successfully",failed:"Failed to change password"},plateAlert:{title:"Print Paused!",message:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print.",understand:"I Understand"},camera:{title:"Camera View",invalidPrinterId:"Invalid printer ID",live:"Live",snapshot:"Snapshot",restartStream:"Restart stream",refreshSnapshot:"Refresh snapshot",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",connectingToCamera:"Connecting to camera...",capturingSnapshot:"Capturing snapshot...",connectionLost:"Connection lost",connectionFailed:"Camera connection failed",reconnecting:"Reconnecting in {{countdown}}s... (attempt {{attempt}}/{{max}})",reconnectNow:"Reconnect now",cameraUnavailable:"Camera unavailable",cameraUnavailableDesc:"Make sure the printer is powered on and connected.",noCamera:"No camera available",retry:"Retry",cameraStream:"Camera stream",zoomOut:"Zoom out",zoomIn:"Zoom in",resetZoom:"Reset zoom",recording:"Recording",startRecording:"Start Recording",stopRecording:"Stop Recording",chamberLight:"Toggle chamber light"},groups:{title:"Group Management",subtitle:"Manage permission groups for access control",backToSettings:"Back to Settings",createGroup:"Create Group",noPermission:"You do not have permission to access this page.",system:"System",noDescription:"No description",usersCount:"{{count}} users",permissionsCount:"{{count}} permissions",edit:"Edit",delete:"Delete",toast:{created:"Group created successfully",updated:"Group updated successfully",deleted:"Group deleted successfully",enterGroupName:"Please enter a group name"},modal:{editGroup:"Edit Group",createGroup:"Create Group",cancel:"Cancel",saving:"Saving...",creating:"Creating...",saveChanges:"Save Changes"},form:{groupName:"Group Name",groupNamePlaceholder:"Enter group name",systemGroupWarning:"System group names cannot be changed",description:"Description",descriptionPlaceholder:"Enter description (optional)",permissions:"Permissions ({{count}} selected)"},deleteModal:{title:"Delete Group",message:"Are you sure you want to delete this group? Users in this group will lose these permissions.",confirm:"Delete Group"}},users:{title:"User Management",subtitle:"Manage users and their access to your Bambuddy instance",backToSettings:"Back to Settings",createUser:"Create User",noPermission:"You do not have permission to access this page.",admin:"Admin",noGroups:"No groups",active:"Active",inactive:"Inactive",edit:"Edit",delete:"Delete",system:"System",noGroupsAvailable:"No groups available",table:{username:"Username",groups:"Groups",status:"Status",actions:"Actions"},toast:{created:"User created successfully",updated:"User updated successfully",deleted:"User deleted successfully",fillRequired:"Please fill in all required fields",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters"},modal:{createUser:"Create User",editUser:"Edit User",cancel:"Cancel",creating:"Creating...",saving:"Saving...",saveChanges:"Save Changes",advancedAuthSubtitle:"with Advanced Authentication"},form:{username:"Username",usernamePlaceholder:"Enter username",email:"Email",emailPlaceholder:"user@example.com",password:"Password",passwordPlaceholder:"Enter password",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm password",newPasswordPlaceholder:"Enter new password",confirmNewPasswordPlaceholder:"Confirm new password",leaveBlankToKeep:"leave blank to keep current",groups:"Groups",optional:"optional",autoGeneratedPassword:"A secure password will be automatically generated and emailed to the user.",passwordManagedByAdvancedAuth:'Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.',resetPassword:"Reset Password",resettingPassword:"Resetting Password..."},deleteModal:{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirm:"Delete User"}},streamOverlay:{title:"Stream Overlay",invalidPrinterId:"Invalid printer ID",cameraStream:"Camera stream",progress:"Progress",eta:"ETA",tomorrow:"Tomorrow",printerIdle:"Printer is idle",printerOffline:"Printer offline",status:{printing:"Printing",paused:"Paused",finished:"Finished",failed:"Failed",idle:"Idle",unknown:"Unknown"}},profiles:{title:"Profiles",subtitle:"Manage your slicer presets and pressure advance calibrations",tabs:{cloud:"Cloud Profiles",local:"Local Profiles",kprofiles:"K-Profiles"},localProfiles:{title:"Local Profiles",subtitle:"Import and manage slicer presets from OrcaSlicer",import:"Import Profiles",importDesc:"Drop .bbscfg, .bbsflmt, .orca_filament, .zip, or .json files here",importing:"Importing...",search:"Search local presets...",noPresets:"No local presets yet",badge:"Local",edit:"Edit",delete:"Delete",cancel:"Cancel",deleteConfirmTitle:"Delete Preset",deleteConfirm:"Are you sure you want to delete this preset? This cannot be undone.",source:"Source",inheritsFrom:"Inherits",filamentType:"Type",vendor:"Vendor",compatiblePrinters:"Printers",nozzleTemp:"Nozzle Temp",cost:"Cost",density:"Density",pressureAdvance:"Pressure Advance",filament:"Filament",process:"Process",printer:"Printer",toast:{importSuccess:"{{count}} preset(s) imported",importSkipped:"{{count}} preset(s) skipped (duplicates)",importError:"{{count}} error(s) during import",deleted:"Preset deleted",updated:"Preset updated"}},connectedAs:"Connected as",logout:"Logout",noLogoutPermission:"You do not have permission to logout",failedToLoad:"Failed to load profiles",retry:"Retry",time:{justNow:"Just now",minsAgo:"{{count}}m ago",hoursAgo:"{{count}}h ago",daysAgo:"{{count}}d ago"},toast:{loggedOut:"Logged out"},login:{title:"Connect to Bambu Cloud",subtitle:"Sync your slicer presets across devices",email:"Email",password:"Password",region:"Region",regionGlobal:"Global",regionChina:"China",verificationCode:"Verification Code",totpCode:"Authenticator Code",checkEmail:"Check your email ({{email}}) for a 6-digit code",enterTotpHint:"Enter the 6-digit code from your authenticator app",accessToken:"Access Token",accessTokenHint:"Paste your Bambu Lab access token (from Bambu Studio)",back:"Back",loginButton:"Login",verifyButton:"Verify",setTokenButton:"Set Token",useToken:"Use access token instead",useEmail:"Login with email instead",toast:{loggedIn:"Logged in successfully",codeSent:"Verification code sent to your email",enterTotp:"Enter code from your authenticator app",tokenSet:"Token set successfully"}},presets:{myPreset:"My preset (editable)",duplicate:"Duplicate",editable:"Editable",failedToLoadDetails:"Failed to load preset details",deleteConfirm:"Delete this preset?",deleteWarning:'This will permanently delete "{{name}}" from Bambu Cloud. This cannot be undone.',noDuplicatePermission:"You do not have permission to duplicate presets",noEditPermission:"You do not have permission to edit presets",noDeletePermission:"You do not have permission to delete presets",types:{filament:"Filament preset",printer:"Printer preset",process:"Process preset"},toast:{deleted:"Preset deleted",created:"Preset created",updated:"Preset updated",duplicated:"Preset duplicated",fieldAdded:'Field "{{key}}" added',exported:"Preset exported"},baseLabel:"Base: {{name}}",currentLabel:"Current: {{name}}",newPreset:"New Preset",editPreset:"Edit Preset",duplicatePreset:"Duplicate Preset",createNewPreset:"Create New Preset",customizeSettings:"Customize settings for your new preset",compareWithBase:"Compare with base preset",compare:"Compare",basePreset:"Base Preset",selectBasePreset:"Select base preset...",presetName:"Preset Name",myCustomPreset:"My custom preset",inheritsFrom:"Inherits from",dropJsonToImport:"Drop JSON to import",tabs:{common:"Common",allFields:"All Fields"},availableFields:"Available Fields",searchFieldsPlaceholder:"Search fields...",noMatchingFields:"No matching fields",allFieldsAdded:"All fields added",addCustomField:"Add custom field",yourOverrides:"Your Overrides",noOverridesYet:"No overrides yet",clickFieldsToAdd:"Click fields on the left to add them",saveAsTemplate:"Save as template",jsonTip:"Tip: Drag & drop a .json file anywhere on this modal to import settings"},cloudView:{searchPlaceholder:"Search presets...",templates:"Templates",refresh:"Refresh",newPreset:"New Preset",clearFilters:"Clear filters",compareMode:"Compare Mode",selectAnotherPreset:"Select another {{type}} preset",clickTwoPresets:"Click two presets of the same type to compare",selectFirst:"1. Select first",selectSecond:"2. Select second",compareNow:"Compare Now",lastSynced:"Last synced:",showingCount:"Showing {{showing}} of {{total}} presets",noPresetsFound:"No presets found",columns:{filament:"Filament",process:"Process",printer:"Printer"},noFilamentPresets:"No filament presets",noProcessPresets:"No process presets",noPrinterPresets:"No printer presets",filters:{type:"Type",owner:"Owner",printer:"Printer",nozzle:"Nozzle",filament:"Filament",layer:"Layer",all:"All",myPresets:"My Presets",builtIn:"Built-in",process:"Process"},noTemplatesPermission:"You do not have permission to manage templates",noRefreshPermission:"You do not have permission to refresh profiles",noCreatePermission:"You do not have permission to create presets"},templates:{title:"Quick Templates",noTemplates:"No templates yet",createFirst:"Create templates from the preset editor",typeFilter:"Type:",deleteTitle:"Delete Template",deleteWarning:"This action cannot be undone",deleteConfirm:'Are you sure you want to delete "{{name}}"?',namePlaceholder:"Template name",descriptionPlaceholder:"Description",settingsJson:"Settings (JSON)",fieldsCount:"{{count}} fields",shownInModals:"Shown in modals",hiddenInModals:"Hidden in modals",apply:"Apply",toast:{deleted:"Template deleted",updated:"Template updated",created:"Template created",applied:"Template applied"}}},support:{debugLoggingActive:"Debug logging is active",manageLogs:"Manage",collectItem7:"Printer connectivity and firmware versions",collectItem8:"Integration status (Spoolman, MQTT, HA)",collectItem9:"Network interfaces (subnets only)",collectItem10:"Python package versions",collectItem11:"Database health checks",collectItem12:"Docker environment details"},fileManager:{title:"File Manager",subtitle:"Organize and manage your print files",uploadFiles:"Upload Files",newFolder:"New Folder",folderName:"Folder Name",folderNamePlaceholder:"e.g., Functional Parts",renameFile:"Rename File",renameFolder:"Rename Folder",moveFiles:"Move {{count}} File(s)",rootNoFolder:"Root (No Folder)",current:"current",linkFolder:"Link Folder",linkFolderDescription:'Link "{{name}}" to a project or archive for quick access.',project:"Project",archive:"Archive",noProjectsFound:"No projects found",noArchivesFound:"No archives found",unlink:"Unlink",link:"Link",dragDropFiles:"Drag & drop files here",dropFilesHere:"Drop files here",orClickToBrowse:"or click to browse",allFileTypesSupported:"All file types supported. ZIP files will be extracted.",zipFilesDetected:"ZIP files detected",zipExtractOptions:"ZIP files will be extracted. Choose how to handle folder structure:",preserveZipStructure:"Preserve folder structure from ZIP",createFolderFromZip:"Create folder from ZIP filename",stlThumbnailGeneration:"STL thumbnail generation",zipMayContainStl:"ZIP files may contain STL files. Thumbnails can be generated during extraction.",thumbnailsCanBeGenerated:"Thumbnails can be generated for STL files. Large models may take longer to process.",generateThumbnailsForStl:"Generate thumbnails for STL files",threemfDetected:"3MF files detected",threemfExtractionInfo:"Printer model, material, color, and print settings will be automatically extracted from 3MF files.",willBeExtracted:"Will be extracted",filesExtracted:"{{count}} files extracted",uploadComplete:"Upload complete: {{succeeded}} succeeded",uploadFailed:"{{count}} failed",uploading:"Uploading...",changeLink:"Change Link...",linkTo:"Link to...",linkToProjectOrArchive:"Link to project or archive",addToQueue:"Add to Queue",schedulePrint:"Schedule",generateThumbnail:"Generate Thumbnail",generateThumbnails:"Generate Thumbnails",generateThumbnailsForMissing:"Generate thumbnails for STL files missing them",gridView:"Grid view",listView:"List view",lowDiskSpaceWarning:"Low disk space warning",lowDiskSpaceDetails:"Only {{free}} free of {{total}} total. Threshold is set to {{threshold}} GB in settings.",files:"Files",folders:"Folders",size:"Size",free:"Free",allFiles:"All Files",wrap:"Wrap",enableTextWrapping:"Enable text wrapping",disableTextWrapping:"Disable text wrapping",dragToResizeTooltip:"Drag to resize, double-click to reset",searchFiles:"Search files...",allTypes:"All types",prints:"Prints",ascending:"Ascending",descending:"Descending",resultsCount:"{{showing}} of {{total}} files",selectAll:"Select All",deselectAll:"Deselect All",selected:"{{count}} selected",adding:"Adding...",loadingFiles:"Loading files...",folderIsEmpty:"Folder is empty",noFilesYet:"No files yet",folderEmptyDescription:"Upload files or move files into this folder to get started.",noFilesDescription:"Upload files to start organizing your print-related files.",noMatchingFiles:"No matching files",noMatchingFilesDescription:"No files match your current search or filter criteria.",clearFilters:"Clear filters",printedCount:"Printed {{count}}x",uploadedBy:"Uploaded By",deleteFolder:"Delete Folder",deleteFile:"Delete File",deleteFilesCount:"Delete {{count}} Files",deleteFolderConfirm:"Are you sure you want to delete this folder? All files inside will also be deleted.",deleteFileConfirm:"Are you sure you want to delete this file?",deleteFilesConfirm:"Are you sure you want to delete {{count}} selected files? This action cannot be undone.",deleting:"Deleting...",noPermissionRenameFolder:"You do not have permission to rename folders",noPermissionLinkFolder:"You do not have permission to link folders",noPermissionDeleteFolder:"You do not have permission to delete folders",noPermissionPrint:"You do not have permission to print",noPermissionAddToQueue:"You do not have permission to add to queue",noPermissionDownload:"You do not have permission to download files",noPermissionRenameFile:"You do not have permission to rename this file",noPermissionGenerateThumbnail:"You do not have permission to generate thumbnails",noPermissionDeleteFile:"You do not have permission to delete this file",noPermissionCreateFolder:"You do not have permission to create folders",noPermissionUpload:"You do not have permission to upload files",noPermissionMoveFiles:"You do not have permission to move files",noPermissionDeleteFiles:"You do not have permission to delete files",toast:{folderCreated:"Folder created",folderDeleted:"Folder deleted",fileDeleted:"File deleted",filesDeleted:"Deleted {{count}} files",filesMoved:"Files moved",folderLinked:"Folder linked",folderUnlinked:"Folder unlinked",addedToQueue:"Added {{count}} file(s) to queue",addedToQueuePartial:"Added {{added}} file(s), {{failed}} failed",failedToAddToQueue:"Failed to add files: {{error}}",fileRenamed:"File renamed",folderRenamed:"Folder renamed",thumbnailsGenerated:"Generated {{count}} thumbnail(s)",thumbnailsGeneratedPartial:"Generated {{succeeded}} thumbnail(s), {{failed}} failed",noStlMissingThumbnails:"No STL files missing thumbnails",failedToGenerateThumbnails:"Failed to generate thumbnails: {{error}}",thumbnailGenerated:"Thumbnail generated",failedToGenerateThumbnail:"Failed to generate thumbnail: {{error}}"}},projects:{title:"Projects",subtitle:"Organize and track your 3D printing projects",newProject:"New Project",editProject:"Edit Project",deleteProject:"Delete Project",projectName:"Project Name",description:"Description",noProjects:"No projects yet",noProjectsFiltered:"No {{status}} projects",noProjectsFilteredHelp:"You don't have any {{status}} projects. Projects will appear here when their status changes.",createFirst:"Create your first project to start organizing related prints, tracking progress, and managing your builds.",createFirstButton:"Create Your First Project",create:"Create",files:"Files",prints:"Prints",plates:"plates",parts:"parts",lastModified:"Last Modified",deleteConfirm:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",addFiles:"Add Files",removeFile:"Remove File",viewDetails:"View Details",namePlaceholder:"e.g., Voron 2.4 Build",descriptionPlaceholder:"Optional description...",color:"Color",targetPlates:"Target Plates",targetPlatesPlaceholder:"e.g., 25",targetPlatesHelp:"Number of print jobs",targetParts:"Target Parts",targetPartsPlaceholder:"e.g., 150",targetPartsHelp:"Total objects needed",tagsLabel:"Tags (comma-separated)",tagsPlaceholder:"e.g., voron, functional, gift",dueDate:"Due Date",priority:"Priority",priorityLow:"Low",priorityNormal:"Normal",priorityHigh:"High",priorityUrgent:"Urgent",statusActive:"Active",statusCompleted:"Completed",statusArchived:"Archived",done:"Done",completed:"completed",failed:"failed",inQueue:"in queue",noPrintsYet:"No prints yet",printJobs:"Print jobs (plates)",partsPrinted:"Parts printed",failedParts:"Failed parts",import:"Import",export:"Export",importProject:"Import project",exportAll:"Export all projects",loading:"Loading projects...",noEditPermission:"You do not have permission to edit projects",noDeletePermission:"You do not have permission to delete projects",noCreatePermission:"You do not have permission to create projects",noImportPermission:"You do not have permission to import projects",noExportPermission:"You do not have permission to export projects",toast:{created:"Project created",updated:"Project updated",deleted:"Project deleted",imported:"Project imported",multipleImported:"{{count}} projects imported",importFailed:"Import failed",exported:"Projects exported (metadata only)"}},projectDetail:{notFound:"Project not found",backToProjects:"Back to Projects",export:"Export",exportProject:"Export project",noExportPermission:"You do not have permission to export projects",noEditPermission:"You do not have permission to edit projects",partOf:"Part of:",priorityLabel:"Priority:",noPrints:"No prints in this project yet",status:{active:"Active",completed:"Completed",archived:"Archived"},priority:{low:"Low",normal:"Normal",high:"High",urgent:"Urgent"},dueDate:{overdue:"Overdue",today:"Due today",daysLeft:"{{count}} days left"},progress:{platesProgress:"Plates Progress",partsProgress:"Parts Progress",printJobs:"print jobs",parts:"parts",percentComplete:"{{percent}}% complete",remaining:"{{count}} remaining"},stats:{printJobs:"Print Jobs",total:"total",failed:"{{count}} failed",partsPrinted:"{{count}} parts printed",printTime:"Print Time",filamentUsed:"Filament Used"},cost:{title:"Cost Tracking",filamentCost:"Filament Cost",energy:"Energy",budget:"Budget",remaining:"Remaining"},subProjects:{title:"Sub-projects ({{count}})"},notes:{title:"Notes",noEditPermission:"You do not have permission to edit notes",placeholder:"Add notes about this project...",empty:"No notes yet. Click Edit to add notes."},files:{title:"Files",linkFolders:"Link folders from the File Manager",forQuickAccess:"to this project for quick access.",fileCount:"{{count}} file(s)",empty:"No folders linked. Go to File Manager and link a folder to this project."},bom:{title:"Bill of Materials",acquired:"{{completed}}/{{total}} acquired",showAll:"Show all",hideDone:"Hide done",addPart:"Add Part",noAddPermission:"You do not have permission to add parts",partNamePlaceholder:"Part name (e.g., M3x8 screws)",partName:"Part name",qty:"Qty",price:"Price ({{currency}})",sourcingUrlPlaceholder:"Sourcing URL (optional)",remarksPlaceholder:"Remarks (optional)",deletePart:"Delete Part",deleteConfirm:'Are you sure you want to delete "{{name}}"?',noUpdatePermission:"You do not have permission to update parts",noEditPermission:"You do not have permission to edit parts",noDeletePermission:"You do not have permission to delete parts",totalCost:"Total cost:",empty:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."},timeline:{title:"Activity Timeline",empty:"No activity yet."},template:{saveAsTemplate:"Save as Template",noCreatePermission:"You do not have permission to create templates"},queue:{title:"Queue",viewAll:"View all",printing:"{{count}} printing",queued:"{{count}} queued"},prints:{title:"Prints ({{count}})"},toast:{projectUpdated:"Project updated",partAdded:"Part added",partRemoved:"Part removed",exportFailed:"Export failed",projectExported:"Project exported",templateCreated:"Template created"}},system:{title:"System Information",version:"Version",uptime:"Uptime",cpuUsage:"CPU Usage",memoryUsage:"Memory Usage",diskUsage:"Disk Usage",networkInfo:"Network Info",logs:"Logs",debugMode:"Debug Mode",enableDebug:"Enable Debug Logging",disableDebug:"Disable Debug Logging",downloadLogs:"Download Logs",clearLogs:"Clear Logs",dockerInfo:"Docker Info",containerName:"Container Name",imageName:"Image Name",platform:"Platform",architecture:"Architecture"},library:{title:"Filament Library",addFilament:"Add Filament",editFilament:"Edit Filament",deleteFilament:"Delete Filament",vendor:"Vendor",material:"Material",color:"Color",kFactor:"K Factor",temperature:"Temperature",noFilaments:"No filaments in library",deleteConfirm:"Are you sure you want to delete this filament?",importFromPrinter:"Import from Printer",exportToFile:"Export to File"},spoolman:{title:"Spoolman Integration",enabled:"Spoolman Enabled",url:"Spoolman URL",connected:"Connected",disconnected:"Not Connected",testConnection:"Test Connection",sync:"Sync",syncing:"Syncing...",lastSync:"Last Sync",linkToSpoolman:"Link to Spoolman",openInSpoolman:"Open in Spoolman",unlinkSpool:"Unlink Spool",selectSpool:"Select Spool",noUnlinkedSpools:"No unlinked spools available",linkSuccess:"Spool linked to Spoolman successfully",linkFailed:"Failed to link spool",spoolId:"Spool ID",fillSourceLabel:"(Spoolman)",weight:"Weight",remaining:"Remaining",disableWeightSync:"Disable AMS Estimated Weight Sync",disableWeightSyncDesc:"Don't update remaining capacity from AMS estimates. Use this if you prefer Spoolman's usage tracking over AMS percentage-based estimates. New spools will still use the AMS estimate as their initial weight.",reportPartialUsage:"Report Partial Usage for Failed Prints",reportPartialUsageDesc:"When a print fails or is cancelled, report the estimated filament used up to that point based on layer progress."},inventory:{title:"Spool Inventory",addSpool:"Add Spool",editSpool:"Edit Spool",material:"Material",selectMaterial:"Select material...",subtype:"Subtype",brand:"Brand",searchBrand:"Search brand...",useCustomBrand:'Use "{{brand}}"',colorName:"Color Name",colorNamePlaceholder:"Jade White, Fire Red...",color:"Color",hexColor:"Hex Color",pickColor:"Pick custom color",labelWeight:"Label Weight",coreWeight:"Empty Spool Weight",searchSpoolWeight:"Search spool weight...",weightUsed:"Used",currentWeight:"Remaining Weight",slicerFilament:"Slicer Filament",slicerFilamentName:"Slicer Preset Name",slicerPreset:"Slicer Preset",searchPresets:"Search filament presets...",selectedPreset:"Selected",noPresetsFound:"No presets found",tempOverrides:"Temperature Overrides",note:"Note",notePlaceholder:"Any additional notes about this spool...",archive:"Archive",restore:"Restore",noSpools:"No spools yet. Add your first spool to get started.",noManualSpools:"No manually added spools available. Add a spool to your inventory first.",kProfiles:"K-Profiles",addKProfile:"Add K-Profile",assignSpool:"Assign Spool",unassignSpool:"Unassign",assignSuccess:"Spool assigned and AMS slot configured",assignFailed:"Failed to assign spool",selectSpool:"Select a spool to assign to this slot",assigned:"Assigned",assigning:"Assigning...",searchSpools:"Search spools...",allMaterials:"All Materials",filterByBrand:"Filter by brand...",showArchived:"Show archived",spoolCreated:"Spool created",spoolUpdated:"Spool updated",spoolDeleted:"Spool deleted",spoolArchived:"Spool archived",spoolRestored:"Spool restored",deleteConfirm:"Are you sure you want to delete this spool? This cannot be undone.",advancedSettings:"Advanced Settings",filamentInfoTab:"Filament Info",paProfileTab:"PA Profile",filamentInfo:"Filament",additional:"Additional",loadingPresets:"Loading cloud presets...",cloudConnected:"Cloud connected",cloudNotConnected:"Cloud not connected (using defaults)",recentColors:"Recent",searchColors:"Search colors...",searchResults:"Search results",allColors:"All colors",commonColors:"Common colors",showLess:"Show less",showAll:"Show all",noColorsFound:"No colors match your search",noResults:"No matches found",selectMaterialFirst:"Please select a material first in the Filament Info tab.",noPrintersConfigured:"No printers configured. Add printers to use PA profiles.",matchingFilter:"Matching",anyBrand:"Any brand",anyVariant:"Any variant",autoSelect:"Auto-select",matches:"matches",match:"match",noMatches:"No matches",connected:"Connected",offline:"Offline",printerOffline:"Printer is offline. Connect to view calibration profiles.",noKProfilesMatch:"No K-profiles match the selected filament.",leftNozzle:"Left Nozzle",rightNozzle:"Right Nozzle",profilesSelected:"calibration profile(s) selected",totalInventory:"Total Inventory",totalConsumed:"Total Consumed",byMaterial:"By Material",inPrinter:"In Printer",lowStock:"Low Stock",sinceTracking:"Since tracking started",loadedInAms:"Loaded in AMS/Ext",remaining:"Remaining",lowStockThreshold:"<20% remaining",search:"Search spools...",showing:"Showing",to:"to",of:"of",show:"Show",spools:"spools",spool:"spool",page:"Page",noSpoolsMatch:"No results found",noSpoolsMatchDesc:"Try adjusting your search or filters to find what you're looking for.",active:"Active",archived:"Archived",all:"All",used:"Used",new:"New",clearFilters:"Clear filters",table:"Table",cards:"Cards",net:"Net",columns:"Columns",configureColumns:"Configure Columns",configureColumnsDesc:"Drag to reorder columns or use arrows. Toggle visibility with the eye icon.",visible:"visible",reset:"Reset",cancel:"Cancel",applyChanges:"Apply Changes",moveUp:"Move up",moveDown:"Move down",hideColumn:"Hide column",showColumn:"Show column",linkToSpool:"Link to Spool",tagLinked:"Tag linked to spool",tagLinkFailed:"Failed to link tag",tagAlreadyLinked:"Tag already linked to another spool",unknownTag:"Unknown RFID tag detected",usageHistory:"Usage History",noUsageHistory:"No usage recorded yet",printName:"Print Name",weightConsumed:"Weight Consumed",clearHistory:"Clear",historyCleared:"Usage history cleared",fillSourceLabel:"(Inv)"},timelapse:{title:"Timelapse",create:"Create Timelapse",download:"Download",delete:"Delete",preview:"Preview",frameRate:"Frame Rate",quality:"Quality",processing:"Processing...",noTimelapses:"No timelapses available"},ams:{title:"AMS",slot:"Slot",empty:"Empty",emptySlot:"Empty slot",unknown:"Unknown",humidity:"Humidity",temperature:"Temperature",filamentType:"Filament Type",filamentColor:"Color",remaining:"Remaining",history:"AMS History",noHistory:"No history available",configureSlot:"Configure Slot",externalSpool:"External Spool",profile:"Profile",kFactor:"K Factor",fill:"Fill",configure:"Configure"},printModal:{title:"Start Print",selectPrinter:"Select Printer",selectPlate:"Select Plate",filamentMapping:"Filament Mapping",printSettings:"Print Settings",bedLeveling:"Bed Leveling",flowCalibration:"Flow Calibration",vibrationCalibration:"Vibration Calibration",layerInspection:"First Layer Inspection",timelapse:"Timelapse",startPrint:"Start Print",addToQueue:"Add to Queue",cancel:"Cancel",noPrintersAvailable:"No printers available",printerBusy:"Printer is busy",printerOffline:"Printer is offline",sameTypeDifferentColor:"Same type, different color",filamentTypeNotLoaded:"Filament type not loaded",openCalendar:"Open calendar",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"Left nozzle",rightNozzleTooltip:"Right nozzle"},backup:{title:"Backup & Restore",createBackup:"Create Backup",restoreBackup:"Restore Backup",restoreDescription:"Replace all data from a backup file",downloadBackup:"Download Backup",uploadBackup:"Upload Backup",lastBackup:"Last Backup",autoBackup:"Auto Backup",backupNow:"Backup Now",restoreWarning:"Warning: Restoring a backup will overwrite all current data.",includeArchives:"Include Archives",includeSettings:"Include Settings",includeProfiles:"Include Profiles",backupSuccess:"Backup created successfully",restoreSuccess:"Backup restored successfully",backupFailed:"Backup failed",restoreFailed:"Restore failed",restoreNote:"Virtual Printer will be stopped during restore"},tags:{title:"Tags",addTag:"Add Tag",editTag:"Edit Tag",deleteTag:"Delete Tag",tagName:"Tag Name",tagColor:"Tag Color",noTags:"No tags",deleteConfirm:"Are you sure you want to delete this tag?",manageTags:"Manage Tags"},uploadModal:{title:"Upload 3MF Files",dragDrop:"Drag & drop .3mf files here",or:"or",browseFiles:"Browse Files",extractionInfo:"The printer model will be automatically extracted from the 3MF file metadata.",uploaded:"uploaded",failed:"failed",uploading:"Uploading...",upload:"Upload",uploadFailed:"Upload failed"},editArchive:{title:"Edit Archive",name:"Name",namePlaceholder:"Print name",printer:"Printer",noPrinter:"No printer",project:"Project",noProject:"No project",itemsPrinted:"Items Printed",itemsPrintedHelp:"Number of items produced in this print job",notes:"Notes",notesPlaceholder:"Add notes about this print...",externalLink:"External Link",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link to Printables, Thingiverse, or other source",tags:"Tags",tagsPlaceholder:"Add tags...",addMoreTags:"Add more tags...",matchingTags:'Matching "{{query}}"',existingTags:"Existing tags",clickToAdd:"(click to add)",status:"Status",failureReason:"Failure Reason",selectReason:"Select reason...",photos:"Photos of Printed Result",photosHelp:"Click + to add photos of your printed result",printResult:"Print result",saving:"Saving...",failureReasons:{adhesionFailure:"Adhesion failure",spaghettiDetached:"Spaghetti / Detached",layerShift:"Layer shift",cloggedNozzle:"Clogged nozzle",filamentRunout:"Filament runout",warping:"Warping",stringing:"Stringing",underExtrusion:"Under-extrusion",powerFailure:"Power failure",userCancelled:"User cancelled",other:"Other"},statuses:{completed:"Completed",failed:"Failed",aborted:"Cancelled",printing:"Printing"}},kProfiles:{title:"K-Profiles",noPrintersConfigured:"No Printers Configured",addPrinterInSettings:"Add a printer in Settings to manage K-profiles",noActivePrinters:"No Active Printers",enablePrinterConnection:"Enable a printer connection to view its K-profiles",loadingProfiles:"Loading K-Profiles...",printerOffline:"Printer Offline",printerOfflineDesc:"The selected printer is not connected. Power it on to view K-profiles.",noMatchingProfiles:"No Matching Profiles",noMatchingProfilesDesc:"No profiles match your search criteria",noKProfiles:"No K-Profiles",noKProfilesDesc:"No pressure advance profiles found for {{diameter}}mm nozzle",createFirstProfile:"Create First Profile",printer:"Printer",nozzle:"Nozzle",refresh:"Refresh",addProfile:"Add Profile",export:"Export",import:"Import",select:"Select",selectAll:"Select All",delete:"Delete",searchPlaceholder:"Search by name or filament...",allExtruders:"All Extruders",leftOnly:"Left Only",rightOnly:"Right Only",allFlow:"All Flow",hfOnly:"HF Only",sOnly:"S Only",sortName:"Sort: Name",sortKValue:"Sort: K-Value",sortFilament:"Sort: Filament",leftExtruder:"Left Extruder",rightExtruder:"Right Extruder",modal:{addTitle:"Add K-Profile",editTitle:"Edit K-Profile",profileName:"Profile Name",profileNamePlaceholder:"My PLA Profile",kValue:"K-Value",kValuePlaceholder:"0.020",kValueHelp:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG",filament:"Filament",selectFilament:"Select filament...",noFilamentsHelp:"No filaments found. Create a K-profile in Bambu Studio first.",flowType:"Flow Type",highFlow:"High Flow",standard:"Standard",nozzleSize:"Nozzle Size",extruder:"Extruder",extruders:"Extruders",left:"Left",right:"Right",notes:"Notes (stored locally)",notesPlaceholder:"Add notes about this profile...",notesHelp:"Notes are saved in Bambuddy, not on the printer",syncing:"Syncing with printer...",savingExtruder:"Saving to extruder {{current}}/{{total}}...",pleaseWait:"Please wait"},deleteConfirm:{title:"Delete Profile",cannotUndo:"This cannot be undone",message:'Are you sure you want to delete "{{name}}" from the printer?'},bulkDelete:{title:"Delete Profiles",cannotUndo:"This cannot be undone",message:"Are you sure you want to delete {{count}} selected profiles from the printer?"},toast:{profileSaved:"K-profile saved",profilesSaved:"K-profile saved to {{count}} extruders",selectAtLeastOneExtruder:"Please select at least one extruder",profileDeleted:"K-profile deleted",profilesDeleted:"Deleted {{count}} profiles",exportedProfiles:"Exported {{count}} profiles",importedProfiles:"Imported {{count}} of {{total}} profiles",noProfilesToExport:"No profiles to export",invalidFileFormat:"Invalid file format",failedToParseImport:"Failed to parse import file",failedToSaveBatch:"Failed to save K-profiles",noteSaved:"Note saved",failedToSaveNote:"Failed to save note"},permission:{noRead:"You do not have permission to refresh profiles",noCreate:"You do not have permission to add profiles",noUpdate:"You do not have permission to update K-profiles",noDelete:"You do not have permission to delete K-profiles",noExport:"You do not have permission to export profiles",noImport:"You do not have permission to import profiles"}},virtualPrinter:{title:"Virtual Printer",running:"Running",stopped:"Stopped",description:{default:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing.",proxy:"Enable a proxy that relays slicer traffic to a real printer, allowing remote printing over any network."},enable:{title:"Enable Virtual Printer",visibleInSlicer:'Visible as "Bambuddy" in slicer discovery',proxyingTo:"Proxying to {{name}}",notActive:"Not active"},model:{title:"Printer Model",description:"Select which printer model to emulate.",restartWarning:"Changing the model will restart the virtual printer"},accessCode:{title:"Access Code",isSet:"Access code is set",notSet:"No access code set - required to enable",placeholder:"Enter 8-char code",placeholderChange:"Enter new code to change",hint:"Must be exactly 8 characters. Used by slicers to authenticate.",charCount:"({{count}}/8)"},targetPrinter:{title:"Target Printer",configured:"Proxy target configured",notConfigured:"No target printer selected - required for proxy mode",placeholder:"Select a printer...",hint:"Select the printer to proxy slicer traffic to. The printer must be in LAN mode.",noPrinters:"No printers configured. Add a printer first to use proxy mode."},remoteInterface:{title:"Network Interface Override",configured:"Interface override active",optional:"Optional - use if auto-detected IP is wrong (e.g. multiple NICs, Docker, VPN)",placeholder:"Auto-detect (default)...",hint:"Override the IP address advertised via SSDP and used in the TLS certificate. Useful when Bambuddy has multiple network interfaces."},mode:{title:"Mode",archive:"Archive",archiveDesc:"Archive files immediately",review:"Review",reviewDesc:"Review before archiving",queue:"Queue",queueDesc:"Archive and add to queue",proxy:"Proxy",proxyDesc:"Relay to real printer"},setupRequired:{title:"Setup Required",description:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings.",readGuide:"Read the setup guide before enabling"},howItWorks:{title:"How it works",titleProxy:"How it works (Proxy Mode)",step1:"Complete the setup guide for your platform",step2:"Enable the virtual printer and set an access code",step3:'In Bambu Studio or OrcaSlicer, go to "Add Printer"',step4:'The "Bambuddy" printer should appear in the discovery list',step5:"Connect using the access code you set",step6:'When you "print" to Bambuddy, the 3MF file is archived instead',proxyStep1:"Select the target printer (must be in LAN mode)",proxyStep2:"For cross-network: select the slicer network interface",proxyStep3:"Enable the proxy - printer appears in slicer discovery via SSDP",proxyStep4:"Connect using the printer's access code",proxyStep5:"Print as normal - traffic is relayed through Bambuddy",proxyStep6:"Camera streaming requires NAT/IP forwarding (see docs)"},status:{title:"Status Details",printerName:"Printer Name",model:"Model",serialNumber:"Serial Number",mode:"Mode",pendingFiles:"Pending Files",targetPrinter:"Target Printer",ftpPort:"FTP Port",mqttPort:"MQTT Port",ftpConnections:"FTP Connections",mqttConnections:"MQTT Connections"},toast:{updated:"Virtual printer settings updated",failedToUpdate:"Failed to update settings",accessCodeRequired:"Please set an access code first",targetPrinterRequired:"Please select a target printer first",accessCodeEmpty:"Access code cannot be empty",accessCodeLength:"Access code must be exactly 8 characters"}},modelViewer:{openInSlicer:"Open in Slicer",tabs:{model:"3D Model",gcode:"G-code Preview"},notAvailable:"not available",notSliced:"not sliced",plates:"Plates",allPlates:"All Plates",plateNumber:"Plate {{number}}",plateCount:"{{count}} plate",plateCount_other:"{{count}} plates",objectCount:"{{count}} object",objectCount_other:"{{count}} objects",filamentCount:"{{count}} filament",filamentCount_other:"{{count}} filaments",eta:"ETA {{minutes}} min",noPreview:"No preview available for this file",pagination:{pageOf:"Page {{current}} of {{total}}",prev:"Prev",next:"Next"},errors:{failedToLoad:"Failed to load file",noMeshes:"No meshes found in 3MF file",unsupportedFormat:"Unsupported file format"}},maintenanceDescriptions:{lubricateRails:"Apply lubricant to linear rails for smooth motion",cleanNozzle:"Clean hotend and nozzle to prevent clogs",checkBelts:"Verify belt tension for accurate prints",cleanBuildPlate:"Clean build plate for better adhesion",checkExtruder:"Inspect extruder gears for wear",checkCooling:"Ensure cooling fans are working properly",generalInspection:"General printer inspection",cleanCarbonRods:"Clean carbon rods to reduce friction",checkPtfeTube:"Inspect PTFE tube for wear or damage",replaceHepaFilter:"Replace HEPA filter for air quality",replaceCarbonFilter:"Replace activated carbon filter",lubricateLeftNozzleRail:"Lubricate left nozzle rail (H2 series)"},smartPlugs:{offline:"Offline",admin:"Admin",openPlugAdminPage:"Open plug admin page",deleteSmartPlug:"Delete Smart Plug",turnOnSmartPlug:"Turn On Smart Plug",turnOffSmartPlug:"Turn Off Smart Plug",turnOn:"Turn On",turnOff:"Turn Off",addSmartPlug:{scanningNetwork:"Scanning network...",chooseEntity:"Choose an entity...",connectionFailed:"Connection failed",searchEntities:"Search entities...",searchPowerSensors:"Search power sensors...",searchEnergySensors:"Search energy sensors...",placeholders:{plugName:"Living Room Plug",mqttStateOnValue:"ON, true, 1",mqttSameAsPower:"Same as power topic, or different"}}},richTextEditor:{bold:"Bold",italic:"Italic",underline:"Underline",bulletList:"Bullet List",numberedList:"Numbered List",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",addLink:"Add Link",removeLink:"Remove Link"},externalLinks:{noLinksConfigured:"No external links configured",deleteLink:"Delete Link",removeCustomIcon:"Remove custom icon",openInNewTab:"Open in new tab",placeholders:{linkName:"My Link"}},keyboardShortcuts:{title:"Keyboard Shortcuts",navigation:"Navigation",archivesSection:"Archives",kProfilesSection:"K-Profiles",generalSection:"General",shortcuts:{goToPrinters:"Go to Printers",goToArchives:"Go to Archives",goToQueue:"Go to Queue",goToStats:"Go to Statistics",goToProfiles:"Go to Cloud Profiles",goToSettings:"Go to Settings",focusSearch:"Focus search",openUploadModal:"Open upload modal",clearSelection:"Clear selection / blur input",contextMenu:"Context menu on cards",refreshProfiles:"Refresh profiles",newProfile:"New profile",exitSelectionMode:"Exit selection mode",showHelp:"Show this help"},footer:"Press Esc or click outside to close"},notificationLog:{title:"Notification Log",events:{printStarted:"Print Started",printComplete:"Print Complete",printFailed:"Print Failed",printStopped:"Print Stopped",progress:"Progress",printerOffline:"Printer Offline",printerError:"Printer Error",lowFilament:"Low Filament",maintenanceDue:"Maintenance Due",test:"Test"},timeAgo:{justNow:"Just now",minutesAgo:"{{minutes}}m ago",hoursAgo:"{{hours}}h ago"}},restoreBackup:{title:"Restore Backup",restoring:"Restoring...",restoreComplete:"Restore Complete",restoreFailed:"Restore Failed",importSettings:"Import settings from a backup file",pleaseWait:"Please wait while your data is being restored",clickToSelect:"Click to select backup file (.json or .zip)",howDuplicateHandling:"How duplicate handling works:",categories:{printers:"Printers",smartPlugs:"Smart Plugs",notificationProviders:"Notification Providers",filaments:"Filaments",archives:"Archives",pendingUploads:"Pending Uploads",settingsTemplates:"Settings & Templates"},matchingInfo:{printers:"matched by serial number",smartPlugs:"matched by IP address",notificationProviders:"matched by name",filaments:"matched by name + type + brand",archives:"matched by content hash",pendingUploads:"matched by filename",settingsTemplates:"always overwritten"},replaceExisting:"Replace existing data",keepExisting:"Keep existing data",replaceDescription:"Overwrite items that already exist with backup data",keepDescription:"Only restore items that don't already exist",caution:"Caution:",cautionText:"Overwriting will replace your current configurations with backup data. Printer access codes are never overwritten for security.",itemsRestored:"Items Restored",itemsSkipped:"Items Skipped",restored:"Restored",skipped:"Skipped (already exist)",filesLabel:"Files (3MF, thumbnails, etc.)",newApiKeysGenerated:"New API Keys Generated",newApiKeysWarning:"These keys are only shown once. Copy them now!",processingBackup:"Processing backup file...",noDataFound:"No data was found to restore in the backup file.",failedToRestore:"Failed to restore backup. Please check the file format."},backupExport:{title:"Export Backup",selectData:"Select data to include",selectAll:"Select All",selectNone:"Select None",categoryDescriptions:{settings:"Language, theme, update preferences",notifications:"ntfy, Pushover, Discord, etc.",templates:"Custom message templates",smartPlugs:"Tasmota plug configurations",externalLinks:"Sidebar links to external services",printers:"Printer info (access codes excluded)",plateDetection:"Empty plate reference images",filaments:"Filament types and costs",maintenance:"Custom maintenance schedules",archives:"All print data + files (3MF, thumbnails, photos)",projects:"Projects, BOM items, and attachments",pendingUploads:"Virtual printer uploads awaiting review",apiKeys:"Webhook API keys (new keys generated on import)"},requiresPrinters:"Requires Printers to be selected",zipFileWarning:"ZIP file will be created.",zipFileDescription:"Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file.",includeAccessCodes:"Include Access Codes",includeAccessCodesDescription:"For transferring to another machine",includeAccessCodesWarning:"Access codes will be included in plain text. Keep this backup file secure!",categoriesSelected:"{{selectedCount}} categories selected"},pendingUploads:{placeholders:{notes:"Add notes about this print..."},discardUpload:"Discard Upload",archiveAllUploads:"Archive All Uploads",discardAllUploads:"Discard All Uploads",archive:"Archive",timeAgo:{justNow:"Just now",minutesAgo:"{{minutes}}m ago",hoursAgo:"{{hours}}h ago",daysAgo:"{{days}}d ago"}},apiBrowser:{placeholders:{requestBody:"JSON request body...",searchEndpoints:"Search endpoints..."}},configureAmsSlot:{searchPresets:"Search presets...",colorPlaceholder:"Color name or hex (e.g., brown, FF8800)",clearCustomColor:"Clear custom color",noCloudPresets:"No cloud presets. Login to Bambu Cloud to sync.",noMatchingPresets:"No matching presets found.",custom:"Custom",builtin:"Built-in",settingsSentToPrinter:"Settings sent to printer",filamentProfile:"Filament Profile"},githubBackup:{title:"GitHub Backup",history:"History",downloadBackup:"Download Backup",restoreBackup:"Restore Backup",noBackupsYet:"No backups yet"},emailSettings:{placeholders:{fromName:"BamBuddy"}},tagManagement:{searchTags:"Search tags...",renameTag:"Rename tag",deleteTag:"Delete tag"},notificationTemplates:{placeholders:{title:"Notification title...",body:"Notification body..."}},batchTag:{placeholders:{newTag:"Enter new tag..."}},photoGallery:{deletePhoto:"Delete Photo"},filamentHoverCard:{copySpoolUuid:"Copy spool UUID"},kProfilesView:{hasNote:"Has note",copyProfile:"Copy profile"},layout:{openMenu:"Open menu",noPermissionSystemInfo:"You do not have permission to view system information"},dashboard:{dragToReorder:"Drag to reorder",hideWidget:"Hide widget"},notificationProviderCard:{deleteNotificationProvider:"Delete Notification Provider"},fileManagerModal:{closeFileManager:"Close file manager",sortFiles:"Sort files",goToParentFolder:"Go to parent folder",threeView:"3D View"},embeddedCameraViewer:{refreshStream:"Refresh stream",close:"Close",zoomOut:"Zoom out",resetZoom:"Reset zoom",zoomIn:"Zoom in",dragToResize:"Drag to resize"},timelapseViewer:{skipBack5s:"Skip back 5s",skipForward5s:"Skip forward 5s"},notificationProviders:{descriptions:{email:"SMTP email notifications",telegram:"Notifications via Telegram bot",discord:"Send to Discord channel via webhook",ntfy:"Free, self-hostable push notifications",pushover:"Simple, reliable push notifications",callmebot:"Free WhatsApp notifications via CallMeBot",webhook:"Generic HTTP POST to any URL"}},logViewer:{searchPlaceholder:"Search message or logger name...",noLogEntries:"No log entries found"},switchbarPopover:{noSwitchesInSwitchbar:"No switches in switchbar"},projectPageModal:{placeholders:{title:"Title",designer:"Designer",license:"License",description:"Enter description...",profileTitle:"Profile Title",profileDescription:"Profile description..."}},spoolmanSettings:{}},koe={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",inventory:"Filament",files:"Dateimanager",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",updateAvailableBanner:"Version {{version}} ist verfügbar!",viewUpdate:"Update anzeigen",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln",smartSwitches:"Smart Switches",logout:"Abmelden"},common:{save:"Speichern",saving:"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",days:"Tage",enable:"Aktivieren",disable:"Deaktivieren",permissions:"Berechtigungen",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",linkNotFound:"Link nicht gefunden",required:"Erforderlich",optional:"Optional",dismiss:"Schließen",apply:"Anwenden",reset:"Zurücksetzen",export:"Exportieren",import:"Importieren",clear:"Leeren",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",noChange:"— Keine Änderung —",unchanged:"Unverändert",unassigned:"Nicht zugewiesen",unknown:"Unbekannt",unknownError:"Unbekannter Fehler",today:"Heute",asap:"Sofort",overdue:"Überfällig",now:"Jetzt",collapse:"Einklappen",expand:"Ausklappen",viewArchive:"Archiv anzeigen",viewInFileManager:"Im Dateimanager anzeigen",addedBy:"Hinzugefügt von {{username}}",prints:"Drucke",more:"+{{count}} weitere",ascending:"Aufsteigend",descending:"Absteigend",printer:"Drucker",remove:"Entfernen",type:"Typ",print:"Drucken",rename:"Umbenennen",move:"Verschieben",create:"Erstellen",duplicate:"Duplizieren",left:"Links",right:"Rechts"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse / Hostname",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",sort:{name:"Name",status:"Status",model:"Modell",location:"Standort",ascending:"Aufsteigend sortieren",descending:"Absteigend sortieren"},cardSize:{small:"Kleine Karten",medium:"Mittlere Karten",large:"Große Karten",extraLarge:"Extra große Karten"},hideOffline:"Offline ausblenden",powerOn:"Einschalten",offlinePrintersWithPlugs:"Offline-Drucker mit Smart-Plugs",noPrintersConfigured:"Noch keine Drucker konfiguriert",readyToPrint:"Druckbereit",external:"Extern",deleteArchives:"Druckarchive löschen",noLabel:"Keine Bezeichnung",printPreview:"Druckvorschau",width:"Breite",height:"Höhe",noObjectsFound:"Keine Objekte gefunden",objectsLoadedOnPrintStart:"Objekte werden beim Druckstart geladen",willBeSkipped:"Wird übersprungen",name:"Name",serialCannotBeChanged:"Seriennummer kann nicht geändert werden",locationHelp:"Dient zur Gruppierung von Druckern und zum Filtern von Warteschlangenaufträgen",wifiSignal:{veryWeak:"Sehr schwach",weak:"Schwach",fair:"Ausreichend",good:"Gut",excellent:"Ausgezeichnet"},maintenanceUpToDate:"Alle Wartungen aktuell - Klicken zum Anzeigen",chamberLightOn:"Kammerbeleuchtung einschalten",chamberLightOff:"Kammerbeleuchtung ausschalten",browseFiles:"Druckerdateien durchsuchen",autoOffAfterPrint:"Automatisches Ausschalten nach Druck",autoOffExecuted:"Auto-off wurde ausgeführt - Drucker einschalten zum Zurücksetzen",hmsErrors:"HMS-Fehler",viewHmsErrors:"{{count}} HMS-Fehler anzeigen",resume:"Fortsetzen",pause:"Pausieren",stop:"Stoppen",camera:"Kamera",skipObject:"Objekt überspringen",reconnect:"Neu verbinden",mqttDebug:"MQTT-Debug",activeNozzle:"Aktiv: {{nozzle}} Düse",nozzleRack:"Düsenhalter",nozzleDocked:"Angedockt",nozzleMounted:"Montiert",nozzleActive:"Aktiv",nozzleIdle:"Inaktiv",nozzleDiameter:"Durchmesser",nozzleType:"Typ",nozzleStatus:"Status",nozzleFilament:"Filament",nozzleWear:"Verschleiß",nozzleMaxTemp:"Max Temp",nozzleSerial:"Seriennr.",nozzleHardenedSteel:"Gehärteter Stahl",nozzleStainlessSteel:"Edelstahl",nozzleTungstenCarbide:"Wolframkarbid",nozzleFlow:"Durchfluss",nozzleHighFlow:"High Flow",nozzleStandardFlow:"Standard",firmwareUpdate:"Firmware-Update",firmwareInstructions:"Gehen Sie auf dem Touchscreen des Druckers zu",firmwareNav:"Navigieren Sie zu",settings:"Einstellungen",firmware:"Firmware",discoverPrinters:"Drucker entdecken",searching:"Suche...",manualEntry:"Manuelle Eingabe",addFromCloud:"Aus Cloud hinzufügen",toast:{printerDeleted:"Drucker gelöscht",printerAdded:"Drucker hinzugefügt",printerUpdated:"Drucker aktualisiert",failedToDelete:"Drucker konnte nicht gelöscht werden",failedToAdd:"Drucker konnte nicht hinzugefügt werden",failedToUpdate:"Drucker konnte nicht aktualisiert werden",commandSent:"Befehl gesendet",failedToSendCommand:"Befehl konnte nicht gesendet werden",turnedOn:"{{name}} eingeschaltet",failedToPowerOn:"{{name}} konnte nicht eingeschaltet werden",scriptTriggered:"Skript ausgelöst",printStopped:"Druck gestoppt",printPaused:"Druck pausiert",printResumed:"Druck fortgesetzt",referenceDeleted:"Referenz gelöscht",detectionAreaSaved:"Erkennungsbereich gespeichert",failedToRunScript:"Skript konnte nicht ausgeführt werden",failedToStopPrint:"Druck konnte nicht gestoppt werden",failedToPausePrint:"Druck konnte nicht pausiert werden",failedToResumePrint:"Druck konnte nicht fortgesetzt werden",failedToControlChamberLight:"Kammerbeleuchtung konnte nicht gesteuert werden",failedToUpdateSetting:"Einstellung konnte nicht aktualisiert werden",failedToSkipObjects:"Objekte konnten nicht übersprungen werden",failedToRereadRfid:"RFID konnte nicht erneut gelesen werden",failedToCheckPlate:"Platte konnte nicht überprüft werden",failedToUpdateLabel:"Bezeichnung konnte nicht aktualisiert werden",failedToDeleteReference:"Referenz konnte nicht gelöscht werden",failedToSaveDetectionArea:"Erkennungsbereich konnte nicht gespeichert werden",plateCheckEnabled:"Plattenprüfung aktiviert",plateCheckDisabled:"Plattenprüfung deaktiviert",calibrationSaved:"Kalibrierung gespeichert!",calibrationFailed:"Kalibrierung fehlgeschlagen",rfidRereadInitiated:"RFID-Neueinlesen gestartet"},connection:{connected:"Verbunden",offline:"Offline"},queue:{inQueue:"{{count}} Druck in Warteschlange",inQueue_plural:"{{count}} Drucke in Warteschlange"},controls:"Steuerung",rfid:{reread:"RFID neu lesen"},permission:{noAdd:"Sie haben keine Berechtigung, Drucker hinzuzufügen",noEdit:"Sie haben keine Berechtigung, Drucker zu bearbeiten",noDelete:"Sie haben keine Berechtigung, Drucker zu löschen",noControl:"Sie haben keine Berechtigung, Drucker zu steuern",noFiles:"Sie haben keine Berechtigung, auf Druckerdateien zuzugreifen",noAmsRfid:"Sie haben keine Berechtigung, AMS-RFID erneut zu lesen",noSmartPlugControl:"Sie haben keine Berechtigung, Smart Plugs zu steuern"},modal:{addTitle:"Drucker hinzufügen",editTitle:"Drucker bearbeiten",myPrinter:"Mein Drucker",selectModel:"Modell auswählen...",locationGroup:"Standort / Gruppe (optional)",locationPlaceholder:"z.B. Werkstatt, Büro, Keller",autoArchiveLabel:"Abgeschlossene Drucke automatisch archivieren",fromPrinterSettings:"Aus Druckereinstellungen",modelOptional:"Modell (optional)",saveChanges:"Änderungen speichern"},skipObjects:{tooltip:"Objekte überspringen",onlyWhilePrinting:"Objekte überspringen (nur während des Drucks)",requiresMultiple:"Objekte überspringen (erfordert 2+ Objekte)",title:"Objekte überspringen",matchIdsInfo:"IDs mit Drucker-Display abgleichen",printerShowsIds:"Der Druckerbildschirm zeigt Objekt-IDs auf der Bauplatte",skipSelected:"Ausgewählte überspringen",skipping:"Überspringe...",noObjectsSelected:"Keine Objekte ausgewählt",selectObjectsToSkip:"Wählen Sie Objekte aus, die Sie vom aktuellen Druck überspringen möchten",skipped:"übersprungen",objectsSkipped:"Objekte übersprungen",activeCount:"{{count}} aktiv",waitForLayer:"Warten Sie auf Schicht 2+ zum Überspringen von Objekten (aktuell Schicht {{layer}})",skip:"Überspringen",confirmTitle:"Objekt überspringen?",confirmMessage:'Möchten Sie "{{name}}" wirklich überspringen? Dies kann nicht rückgängig gemacht werden.'},confirm:{deleteTitle:"Drucker löschen",deleteMessage:'Möchten Sie "{{name}}" wirklich löschen? Alle Verbindungseinstellungen werden entfernt.',deleteArchivesNote:"Der gesamte Druckverlauf für diesen Drucker wird dauerhaft gelöscht.",keepArchivesNote:"Der Druckverlauf wird beibehalten, aber nicht mehr mit diesem Drucker verknüpft.",stopTitle:"Druck stoppen",stopMessage:'Möchten Sie den aktuellen Druck auf "{{name}}" wirklich stoppen? Der Druckauftrag wird abgebrochen.',stopButton:"Druck stoppen",pauseTitle:"Druck pausieren",pauseMessage:'Möchten Sie den aktuellen Druck auf "{{name}}" wirklich pausieren?',pauseButton:"Druck pausieren",resumeTitle:"Druck fortsetzen",resumeMessage:'Möchten Sie den Druck auf "{{name}}" fortsetzen?',resumeButton:"Druck fortsetzen",powerOnTitle:"Drucker einschalten",powerOnMessage:'Möchten Sie die Stromversorgung für "{{name}}" wirklich EINSCHALTEN?',powerOnButton:"Einschalten",powerOffTitle:"Drucker ausschalten",powerOffMessage:'Möchten Sie die Stromversorgung für "{{name}}" wirklich AUSSCHALTEN?',powerOffWarning:'WARNUNG: "{{name}}" druckt gerade! Möchten Sie die Stromversorgung wirklich AUSSCHALTEN? Dies unterbricht den Druck und kann den Drucker beschädigen.',powerOffButton:"Ausschalten"},discovery:{title:"Drucker entdecken",searching:"Suche...",scanning:"Scanne...",scanProgress:"Scanne... {{scanned}}/{{total}}",foundPrinters:"{{count}} Drucker gefunden",noPrintersFound:"Keine Drucker gefunden",noPrintersFoundSubnet:"Keine Drucker im angegebenen Subnetz gefunden.",noPrintersFoundNetwork:"Keine Drucker im Netzwerk gefunden.",allConfigured:"Alle erkannten Drucker sind bereits konfiguriert.",alreadyAdded:"Bereits hinzugefügt",select:"Auswählen",manualEntry:"Manuelle Eingabe",addFromCloud:"Aus Cloud hinzufügen",subnetToScan:"Zu scannendes Subnetz",dockerNote:"Docker erkannt. Geben Sie das Subnetz Ihres Druckers in CIDR-Notation ein. Erfordert network_mode: host in docker-compose.yml.",scanSubnet:"Subnetz nach Druckern scannen",discoverNetwork:"Drucker im Netzwerk suchen",scanningSubnet:"Subnetz wird nach Bambu-Druckern gescannt...",scanningNetwork:"Netzwerk wird gescannt...",serialRequired:"Seriennummer erforderlich",unknown:"Unbekannt",failedToStart:"Erkennung konnte nicht gestartet werden"},filaments:"Filamente",openCameraOverlay:"Kamera-Overlay öffnen",openCameraWindow:"Kamera in neuem Fenster öffnen",firmwareUpdateAvailable:"Firmware-Update verfügbar: {{current}} → {{latest}}",firmwareUpToDate:"Firmware {{version}} — Aktuell",firmwareUpdateButton:"Update",plateDetection:{noPermission:"Sie haben keine Berechtigung, Drucker zu aktualisieren",enabledClick:"Plattenprüfung aktiviert - Klicken zum Deaktivieren",disabledClick:"Plattenprüfung deaktiviert - Klicken zum Aktivieren",manageCalibration:"Platten-Erkennungskalibrierung verwalten",calibrationRequired:"Kalibrierung erforderlich",calibrationInstructions:"Bitte stellen Sie sicher, dass die Druckplatte <strong>vollständig leer</strong> ist, und klicken Sie dann auf Kalibrieren.",calibrationDescription:"Die Kalibrierung erfasst ein Referenzbild der leeren Platte. Zukünftige Prüfungen vergleichen mit dieser Referenz, um Objekte zu erkennen.",calibrationTip:"<strong>Tipp:</strong> Sie können bis zu 5 Kalibrierungen für verschiedene Platten speichern. Das System verwendet automatisch die beste Übereinstimmung bei der Prüfung.",plateEmpty:"Platte erscheint leer",objectsDetected:"Objekte auf Platte erkannt",confidence:"Konfidenz",difference:"Differenz",analysisPreview:"Analysevorschau:",analysisLegend:"Grüner Rahmen = Erkennungsbereich, Rote Überlagerung = Unterschiede zur Kalibrierung",savedReferences:"Gespeicherte Referenzen ({{count}}/{{max}})",deleteReference:"Referenz löschen",labelPlaceholder:"Bezeichnung...",clickToEdit:"{{label}} - Zum Bearbeiten klicken",clickToAddLabel:"Zum Hinzufügen einer Bezeichnung klicken"},fans:{partCooling:"Bauteilkühlung",auxiliary:"Hilfsventilator",chamber:"Kammerventilator"},clickToViewHmsErrors:"Klicken, um HMS-Fehler anzuzeigen",estimatedCompletion:"Geschätzte Fertigstellungszeit",slotOptions:"Slot-Optionen",firmwareModal:{title:"Firmware-Update",titleUpToDate:"Firmware-Info",currentVersion:"Aktuell:",latestVersion:"Neueste:",releaseNotes:"Versionshinweise",checkingPrereqs:"Prüfe Voraussetzungen...",sdCardReady:"SD-Karte bereit. Klicken Sie unten, um die Firmware hochzuladen.",uploadedSuccess:"Firmware auf SD-Karte hochgeladen!",applyInstructions:"So wenden Sie das Update auf Ihrem Drucker an:",step1:"Gehen Sie auf dem Touchscreen des Druckers zu <strong>Einstellungen</strong>",step2:"Navigieren Sie zu <strong>Firmware</strong>",step3:"Wählen Sie <strong>Update von SD-Karte</strong>",step4:"Das Update dauert 10-20 Minuten",done:"Fertig",starting:"Starte...",uploadFirmware:"Firmware hochladen",uploadFailed:"Upload fehlgeschlagen: {{error}}",uploadedToast:"Firmware hochgeladen! Starten Sie das Update vom Druckerbildschirm."},accessCodePlaceholder:"Leer lassen, um den aktuellen zu behalten",roi:{title:"Erkennungsbereich (ROI)",xStart:"X-Start",yStart:"Y-Start",width:"Breite",height:"Höhe",instruction:"Passen Sie den Erkennungsbereich an, um sich auf die Druckplatte zu konzentrieren. Der grüne Rahmen in der Vorschau zeigt den aktuellen Bereich."}},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",sortLargest:"Größte zuerst",sortSmallest:"Kleinste zuerst",sortSize:"Größe",noArchives:"Keine Archive gefunden",noArchivesSearch:"Keine Archive entsprechen Ihrer Suche",noArchivesYet:"Noch keine Archive",loadingArchives:"Lade Archive...",releaseToUpload:"Loslassen zum Hochladen",showAll:"Alle anzeigen",showFavoritesOnly:"Nur Favoriten anzeigen",gridView:"Rasteransicht",listView:"Listenansicht",calendarView:"Kalenderansicht",manageTags:"Tags verwalten",showFailedPrints:"Fehlgeschlagene Drucke anzeigen",hideFailedPrints:"Fehlgeschlagene Drucke ausblenden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"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"},toast:{source3mfAttached:"Quell-3MF angehängt: {{filename}}",failedUploadSource3mf:"Fehler beim Hochladen der Quell-3MF",source3mfRemoved:"Quell-3MF entfernt",failedRemoveSource3mf:"Fehler beim Entfernen der Quell-3MF",f3dAttached:"F3D angehängt: {{filename}}",failedUploadF3d:"Fehler beim Hochladen der F3D",f3dRemoved:"F3D entfernt",failedRemoveF3d:"Fehler beim Entfernen der F3D",timelapseAttached:"Zeitraffer angehängt: {{filename}}",timelapseAlreadyAttached:"Zeitraffer bereits angehängt",noMatchingTimelapse:"Kein passender Zeitraffer gefunden",failedScanTimelapse:"Fehler beim Suchen nach Zeitraffer",failedAttachTimelapse:"Fehler beim Anhängen des Zeitraffers",archiveDeleted:"Archiv gelöscht",failedDeleteArchive:"Fehler beim Löschen des Archivs",addedToFavorites:"Zu Favoriten hinzugefügt",removedFromFavorites:"Aus Favoriten entfernt",projectUpdated:"Projekt aktualisiert",failedUpdateProject:"Fehler beim Aktualisieren des Projekts",linkCopied:"Link in die Zwischenablage kopiert",failedCopyLink:"Fehler beim Kopieren des Links",photoDeleted:"Foto gelöscht",failedDeletePhoto:"Fehler beim Löschen des Fotos",failedDeleteArchives:"Fehler beim Löschen der Archive",failedUpdateFavorites:"Fehler beim Aktualisieren der Favoriten",exportDownloaded:"Export heruntergeladen",exportFailed:"Export fehlgeschlagen"},menu:{print:"Drucken",schedule:"Planen",openInBambuStudio:"Im Slicer öffnen",slice:"Slicen",externalLink:"Externer Link",viewOnMakerWorld:"Auf MakerWorld ansehen",preview3d:"3D-Vorschau",viewTimelapse:"Zeitraffer ansehen",scanForTimelapse:"Nach Zeitraffer suchen",downloadSource3mf:"Quell-3MF herunterladen",uploadSource3mf:"Quell-3MF hochladen",replaceSource3mf:"Quell-3MF ersetzen",removeSource3mf:"Quell-3MF entfernen",uploadF3d:"F3D hochladen",replaceF3d:"F3D ersetzen",downloadF3d:"F3D herunterladen",removeF3d:"F3D entfernen",download:"Herunterladen",copyDownloadLink:"Download-Link kopieren",qrCode:"QR-Code",viewPhotos:"Fotos ansehen",viewPhotosCount:"Fotos ansehen ({{count}})",projectPage:"Projektseite",addToFavorites:"Zu Favoriten hinzufügen",removeFromFavorites:"Aus Favoriten entfernen",edit:"Bearbeiten",goToProject:"Zum Projekt: {{name}}",addToProject:"Zu Projekt hinzufügen",removeFromProject:"Aus Projekt entfernen",loading:"Laden...",noProjectsAvailable:"Keine Projekte verfügbar",select:"Auswählen",deselect:"Abwählen",delete:"Löschen"},permission:{noReprint:"Sie haben keine Berechtigung, dieses Archiv erneut zu drucken",noAddToQueue:"Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen",noUpdateArchives:"Sie haben keine Berechtigung, Archive zu aktualisieren",noUploadFiles:"Sie haben keine Berechtigung, Dateien hochzuladen",noDownload:"Sie haben keine Berechtigung, Archive herunterzuladen",noCopyLink:"Sie haben keine Berechtigung, Download-Links zu kopieren",noDelete:"Sie haben keine Berechtigung, dieses Archiv zu löschen",noCreate:"Sie haben keine Berechtigung, Archive zu erstellen"},card:{previousPlate:"Vorherige Platte",nextPlate:"Nächste Platte",plateNumber:"Platte {{index}}",moreOptions:"Rechtsklick für mehr Optionen",addToFavorites:"Zu Favoriten hinzufügen",removeFromFavorites:"Aus Favoriten entfernen",cancelled:"abgebrochen",failed:"fehlgeschlagen",duplicate:"Duplikat",duplicateTitle:"Dieses Modell wurde bereits zuvor gedruckt",openSource3mf:"Quell-3MF in Bambu Studio öffnen (Rechtsklick für mehr Optionen)",downloadF3d:"Fusion 360 Designdatei herunterladen",viewTimelapse:"Zeitraffer ansehen",viewPhoto:"1 Foto ansehen",viewPhotos:"{{count}} Fotos ansehen",openFolder:"Ordner öffnen: {{name}}",slicedFile:"Geslicte Datei - druckbereit",sourceFile:"Nur Quelldatei - keine AMS-Zuordnung verfügbar",gcode:"GCODE",source:"QUELLE",project:"Projekt: {{name}}",estimated:"Geschätzt: {{time}}",actual:"Tatsächlich: {{time}}",accuracy:"Genauigkeit: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} Schicht",layers:"{{count}} Schichten",object:"{{count}} Objekt",objects:"{{count}} Objekte",slicedFor:"Geslict für {{model}}",uploadedBy:"Hochgeladen von",noPermissionReprint:"Sie haben keine Berechtigung, erneut zu drucken",noPermissionEdit:"Sie haben keine Berechtigung, Archive zu bearbeiten",noPermissionDelete:"Sie haben keine Berechtigung, Archive zu löschen",reprint:"Drucken",schedulePrint:"Druck planen",schedule:"Planen",openInBambuStudio:"Im Slicer öffnen",openInBambuStudioToSlice:"Im Slicer öffnen zum Slicen",slice:"Slicen",externalLink:"Externer Link",makerWorld:"MakerWorld: {{designer}}",viewProject:"Projekt ansehen",noExternalLink:"Kein externer Link",preview3d:"3D-Vorschau",download:"Herunterladen",edit:"Bearbeiten",delete:"Löschen"},modal:{deleteArchive:"Archiv löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.',deleteButton:"Löschen",removeSource3mf:"Quell-3MF entfernen",removeSource3mfConfirm:'Möchten Sie die Quell-3MF-Datei wirklich von "{{name}}" entfernen? Die ursprüngliche Slicer-Projektdatei wird gelöscht.',removeButton:"Entfernen",removeF3d:"F3D entfernen",removeF3dConfirm:'Möchten Sie die Fusion 360 Designdatei wirklich von "{{name}}" entfernen?',timelapse:"{{name}} - Zeitraffer",selectTimelapse:"Zeitraffer auswählen",selectTimelapseDesc:"Keine automatische Übereinstimmung gefunden. Wählen Sie den Zeitraffer für diesen Druck:",deleteArchives:"Archive löschen",deleteArchivesConfirm:"Möchten Sie wirklich {{count}} Archiv(e) löschen? Diese Aktion kann nicht rückgängig gemacht werden.",deleteCount:"{{count}} löschen"},page:{title:"Archive",printsCount:"{{filtered}} von {{total}} Drucken",dropFilesHere:".3mf-Dateien hier ablegen",releaseToUpload:"Loslassen zum Hochladen",only3mfSupported:"Nur .3mf-Dateien werden unterstützt",close:"Schließen",selected:"{{count}} ausgewählt",selectAll:"Alle auswählen",tags:"Tags",project:"Projekt",favorite:"Favorit",delete:"Löschen",toggledFavorites:"Favoriten für {{count}} Archiv(e) umgeschaltet",failedUpdateFavorites:"Fehler beim Aktualisieren der Favoriten",archivesDeleted:"{{count}} Archiv(e) gelöscht",failedDeleteArchives:"Fehler beim Löschen der Archive",photoDeleted:"Foto gelöscht",failedDeletePhoto:"Fehler beim Löschen des Fotos"},list:{name:"Name",printer:"Drucker",date:"Datum",size:"Größe",actions:"Aktionen",hasTimelapse:"Hat Zeitraffer"}},queue:{title:"Druckwarteschlange",subtitle:"Planen und verwalten Sie Ihre Druckaufträge",addToQueue:"Zur Warteschlange hinzufügen",print:"Drucken",reprint:"Erneut drucken",schedulePrint:"Druck planen",editQueueItem:"Warteschlangeneintrag bearbeiten",printToPrinters:"Auf {{count}} Druckern drucken",queueToPrinters:"Zu {{count}} Druckern hinzufügen",sending:"Wird gesendet...",sendingProgress:"Sende {{current}}/{{total}}...",adding:"Wird hinzugefügt...",addingProgress:"Füge hinzu {{current}}/{{total}}...",savingProgress:"Speichere {{current}}/{{total}}...",clearQueue:"Warteschlange leeren",clearHistory:"Verlauf löschen",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",startNow:"Jetzt starten",printingInProgress:"Druck läuft...",viewArchive:"Archiv anzeigen",viewInFileManager:"Im Dateimanager anzeigen",itemCount:"{{count}} Element",itemCount_plural:"{{count}} Elemente",dragToReorder:"Ziehen zum Neuordnen (nur Sofort)",reorderHint:"Position betrifft nur Sofort-Elemente. Geplante Elemente werden zur festgelegten Zeit ausgeführt.",addedBy:"Hinzugefügt von {{name}}",nextInQueue:"Nächster in der Warteschlange",clearPlate:"Druckplatte freigeben & Nächsten starten",clearPlateSuccess:"Druckplatte freigegeben — bereit für nächsten Druck",plateReady:"Druckplatte freigegeben — bereit für nächsten Druck",sections:{currentlyPrinting:"Aktuell druckend",queued:"In Warteschlange",history:"Verlauf"},status:{pending:"Ausstehend",waiting:"Wartend",printing:"Druckt",paused:"Pausiert",completed:"Abgeschlossen",failed:"Fehlgeschlagen",skipped:"Übersprungen",cancelled:"Abgebrochen"},summary:{printing:"Druckt",queued:"In Warteschlange",totalTime:"Gesamte Wartezeit",history:"Verlauf"},filter:{allPrinters:"Alle Drucker",unassigned:"Nicht zugewiesen",allStatus:"Alle Status",allLocations:"Alle Standorte",any:"Beliebig"},sort:{byPosition:"Nach Position sortieren",byName:"Nach Name sortieren",byPrinter:"Nach Drucker sortieren",bySchedule:"Nach Zeitplan sortieren",byDate:"Nach Datum sortieren",ascendingOldest:"Aufsteigend (älteste zuerst)",descendingNewest:"Absteigend (neueste zuerst)"},badges:{staged:"Bereitgestellt",requiresPrevious:"Erfordert vorherigen Erfolg",autoPowerOff:"Automatisch ausschalten"},empty:{title:"Keine Drucke geplant",description:'Planen Sie einen Druck von der Archivseite über die Option "Planen" im Kontextmenü oder ziehen Sie Dateien hierher.'},time:{asap:"Sofort",overdue:"Überfällig",now:"Jetzt",lessThanMinute:"In weniger als einer Minute",inMinutes:"In {{count}} Min",inHours:"In {{count}} Stunden"},actions:{stopPrint:"Druck stoppen",startPrint:"Druck starten",requeue:"Erneut einreihen"},bulkEdit:{title:"{{count}} Element bearbeiten",title_plural:"{{count}} Elemente bearbeiten",description:"Nur geänderte Einstellungen werden auf ausgewählte Elemente angewendet.",printer:"Drucker",noChange:"— Keine Änderung —",queueOptions:"Warteschlangenoptionen",staged:"Bereitgestellt (manueller Start)",autoPowerOff:"Nach Druck automatisch ausschalten",requirePrevious:"Vorherigen Erfolg erfordern",printOptions:"Druckoptionen",bedLevelling:"Bett-Nivellierung",flowCalibration:"Fluss-Kalibrierung",vibrationCalibration:"Vibrations-Kalibrierung",layerInspection:"Erste-Schicht-Prüfung",timelapse:"Zeitraffer",useAms:"AMS verwenden",applyChanges:"Änderungen übernehmen",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",selected:"{{count}} ausgewählt",editSelected:"Ausgewählte bearbeiten",cancelSelected:"Ausgewählte abbrechen"},confirm:{cancelTitle:"Geplanten Druck abbrechen",cancelMessage:'Möchten Sie "{{name}}" wirklich abbrechen?',stopTitle:"Druck stoppen",stopMessage:'Möchten Sie den aktuellen Druck "{{name}}" wirklich stoppen? Der Druckauftrag wird am Drucker abgebrochen.',removeTitle:"Aus Verlauf entfernen",removeMessage:'Möchten Sie "{{name}}" wirklich aus dem Warteschlangenverlauf entfernen?',clearHistoryTitle:"Verlauf löschen",clearHistoryMessage:"Möchten Sie alle {{count}} Element(e) aus dem Verlauf entfernen?",cancelButton:"Druck abbrechen",stopButton:"Druck stoppen",thisPrint:"diesen Druck",thisItem:"dieses Element"},toast:{cancelled:"Warteschlangenelement abgebrochen",cancelFailed:"Element konnte nicht abgebrochen werden",removed:"Warteschlangenelement entfernt",removeFailed:"Element konnte nicht entfernt werden",stopped:"Druck gestoppt",stopFailed:"Druck konnte nicht gestoppt werden",released:"Druck in Warteschlange freigegeben",startFailed:"Druck konnte nicht gestartet werden",reorderFailed:"Warteschlange konnte nicht neu geordnet werden",historyCleared:"{{count}} Verlaufselement(e) gelöscht",clearHistoryFailed:"Verlauf konnte nicht gelöscht werden",updateFailed:"Elemente konnten nicht aktualisiert werden",bulkCancelled:"{{count}} Element(e) abgebrochen",bulkCancelFailed:"Elemente konnten nicht abgebrochen werden"},permissions:{noStopPrint:"Sie haben keine Berechtigung, Drucke zu stoppen",noStartPrint:"Sie haben keine Berechtigung, Drucke zu starten",noEdit:"Sie haben keine Berechtigung, dieses Warteschlangenelement zu bearbeiten",noCancel:"Sie haben keine Berechtigung, dieses Warteschlangenelement abzubrechen",noRequeue:"Sie haben keine Berechtigung, Elemente erneut einzureihen",noRemove:"Sie haben keine Berechtigung, dieses Warteschlangenelement zu entfernen",noClearHistory:"Sie haben keine Berechtigung, den gesamten Verlauf zu löschen",noEditItems:"Sie haben keine Berechtigung, Warteschlangenelemente zu bearbeiten",noCancelItems:"Sie haben keine Berechtigung, Warteschlangenelemente abzubrechen"}},stats:{title:"Dashboard",subtitle:"Widgets zum Neuanordnen ziehen. Auf das Augensymbol klicken zum Ausblenden.",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",printTime:"Druckzeit",totalFilament:"Gesamtverbrauch Filament",filamentUsed:"Filamentverbrauch",filamentCost:"Filamentkosten",totalCost:"Gesamtkosten",energyUsed:"Energieverbrauch",energyCost:"Energiekosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",printsByPrinter:"Drucke nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt",quickStats:"Schnellstatistiken",printActivity:"Druckaktivität",filamentTypes:"Filamenttypen",filamentTrends:"Filamenttrends",failureAnalysis:"Fehleranalyse",timeAccuracy:"Zeitgenauigkeit",successful:"Erfolgreich:",failed:"Fehlgeschlagen:",perfectEstimate:"100% = perfekte Schätzung",noTimeAccuracyData:"Noch keine Zeitgenauigkeitsdaten",noFilamentData:"Keine Filamentdaten verfügbar",noPrinterData:"Keine Druckerdaten verfügbar",noPrintData:"Keine Druckdaten verfügbar",noPrintDataLast30Days:"Keine Druckdaten in den letzten 30 Tagen",failureReasons:"Fehlerursachen",topFailureReasons:"Häufigste Fehlerursachen",failedPrintsCount:"{{failed}} / {{total}} Drucke fehlgeschlagen",lastWeekRate:"Letzte Woche: {{rate}}%",resetLayout:"Layout zurücksetzen",recalculateCosts:"Kosten neu berechnen",recalculateCostsHint:"Alle Archivkosten mit aktuellen Filamentpreisen neu berechnen",exportStats:"Statistiken exportieren",exportAsCsv:"Als CSV exportieren",exportAsExcel:"Als Excel exportieren",hiddenCount:"{{count}} ausgeblendet",exportDownloaded:"Export heruntergeladen",exportFailed:"Export fehlgeschlagen",layoutReset:"Layout zurückgesetzt",recalculatedCosts:"Kosten für {{count}} Archive neu berechnet",recalculateFailed:"Kosten konnten nicht neu berechnet werden",loadingStats:"Statistiken werden geladen...",noPermissionResetLayout:"Sie haben keine Berechtigung, das Layout zurückzusetzen",noPermissionRecalculate:"Sie haben keine Berechtigung, Kosten neu zu berechnen"},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",statusTab:"Status",settingsTab:"Einstellungen",overdueCount:"{{count}} überfällig",dueSoonCount:"{{count}} bald fällig",dueSoon:"Bald fällig",allGood:"Alles in Ordnung",overdueBy:"Überfällig um {{duration}}",dueIn:"Fällig in {{duration}}",timeLeft:"{{duration}} verbleibend",day:"1 Tag",days:"{{count}} Tage",week:"1 Woche",weeks:"{{count}} Wochen",month:"1 Monat",months:"{{count}} Monate",year:"1 Jahr",maintenanceTypes:"Wartungstypen",maintenanceTypesDescription:"Systemtypen und Ihre benutzerdefinierten Wartungsaufgaben",addCustomType:"Benutzerdefinierten Typ hinzufügen",intervalType:"Intervalltyp",intervalValue:"Intervall ({{type}})",icon:"Symbol",documentationLink:"Dokumentationslink (optional)",assignToPrinters:"Druckern zuweisen",selectAtLeastOnePrinter:"Wählen Sie mindestens einen Drucker",addType:"Typ hinzufügen",custom:"Benutzerdefiniert",printHours:"Druckstunden",calendarDays:"Kalendertage",exampleName:"z.B. HEPA-Filter ersetzen",viewDocumentation:"Dokumentation anzeigen",timeBasedInterval:"Zeitbasiertes Intervall",intervalOverrides:"Intervall-Überschreibungen",intervalOverridesDescription:"Intervalle für bestimmte Drucker anpassen",assignedToPrinters:"Druckern zugewiesen:",noPrintersAssigned:"Keine Drucker zugewiesen",addPrinterShort:"Hinzufügen:",printersAssignedClick:"{{count}} Drucker zugewiesen - klicken zum Verwalten",removeFromPrinter:"Von diesem Drucker entfernen",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",cleanCarbonRods:"Kohlenstoffstangen reinigen",checkPtfeTube:"PTFE-Schlauch prüfen",replaceHepaFilter:"HEPA-Filter ersetzen",replaceCarbonFilter:"Aktivkohlefilter ersetzen",lubricateLeftNozzleRail:"Linke Düsenschiene schmieren"},maintenanceComplete:"Wartung als abgeschlossen markiert",typeUpdated:"Wartungstyp aktualisiert",typeDeleted:"Wartungstyp gelöscht",printHoursUpdated:"Druckstunden aktualisiert",printerAssigned:"Drucker zugewiesen",printerRemoved:"Drucker entfernt",deleteTypeConfirm:'"{{name}}" löschen?',noPermissionUpdate:"Sie haben keine Berechtigung, Wartungselemente zu aktualisieren",noPermissionPerform:"Sie haben keine Berechtigung, Wartungen durchzuführen",noPermissionEditTypes:"Sie haben keine Berechtigung, Wartungstypen zu bearbeiten",noPermissionDeleteTypes:"Sie haben keine Berechtigung, Wartungstypen zu löschen",noPermissionEditHours:"Sie haben keine Berechtigung, Druckstunden zu bearbeiten",noPermissionRemovePrinter:"Sie haben keine Berechtigung, Druckerzuweisungen zu entfernen",noPermissionAssignPrinter:"Sie haben keine Berechtigung, Drucker zuzuweisen",noPermissionEditIntervals:"Sie haben keine Berechtigung, Intervalle zu bearbeiten",configureSettings:"Wartungstypen und Intervalle konfigurieren"},settings:{title:"Einstellungen",general:"Allgemein",tabs:{general:"Allgemein",smartPlugs:"Smart Plugs",notifications:"Benachrichtigungen",filament:"Filament",network:"Netzwerk",apiKeys:"API-Schlüssel",virtualPrinter:"Virtueller Drucker",users:"Authentifizierung",backup:"Sicherung",emailAuth:"E-Mail-Authentifizierung"},email:{smtpSettings:"SMTP-Konfiguration",smtpHost:"SMTP-Server",smtpPort:"SMTP-Port",security:"Sicherheit",authentication:"Authentifizierung",username:"Benutzername",password:"Passwort",fromEmail:"Absender-E-Mail",fromName:"Absendername",testConnection:"SMTP-Verbindung testen",testRecipient:"Test-Empfänger-E-Mail",sendTest:"Test-E-Mail senden",sending:"Wird gesendet...",save:"Einstellungen speichern",saving:"Wird gespeichert...",advancedAuth:"Erweiterte Authentifizierung",advancedAuthEnabled:"Erweiterte Authentifizierung ist aktiviert",advancedAuthEnabledDesc:"E-Mail-basierte Benutzerverwaltungsfunktionen sind aktiv. Neue Benutzer erhalten automatisch generierte Passwörter per E-Mail und können ihr Passwort über die Passwort vergessen Funktion zurücksetzen.",advancedAuthDisabled:"Erweiterte Authentifizierung ist deaktiviert",advancedAuthDisabledDesc:"Aktivieren Sie die erweiterte Authentifizierung, um E-Mail-basierte Funktionen für die Benutzerverwaltung zu aktivieren.",enable:"Aktivieren",disable:"Deaktivieren",feature1:"Passwörter werden automatisch generiert und an neue Benutzer gesendet",feature2:"Benutzer können sich mit Benutzername oder E-Mail anmelden",feature3:"Passwort vergessen Funktion ist verfügbar",feature4:"Administratoren können Benutzerpasswörter per E-Mail zurücksetzen",errors:{requiredFields:"Bitte füllen Sie alle Pflichtfelder aus",usernameRequired:"Benutzername ist erforderlich, wenn Authentifizierung aktiviert ist",enterTestEmail:"Bitte geben Sie eine Test-E-Mail-Adresse ein",smtpServerAndEmail:"Bitte füllen Sie SMTP-Server und Absender-E-Mail aus, bevor Sie testen",usernamePasswordRequired:"Benutzername und Passwort sind erforderlich, wenn Authentifizierung aktiviert ist",configureSmtpFirst:"Bitte konfigurieren und testen Sie zuerst die SMTP-Einstellungen"},success:{settingsSaved:"SMTP-Einstellungen erfolgreich gespeichert"},securityOptions:{starttls:"STARTTLS (Port 587)",ssl:"SSL/TLS (Port 465)",none:"Keine (Port 25)"},authOptions:{enabled:"Aktiviert",disabled:"Deaktiviert"}},appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},filamentTracking:"Filament-Verfolgung",filamentTrackingDesc:"Wählen Sie, wie Sie Ihre Filamentspulen verfolgen möchten. Sie können das integrierte Inventar oder einen externen Spoolman-Server verwenden.",trackingModeBuiltIn:"Integriertes Inventar",trackingModeBuiltInDesc:"RFID-Erkennung und Verbrauchserfassung inklusive",trackingModeSpoolmanDesc:"Externer Filament-Management-Server",builtInFeatureRfid:"Erkennt automatisch Bambu Lab RFID-Spulen im AMS",builtInFeatureUsage:"Erfasst den Filamentverbrauch pro Druck",builtInFeatureCatalog:"Spulen, Farben und K-Faktor-Profile verwalten",spoolmanUrl:"Spoolman URL",spoolmanUrlHint:"URL Ihres Spoolman-Servers (z.B. http://localhost:7912)",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden",status:"Status",connect:"Verbinden",disconnect:"Trennen",howSyncWorks:"So funktioniert die Synchronisierung",syncInfoRfidOnly:"Nur offizielle Bambu Lab Spulen mit RFID werden synchronisiert",syncInfoAutoCreate:"Neue Spulen werden bei der ersten Synchronisierung automatisch in Spoolman erstellt",syncInfoThirdPartySkipped:"Nicht-Bambu-Lab-Spulen (Drittanbieter, nachgefüllt) werden übersprungen",linkingExistingSpools:"Vorhandene Spulen verknüpfen",linkingExistingSpoolsDesc:'Um vorhandene Spoolman-Spulen mit Ihrem AMS zu verknüpfen, fahren Sie über einen AMS-Slot und klicken Sie auf "Mit Spoolman verknüpfen".',syncMode:"Synchronisierungsmodus",syncModeAuto:"Automatisch",syncModeManual:"Nur manuell",syncModeAutoDesc:"AMS-Daten werden automatisch synchronisiert, wenn Änderungen erkannt werden",syncModeManualDesc:"Nur bei manueller Auslösung synchronisieren",syncAmsData:"AMS-Daten synchronisieren",syncAmsDataDesc:"AMS-Daten des Druckers manuell mit Spoolman synchronisieren",allPrinters:"Alle Drucker",noDefaultPrinter:"Kein Standard (jedes Mal fragen)",sidebarOrder:"Seitenleisten-Reihenfolge",saveThumbnails:"Vorschaubilder speichern",captureFinishPhoto:"Abschlussfoto aufnehmen",noPrintersConfigured:"Keine Drucker konfiguriert",archiveMode:{always:"Immer Archiveintrag erstellen",never:"Nie Archiveintrag erstellen",ask:"Jedes Mal fragen"},checkForUpdatesLabel:"Nach Updates suchen",checkPrinterFirmware:"Drucker-Firmware prüfen",enableRetry:"Wiederholung aktivieren",homeAssistantDescription:"Smart Plugs über Home Assistant steuern",environmentManagedLabel:"(Umgebungsvariable)",autoEnabledViaEnv:"Automatisch über Umgebungsvariablen aktiviert",urlFromEnvReadOnly:"Wert wird über HA_URL Umgebungsvariable gesetzt (schreibgeschützt)",tokenFromEnvReadOnly:"Wert wird über HA_TOKEN Umgebungsvariable gesetzt (schreibgeschützt)",mqttConnectedTo:"Verbunden mit",prometheusDescription:"Druckerdaten im Prometheus-Format bereitstellen",noSmartPlugsTitle:"Keine Smart Plugs konfiguriert",noSmartPlugsDescription:"Fügen Sie einen Tasmota-basierten Smart Plug hinzu, um den Energieverbrauch zu verfolgen und die Stromsteuerung zu automatisieren.",noProvidersTitle:"Keine Anbieter konfiguriert",noProvidersDescription:"Fügen Sie einen Anbieter hinzu, um Benachrichtigungen zu erhalten.",noTemplatesAvailable:"Keine Vorlagen verfügbar. Starten Sie das Backend neu, um Standardvorlagen zu laden.",apiPermissionView:"Druckerstatus und Warteschlange anzeigen",apiPermissionEdit:"Elemente zur Druckwarteschlange hinzufügen und entfernen",apiKeysEmptyTitle:"Keine API-Schlüssel",apiKeysEmptyDescription:"Erstellen Sie einen API-Schlüssel zur Integration mit externen Diensten.",noUsersFound:"Keine Benutzer gefunden",noGroupsFound:"Keine Gruppen gefunden",noGroupsAvailable:"Keine Gruppen verfügbar",passwordsDoNotMatch:"Passwörter stimmen nicht überein",systemGroupWarning:"System-Gruppennamen können nicht geändert werden",authDisabledTitle:"Authentifizierung ist deaktiviert",authDisabledFeature1:"Anmeldung zum Zugriff auf das System erforderlich",authDisabledFeature2:"Mehrere Benutzer mit gruppenbasierten Berechtigungen erstellen",authDisabledFeature3:"Zugriff mit über 50 granularen Berechtigungen steuern",userHasCreated:"Dieser Benutzer hat erstellt:",userItemsQuestion:"Was möchten Sie mit diesen Elementen tun?",deleteUserConfirm:"Möchten Sie diesen Benutzer wirklich löschen?",actionCannotBeUndone:"Diese Aktion kann nicht rückgängig gemacht werden.",addFirstSmartPlug:"Ersten Smart Plug hinzufügen",providers:"Anbieter",log:"Protokoll",testAll:"Alle testen",testResults:"Testergebnisse",testPassedCount:"{{count}} bestanden",testFailedCount:"{{count}} fehlgeschlagen",messageTemplates:"Nachrichtenvorlagen",messageTemplatesDescription:"Passen Sie Benachrichtigungen für jedes Ereignis an.",apiKeys:"API-Schlüssel",apiKeysDescription:"Erstellen Sie API-Schlüssel für externe Integrationen und Webhooks.",createKey:"Schlüssel erstellen",apiKeyCreated:"API-Schlüssel erfolgreich erstellt",apiKeyCopyWarning:"Kopieren Sie diesen Schlüssel jetzt - er wird nicht mehr angezeigt!",useInApiBrowser:"Im API-Browser verwenden",createNewApiKey:"Neuen API-Schlüssel erstellen",keyName:"Schlüsselname",keyNamePlaceholder:"z.B. Home Assistant, OctoPrint",readStatus:"Status lesen",readStatusDescription:"Druckerstatus und Warteschlange anzeigen",manageQueue:"Warteschlange verwalten",manageQueueDescription:"Elemente zur Druckwarteschlange hinzufügen und entfernen",controlPrinter:"Drucker steuern",controlPrinterDescription:"Drucke pausieren, fortsetzen und stoppen",unnamedKey:"Unbenannter Schlüssel",lastUsed:"Zuletzt verwendet",read:"Lesen",control:"Steuern",createFirstKey:"Ersten Schlüssel erstellen",webhookEndpoints:"Webhook-Endpunkte",webhookApiKeyHint:"Verwenden Sie Ihren API-Schlüssel im X-API-Key-Header.",webhook:{getAllStatus:"Alle Druckerstatus abrufen",getSpecificStatus:"Spezifischen Druckerstatus abrufen",addToQueue:"Zur Druckwarteschlange hinzufügen",pausePrint:"Druck pausieren",resumePrint:"Druck fortsetzen",stopPrint:"Druck stoppen"},apiBrowser:"API-Browser",apiBrowserDescription:"Erkunden und testen Sie alle verfügbaren API-Endpunkte.",apiKeyForTesting:"API-Schlüssel zum Testen",apiKeyPlaceholder:"Fügen Sie hier Ihren API-Schlüssel ein, um authentifizierte Endpunkte zu testen...",apiKeyHint:"Dieser Schlüssel wird als X-API-Key-Header mit Anfragen gesendet.",deleteApiKeyTitle:"API-Schlüssel löschen",deleteApiKeyMessage:"Möchten Sie diesen API-Schlüssel wirklich löschen? Alle Integrationen, die diesen Schlüssel verwenden, funktionieren nicht mehr.",deleteKey:"Schlüssel löschen",amsDisplayThresholds:"AMS-Anzeigeschwellenwerte",amsThresholdsDescription:"Konfigurieren Sie Farbschwellenwerte für AMS-Feuchtigkeits- und Temperaturanzeigen.",humidity:"Luftfeuchtigkeit",goodGreen:"Gut (grün)",fairOrange:"Mittel (orange)",aboveFairBad:"Über dem mittleren Schwellenwert wird rot angezeigt (schlecht)",temperature:"Temperatur",goodBlue:"Gut (blau)",aboveFairHot:"Über dem mittleren Schwellenwert wird rot angezeigt (heiß)",historyRetention:"Verlaufsaufbewahrung",keepSensorHistory:"Sensorverlauf behalten für",historyRetentionDescription:"Ältere Feuchtigkeits- und Temperaturdaten werden automatisch gelöscht",printModal:"Druckdialog",expandCustomMapping:"Benutzerdefinierte Zuordnung standardmäßig erweitern",expandCustomMappingDescription:"Bei Druck auf mehrere Drucker die AMS-Zuordnung pro Drucker erweitert anzeigen",authentication:"Authentifizierung",authEnabledDescription:"Ihre Instanz ist mit Benutzerauthentifizierung gesichert",authDisabledDescription:"Aktivieren Sie die Anmeldepflicht und verwalten Sie den Benutzerzugriff",authDisabledMessage:"Aktivieren Sie die Authentifizierung, um Benutzerkonten zu erstellen, Berechtigungen zu verwalten und Ihre Bambuddy-Instanz zu sichern.",enableAuthentication:"Authentifizierung aktivieren",currentUser:"Aktueller Benutzer",changePassword:"Passwort ändern",admin:"Admin",users:"Benutzer",addUser:"Benutzer hinzufügen",groups:"Gruppen",addGroup:"Gruppe hinzufügen",system:"System",noDescription:"Keine Beschreibung",userCount:"{{count}} Benutzer",permissionCount:"{{count}} Berechtigungen",createUser:"Benutzer erstellen",username:"Benutzername",enterUsername:"Benutzername eingeben",password:"Passwort",enterPassword:"Passwort eingeben (min. 6 Zeichen)",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Passwort bestätigen",viewReleaseOnGitHub:"Release auf GitHub anzeigen",turnAllPlugsOn:"Alle Stecker einschalten",turnAllPlugsOff:"Alle Stecker ausschalten",clearNotificationLogs:"Benachrichtigungsprotokolle löschen",clearLogsMessage:"Dadurch werden alle Benachrichtigungsprotokolle, die älter als 30 Tage sind, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",clearLogs:"Protokolle löschen",resetUiPreferences:"UI-Einstellungen zurücksetzen",resetUiPreferencesMessage:"Dadurch werden alle UI-Einstellungen auf Standardwerte zurückgesetzt: Seitenleisten-Reihenfolge, Theme, Dashboard-Layout, Ansichtsmodi und Sortiereinstellungen. Ihre Drucker, Archive und Servereinstellungen werden NICHT beeinträchtigt. Die Seite wird nach dem Löschen neu geladen.",resetPreferences:"Einstellungen zurücksetzen",deleteGroupTitle:"Gruppe löschen",deleteGroupMessage:"Möchten Sie diese Gruppe wirklich löschen? Benutzer in dieser Gruppe verlieren diese Berechtigungen.",deleteGroup:"Gruppe löschen",disableAuthenticationTitle:"Authentifizierung deaktivieren",disableAuthenticationMessage:"Möchten Sie die Authentifizierung wirklich deaktivieren? Dadurch wird Ihre Bambuddy-Instanz ohne Anmeldung zugänglich. Alle Benutzer bleiben in der Datenbank, aber die Authentifizierung wird deaktiviert.",disableAuthentication:"Authentifizierung deaktivieren",configureBambuddy:"Bambuddy konfigurieren",systemDefault:"Systemstandard",archiveSettings:"Archiv-Einstellungen",newWindow:"Neues Fenster",embeddedOverlay:"Eingebettetes Overlay",preferredSlicer:"Bevorzugter Slicer",preferredSlicerDescription:"Wähle die Slicer-Anwendung zum Öffnen von Dateien",externalCameras:"Externe Kameras",costTracking:"Kostenverfolgung",printsOnly:"Nur Drucke",totalConsumption:"Gesamtverbrauch",dataManagement:"Datenverwaltung",clearNotificationLogsDescription:"Benachrichtigungsprotokolle älter als 30 Tage löschen",resetUiPreferencesDescription:"Seitenleisten-Reihenfolge, Theme, Ansichtsmodi und Layout-Einstellungen zurücksetzen. Drucker, Archive und Einstellungen werden nicht beeinflusst.",enableHomeAssistant:"Home Assistant aktivieren",enableMqtt:"MQTT aktivieren",useTls:"TLS verwenden",enableMetricsEndpoint:"Metrik-Endpunkt aktivieren",availableMetrics:"Verfügbare Metriken",editUser:"Benutzer bearbeiten",deleteUserTitle:"Benutzer löschen",groupName:"Gruppenname",leaveEmptyForAnonymous:"Leer lassen für anonym",leaveEmptyForNoAuth:"Leer lassen für keine Authentifizierung",enterNewPassword:"Neues Passwort eingeben",confirmNewPassword:"Neues Passwort bestätigen",enterGroupName:"Gruppenname eingeben",enterDescriptionOptional:"Beschreibung eingeben (optional)",enterCurrentPassword:"Aktuelles Passwort eingeben",enterNewPasswordMin6:"Neues Passwort eingeben (min. 6 Zeichen)",toast:{keyCopied:"Schlüssel in Zwischenablage kopiert",copyFailed:"Schlüssel konnte nicht kopiert werden",keyAddedToBrowser:"Schlüssel zum API-Browser hinzugefügt",clearLogsFailed:"Protokolle konnten nicht gelöscht werden",uiPreferencesReset:"UI-Einstellungen zurückgesetzt. Wird neu geladen...",authDisabled:"Authentifizierung erfolgreich deaktiviert",authDisableFailed:"Authentifizierung konnte nicht deaktiviert werden",apiKeyCreated:"API-Schlüssel erstellt",apiKeyDeleted:"API-Schlüssel gelöscht",userCreated:"Benutzer erfolgreich erstellt",userUpdated:"Benutzer erfolgreich aktualisiert",userDeleted:"Benutzer erfolgreich gelöscht",groupCreated:"Gruppe erfolgreich erstellt",groupUpdated:"Gruppe erfolgreich aktualisiert",groupDeleted:"Gruppe erfolgreich gelöscht",fillRequiredFields:"Bitte füllen Sie alle erforderlichen Felder aus",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein",enterGroupName:"Bitte geben Sie einen Gruppennamen ein",settingsSaved:"Einstellungen gespeichert",cameraSettingsSaved:"Kamera-Einstellungen gespeichert",enterCameraUrl:"Bitte geben Sie eine Kamera-URL ein",passwordChanged:"Passwort erfolgreich geändert",connectionFailed:"Verbindung fehlgeschlagen",testFailed:"Test fehlgeschlagen",cameraConnected:"Kamera verbunden{{resolution}}"},testConnection:"Verbindung testen",catalog:{spoolCatalog:"Spulenkatalog",spoolCatalogDescription:"Leerspulengewichte nach Marke/Typ. Wird für die automatische Gewichtssuche beim Hinzufügen von Spulen verwendet.",searchCatalog:"Katalog durchsuchen...",addNewEntry:"Neuen Eintrag hinzufügen",namePlaceholder:"Name (z.B. Bambu Lab - Plastik)",weight:"Gewicht",type:"Typ",default:"Standard",custom:"Benutzerdefiniert",noMatch:"Keine Einträge entsprechen Ihrer Suche",empty:"Keine Einträge im Katalog",deleteEntry:"Eintrag löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',resetCatalog:"Katalog zurücksetzen",resetConfirm:"Katalog auf Standardwerte zurücksetzen? Alle benutzerdefinierten Einträge werden entfernt.",loadFailed:"Spulenkatalog konnte nicht geladen werden",nameWeightRequired:"Name und Gewicht sind erforderlich",entryAdded:"Eintrag hinzugefügt",addFailed:"Eintrag konnte nicht hinzugefügt werden",entryUpdated:"Eintrag aktualisiert",updateFailed:"Eintrag konnte nicht aktualisiert werden",entryDeleted:"Eintrag gelöscht",deleteFailed:"Eintrag konnte nicht gelöscht werden",resetSuccess:"Katalog auf Standardwerte zurückgesetzt",resetFailed:"Katalog konnte nicht zurückgesetzt werden",exported:"{{count}} Einträge exportiert",imported:"{{added}} Einträge importiert ({{skipped}} übersprungen)",importFailed:"Import fehlgeschlagen: ungültiges JSON-Format",exportTooltip:"Katalog als JSON exportieren",importTooltip:"Katalog aus JSON importieren",resetTooltip:"Auf Standardwerte zurücksetzen"},colorCatalog:{title:"Farbkatalog",description:"Filamentfarben nach Hersteller/Material. Wird für die automatische Farbsuche beim Hinzufügen von Spulen verwendet.",searchColors:"Farben durchsuchen...",allManufacturers:"Alle Hersteller",addNewColor:"Neue Farbe hinzufügen",manufacturer:"Hersteller",colorName:"Farbname",hex:"Hex",materialOptional:"Material (optional)",showing:"{{filtered}} von {{total}} Farben angezeigt",noMatch:"Keine Farben entsprechen Ihrer Suche",empty:"Keine Farben im Katalog",deleteColor:"Farbe löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',resetCatalog:"Farbkatalog zurücksetzen",resetConfirm:"Katalog auf Standardwerte zurücksetzen? Alle benutzerdefinierten Farben werden entfernt.",sync:"Sync",starting:"Starten...",syncTooltip:"Von FilamentColors.xyz synchronisieren (2000+ Farben)",loadFailed:"Farbkatalog konnte nicht geladen werden",fieldsRequired:"Hersteller, Farbname und Hex-Farbe sind erforderlich",colorAdded:"Farbe hinzugefügt",addFailed:"Farbe konnte nicht hinzugefügt werden",colorUpdated:"Farbe aktualisiert",updateFailed:"Farbe konnte nicht aktualisiert werden",colorDeleted:"Farbe gelöscht",deleteFailed:"Farbe konnte nicht gelöscht werden",resetSuccess:"Farbkatalog auf Standardwerte zurückgesetzt",resetFailed:"Katalog konnte nicht zurückgesetzt werden",syncUpToDate:"Bereits aktuell ({{count}} Farben geprüft)",syncComplete:"{{added}} neue Farben hinzugefügt ({{skipped}} bereits vorhanden)",syncError:"Sync-Fehler",syncFailed:"Synchronisierung von FilamentColors.xyz fehlgeschlagen",exported:"{{count}} Farben exportiert",imported:"{{added}} Farben importiert ({{skipped}} übersprungen)",importFailed:"Import fehlgeschlagen: ungültiges JSON-Format"}},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"},hmsErrors:{title:"Fehler - {{name}}",noErrors:"Keine Fehler",viewOnWiki:"Im Bambu Lab Wiki ansehen",clearInstructions:"Löschen Sie die Fehler am Drucker, um sie hier zu entfernen."},mqttDebug:{title:"MQTT-Debug-Protokoll",searchPlaceholder:"Topic oder Payload suchen...",noMessages:"Noch keine Nachrichten protokolliert",startLoggingHint:'Klicken Sie auf "Protokollierung starten", um MQTT-Nachrichten aufzuzeichnen',noMessagesMatch:"Keine Nachrichten entsprechen Ihrem Filter",adjustFilterHint:"Versuchen Sie, Ihre Such- oder Filterkriterien anzupassen",incoming:"Eingehend",outgoing:"Ausgehend",loggingStopped:"Protokollierung gestoppt",loggingActive:"Protokollierung aktiv - Nachrichten werden automatisch aktualisiert",startLogging:"Protokollierung starten",stopLogging:"Protokollierung stoppen",clearLog:"Protokoll löschen",topic:"Topic",timestamp:"Zeitstempel",direction:"Richtung",all:"Alle"},printerFiles:{title:"Dateimanager",storageUsed:"Belegt:",storageFree:"Frei:",filterPlaceholder:"Dateien filtern...",deleteButton:"Löschen",deleteFiles:"{{count}} Dateien löschen",deleteFileConfirm:'"{{name}}" löschen? Dies kann nicht rückgängig gemacht werden.',deleteFilesConfirm:"{{count}} ausgewählte Dateien löschen? Dies kann nicht rückgängig gemacht werden.",noFiles:"Keine Dateien auf dem Drucker",loadingFiles:"Dateien werden geladen...",failedToLoad:"Dateien konnten nicht geladen werden",toast:{filesDeleted:"{{count}} Datei(en) gelöscht",deleteFailed:"Löschen fehlgeschlagen: {{error}}"}},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?"},login:{title:"Bambuddy Anmeldung",subtitle:"Melden Sie sich bei Ihrem Konto an",username:"Benutzername",usernamePlaceholder:"Benutzername eingeben",usernameOrEmail:"Benutzername oder E-Mail",usernameOrEmailPlaceholder:"Benutzername oder @ E-Mail",password:"Passwort",passwordPlaceholder:"Passwort eingeben",signIn:"Anmelden",signingIn:"Anmeldung läuft...",forgotPassword:"Passwort vergessen?",loginSuccess:"Erfolgreich angemeldet",loginFailed:"Anmeldung fehlgeschlagen",enterCredentials:"Bitte Benutzername und Passwort eingeben",forgotPasswordTitle:"Passwort vergessen",forgotPasswordMessage:"Wenn Sie Ihr Passwort vergessen haben, wenden Sie sich bitte an Ihren Systemadministrator.",forgotPasswordEmailMessage:"Geben Sie Ihre E-Mail-Adresse ein und wir senden Ihnen ein neues Passwort.",emailAddress:"E-Mail-Adresse",emailPlaceholder:"ihre.email@beispiel.de",cancel:"Abbrechen",sending:"Wird gesendet...",sendResetEmail:"Zurücksetzungs-E-Mail senden",howToReset:"So setzen Sie Ihr Passwort zurück:",resetStep1:"Kontaktieren Sie Ihren Bambuddy-Administrator",resetStep2:"Bitten Sie ihn, Ihr Passwort in der Benutzerverwaltung zurückzusetzen",resetStep3:"Er kann ein neues temporäres Passwort für Sie festlegen",resetStep4:"Melden Sie sich mit dem neuen Passwort an und ändern Sie es in den Einstellungen",gotIt:"Verstanden"},setup:{title:"Bambuddy Einrichtung",subtitle:"Konfigurieren Sie die Authentifizierung für Ihre Bambuddy-Instanz",enableAuth:"Authentifizierung aktivieren",adminAccount:"Admin-Konto",adminAccountDesc:"Wenn bereits Admin-Benutzer existieren, wird die Authentifizierung mit den vorhandenen Admin-Konten aktiviert. Lassen Sie die Felder unten leer, um vorhandene Admins zu verwenden, oder geben Sie neue Anmeldedaten ein, um einen neuen Admin-Benutzer zu erstellen.",adminUsername:"Admin-Benutzername",adminPassword:"Admin-Passwort",optionalIfAdminExists:"(optional, wenn Admin-Benutzer existieren)",adminUsernamePlaceholder:"Admin-Benutzernamen eingeben (optional)",adminPasswordPlaceholder:"Admin-Passwort eingeben (optional)",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Admin-Passwort bestätigen",settingUp:"Einrichtung läuft...",completeSetup:"Einrichtung abschließen",toast:{authEnabledAdminCreated:"Authentifizierung aktiviert und Admin-Benutzer erstellt",authEnabledExistingAdmins:"Authentifizierung mit vorhandenen Admin-Benutzern aktiviert",setupCompleted:"Einrichtung abgeschlossen",enterBothCredentials:"Bitte geben Sie sowohl Admin-Benutzernamen als auch Passwort ein, oder lassen Sie beide leer, um vorhandene Admin-Benutzer zu verwenden",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein"}},changePassword:{title:"Passwort ändern",currentPassword:"Aktuelles Passwort",currentPasswordPlaceholder:"Aktuelles Passwort eingeben",newPassword:"Neues Passwort",newPasswordPlaceholder:"Neues Passwort eingeben (min. 6 Zeichen)",confirmPassword:"Neues Passwort bestätigen",confirmPasswordPlaceholder:"Neues Passwort bestätigen",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein",changing:"Wird geändert...",success:"Passwort erfolgreich geändert",failed:"Passwortänderung fehlgeschlagen"},plateAlert:{title:"Druck pausiert!",message:"Objekte auf dem Druckbett erkannt. Der Druck wurde automatisch pausiert. Bitte räumen Sie das Druckbett und setzen Sie den Druck fort.",understand:"Verstanden"},camera:{title:"Kameraansicht",invalidPrinterId:"Ungültige Drucker-ID",live:"Live",snapshot:"Schnappschuss",restartStream:"Stream neu starten",refreshSnapshot:"Schnappschuss aktualisieren",fullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",connectingToCamera:"Verbinde mit Kamera...",capturingSnapshot:"Schnappschuss wird aufgenommen...",connectionLost:"Verbindung verloren",connectionFailed:"Kameraverbindung fehlgeschlagen",reconnecting:"Neuverbindung in {{countdown}}s... (Versuch {{attempt}}/{{max}})",reconnectNow:"Jetzt verbinden",cameraUnavailable:"Kamera nicht verfügbar",cameraUnavailableDesc:"Stellen Sie sicher, dass der Drucker eingeschaltet und verbunden ist.",noCamera:"Keine Kamera verfügbar",retry:"Erneut versuchen",cameraStream:"Kamera-Stream",zoomOut:"Verkleinern",zoomIn:"Vergrößern",resetZoom:"Zoom zurücksetzen",recording:"Aufnahme",startRecording:"Aufnahme starten",stopRecording:"Aufnahme stoppen",chamberLight:"Kammerbeleuchtung umschalten"},groups:{title:"Gruppenverwaltung",subtitle:"Berechtigungsgruppen für Zugriffskontrolle verwalten",backToSettings:"Zurück zu Einstellungen",createGroup:"Gruppe erstellen",noPermission:"Sie haben keine Berechtigung, auf diese Seite zuzugreifen.",system:"System",noDescription:"Keine Beschreibung",usersCount:"{{count}} Benutzer",permissionsCount:"{{count}} Berechtigungen",edit:"Bearbeiten",delete:"Löschen",toast:{created:"Gruppe erfolgreich erstellt",updated:"Gruppe erfolgreich aktualisiert",deleted:"Gruppe erfolgreich gelöscht",enterGroupName:"Bitte geben Sie einen Gruppennamen ein"},modal:{editGroup:"Gruppe bearbeiten",createGroup:"Gruppe erstellen",cancel:"Abbrechen",saving:"Speichern...",creating:"Erstellen...",saveChanges:"Änderungen speichern"},form:{groupName:"Gruppenname",groupNamePlaceholder:"Gruppennamen eingeben",systemGroupWarning:"Systemgruppennamen können nicht geändert werden",description:"Beschreibung",descriptionPlaceholder:"Beschreibung eingeben (optional)",permissions:"Berechtigungen ({{count}} ausgewählt)"},deleteModal:{title:"Gruppe löschen",message:"Sind Sie sicher, dass Sie diese Gruppe löschen möchten? Benutzer in dieser Gruppe verlieren diese Berechtigungen.",confirm:"Gruppe löschen"}},users:{title:"Benutzerverwaltung",subtitle:"Benutzer und deren Zugriff auf Ihre Bambuddy-Instanz verwalten",backToSettings:"Zurück zu Einstellungen",createUser:"Benutzer erstellen",noPermission:"Sie haben keine Berechtigung, auf diese Seite zuzugreifen.",admin:"Admin",noGroups:"Keine Gruppen",active:"Aktiv",inactive:"Inaktiv",edit:"Bearbeiten",delete:"Löschen",system:"System",noGroupsAvailable:"Keine Gruppen verfügbar",table:{username:"Benutzername",groups:"Gruppen",status:"Status",actions:"Aktionen"},toast:{created:"Benutzer erfolgreich erstellt",updated:"Benutzer erfolgreich aktualisiert",deleted:"Benutzer erfolgreich gelöscht",fillRequired:"Bitte füllen Sie alle Pflichtfelder aus",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein"},modal:{createUser:"Benutzer erstellen",editUser:"Benutzer bearbeiten",cancel:"Abbrechen",creating:"Erstellen...",saving:"Speichern...",saveChanges:"Änderungen speichern",advancedAuthSubtitle:"mit erweiterter Authentifizierung"},form:{username:"Benutzername",usernamePlaceholder:"Benutzernamen eingeben",email:"E-Mail",emailPlaceholder:"benutzer@beispiel.de",password:"Passwort",passwordPlaceholder:"Passwort eingeben",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Passwort bestätigen",newPasswordPlaceholder:"Neues Passwort eingeben",confirmNewPasswordPlaceholder:"Neues Passwort bestätigen",leaveBlankToKeep:"leer lassen, um das aktuelle zu behalten",groups:"Gruppen",optional:"optional",autoGeneratedPassword:"Ein sicheres Passwort wird automatisch generiert und per E-Mail an den Benutzer gesendet.",passwordManagedByAdvancedAuth:'Das Passwort wird durch erweiterte Authentifizierung verwaltet. Verwenden Sie "Passwort zurücksetzen", um ein neues Passwort per E-Mail an den Benutzer zu senden.',resetPassword:"Passwort zurücksetzen",resettingPassword:"Passwort wird zurückgesetzt..."},deleteModal:{title:"Benutzer löschen",message:"Sind Sie sicher, dass Sie diesen Benutzer löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",confirm:"Benutzer löschen"}},streamOverlay:{title:"Stream-Overlay",invalidPrinterId:"Ungültige Drucker-ID",cameraStream:"Kamera-Stream",progress:"Fortschritt",eta:"ETA",tomorrow:"Morgen",printerIdle:"Drucker ist inaktiv",printerOffline:"Drucker offline",status:{printing:"Druckt",paused:"Pausiert",finished:"Fertig",failed:"Fehlgeschlagen",idle:"Inaktiv",unknown:"Unbekannt"}},profiles:{title:"Profile",subtitle:"Verwalten Sie Ihre Slicer-Voreinstellungen und Druckvorschub-Kalibrierungen",tabs:{cloud:"Cloud-Profile",local:"Lokale Profile",kprofiles:"K-Profile"},localProfiles:{title:"Lokale Profile",subtitle:"Slicer-Voreinstellungen aus OrcaSlicer importieren und verwalten",import:"Profile importieren",importDesc:".bbscfg-, .bbsflmt-, .orca_filament-, .zip- oder .json-Dateien hier ablegen",importing:"Importiere...",search:"Lokale Voreinstellungen durchsuchen...",noPresets:"Noch keine lokalen Voreinstellungen",badge:"Lokal",edit:"Bearbeiten",delete:"Löschen",cancel:"Abbrechen",deleteConfirmTitle:"Voreinstellung löschen",deleteConfirm:"Möchten Sie diese Voreinstellung wirklich löschen? Dies kann nicht rückgängig gemacht werden.",source:"Quelle",inheritsFrom:"Erbt von",filamentType:"Typ",vendor:"Hersteller",compatiblePrinters:"Drucker",nozzleTemp:"Düsentemperatur",cost:"Kosten",density:"Dichte",pressureAdvance:"Druckvorschub",filament:"Filament",process:"Prozess",printer:"Drucker",toast:{importSuccess:"{{count}} Voreinstellung(en) importiert",importSkipped:"{{count}} Voreinstellung(en) übersprungen (Duplikate)",importError:"{{count}} Fehler beim Import",deleted:"Voreinstellung gelöscht",updated:"Voreinstellung aktualisiert"}},connectedAs:"Verbunden als",logout:"Abmelden",noLogoutPermission:"Sie haben keine Berechtigung zum Abmelden",failedToLoad:"Profile konnten nicht geladen werden",retry:"Erneut versuchen",time:{justNow:"Gerade eben",minsAgo:"vor {{count}}m",hoursAgo:"vor {{count}}h",daysAgo:"vor {{count}}d"},toast:{loggedOut:"Abgemeldet"},login:{title:"Mit Bambu Cloud verbinden",subtitle:"Synchronisieren Sie Ihre Slicer-Voreinstellungen geräteübergreifend",email:"E-Mail",password:"Passwort",region:"Region",regionGlobal:"Global",regionChina:"China",verificationCode:"Bestätigungscode",totpCode:"Authenticator-Code",checkEmail:"Prüfen Sie Ihre E-Mail ({{email}}) für einen 6-stelligen Code",enterTotpHint:"Geben Sie den 6-stelligen Code aus Ihrer Authenticator-App ein",accessToken:"Zugriffstoken",accessTokenHint:"Fügen Sie Ihr Bambu Lab Zugriffstoken ein (aus Bambu Studio)",back:"Zurück",loginButton:"Anmelden",verifyButton:"Bestätigen",setTokenButton:"Token setzen",useToken:"Stattdessen Zugriffstoken verwenden",useEmail:"Stattdessen mit E-Mail anmelden",toast:{loggedIn:"Erfolgreich angemeldet",codeSent:"Bestätigungscode an Ihre E-Mail gesendet",enterTotp:"Geben Sie den Code aus Ihrer Authenticator-App ein",tokenSet:"Token erfolgreich gesetzt"}},presets:{myPreset:"Mein Profil (bearbeitbar)",duplicate:"Duplizieren",editable:"Bearbeitbar",failedToLoadDetails:"Profil-Details konnten nicht geladen werden",deleteConfirm:"Dieses Profil löschen?",deleteWarning:'"{{name}}" wird dauerhaft aus Bambu Cloud gelöscht. Dies kann nicht rückgängig gemacht werden.',noDuplicatePermission:"Sie haben keine Berechtigung zum Duplizieren von Profilen",noEditPermission:"Sie haben keine Berechtigung zum Bearbeiten von Profilen",noDeletePermission:"Sie haben keine Berechtigung zum Löschen von Profilen",types:{filament:"Filament-Profil",printer:"Drucker-Profil",process:"Prozess-Profil"},toast:{deleted:"Profil gelöscht",created:"Profil erstellt",updated:"Profil aktualisiert",duplicated:"Profil dupliziert",fieldAdded:'Feld "{{key}}" hinzugefügt',exported:"Profil exportiert"},baseLabel:"Basis: {{name}}",currentLabel:"Aktuell: {{name}}",newPreset:"Neues Profil",editPreset:"Profil bearbeiten",duplicatePreset:"Profil duplizieren",createNewPreset:"Neues Profil erstellen",customizeSettings:"Passen Sie die Einstellungen für Ihr neues Profil an",compareWithBase:"Mit Basis-Profil vergleichen",compare:"Vergleichen",basePreset:"Basis-Profil",selectBasePreset:"Basis-Profil auswählen...",presetName:"Profilname",myCustomPreset:"Mein eigenes Profil",inheritsFrom:"Erbt von",dropJsonToImport:"JSON zum Importieren ablegen",tabs:{common:"Allgemein",allFields:"Alle Felder"},availableFields:"Verfügbare Felder",searchFieldsPlaceholder:"Felder suchen...",noMatchingFields:"Keine passenden Felder",allFieldsAdded:"Alle Felder hinzugefügt",addCustomField:"Eigenes Feld hinzufügen",yourOverrides:"Ihre Überschreibungen",noOverridesYet:"Noch keine Überschreibungen",clickFieldsToAdd:"Klicken Sie links auf Felder, um sie hinzuzufügen",saveAsTemplate:"Als Vorlage speichern",jsonTip:"Tipp: Ziehen Sie eine .json-Datei auf dieses Fenster, um Einstellungen zu importieren"},cloudView:{searchPlaceholder:"Profile suchen...",templates:"Vorlagen",refresh:"Aktualisieren",newPreset:"Neues Profil",clearFilters:"Filter zurücksetzen",compareMode:"Vergleichsmodus",selectAnotherPreset:"Wählen Sie ein weiteres {{type}}-Profil",clickTwoPresets:"Klicken Sie auf zwei Profile des gleichen Typs zum Vergleichen",selectFirst:"1. Erstes auswählen",selectSecond:"2. Zweites auswählen",compareNow:"Jetzt vergleichen",lastSynced:"Zuletzt synchronisiert:",showingCount:"{{showing}} von {{total}} Profilen",noPresetsFound:"Keine Profile gefunden",columns:{filament:"Filament",process:"Prozess",printer:"Drucker"},noFilamentPresets:"Keine Filament-Profile",noProcessPresets:"Keine Prozess-Profile",noPrinterPresets:"Keine Drucker-Profile",filters:{type:"Typ",owner:"Besitzer",printer:"Drucker",nozzle:"Düse",filament:"Filament",layer:"Schicht",all:"Alle",myPresets:"Meine Profile",builtIn:"Voreingestellt",process:"Prozess"},noTemplatesPermission:"Sie haben keine Berechtigung, Vorlagen zu verwalten",noRefreshPermission:"Sie haben keine Berechtigung, Profile zu aktualisieren",noCreatePermission:"Sie haben keine Berechtigung, Profile zu erstellen"},templates:{title:"Schnellvorlagen",noTemplates:"Noch keine Vorlagen",createFirst:"Erstellen Sie Vorlagen aus dem Preset-Editor",typeFilter:"Typ:",deleteTitle:"Vorlage löschen",deleteWarning:"Diese Aktion kann nicht rückgängig gemacht werden",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',namePlaceholder:"Vorlagenname",descriptionPlaceholder:"Beschreibung",settingsJson:"Einstellungen (JSON)",fieldsCount:"{{count}} Felder",shownInModals:"In Dialogen angezeigt",hiddenInModals:"In Dialogen ausgeblendet",apply:"Anwenden",toast:{deleted:"Vorlage gelöscht",updated:"Vorlage aktualisiert",created:"Vorlage erstellt",applied:"Vorlage angewendet"}}},support:{debugLoggingActive:"Debug-Protokollierung ist aktiv",manageLogs:"Verwalten",collectItem7:"Drucker-Verbindungsstatus und Firmware-Versionen",collectItem8:"Integrationsstatus (Spoolman, MQTT, HA)",collectItem9:"Netzwerkschnittstellen (nur Subnetze)",collectItem10:"Python-Paketversionen",collectItem11:"Datenbankzustandsprüfungen",collectItem12:"Docker-Umgebungsdetails"},fileManager:{title:"Dateimanager",subtitle:"Organisieren und verwalten Sie Ihre Druckdateien",uploadFiles:"Dateien hochladen",newFolder:"Neuer Ordner",folderName:"Ordnername",folderNamePlaceholder:"z.B. Funktionsteile",renameFile:"Datei umbenennen",renameFolder:"Ordner umbenennen",moveFiles:"{{count}} Datei(en) verschieben",rootNoFolder:"Stammverzeichnis (Kein Ordner)",current:"aktuell",linkFolder:"Ordner verknüpfen",linkFolderDescription:'"{{name}}" mit einem Projekt oder Archiv verknüpfen für schnellen Zugriff.',project:"Projekt",archive:"Archiv",noProjectsFound:"Keine Projekte gefunden",noArchivesFound:"Keine Archive gefunden",unlink:"Verknüpfung aufheben",link:"Verknüpfen",dragDropFiles:"Dateien hierher ziehen",dropFilesHere:"Dateien hier ablegen",orClickToBrowse:"oder klicken zum Durchsuchen",allFileTypesSupported:"Alle Dateitypen werden unterstützt. ZIP-Dateien werden extrahiert.",zipFilesDetected:"ZIP-Dateien erkannt",zipExtractOptions:"ZIP-Dateien werden extrahiert. Wählen Sie, wie die Ordnerstruktur behandelt werden soll:",preserveZipStructure:"Ordnerstruktur aus ZIP beibehalten",createFolderFromZip:"Ordner aus ZIP-Dateiname erstellen",stlThumbnailGeneration:"STL-Vorschaubildgenerierung",zipMayContainStl:"ZIP-Dateien können STL-Dateien enthalten. Vorschaubilder können während der Extraktion generiert werden.",thumbnailsCanBeGenerated:"Vorschaubilder können für STL-Dateien generiert werden. Große Modelle benötigen möglicherweise mehr Zeit.",generateThumbnailsForStl:"Vorschaubilder für STL-Dateien generieren",threemfDetected:"3MF-Dateien erkannt",threemfExtractionInfo:"Druckermodell, Material, Farbe und Druckeinstellungen werden automatisch aus 3MF-Dateien extrahiert.",willBeExtracted:"Wird extrahiert",filesExtracted:"{{count}} Dateien extrahiert",uploadComplete:"Upload abgeschlossen: {{succeeded}} erfolgreich",uploadFailed:"{{count}} fehlgeschlagen",uploading:"Hochladen...",changeLink:"Verknüpfung ändern...",linkTo:"Verknüpfen mit...",linkToProjectOrArchive:"Mit Projekt oder Archiv verknüpfen",addToQueue:"Zur Warteschlange",schedulePrint:"Planen",generateThumbnail:"Vorschaubild generieren",generateThumbnails:"Vorschaubilder generieren",generateThumbnailsForMissing:"Vorschaubilder für STL-Dateien ohne Vorschau generieren",gridView:"Rasteransicht",listView:"Listenansicht",lowDiskSpaceWarning:"Warnung: Wenig Speicherplatz",lowDiskSpaceDetails:"Nur {{free}} frei von {{total}} gesamt. Schwellenwert ist auf {{threshold}} GB eingestellt.",files:"Dateien",folders:"Ordner",size:"Größe",free:"Frei",allFiles:"Alle Dateien",wrap:"Umbrechen",enableTextWrapping:"Textumbruch aktivieren",disableTextWrapping:"Textumbruch deaktivieren",dragToResizeTooltip:"Ziehen zum Ändern der Größe, Doppelklick zum Zurücksetzen",searchFiles:"Dateien suchen...",allTypes:"Alle Typen",prints:"Drucke",ascending:"Aufsteigend",descending:"Absteigend",resultsCount:"{{showing}} von {{total}} Dateien",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",selected:"{{count}} ausgewählt",adding:"Hinzufügen...",loadingFiles:"Dateien werden geladen...",folderIsEmpty:"Ordner ist leer",noFilesYet:"Noch keine Dateien",folderEmptyDescription:"Laden Sie Dateien hoch oder verschieben Sie Dateien in diesen Ordner.",noFilesDescription:"Laden Sie Dateien hoch, um Ihre Druckdateien zu organisieren.",noMatchingFiles:"Keine passenden Dateien",noMatchingFilesDescription:"Keine Dateien entsprechen Ihren aktuellen Such- oder Filterkriterien.",clearFilters:"Filter zurücksetzen",printedCount:"{{count}}x gedruckt",uploadedBy:"Hochgeladen von",deleteFolder:"Ordner löschen",deleteFile:"Datei löschen",deleteFilesCount:"{{count}} Dateien löschen",deleteFolderConfirm:"Möchten Sie diesen Ordner wirklich löschen? Alle Dateien darin werden ebenfalls gelöscht.",deleteFileConfirm:"Möchten Sie diese Datei wirklich löschen?",deleteFilesConfirm:"Möchten Sie {{count}} ausgewählte Dateien wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",deleting:"Wird gelöscht...",noPermissionRenameFolder:"Sie haben keine Berechtigung, Ordner umzubenennen",noPermissionLinkFolder:"Sie haben keine Berechtigung, Ordner zu verknüpfen",noPermissionDeleteFolder:"Sie haben keine Berechtigung, Ordner zu löschen",noPermissionPrint:"Sie haben keine Berechtigung zum Drucken",noPermissionAddToQueue:"Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen",noPermissionDownload:"Sie haben keine Berechtigung, Dateien herunterzuladen",noPermissionRenameFile:"Sie haben keine Berechtigung, diese Datei umzubenennen",noPermissionGenerateThumbnail:"Sie haben keine Berechtigung, Vorschaubilder zu generieren",noPermissionDeleteFile:"Sie haben keine Berechtigung, diese Datei zu löschen",noPermissionCreateFolder:"Sie haben keine Berechtigung, Ordner zu erstellen",noPermissionUpload:"Sie haben keine Berechtigung, Dateien hochzuladen",noPermissionMoveFiles:"Sie haben keine Berechtigung, Dateien zu verschieben",noPermissionDeleteFiles:"Sie haben keine Berechtigung, Dateien zu löschen",toast:{folderCreated:"Ordner erstellt",folderDeleted:"Ordner gelöscht",fileDeleted:"Datei gelöscht",filesDeleted:"{{count}} Dateien gelöscht",filesMoved:"Dateien verschoben",folderLinked:"Ordner verknüpft",folderUnlinked:"Ordnerverknüpfung aufgehoben",addedToQueue:"{{count}} Datei(en) zur Warteschlange hinzugefügt",addedToQueuePartial:"{{added}} Datei(en) hinzugefügt, {{failed}} fehlgeschlagen",failedToAddToQueue:"Fehler beim Hinzufügen: {{error}}",fileRenamed:"Datei umbenannt",folderRenamed:"Ordner umbenannt",thumbnailsGenerated:"{{count}} Vorschaubild(er) generiert",thumbnailsGeneratedPartial:"{{succeeded}} Vorschaubild(er) generiert, {{failed}} fehlgeschlagen",noStlMissingThumbnails:"Keine STL-Dateien ohne Vorschaubild",failedToGenerateThumbnails:"Fehler beim Generieren der Vorschaubilder: {{error}}",thumbnailGenerated:"Vorschaubild generiert",failedToGenerateThumbnail:"Fehler beim Generieren des Vorschaubildes: {{error}}"}},projects:{title:"Projekte",subtitle:"Organisieren und verfolgen Sie Ihre 3D-Druckprojekte",newProject:"Neues Projekt",editProject:"Projekt bearbeiten",deleteProject:"Projekt löschen",projectName:"Projektname",description:"Beschreibung",noProjects:"Noch keine Projekte",noProjectsFiltered:"Keine {{status}} Projekte",noProjectsFilteredHelp:"Sie haben keine {{status}} Projekte. Projekte werden hier angezeigt, wenn sich ihr Status ändert.",createFirst:"Erstellen Sie Ihr erstes Projekt, um verwandte Drucke zu organisieren, den Fortschritt zu verfolgen und Ihre Builds zu verwalten.",createFirstButton:"Erstes Projekt erstellen",create:"Erstellen",files:"Dateien",prints:"Drucke",plates:"Platten",parts:"Teile",lastModified:"Zuletzt geändert",deleteConfirm:"Möchten Sie dieses Projekt wirklich löschen? Archive und Warteschlangenelemente werden getrennt, aber nicht gelöscht.",addFiles:"Dateien hinzufügen",removeFile:"Datei entfernen",viewDetails:"Details anzeigen",namePlaceholder:"z.B. Voron 2.4 Build",descriptionPlaceholder:"Optionale Beschreibung...",color:"Farbe",targetPlates:"Ziel-Platten",targetPlatesPlaceholder:"z.B. 25",targetPlatesHelp:"Anzahl der Druckaufträge",targetParts:"Ziel-Teile",targetPartsPlaceholder:"z.B. 150",targetPartsHelp:"Benötigte Objekte insgesamt",tagsLabel:"Tags (kommagetrennt)",tagsPlaceholder:"z.B. voron, funktional, geschenk",dueDate:"Fälligkeitsdatum",priority:"Priorität",priorityLow:"Niedrig",priorityNormal:"Normal",priorityHigh:"Hoch",priorityUrgent:"Dringend",statusActive:"Aktiv",statusCompleted:"Abgeschlossen",statusArchived:"Archiviert",done:"Fertig",completed:"abgeschlossen",failed:"fehlgeschlagen",inQueue:"in Warteschlange",noPrintsYet:"Noch keine Drucke",printJobs:"Druckaufträge (Platten)",partsPrinted:"Gedruckte Teile",failedParts:"Fehlgeschlagene Teile",import:"Importieren",export:"Exportieren",importProject:"Projekt importieren",exportAll:"Alle Projekte exportieren",loading:"Projekte werden geladen...",noEditPermission:"Sie haben keine Berechtigung, Projekte zu bearbeiten",noDeletePermission:"Sie haben keine Berechtigung, Projekte zu löschen",noCreatePermission:"Sie haben keine Berechtigung, Projekte zu erstellen",noImportPermission:"Sie haben keine Berechtigung, Projekte zu importieren",noExportPermission:"Sie haben keine Berechtigung, Projekte zu exportieren",toast:{created:"Projekt erstellt",updated:"Projekt aktualisiert",deleted:"Projekt gelöscht",imported:"Projekt importiert",multipleImported:"{{count}} Projekte importiert",importFailed:"Import fehlgeschlagen",exported:"Projekte exportiert (nur Metadaten)"}},projectDetail:{notFound:"Projekt nicht gefunden",backToProjects:"Zurück zu Projekten",export:"Exportieren",exportProject:"Projekt exportieren",noExportPermission:"Sie haben keine Berechtigung, Projekte zu exportieren",noEditPermission:"Sie haben keine Berechtigung, Projekte zu bearbeiten",partOf:"Teil von:",priorityLabel:"Priorität:",noPrints:"Noch keine Drucke in diesem Projekt",status:{active:"Aktiv",completed:"Abgeschlossen",archived:"Archiviert"},priority:{low:"Niedrig",normal:"Normal",high:"Hoch",urgent:"Dringend"},dueDate:{overdue:"Überfällig",today:"Heute fällig",daysLeft:"{{count}} Tage übrig"},progress:{platesProgress:"Platten-Fortschritt",partsProgress:"Teile-Fortschritt",printJobs:"Druckaufträge",parts:"Teile",percentComplete:"{{percent}}% abgeschlossen",remaining:"{{count}} verbleibend"},stats:{printJobs:"Druckaufträge",total:"gesamt",failed:"{{count}} fehlgeschlagen",partsPrinted:"{{count}} Teile gedruckt",printTime:"Druckzeit",filamentUsed:"Filament verbraucht"},cost:{title:"Kostenverfolgung",filamentCost:"Filamentkosten",energy:"Energie",budget:"Budget",remaining:"Verbleibend"},subProjects:{title:"Unterprojekte ({{count}})"},notes:{title:"Notizen",noEditPermission:"Sie haben keine Berechtigung, Notizen zu bearbeiten",placeholder:"Notizen zu diesem Projekt hinzufügen...",empty:"Noch keine Notizen. Klicken Sie auf Bearbeiten, um Notizen hinzuzufügen."},files:{title:"Dateien",linkFolders:"Ordner aus dem Dateimanager verknüpfen",forQuickAccess:"für schnellen Zugriff auf dieses Projekt.",fileCount:"{{count}} Datei(en)",empty:"Keine Ordner verknüpft. Gehen Sie zum Dateimanager und verknüpfen Sie einen Ordner mit diesem Projekt."},bom:{title:"Stückliste",acquired:"{{completed}}/{{total}} beschafft",showAll:"Alle anzeigen",hideDone:"Erledigte ausblenden",addPart:"Teil hinzufügen",noAddPermission:"Sie haben keine Berechtigung, Teile hinzuzufügen",partNamePlaceholder:"Teilename (z.B. M3x8 Schrauben)",partName:"Teilename",qty:"Menge",price:"Preis ({{currency}})",sourcingUrlPlaceholder:"Bezugsquelle-URL (optional)",remarksPlaceholder:"Bemerkungen (optional)",deletePart:"Teil löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',noUpdatePermission:"Sie haben keine Berechtigung, Teile zu aktualisieren",noEditPermission:"Sie haben keine Berechtigung, Teile zu bearbeiten",noDeletePermission:"Sie haben keine Berechtigung, Teile zu löschen",totalCost:"Gesamtkosten:",empty:"Keine Teile in der Stückliste. Fügen Sie Hardware, Elektronik oder andere Komponenten hinzu, um zu verfolgen, was beschafft werden muss."},timeline:{title:"Aktivitätsverlauf",empty:"Noch keine Aktivität."},template:{saveAsTemplate:"Als Vorlage speichern",noCreatePermission:"Sie haben keine Berechtigung, Vorlagen zu erstellen"},queue:{title:"Warteschlange",viewAll:"Alle anzeigen",printing:"{{count}} druckend",queued:"{{count}} in Warteschlange"},prints:{title:"Drucke ({{count}})"},toast:{projectUpdated:"Projekt aktualisiert",partAdded:"Teil hinzugefügt",partRemoved:"Teil entfernt",exportFailed:"Export fehlgeschlagen",projectExported:"Projekt exportiert",templateCreated:"Vorlage erstellt"}},system:{title:"Systeminformationen",version:"Version",uptime:"Laufzeit",cpuUsage:"CPU-Auslastung",memoryUsage:"Speicherauslastung",diskUsage:"Festplattenauslastung",networkInfo:"Netzwerkinformationen",logs:"Protokolle",debugMode:"Debug-Modus",enableDebug:"Debug-Protokollierung aktivieren",disableDebug:"Debug-Protokollierung deaktivieren",downloadLogs:"Protokolle herunterladen",clearLogs:"Protokolle löschen",dockerInfo:"Docker-Info",containerName:"Container-Name",imageName:"Image-Name",platform:"Plattform",architecture:"Architektur"},library:{title:"Filament-Bibliothek",addFilament:"Filament hinzufügen",editFilament:"Filament bearbeiten",deleteFilament:"Filament löschen",vendor:"Hersteller",material:"Material",color:"Farbe",kFactor:"K-Faktor",temperature:"Temperatur",noFilaments:"Keine Filamente in der Bibliothek",deleteConfirm:"Möchten Sie dieses Filament wirklich löschen?",importFromPrinter:"Vom Drucker importieren",exportToFile:"In Datei exportieren"},spoolman:{title:"Spoolman-Integration",enabled:"Spoolman aktiviert",url:"Spoolman URL",connected:"Verbunden",disconnected:"Nicht verbunden",testConnection:"Verbindung testen",sync:"Synchronisieren",syncing:"Synchronisiert...",lastSync:"Letzte Synchronisierung",linkToSpoolman:"Mit Spoolman verknüpfen",openInSpoolman:"In Spoolman öffnen",unlinkSpool:"Spule trennen",selectSpool:"Spule auswählen",noUnlinkedSpools:"Keine nicht verknüpften Spulen verfügbar",linkSuccess:"Spule erfolgreich mit Spoolman verknüpft",linkFailed:"Verknüpfung mit Spoolman fehlgeschlagen",spoolId:"Spulen-ID",fillSourceLabel:"(Spoolman)",weight:"Gewicht",remaining:"Verbleibend",disableWeightSync:"AMS-Gewichtsschätzung deaktivieren",disableWeightSyncDesc:"Verbleibende Kapazität nicht aus AMS-Schätzungen aktualisieren. Verwenden Sie dies, wenn Sie die Verbrauchserfassung von Spoolman gegenüber den prozentualen AMS-Schätzungen bevorzugen. Neue Spulen verwenden weiterhin die AMS-Schätzung als Anfangsgewicht.",reportPartialUsage:"Teilverbrauch bei fehlgeschlagenen Drucken melden",reportPartialUsageDesc:"Wenn ein Druck fehlschlägt oder abgebrochen wird, den geschätzten Filamentverbrauch bis zu diesem Zeitpunkt basierend auf dem Schichtfortschritt melden."},inventory:{title:"Spulen-Inventar",addSpool:"Spule hinzufügen",editSpool:"Spule bearbeiten",material:"Material",selectMaterial:"Material auswählen...",subtype:"Untertyp",brand:"Marke",searchBrand:"Marke suchen...",useCustomBrand:'"{{brand}}" verwenden',colorName:"Farbname",colorNamePlaceholder:"Jade White, Fire Red...",color:"Farbe",hexColor:"Hex-Farbe",pickColor:"Benutzerdefinierte Farbe wählen",labelWeight:"Nenngewicht",coreWeight:"Leergewicht der Spule",searchSpoolWeight:"Spulengewicht suchen...",weightUsed:"Verbraucht",currentWeight:"Restgewicht",slicerFilament:"Slicer-Filament",slicerFilamentName:"Slicer-Preset-Name",slicerPreset:"Slicer-Preset",searchPresets:"Filament-Presets suchen...",selectedPreset:"Ausgewählt",noPresetsFound:"Keine Presets gefunden",tempOverrides:"Temperatur-Überschreibungen",note:"Notiz",notePlaceholder:"Zusätzliche Notizen zu dieser Spule...",archive:"Archivieren",restore:"Wiederherstellen",noSpools:"Noch keine Spulen. Fügen Sie Ihre erste Spule hinzu.",noManualSpools:"Keine manuell hinzugefügten Spulen verfügbar. Fügen Sie zuerst eine Spule zum Inventar hinzu.",kProfiles:"K-Profile",addKProfile:"K-Profil hinzufügen",assignSpool:"Spule zuweisen",unassignSpool:"Zuweisung aufheben",assignSuccess:"Spule zugewiesen und AMS-Slot konfiguriert",assignFailed:"Spulenzuweisung fehlgeschlagen",selectSpool:"Wählen Sie eine Spule für diesen Slot",assigned:"Zugewiesen",assigning:"Wird zugewiesen...",searchSpools:"Spulen suchen...",allMaterials:"Alle Materialien",filterByBrand:"Nach Marke filtern...",showArchived:"Archivierte anzeigen",spoolCreated:"Spule erstellt",spoolUpdated:"Spule aktualisiert",spoolDeleted:"Spule gelöscht",spoolArchived:"Spule archiviert",spoolRestored:"Spule wiederhergestellt",deleteConfirm:"Möchten Sie diese Spule wirklich löschen? Dies kann nicht rückgängig gemacht werden.",advancedSettings:"Erweiterte Einstellungen",filamentInfoTab:"Filament-Info",paProfileTab:"PA-Profil",filamentInfo:"Filament",additional:"Zusätzlich",loadingPresets:"Cloud-Presets werden geladen...",cloudConnected:"Cloud verbunden",cloudNotConnected:"Cloud nicht verbunden (Standardwerte)",recentColors:"Zuletzt",searchColors:"Farben suchen...",searchResults:"Suchergebnisse",allColors:"Alle Farben",commonColors:"Häufige Farben",showLess:"Weniger",showAll:"Alle",noColorsFound:"Keine Farben gefunden",noResults:"Keine Ergebnisse",selectMaterialFirst:"Bitte zuerst ein Material im Filament-Info Tab auswählen.",noPrintersConfigured:"Keine Drucker konfiguriert. Fügen Sie Drucker hinzu.",matchingFilter:"Filter",anyBrand:"Jede Marke",anyVariant:"Jede Variante",autoSelect:"Auto-Auswahl",matches:"Treffer",match:"Treffer",noMatches:"Keine Treffer",connected:"Verbunden",offline:"Offline",printerOffline:"Drucker ist offline. Verbinden Sie ihn, um Kalibrierungsprofile anzuzeigen.",noKProfilesMatch:"Keine K-Profile stimmen mit dem gewählten Filament überein.",leftNozzle:"Linke Düse",rightNozzle:"Rechte Düse",profilesSelected:"Kalibrierungsprofil(e) ausgewählt",totalInventory:"Gesamtbestand",totalConsumed:"Gesamtverbrauch",byMaterial:"Nach Material",inPrinter:"Im Drucker",lowStock:"Niedriger Bestand",sinceTracking:"Seit Beginn der Erfassung",loadedInAms:"Im AMS/Ext geladen",remaining:"Verbleibend",lowStockThreshold:"<20% verbleibend",search:"Spulen suchen...",showing:"Zeige",to:"bis",of:"von",show:"Zeige",spools:"Spulen",spool:"Spule",page:"Seite",noSpoolsMatch:"Keine Ergebnisse",noSpoolsMatchDesc:"Versuchen Sie, Ihre Suche oder Filter anzupassen.",active:"Aktiv",archived:"Archiviert",all:"Alle",used:"Verwendet",new:"Neu",clearFilters:"Filter löschen",table:"Tabelle",cards:"Karten",net:"Netto",columns:"Spalten",configureColumns:"Spalten konfigurieren",configureColumnsDesc:"Ziehen zum Neuordnen oder Pfeile verwenden. Sichtbarkeit mit dem Augensymbol umschalten.",visible:"sichtbar",reset:"Zurücksetzen",cancel:"Abbrechen",applyChanges:"Änderungen anwenden",moveUp:"Nach oben",moveDown:"Nach unten",hideColumn:"Spalte ausblenden",showColumn:"Spalte einblenden",linkToSpool:"Mit Spule verknüpfen",tagLinked:"Tag mit Spule verknüpft",tagLinkFailed:"Tag-Verknüpfung fehlgeschlagen",tagAlreadyLinked:"Tag bereits mit anderer Spule verknüpft",unknownTag:"Unbekannter RFID-Tag erkannt",usageHistory:"Verbrauchshistorie",noUsageHistory:"Noch kein Verbrauch erfasst",printName:"Druckname",weightConsumed:"Verbrauchtes Gewicht",clearHistory:"Löschen",historyCleared:"Verbrauchshistorie gelöscht",fillSourceLabel:"(Inv)"},timelapse:{title:"Zeitraffer",create:"Zeitraffer erstellen",download:"Herunterladen",delete:"Löschen",preview:"Vorschau",frameRate:"Bildrate",quality:"Qualität",processing:"Wird verarbeitet...",noTimelapses:"Keine Zeitraffer verfügbar"},ams:{title:"AMS",slot:"Slot",empty:"Leer",emptySlot:"Leerer Slot",unknown:"Unbekannt",humidity:"Luftfeuchtigkeit",temperature:"Temperatur",filamentType:"Filamenttyp",filamentColor:"Farbe",remaining:"Verbleibend",history:"AMS-Verlauf",noHistory:"Kein Verlauf verfügbar",configureSlot:"Slot konfigurieren",externalSpool:"Externe Spule",profile:"Profil",kFactor:"K-Faktor",fill:"Füllstand",configure:"Konfigurieren"},printModal:{title:"Druck starten",selectPrinter:"Drucker auswählen",selectPlate:"Platte auswählen",filamentMapping:"Filamentzuordnung",printSettings:"Druckeinstellungen",bedLeveling:"Bett-Nivellierung",flowCalibration:"Fluss-Kalibrierung",vibrationCalibration:"Vibrations-Kalibrierung",layerInspection:"Erste-Schicht-Prüfung",timelapse:"Zeitraffer",startPrint:"Druck starten",addToQueue:"Zur Warteschlange hinzufügen",cancel:"Abbrechen",noPrintersAvailable:"Keine Drucker verfügbar",printerBusy:"Drucker ist beschäftigt",printerOffline:"Drucker ist offline",sameTypeDifferentColor:"Gleicher Typ, andere Farbe",filamentTypeNotLoaded:"Filamenttyp nicht geladen",openCalendar:"Kalender öffnen",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"Linke Düse",rightNozzleTooltip:"Rechte Düse"},backup:{title:"Sichern & Wiederherstellen",createBackup:"Sicherung erstellen",restoreBackup:"Sicherung wiederherstellen",restoreDescription:"Alle Daten aus einer Sicherungsdatei ersetzen",downloadBackup:"Sicherung herunterladen",uploadBackup:"Sicherung hochladen",lastBackup:"Letzte Sicherung",autoBackup:"Automatische Sicherung",backupNow:"Jetzt sichern",restoreWarning:"Warnung: Das Wiederherstellen einer Sicherung überschreibt alle aktuellen Daten.",includeArchives:"Archive einschließen",includeSettings:"Einstellungen einschließen",includeProfiles:"Profile einschließen",backupSuccess:"Sicherung erfolgreich erstellt",restoreSuccess:"Sicherung erfolgreich wiederhergestellt",backupFailed:"Sicherung fehlgeschlagen",restoreFailed:"Wiederherstellung fehlgeschlagen",restoreNote:"Virtueller Drucker wird während der Wiederherstellung gestoppt"},tags:{title:"Tags",addTag:"Tag hinzufügen",editTag:"Tag bearbeiten",deleteTag:"Tag löschen",tagName:"Tag-Name",tagColor:"Tag-Farbe",noTags:"Keine Tags",deleteConfirm:"Möchten Sie diesen Tag wirklich löschen?",manageTags:"Tags verwalten"},uploadModal:{title:"3MF-Dateien hochladen",dragDrop:"3MF-Dateien hierher ziehen",or:"oder",browseFiles:"Dateien durchsuchen",extractionInfo:"Das Druckermodell wird automatisch aus den 3MF-Datei-Metadaten extrahiert.",uploaded:"hochgeladen",failed:"fehlgeschlagen",uploading:"Wird hochgeladen...",upload:"Hochladen",uploadFailed:"Hochladen fehlgeschlagen"},editArchive:{title:"Archiv bearbeiten",name:"Name",namePlaceholder:"Druckname",printer:"Drucker",noPrinter:"Kein Drucker",project:"Projekt",noProject:"Kein Projekt",itemsPrinted:"Gedruckte Teile",itemsPrintedHelp:"Anzahl der in diesem Druckauftrag produzierten Teile",notes:"Notizen",notesPlaceholder:"Notizen zu diesem Druck hinzufügen...",externalLink:"Externer Link",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link zu Printables, Thingiverse oder anderer Quelle",tags:"Tags",tagsPlaceholder:"Tags hinzufügen...",addMoreTags:"Weitere Tags hinzufügen...",matchingTags:'Übereinstimmend mit "{{query}}"',existingTags:"Vorhandene Tags",clickToAdd:"(zum Hinzufügen klicken)",status:"Status",failureReason:"Fehlergrund",selectReason:"Grund auswählen...",photos:"Fotos des Druckergebnisses",photosHelp:"Klicken Sie auf + um Fotos Ihres Druckergebnisses hinzuzufügen",printResult:"Druckergebnis",saving:"Wird gespeichert...",failureReasons:{adhesionFailure:"Haftungsfehler",spaghettiDetached:"Spaghetti / Abgelöst",layerShift:"Schichtversatz",cloggedNozzle:"Verstopfte Düse",filamentRunout:"Filament aufgebraucht",warping:"Verformung",stringing:"Fadenziehen",underExtrusion:"Unterextrusion",powerFailure:"Stromausfall",userCancelled:"Vom Benutzer abgebrochen",other:"Sonstiges"},statuses:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",aborted:"Abgebrochen",printing:"Druckt"}},kProfiles:{title:"K-Profile",noPrintersConfigured:"Keine Drucker konfiguriert",addPrinterInSettings:"Fügen Sie einen Drucker in den Einstellungen hinzu, um K-Profile zu verwalten",noActivePrinters:"Keine aktiven Drucker",enablePrinterConnection:"Aktivieren Sie eine Druckerverbindung, um K-Profile anzuzeigen",loadingProfiles:"Lade K-Profile...",printerOffline:"Drucker offline",printerOfflineDesc:"Der ausgewählte Drucker ist nicht verbunden. Schalten Sie ihn ein, um K-Profile anzuzeigen.",noMatchingProfiles:"Keine passenden Profile",noMatchingProfilesDesc:"Keine Profile entsprechen Ihren Suchkriterien",noKProfiles:"Keine K-Profile",noKProfilesDesc:"Keine Druckvorschub-Profile für {{diameter}}mm Düse gefunden",createFirstProfile:"Erstes Profil erstellen",printer:"Drucker",nozzle:"Düse",refresh:"Aktualisieren",addProfile:"Profil hinzufügen",export:"Exportieren",import:"Importieren",select:"Auswählen",selectAll:"Alle auswählen",delete:"Löschen",searchPlaceholder:"Nach Name oder Filament suchen...",allExtruders:"Alle Extruder",leftOnly:"Nur links",rightOnly:"Nur rechts",allFlow:"Alle Flusstypen",hfOnly:"Nur HF",sOnly:"Nur S",sortName:"Sortieren: Name",sortKValue:"Sortieren: K-Wert",sortFilament:"Sortieren: Filament",leftExtruder:"Linker Extruder",rightExtruder:"Rechter Extruder",modal:{addTitle:"K-Profil hinzufügen",editTitle:"K-Profil bearbeiten",profileName:"Profilname",profileNamePlaceholder:"Mein PLA-Profil",kValue:"K-Wert",kValuePlaceholder:"0,020",kValueHelp:"Typischer Bereich: 0,01 - 0,06 für PLA, 0,02 - 0,10 für PETG",filament:"Filament",selectFilament:"Filament auswählen...",noFilamentsHelp:"Keine Filamente gefunden. Erstellen Sie zuerst ein K-Profil in Bambu Studio.",flowType:"Flusstyp",highFlow:"High Flow",standard:"Standard",nozzleSize:"Düsengröße",extruder:"Extruder",extruders:"Extruder",left:"Links",right:"Rechts",notes:"Notizen (lokal gespeichert)",notesPlaceholder:"Notizen zu diesem Profil hinzufügen...",notesHelp:"Notizen werden in Bambuddy gespeichert, nicht auf dem Drucker",syncing:"Synchronisiert mit Drucker...",savingExtruder:"Speichern auf Extruder {{current}}/{{total}}...",pleaseWait:"Bitte warten"},deleteConfirm:{title:"Profil löschen",cannotUndo:"Dies kann nicht rückgängig gemacht werden",message:'Möchten Sie "{{name}}" wirklich vom Drucker löschen?'},bulkDelete:{title:"Profile löschen",cannotUndo:"Dies kann nicht rückgängig gemacht werden",message:"Möchten Sie wirklich {{count}} ausgewählte Profile vom Drucker löschen?"},toast:{profileSaved:"K-Profil gespeichert",profilesSaved:"K-Profil auf {{count}} Extrudern gespeichert",selectAtLeastOneExtruder:"Bitte wählen Sie mindestens einen Extruder aus",profileDeleted:"K-Profil gelöscht",profilesDeleted:"{{count}} Profile gelöscht",exportedProfiles:"{{count}} Profile exportiert",importedProfiles:"{{count}} von {{total}} Profilen importiert",noProfilesToExport:"Keine Profile zum Exportieren",invalidFileFormat:"Ungültiges Dateiformat",failedToParseImport:"Import-Datei konnte nicht gelesen werden",failedToSaveBatch:"K-Profile konnten nicht gespeichert werden",noteSaved:"Notiz gespeichert",failedToSaveNote:"Notiz konnte nicht gespeichert werden"},permission:{noRead:"Sie haben keine Berechtigung, Profile zu aktualisieren",noCreate:"Sie haben keine Berechtigung, Profile hinzuzufügen",noUpdate:"Sie haben keine Berechtigung, K-Profile zu aktualisieren",noDelete:"Sie haben keine Berechtigung, K-Profile zu löschen",noExport:"Sie haben keine Berechtigung, Profile zu exportieren",noImport:"Sie haben keine Berechtigung, Profile zu importieren"}},virtualPrinter:{title:"Virtueller Drucker",running:"Läuft",stopped:"Gestoppt",description:{default:"Aktiviere einen virtuellen Drucker, der in Bambu Studio und OrcaSlicer erscheint. Dateien, die an diesen Drucker gesendet werden, werden direkt archiviert ohne zu drucken.",proxy:"Aktiviere einen Proxy, der Slicer-Datenverkehr an einen echten Drucker weiterleitet, um Ferndruck über jedes Netzwerk zu ermöglichen."},enable:{title:"Virtuellen Drucker aktivieren",visibleInSlicer:'Sichtbar als "Bambuddy" in der Slicer-Erkennung',proxyingTo:"Proxy zu {{name}}",notActive:"Nicht aktiv"},model:{title:"Druckermodell",description:"Wähle welches Druckermodell emuliert werden soll.",restartWarning:"Das Ändern des Modells startet den virtuellen Drucker neu"},accessCode:{title:"Zugangscode",isSet:"Zugangscode ist gesetzt",notSet:"Kein Zugangscode gesetzt - erforderlich zum Aktivieren",placeholder:"8-Zeichen-Code eingeben",placeholderChange:"Neuen Code eingeben zum Ändern",hint:"Muss genau 8 Zeichen lang sein. Wird von Slicern zur Authentifizierung verwendet.",charCount:"({{count}}/8)"},targetPrinter:{title:"Zieldrucker",configured:"Proxy-Ziel konfiguriert",notConfigured:"Kein Zieldrucker ausgewählt - erforderlich für Proxy-Modus",placeholder:"Drucker auswählen...",hint:"Wähle den Drucker aus, an den der Slicer-Datenverkehr weitergeleitet werden soll. Der Drucker muss im LAN-Modus sein.",noPrinters:"Keine Drucker konfiguriert. Füge zuerst einen Drucker hinzu, um den Proxy-Modus zu verwenden."},remoteInterface:{title:"Netzwerkschnittstelle überschreiben",configured:"Schnittstellenüberschreibung aktiv",optional:"Optional - verwenden wenn die automatisch erkannte IP falsch ist (z.B. mehrere NICs, Docker, VPN)",placeholder:"Automatisch erkennen (Standard)...",hint:"Überschreibt die per SSDP beworbene und im TLS-Zertifikat verwendete IP-Adresse. Nützlich wenn Bambuddy mehrere Netzwerkschnittstellen hat."},mode:{title:"Modus",archive:"Archivieren",archiveDesc:"Dateien sofort archivieren",review:"Überprüfen",reviewDesc:"Vor dem Archivieren überprüfen",queue:"Warteschlange",queueDesc:"Archivieren und zur Warteschlange hinzufügen",proxy:"Proxy",proxyDesc:"An echten Drucker weiterleiten"},setupRequired:{title:"Einrichtung erforderlich",description:"Die virtuelle Druckerfunktion erfordert zusätzliche Systemkonfiguration, bevor sie funktioniert. Dies beinhaltet Portweiterleitung, Firewall-Regeln und plattformspezifische Einstellungen.",readGuide:"Lese die Einrichtungsanleitung vor dem Aktivieren"},howItWorks:{title:"So funktioniert es",titleProxy:"So funktioniert es (Proxy-Modus)",step1:"Schließe die Einrichtungsanleitung für deine Plattform ab",step2:"Aktiviere den virtuellen Drucker und setze einen Zugangscode",step3:'In Bambu Studio oder OrcaSlicer gehe zu "Drucker hinzufügen"',step4:'Der "Bambuddy"-Drucker sollte in der Erkennungsliste erscheinen',step5:"Verbinde mit dem von dir gesetzten Zugangscode",step6:'Wenn du zu Bambuddy "druckst", wird die 3MF-Datei stattdessen archiviert',proxyStep1:"Wähle den Zieldrucker (muss im LAN-Modus sein)",proxyStep2:"Bei Netzwerkübergreifend: Wähle die Slicer-Netzwerkschnittstelle",proxyStep3:"Aktiviere den Proxy - Drucker erscheint per SSDP in der Slicer-Erkennung",proxyStep4:"Verbinde mit dem Zugangscode des Druckers",proxyStep5:"Drucke wie gewohnt - der Datenverkehr wird über Bambuddy weitergeleitet",proxyStep6:"Kamera-Streaming erfordert NAT/IP-Weiterleitung (siehe Dokumentation)"},status:{title:"Status-Details",printerName:"Druckername",model:"Modell",serialNumber:"Seriennummer",mode:"Modus",pendingFiles:"Ausstehende Dateien",targetPrinter:"Zieldrucker",ftpPort:"FTP-Port",mqttPort:"MQTT-Port",ftpConnections:"FTP-Verbindungen",mqttConnections:"MQTT-Verbindungen"},toast:{updated:"Virtuelle Druckereinstellungen aktualisiert",failedToUpdate:"Einstellungen konnten nicht aktualisiert werden",accessCodeRequired:"Bitte zuerst einen Zugangscode setzen",targetPrinterRequired:"Bitte zuerst einen Zieldrucker auswählen",accessCodeEmpty:"Zugangscode darf nicht leer sein",accessCodeLength:"Zugangscode muss genau 8 Zeichen lang sein"}},modelViewer:{openInSlicer:"Im Slicer öffnen",tabs:{model:"3D-Modell",gcode:"G-Code Vorschau"},notAvailable:"nicht verfügbar",notSliced:"nicht geslicet",plates:"Platten",allPlates:"Alle Platten",plateNumber:"Platte {{number}}",plateCount:"{{count}} Platte",plateCount_other:"{{count}} Platten",objectCount:"{{count}} Objekt",objectCount_other:"{{count}} Objekte",filamentCount:"{{count}} Filament",filamentCount_other:"{{count}} Filamente",eta:"ETA {{minutes}} Min",noPreview:"Keine Vorschau für diese Datei verfügbar",pagination:{pageOf:"Seite {{current}} von {{total}}",prev:"Zurück",next:"Weiter"},errors:{failedToLoad:"Datei konnte nicht geladen werden",noMeshes:"Keine Meshes in 3MF-Datei gefunden",unsupportedFormat:"Nicht unterstütztes Dateiformat"}},maintenanceDescriptions:{lubricateRails:"Schmiermittel auf Linearschienen für sanfte Bewegung auftragen",cleanNozzle:"Hotend und Düse reinigen, um Verstopfungen zu verhindern",checkBelts:"Riemenspannung für präzise Drucke überprüfen",cleanBuildPlate:"Druckplatte für bessere Haftung reinigen",checkExtruder:"Extruderzahnräder auf Verschleiß prüfen",checkCooling:"Sicherstellen, dass Lüfter ordnungsgemäß funktionieren",generalInspection:"Allgemeine Druckerinspektion",cleanCarbonRods:"Karbonstäbe reinigen, um Reibung zu reduzieren",checkPtfeTube:"PTFE-Schlauch auf Verschleiß oder Beschädigung prüfen",replaceHepaFilter:"HEPA-Filter für Luftqualität ersetzen",replaceCarbonFilter:"Aktivkohlefilter ersetzen",lubricateLeftNozzleRail:"Linke Düsenschiene schmieren (H2-Serie)"},smartPlugs:{offline:"Offline",admin:"Admin",openPlugAdminPage:"Plug-Admin-Seite öffnen",deleteSmartPlug:"Smart Plug löschen",turnOnSmartPlug:"Smart Plug einschalten",turnOffSmartPlug:"Smart Plug ausschalten",turnOn:"Einschalten",turnOff:"Ausschalten",addSmartPlug:{scanningNetwork:"Netzwerk wird durchsucht...",chooseEntity:"Entität auswählen...",connectionFailed:"Verbindung fehlgeschlagen",searchEntities:"Entitäten suchen...",searchPowerSensors:"Leistungssensoren suchen...",searchEnergySensors:"Energiesensoren suchen...",placeholders:{plugName:"Wohnzimmer Steckdose",mqttStateOnValue:"ON, true, 1",mqttSameAsPower:"Gleich wie Leistungs-Topic oder anders"}}},richTextEditor:{bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",bulletList:"Aufzählungsliste",numberedList:"Nummerierte Liste",alignLeft:"Linksbündig",alignCenter:"Zentriert",alignRight:"Rechtsbündig",addLink:"Link hinzufügen",removeLink:"Link entfernen"},externalLinks:{noLinksConfigured:"Keine externen Links konfiguriert",deleteLink:"Link löschen",removeCustomIcon:"Benutzerdefiniertes Symbol entfernen",openInNewTab:"In neuem Tab öffnen",placeholders:{linkName:"Mein Link"}},keyboardShortcuts:{title:"Tastaturkürzel",navigation:"Navigation",archivesSection:"Archive",kProfilesSection:"K-Profile",generalSection:"Allgemein",shortcuts:{goToPrinters:"Zu Drucker gehen",goToArchives:"Zu Archiv gehen",goToQueue:"Zur Warteschlange gehen",goToStats:"Zu Statistiken gehen",goToProfiles:"Zu Cloud-Profilen gehen",goToSettings:"Zu Einstellungen gehen",focusSearch:"Suche fokussieren",openUploadModal:"Upload-Modal öffnen",clearSelection:"Auswahl löschen / Eingabe aufheben",contextMenu:"Kontextmenü auf Karten",refreshProfiles:"Profile aktualisieren",newProfile:"Neues Profil",exitSelectionMode:"Auswahlmodus beenden",showHelp:"Diese Hilfe anzeigen"},footer:"Drücken Sie Esc oder klicken Sie außerhalb, um zu schließen"},notificationLog:{title:"Benachrichtigungsprotokoll",events:{printStarted:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",progress:"Fortschritt",printerOffline:"Drucker offline",printerError:"Druckerfehler",lowFilament:"Wenig Filament",maintenanceDue:"Wartung fällig",test:"Test"},timeAgo:{justNow:"Gerade eben",minutesAgo:"vor {{minutes}}m",hoursAgo:"vor {{hours}}h"}},restoreBackup:{title:"Backup wiederherstellen",restoring:"Wird wiederhergestellt...",restoreComplete:"Wiederherstellung abgeschlossen",restoreFailed:"Wiederherstellung fehlgeschlagen",importSettings:"Einstellungen aus Backup-Datei importieren",pleaseWait:"Bitte warten Sie, während Ihre Daten wiederhergestellt werden",clickToSelect:"Klicken Sie, um Backup-Datei auszuwählen (.json oder .zip)",howDuplicateHandling:"So funktioniert die Duplikatbehandlung:",categories:{printers:"Drucker",smartPlugs:"Smart Plugs",notificationProviders:"Benachrichtigungsanbieter",filaments:"Filamente",archives:"Archive",pendingUploads:"Ausstehende Uploads",settingsTemplates:"Einstellungen & Vorlagen"},matchingInfo:{printers:"abgeglichen nach Seriennummer",smartPlugs:"abgeglichen nach IP-Adresse",notificationProviders:"abgeglichen nach Name",filaments:"abgeglichen nach Name + Typ + Marke",archives:"abgeglichen nach Inhalts-Hash",pendingUploads:"abgeglichen nach Dateiname",settingsTemplates:"immer überschrieben"},replaceExisting:"Vorhandene Daten ersetzen",keepExisting:"Vorhandene Daten behalten",replaceDescription:"Bereits vorhandene Elemente mit Backup-Daten überschreiben",keepDescription:"Nur Elemente wiederherstellen, die noch nicht existieren",caution:"Vorsicht:",cautionText:"Das Überschreiben ersetzt Ihre aktuellen Konfigurationen durch Backup-Daten. Drucker-Zugangscodes werden aus Sicherheitsgründen niemals überschrieben.",itemsRestored:"Wiederhergestellte Elemente",itemsSkipped:"Übersprungene Elemente",restored:"Wiederhergestellt",skipped:"Übersprungen (existieren bereits)",filesLabel:"Dateien (3MF, Thumbnails, etc.)",newApiKeysGenerated:"Neue API-Schlüssel generiert",newApiKeysWarning:"Diese Schlüssel werden nur einmal angezeigt. Kopieren Sie sie jetzt!",processingBackup:"Backup-Datei wird verarbeitet...",noDataFound:"In der Backup-Datei wurden keine wiederherzustellenden Daten gefunden.",failedToRestore:"Backup konnte nicht wiederhergestellt werden. Bitte überprüfen Sie das Dateiformat."},backupExport:{title:"Backup exportieren",selectData:"Zu exportierende Daten auswählen",selectAll:"Alle auswählen",selectNone:"Keine auswählen",categoryDescriptions:{settings:"Sprache, Theme, Update-Einstellungen",notifications:"ntfy, Pushover, Discord, usw.",templates:"Benutzerdefinierte Nachrichtenvorlagen",smartPlugs:"Tasmota-Plug-Konfigurationen",externalLinks:"Seitenleiste Links zu externen Diensten",printers:"Druckerinformationen (Zugangscodes ausgeschlossen)",plateDetection:"Leere Platten-Referenzbilder",filaments:"Filamenttypen und -kosten",maintenance:"Benutzerdefinierte Wartungspläne",archives:"Alle Druckdaten + Dateien (3MF, Thumbnails, Fotos)",projects:"Projekte, BOM-Elemente und Anhänge",pendingUploads:"Virtueller Drucker-Uploads zur Überprüfung",apiKeys:"Webhook-API-Schlüssel (neue Schlüssel bei Import generiert)"},requiresPrinters:"Drucker müssen ausgewählt sein",zipFileWarning:"ZIP-Datei wird erstellt.",zipFileDescription:"Enthält alle 3MF-Dateien, Thumbnails, Zeitraffer und Fotos. Dies kann eine Weile dauern und zu einer großen Datei führen.",includeAccessCodes:"Zugangscodes einschließen",includeAccessCodesDescription:"Für die Übertragung auf eine andere Maschine",includeAccessCodesWarning:"Zugangscodes werden im Klartext eingeschlossen. Bewahren Sie diese Backup-Datei sicher auf!",categoriesSelected:"{{selectedCount}} Kategorien ausgewählt"},pendingUploads:{placeholders:{notes:"Notizen zu diesem Druck hinzufügen..."},discardUpload:"Upload verwerfen",archiveAllUploads:"Alle Uploads archivieren",discardAllUploads:"Alle Uploads verwerfen",archive:"Archivieren",timeAgo:{justNow:"Gerade eben",minutesAgo:"vor {{minutes}}m",hoursAgo:"vor {{hours}}h",daysAgo:"vor {{days}}d"}},apiBrowser:{placeholders:{requestBody:"JSON-Anforderungstext...",searchEndpoints:"Endpunkte suchen..."}},configureAmsSlot:{searchPresets:"Voreinstellungen suchen...",colorPlaceholder:"Farbname oder Hex (z.B. braun, FF8800)",clearCustomColor:"Benutzerdefinierte Farbe löschen",noCloudPresets:"Keine Cloud-Voreinstellungen. Melden Sie sich bei Bambu Cloud an, um zu synchronisieren.",noMatchingPresets:"Keine passenden Voreinstellungen gefunden.",custom:"Benutzerdefiniert",builtin:"Integriert",settingsSentToPrinter:"Einstellungen an Drucker gesendet",filamentProfile:"Filamentprofil"},githubBackup:{title:"GitHub-Backup",history:"Verlauf",downloadBackup:"Backup herunterladen",restoreBackup:"Backup wiederherstellen",noBackupsYet:"Noch keine Backups"},emailSettings:{placeholders:{fromName:"BamBuddy"}},tagManagement:{searchTags:"Tags suchen...",renameTag:"Tag umbenennen",deleteTag:"Tag löschen"},notificationTemplates:{placeholders:{title:"Benachrichtigungstitel...",body:"Benachrichtigungstext..."}},batchTag:{placeholders:{newTag:"Neuen Tag eingeben..."}},photoGallery:{deletePhoto:"Foto löschen"},filamentHoverCard:{copySpoolUuid:"Spulen-UUID kopieren"},kProfilesView:{hasNote:"Hat Notiz",copyProfile:"Profil kopieren"},layout:{openMenu:"Menü öffnen",noPermissionSystemInfo:"Sie haben keine Berechtigung zum Anzeigen von Systeminformationen"},dashboard:{dragToReorder:"Ziehen zum Neuordnen",hideWidget:"Widget ausblenden"},notificationProviderCard:{deleteNotificationProvider:"Benachrichtigungsanbieter löschen"},fileManagerModal:{closeFileManager:"Dateimanager schließen",sortFiles:"Dateien sortieren",goToParentFolder:"Zum übergeordneten Ordner gehen",threeView:"3D-Ansicht"},embeddedCameraViewer:{refreshStream:"Stream aktualisieren",close:"Schließen",zoomOut:"Verkleinern",resetZoom:"Zoom zurücksetzen",zoomIn:"Vergrößern",dragToResize:"Ziehen zum Größe ändern"},timelapseViewer:{skipBack5s:"5s zurückspringen",skipForward5s:"5s vorspringen"},notificationProviders:{descriptions:{email:"SMTP-E-Mail-Benachrichtigungen",telegram:"Benachrichtigungen über Telegram-Bot",discord:"An Discord-Kanal über Webhook senden",ntfy:"Kostenlose, selbst hostbare Push-Benachrichtigungen",pushover:"Einfache, zuverlässige Push-Benachrichtigungen",callmebot:"Kostenlose WhatsApp-Benachrichtigungen über CallMeBot",webhook:"Generischer HTTP POST zu beliebiger URL"}},logViewer:{searchPlaceholder:"Nachricht oder Logger-Name suchen...",noLogEntries:"Keine Logeinträge gefunden"},switchbarPopover:{noSwitchesInSwitchbar:"Keine Schalter in Schalterleiste"},projectPageModal:{placeholders:{title:"Titel",designer:"Designer",license:"Lizenz",description:"Beschreibung eingeben...",profileTitle:"Profil-Titel",profileDescription:"Profilbeschreibung..."}},spoolmanSettings:{}},Moe={nav:{printers:"プリンター",archives:"アーカイブ",queue:"キュー",stats:"統計",profiles:"プロファイル",maintenance:"メンテナンス",projects:"プロジェクト",inventory:"フィラメント",files:"ファイル管理",settings:"設定",system:"システム",collapseSidebar:"サイドバーを閉じる",expandSidebar:"サイドバーを開く",update:"アップデート",updateAvailable:"アップデートあり: v{{version}}",viewOnGithub:"GitHubで表示",keyboardShortcuts:"キーボードショートカット (?)",switchToLight:"ライトモードに切替",switchToDark:"ダークモードに切替",smartSwitches:"スマートスイッチ",logout:"ログアウト",updateAvailableBanner:"バージョン {{version}} が利用可能です!",viewUpdate:"アップデートを表示"},common:{save:"保存",saving:"保存中...",cancel:"キャンセル",delete:"削除",edit:"編集",add:"追加",close:"閉じる",confirm:"確認",loading:"読み込み中...",error:"エラー",success:"成功",warning:"警告",enabled:"有効",disabled:"無効",yes:"はい",no:"いいえ",on:"オン",off:"オフ",all:"すべて",none:"なし",search:"検索",filter:"フィルター",sort:"並べ替え",refresh:"更新",download:"ダウンロード",upload:"アップロード",actions:"操作",status:"ステータス",name:"名前",description:"説明",date:"日付",time:"時間",hours:"時間",minutes:"分",seconds:"秒",disable:"無効にする",permissions:"権限",noPrinters:"プリンターが登録されていません",noData:"データがありません",required:"必須",optional:"オプション",dismiss:"閉じる",apply:"適用",clear:"クリア",noChange:"— 変更なし —",unassigned:"未割当",unknown:"不明",unknownError:"不明なエラー",today:"今日",asap:"即時",now:"今すぐ",collapse:"折りたたむ",expand:"展開",viewArchive:"アーカイブを表示",viewInFileManager:"ファイルマネージャーで表示",addedBy:"{{username}}が追加",more:"もっと見る",printer:"プリンター",type:"種類",print:"印刷",rename:"名前変更",move:"移動",create:"作成",days:"日",enable:"有効化",linkNotFound:"リンクが見つかりません",reset:"リセット",export:"エクスポート",import:"インポート",selectAll:"すべて選択",deselectAll:"すべて選択解除",unchanged:"変更なし",overdue:"期限超過",prints:"プリント",ascending:"昇順",descending:"降順",remove:"削除",duplicate:"複製",left:"左",right:"右",done:"完了",saveChanges:"変更を保存",turnOn:"オンにする",turnOff:"オフにする",deletePhoto:"写真を削除",deletePhotoConfirm:"この写真を削除しますか?元に戻せません。",project:"プロジェクト",archive:"アーカイブ",show:"表示",hide:"非表示",back:"戻る",retry:"リトライ",model:"モデル",ok:"OK"},printers:{title:"プリンター",addPrinter:"プリンターを追加",editPrinter:"プリンターを編集",deletePrinter:"プリンターを削除",printerName:"プリンター名",serialNumber:"シリアル番号",ipAddress:"IPアドレス / ホスト名",accessCode:"アクセスコード",model:"モデル",nozzleCount:"ノズル数",autoArchive:"自動アーカイブ",status:{idle:"待機中",printing:"印刷中",paused:"一時停止",offline:"オフライン",finished:"完了",unknown:"不明",error:"エラー"},temperatures:{nozzle:"ノズル",bed:"ベッド",chamber:"チャンバー"},progress:"{{percent}}% 完了",timeRemaining:"残り {{time}}",maintenanceOk:"メンテナンス正常",maintenanceWarning:"{{count}}件の警告",maintenanceWarning_plural:"{{count}}件の警告",maintenanceDue:"{{count}}件のメンテナンス期限",sort:{name:"名前",status:"ステータス",model:"モデル",location:"ロケーション",ascending:"昇順で並べ替え",descending:"降順で並べ替え"},cardSize:{small:"小",medium:"中",large:"大",extraLarge:"特大"},hideOffline:"オフラインを非表示",powerOn:"電源オン",noPrintersConfigured:"プリンターが設定されていません",readyToPrint:"印刷可能",external:"外部",deleteArchives:"印刷アーカイブを削除",willBeSkipped:"スキップされます",name:"名前",wifiSignal:{veryWeak:"非常に弱い",weak:"弱い",fair:"注意",good:"良好",excellent:"非常に良い"},maintenanceUpToDate:"すべてのメンテナンスが最新です",chamberLightOn:"チャンバーライトをオンにしました",chamberLightOff:"チャンバーライトをオフにしました",browseFiles:"プリンターのファイルを参照",hmsErrors:"クリックしてHMSエラーを表示",resume:"再開",pause:"一時停止",stop:"停止",reconnect:"再接続",mqttDebug:"MQTTデバッグ",activeNozzle:"アクティブ: {{side}}ノズル",nozzleRack:"ノズルラック",nozzleDocked:"ドッキング中",nozzleMounted:"マウント中",nozzleActive:"アクティブ",nozzleIdle:"アイドル",nozzleDiameter:"直径",nozzleType:"タイプ",nozzleStatus:"ステータス",nozzleFilament:"フィラメント",nozzleWear:"摩耗",nozzleMaxTemp:"最高温度",nozzleSerial:"シリアル",nozzleHardenedSteel:"焼入れ鋼",nozzleStainlessSteel:"ステンレス鋼",nozzleTungstenCarbide:"タングステンカーバイド",nozzleFlow:"フロー",nozzleHighFlow:"ハイフロー",nozzleStandardFlow:"スタンダード",toast:{printStopped:"印刷を停止しました",printPaused:"印刷を一時停止しました",printResumed:"印刷を再開しました",failedToSkipObjects:"オブジェクトのスキップに失敗しました",rfidRereadInitiated:"RFID再読み取りを開始しました",printerDeleted:"プリンターを削除しました",printerAdded:"プリンターを追加しました",printerUpdated:"プリンターを更新しました",failedToDelete:"プリンターの削除に失敗しました",failedToAdd:"プリンターの追加に失敗しました",failedToUpdate:"プリンターの更新に失敗しました",commandSent:"コマンドを送信しました",failedToSendCommand:"コマンドの送信に失敗しました",turnedOn:"{{name}} の電源をオンにしました",failedToPowerOn:"{{name}} の電源オンに失敗しました",scriptTriggered:"スクリプトを実行しました",referenceDeleted:"リファレンスを削除しました",detectionAreaSaved:"検出エリアを保存しました",failedToDiscover:"プリンターの検出に失敗しました",cloudLoginRequired:"クラウドログインが必要です",failedToRunScript:"スクリプトの実行に失敗しました",failedToStopPrint:"印刷の停止に失敗しました",failedToPausePrint:"印刷の一時停止に失敗しました",failedToResumePrint:"印刷の再開に失敗しました",failedToControlChamberLight:"チャンバーライトの制御に失敗しました",failedToUpdateSetting:"設定の更新に失敗しました",failedToRereadRfid:"RFIDの再読み取りに失敗しました",failedToCheckPlate:"プレートの確認に失敗しました",failedToUpdateLabel:"ラベルの更新に失敗しました",failedToDeleteReference:"リファレンスの削除に失敗しました",failedToSaveDetectionArea:"検出エリアの保存に失敗しました",plateCheckEnabled:"プレートチェックを有効にしました",plateCheckDisabled:"プレートチェックを無効にしました",calibrationSaved:"キャリブレーションを保存しました!",calibrationFailed:"キャリブレーションに失敗しました"},connection:{connected:"接続中",offline:"オフライン"},queue:{inQueue:"キュー内",inQueue_plural:"{{count}}件がキュー内"},controls:"コントロール",permission:{noFiles:"このディレクトリにファイルがありません",noAdd:"プリンターを追加する権限がありません",noEdit:"プリンターを編集する権限がありません",noDelete:"プリンターを削除する権限がありません",noControl:"プリンターを制御する権限がありません",noAmsRfid:"AMS RFIDを再読み取りする権限がありません",noSmartPlugControl:"スマートプラグを制御する権限がありません"},modal:{selectModel:"モデルを選択...",locationGroup:"ロケーション / グループ",locationPlaceholder:"例: 工房、オフィス、地下室",modelOptional:"モデル(任意)",addTitle:"プリンターを追加",editTitle:"プリンターを編集",myPrinter:"マイプリンター",autoArchiveLabel:"完了した印刷を自動アーカイブ",fromPrinterSettings:"プリンターの設定から取得",saveChanges:"変更を保存"},skipObjects:{onlyWhilePrinting:"オブジェクトスキップ(印刷中のみ)",title:"オブジェクトスキップ",skipped:"スキップ済み",objectsSkipped:"オブジェクトをスキップしました",activeCount:"{{count}}個アクティブ",waitForLayer:"オブジェクトをスキップするにはレイヤー2以降をお待ちください(現在レイヤー{{layer}})",skip:"スキップ",tooltip:"オブジェクトスキップ",requiresMultiple:"オブジェクトスキップ(2個以上必要)",matchIdsInfo:"プリンター画面のIDと照合してください",printerShowsIds:"プリンター画面にビルドプレート上のオブジェクトIDが表示されます",skipSelected:"選択をスキップ",skipping:"スキップ中...",noObjectsSelected:"オブジェクトが選択されていません",selectObjectsToSkip:"現在の印刷からスキップするオブジェクトを選択してください",confirmTitle:"オブジェクトをスキップしますか?",confirmMessage:"「{{name}}」をスキップしますか?この操作は元に戻せません。"},confirm:{deleteTitle:"プリンターを削除",deleteMessage:"「{{name}}」を削除しますか?すべての接続設定が削除されます。",stopTitle:"印刷を停止",stopMessage:"「{{name}}」の現在の印刷を停止しますか?印刷ジョブがキャンセルされます。",stopButton:"印刷を停止",pauseTitle:"印刷を一時停止",pauseMessage:"「{{name}}」の現在の印刷を一時停止しますか?",pauseButton:"印刷を一時停止",resumeTitle:"印刷を再開",resumeMessage:"「{{name}}」の印刷を再開しますか?",resumeButton:"印刷を再開",powerOnTitle:"プリンターの電源をオン",powerOnMessage:"「{{name}}」の電源をオンにしますか?",powerOffTitle:"プリンターの電源をオフ",powerOffMessage:"「{{name}}」の電源をオフにしますか?",powerOffWarning:"警告: 「{{name}}」は現在印刷中です!電源をオフにしますか?印刷が中断され、プリンターが損傷する可能性があります。",deleteArchivesNote:"このプリンターのすべての印刷履歴が完全に削除されます。",keepArchivesNote:"印刷履歴は保持されますが、このプリンターとの関連は解除されます。",powerOnButton:"電源オン",powerOffButton:"電源オフ"},discovery:{title:"プリンター",scanning:"スキャン中...",allConfigured:"検出されたすべてのプリンターは既に設定済みです。",subnetToScan:"スキャンするサブネット",scanSubnet:"サブネットをスキャンしてプリンターを検出",discoverNetwork:"ネットワーク上のプリンターを検出",scanningSubnet:"サブネットでBambuプリンターをスキャン中...",scanningNetwork:"ネットワークをスキャン中...",serialRequired:"シリアル番号が必要です",unknown:"不明",failedToStart:"印刷の開始に失敗しました",searching:"検索中...",scanProgress:"スキャン中... {{scanned}}/{{total}}",foundPrinters:"{{count}}台のプリンターを検出",noPrintersFound:"プリンターが見つかりません",noPrintersFoundSubnet:"指定されたサブネットにプリンターが見つかりません。",noPrintersFoundNetwork:"ネットワーク上にプリンターが見つかりません。",alreadyAdded:"追加済み",select:"選択",manualEntry:"手動入力",addFromCloud:"クラウドから追加",dockerNote:"Dockerを検出しました。プリンターのサブネットをCIDR表記で入力してください。docker-compose.ymlでnetwork_mode: hostが必要です。"},filaments:"フィラメント",firmwareUpdateAvailable:"ファームウェアアップデートあり: {{current}} → {{latest}}",firmwareUpToDate:"ファームウェア {{version}} — 最新",plateDetection:{noPermission:"このページにアクセスする権限がありません。",title:"プレート検出",description:"印刷前にビルドプレート上のオブジェクトを検出",referenceCapture:"リファレンス画像を撮影",captureReference:"リファレンスを撮影",deleteReference:"リファレンスを削除",sensitivity:"感度",detectionArea:"検出エリア",saveArea:"エリアを保存",resetArea:"エリアをリセット",testDetection:"検出テスト",testing:"テスト中...",objectsDetected:"オブジェクトを検出しました",noObjectsDetected:"オブジェクトは検出されませんでした",requiresCamera:"カメラが必要です",referenceRequired:"まずリファレンス画像を撮影してください",enabledClick:"プレートチェック有効 - クリックして無効化",disabledClick:"プレートチェック無効 - クリックして有効化",manageCalibration:"プレート検出キャリブレーションを管理",calibrationRequired:"キャリブレーションが必要です",calibrationInstructions:"ビルドプレートが<strong>完全に空</strong>であることを確認してから、キャリブレーションをクリックしてください。",calibrationDescription:"キャリブレーションは空のプレートのリファレンス画像を撮影します。以降のチェックではこのリファレンスと比較してオブジェクトを検出します。",calibrationTip:"<strong>ヒント:</strong> 異なるプレート用に最大5つのキャリブレーションを保存できます。チェック時に最適なものが自動的に使用されます。",plateEmpty:"プレートは空のようです",confidence:"信頼度",difference:"差分",analysisPreview:"分析プレビュー:",analysisLegend:"緑の枠 = 検出エリア、赤のオーバーレイ = キャリブレーションとの差分",savedReferences:"保存済みリファレンス ({{count}}/{{max}})",labelPlaceholder:"ラベル...",clickToEdit:"{{label}} - クリックして編集",clickToAddLabel:"クリックしてラベルを追加"},fans:{partCooling:"パーツ冷却ファン",auxiliary:"補助ファン",chamber:"チャンバーファン"},estimatedCompletion:"完了予定時刻",slotOptions:"スロットオプション",firmwareModal:{title:"ファームウェアアップデート",titleUpToDate:"ファームウェア情報",currentVersion:"現在のバージョン",latestVersion:"最新バージョン",releaseNotes:"リリースノート",sdCardReady:"SDカード準備完了。下をクリックしてファームウェアをアップロードしてください。",applyInstructions:"プリンターでアップデートを適用するには:",step1:"プリンターのタッチスクリーンで設定に移動",step2:"ファームウェアに移動",step3:"SDカードからアップデートを選択",step4:"アップデートには10〜20分かかります",done:"完了",starting:"開始中...",uploadFirmware:"ファームウェアをアップロード",checkingPrereqs:"前提条件を確認中...",uploadedSuccess:"ファームウェアをSDカードにアップロードしました!",uploadFailed:"アップロード開始に失敗しました: {{error}}",uploadedToast:"ファームウェアをアップロードしました!プリンター画面からアップデートを実行してください。"},accessCodePlaceholder:"プリンター設定から取得",roi:{title:"プリンター",xStart:"X開始",yStart:"Y開始",width:"幅",height:"高さ",instruction:"ビルドプレートに焦点を合わせるように検出エリアを調整してください。プレビューの緑の枠が現在のエリアを示しています。"},deleteConfirm:"「{{name}}」を削除しますか?",maintenanceDue_plural:"{{count}}件の期限",offlinePrintersWithPlugs:"スマートプラグ付きオフラインプリンター",noLabel:"ラベルなし",printPreview:"印刷プレビュー",width:"幅",height:"高さ",noObjectsFound:"オブジェクトが見つかりません",objectsLoadedOnPrintStart:"オブジェクトは印刷開始時に読み込まれます",serialCannotBeChanged:"シリアル番号は変更できません",locationHelp:"プリンターのグループ化とキュージョブのフィルタリングに使用",autoOffAfterPrint:"印刷後に自動電源オフ",autoOffExecuted:"自動オフが実行されました - リセットするにはプリンターの電源を入れてください",viewHmsErrors:"{{count}}件のHMSエラーを表示",camera:"カメラ",skipObject:"オブジェクトスキップ",firmwareUpdate:"ファームウェアアップデート",firmwareInstructions:"プリンターのタッチスクリーンで",firmwareNav:"に移動",settings:"設定",firmware:"ファームウェア",discoverPrinters:"プリンターを検出",searching:"検索中...",manualEntry:"手動入力",addFromCloud:"クラウドから追加",cloud:{title:"Bambu Cloud プリンター",loginRequired:"クラウドにログインしてプリンターを追加してください",loginFirst:"まずプロファイルページからBambu Cloudにログインしてください",goToProfiles:"プロファイルへ移動",loadingPrinters:"クラウドプリンターを読み込み中...",noPrinters:"クラウドにプリンターが見つかりません",alreadyConfigured:"設定済み",accessCodeRequired:"アクセスコードが必要です",addPrinter:"プリンターを追加",adding:"追加中..."},name_field:"名前",nozzleSize:"ノズルサイズ",rfid:{reread:"RFID再読み取り"},openCameraOverlay:"カメラオーバーレイを開く",openCameraWindow:"カメラを新しいウィンドウで開く",firmwareUpdateButton:"アップデート",clickToViewHmsErrors:"クリックしてHMSエラーを表示"},archives:{title:"印刷アーカイブ",searchPlaceholder:"アーカイブを検索...",filterByPrinter:"プリンターで絞り込み",filterByStatus:"ステータスで絞り込み",sortBy:"並べ替え",sortNewest:"新しい順",sortOldest:"古い順",sortName:"名前順",sortDuration:"時間順",noArchives:"アーカイブが見つかりません",noArchivesYet:"アーカイブはまだありません",releaseToUpload:"ドロップしてアップロード",showAll:"すべて表示",showFavoritesOnly:"お気に入りのみ表示",gridView:"グリッド表示",listView:"リスト表示",calendarView:"カレンダー表示",showFailedPrints:"失敗した印刷を表示",hideFailedPrints:"失敗した印刷を非表示",printTime:"印刷時間",filamentUsed:"フィラメント使用量",cost:"コスト",reprint:"再印刷",preview:"プレビュー",deleteArchive:"アーカイブを削除",deleteConfirm:"このアーカイブを削除しますか?",favorite:"お気に入り",unfavorite:"お気に入りから削除",viewDetails:"詳細を表示",status:{completed:"完了",failed:"失敗",stopped:"中止"},toast:{source3mfAttached:"ソース3MFを添付しました: {{filename}}",source3mfRemoved:"ソース3MFを削除しました",f3dAttached:"F3Dを添付しました: {{filename}}",f3dRemoved:"F3Dを削除しました",timelapseAttached:"タイムラプスを添付しました: {{filename}}",addedToFavorites:"お気に入りに追加しました",removedFromFavorites:"お気に入りから削除しました",linkCopied:"リンクをクリップボードにコピーしました",photoDeleted:"写真を削除しました",exportDownloaded:"エクスポートをダウンロードしました",exportFailed:"エクスポートに失敗しました",addedToProject:"プロジェクトに追加しました",removedFromProject:"プロジェクトから削除しました",failedToAddToProject:"プロジェクトへの追加に失敗しました",failedToRemoveFromProject:"プロジェクトからの削除に失敗しました",noFile:"印刷ファイルがありません",slicerOpened:"スライサーを開きました",failedToOpenSlicer:"スライサーの起動に失敗しました",archived:"アーカイブしました",sentToFileManager:"ファイルマネージャーに送信しました",deleted:"アーカイブを削除しました",updated:"アーカイブを更新しました",failedToDelete:"アーカイブの削除に失敗しました",failedToUpdate:"アーカイブの更新に失敗しました",failedToSend:"送信に失敗しました",sentToPrinter:"プリンターに送信しました",addedToQueue:"キューに追加しました",failedUploadSource3mf:"ソース3MFのアップロードに失敗しました",failedRemoveSource3mf:"ソース3MFの削除に失敗しました",failedUploadF3d:"F3Dのアップロードに失敗しました",failedRemoveF3d:"F3Dの削除に失敗しました",timelapseAlreadyAttached:"タイムラプスは既に添付されています",noMatchingTimelapse:"一致するタイムラプスが見つかりません",failedScanTimelapse:"タイムラプスのスキャンに失敗しました",failedAttachTimelapse:"タイムラプスの添付に失敗しました",archiveDeleted:"アーカイブを削除しました",failedDeleteArchive:"アーカイブの削除に失敗しました",projectUpdated:"プロジェクトを更新しました",failedUpdateProject:"プロジェクトの更新に失敗しました",failedCopyLink:"リンクのコピーに失敗しました",failedDeletePhoto:"写真の削除に失敗しました",failedDeleteArchives:"アーカイブの削除に失敗しました",failedUpdateFavorites:"お気に入りの更新に失敗しました"},menu:{schedule:"スケジュール",slice:"スライス",externalLink:"外部リンク",viewOnMakerWorld:"MakerWorldで表示",preview3d:"3Dプレビュー",viewTimelapse:"タイムラプスを表示",downloadSource3mf:"ソース3MFをダウンロード",uploadSource3mf:"ソース3MFをアップロード",replaceSource3mf:"ソース3MFを置換",removeSource3mf:"ソース3MFを削除",uploadF3d:"F3Dをアップロード",replaceF3d:"F3Dを置換",downloadF3d:"Fusion 360デザインファイルをダウンロード",removeF3d:"F3Dを削除",download:"ダウンロード",qrCode:"QRコード",viewPhotos:"{{count}}枚の写真を表示",projectPage:"プロジェクトページ",goToProject:"プロジェクトへ: {{name}}",addToProject:"プロジェクトに追加",loading:"アーカイブを読み込み中...",select:"選択",deselect:"選択解除",print:"印刷",openInBambuStudio:"スライサーで開く",scanForTimelapse:"タイムラプスをスキャン",copyDownloadLink:"ダウンロードリンクをコピー",viewPhotosCount:"写真を表示 ({{count}})",addToFavorites:"お気に入りに追加",removeFromFavorites:"お気に入りから削除",edit:"編集",removeFromProject:"プロジェクトから削除",noProjectsAvailable:"利用可能なプロジェクトがありません",delete:"削除"},card:{plateNumber:"プレート {{number}}",moreOptions:"その他のオプション",failed:"失敗",openSource3mf:"ソース3MFをBambu Studioで開く(右クリックでオプション表示)",downloadF3d:"Fusion 360デザインファイルをダウンロード",viewTimelapse:"タイムラプスを表示",viewPhotos:"{{count}}枚の写真を表示",openFolder:"フォルダーを開く: {{name}}",source:"ソース",project:"プロジェクト",layer:"レイヤー",layers:"レイヤー",objects:"{{count}}オブジェクト",noPermissionEdit:"プロファイルを編集する権限がありません",reprint:"再印刷",schedulePrint:"印刷をスケジュール",schedule:"スケジュール",slice:"スライス",externalLink:"外部リンク",preview3d:"3Dプレビュー",download:"ダウンロード",previousPlate:"前のプレート",nextPlate:"次のプレート",addToFavorites:"お気に入りに追加",removeFromFavorites:"お気に入りから削除",cancelled:"キャンセル",duplicate:"重複",duplicateTitle:"このモデルは以前印刷されています",viewPhoto:"写真を表示",slicedFile:"スライス済みファイル - 印刷可能",sourceFile:"ソースファイルのみ - AMSマッピング不可",gcode:"GCODE",estimated:"推定: {{time}}",actual:"実際: {{time}}",accuracy:"精度: {{percent}}%",filament:"{{weight}}g",object:"{{count}}オブジェクト",slicedFor:"{{model}}用にスライス",uploadedBy:"アップロード者",noPermissionReprint:"再印刷する権限がありません",noPermissionDelete:"アーカイブを削除する権限がありません",openInBambuStudio:"スライサーで開く",openInBambuStudioToSlice:"スライサーでスライス",makerWorld:"MakerWorld: {{designer}}",viewProject:"プロジェクトを表示",noExternalLink:"外部リンクなし",edit:"編集",delete:"削除"},modal:{deleteArchive:"アーカイブを削除",deleteConfirm:"このアーカイブを削除しますか?",removeSource3mf:"ソース3MFを削除",removeSource3mfConfirm:'"{{name}}"からソース3MFファイルを削除してもよろしいですか?元のスライサープロジェクトファイルが削除されます。',removeF3d:"F3Dを削除",removeF3dConfirm:'"{{name}}"からFusion 360デザインファイルを削除してもよろしいですか?',selectTimelapse:"タイムラプスを選択",selectTimelapseDesc:"自動一致が見つかりませんでした。この印刷のタイムラプスを選択してください:",deleteArchives:"印刷アーカイブを削除",deleteCount:"{{count}}件を削除",deleteButton:"削除",removeButton:"削除",timelapse:"{{name}} - タイムラプス",deleteArchivesConfirm:"{{count}}件のアーカイブを削除しますか?この操作は元に戻せません。"},page:{title:"印刷アーカイブ",printsCount:"{{count}}回印刷",dropFilesHere:".3mfファイルをここにドロップ",releaseToUpload:"ドロップしてアップロード",only3mfSupported:".3mfファイルのみ対応しています",selected:"{{count}}件選択中",selectAll:"すべて選択",tags:"タグ",project:"プロジェクト",favorite:"お気に入り",toggledFavorites:"{{count}}件のアーカイブのお気に入りを切替えました",photoDeleted:"写真を削除しました",close:"閉じる",delete:"削除",failedUpdateFavorites:"お気に入りの更新に失敗しました",archivesDeleted:"{{count}}件のアーカイブを削除しました",failedDeleteArchives:"アーカイブの削除に失敗しました",failedDeletePhoto:"写真の削除に失敗しました"},list:{size:"サイズ",hasTimelapse:"タイムラプスあり",name:"名前",printer:"プリンター",date:"日付",actions:"操作"},noPrinterAvailable:"利用可能なプリンターがありません",archiveOrReprint:"アーカイブまたは再印刷",multiPrinterPrint:"マルチプリンター印刷",noPrintersForReprint:"再印刷用のプリンターがありません",searchMakerworld:"MakerWorldで検索",searchPrintables:"Printablesで検索",searchThingiverse:"Thingiverseで検索",openInSlicer:"スライサーで開く",openWithProtocol:"{{slicer}}で開く",context:{reprint:"再印刷",addToQueue:"キューに追加",delete:"削除",edit:"編集",compare:"比較",viewTimelapse:"タイムラプスを表示",downloadTimelapse:"タイムラプスをダウンロード",openInBambuStudio:"スライサーで開く",openInOrcaSlicer:"OrcaSlicerで開く",addToProject:"プロジェクトに追加",removeFromProject:"プロジェクトから削除",downloadGcode:"GCodeをダウンロード",download3mf:"3MFをダウンロード",downloadModel:"モデルをダウンロード",viewPhotos:"写真を表示",searchOnline:"オンラインで検索",sendToFileManager:"ファイルマネージャーに送信",sendToPrinter:"プリンターに送信",openStlViewer:"STLビューアーで開く"},permissions:{noReprint:"再印刷する権限がありません",noDelete:"削除する権限がありません",noEdit:"編集する権限がありません",noDownload:"ダウンロードする権限がありません",noQueue:"キューに追加する権限がありません",noSendToPrinter:"プリンターに送信する権限がありません",noSendToFileManager:"ファイルマネージャーに送信する権限がありません",noUpload:"アップロードする権限がありません",noBulkDelete:"一括削除する権限がありません"},costPerPrint:"印刷あたりのコスト",energyCost:"エネルギーコスト",totalCost:"合計コスト",noFilament:"フィラメントデータなし",printCount:"{{count}}回印刷",timesShort:"{{count}}回",perPrint:"/1回あたり",gcodeAvailable:"GCode利用可能",noGcode:"GCodeなし",plates:"プレート",filaments:"フィラメント",settings_label:"設定",weight:"重量",printSettings:"印刷設定",layerHeight:"レイヤー高さ",nozzleTemp:"ノズル温度",bedTemp:"ベッド温度",infill:"インフィル",supports:"サポート",model3d:"3Dモデル",noModel:"モデルなし",printNumber:"印刷 #{{number}}",sortLargest:"大きい順",sortSmallest:"小さい順",sortSize:"サイズ",noArchivesSearch:"検索条件に一致するアーカイブがありません",loadingArchives:"アーカイブを読み込み中...",manageTags:"タグを管理",permission:{noReprint:"このアーカイブを再印刷する権限がありません",noAddToQueue:"キューに追加する権限がありません",noUpdateArchives:"アーカイブを更新する権限がありません",noUploadFiles:"ファイルをアップロードする権限がありません",noDownload:"アーカイブをダウンロードする権限がありません",noCopyLink:"ダウンロードリンクをコピーする権限がありません",noDelete:"このアーカイブを削除する権限がありません",noCreate:"アーカイブを作成する権限がありません"}},queue:{title:"印刷キュー",addToQueue:"キューに追加",schedulePrint:"印刷をスケジュール",editQueueItem:"キューアイテムを編集",adding:"追加中...",clearQueue:"キューをクリア",clearHistory:"履歴をクリア",emptyQueue:"キューは空です",position:"順番",scheduledTime:"予定時刻",moveUp:"上に移動",moveDown:"下に移動",startNow:"今すぐ開始",printingInProgress:"印刷中...",viewArchive:"アーカイブを表示",viewInFileManager:"ファイルマネージャーで表示",itemCount:"{{count}}件",dragToReorder:"ドラッグして並べ替え(ASAPのみ)",addedBy:"{{username}}が追加",nextInQueue:"次のキュー",clearPlate:"プレートをクリアして次を開始",clearPlateSuccess:"プレートをクリアしました — 次の印刷の準備完了",plateReady:"プレートをクリアしました — 次の印刷の準備完了",sections:{currentlyPrinting:"印刷中",queued:"キュー中",history:"履歴"},status:{pending:"待機中",waiting:"待機中",printing:"印刷中",paused:"一時停止",completed:"完了",failed:"失敗",skipped:"スキップ",cancelled:"キャンセル済み"},summary:{printing:"印刷中",queued:"キュー中",history:"履歴",totalTime:"キュー合計時間"},filter:{allPrinters:"すべてのプリンター",unassigned:"未割当",allStatus:"すべてのステータス",allLocations:"すべてのロケーション",any:"すべて"},sort:{byPosition:"順番で並べ替え",byName:"名前で並べ替え",byPrinter:"プリンターで並べ替え",bySchedule:"スケジュールで並べ替え",byDate:"日付で並べ替え",ascendingOldest:"昇順(古い順)",descendingNewest:"降順(新しい順)"},badges:{staged:"ステージ済み",autoPowerOff:"自動電源オフ",requiresPrevious:"前の成功が必要"},empty:{title:"スケジュールされた印刷はありません",description:"アーカイブページのコンテキストメニューから「スケジュール」オプションを使用するか、ファイルをドラッグ&ドロップして始めましょう。"},time:{asap:"即時",overdue:"期限超過",now:"今すぐ",inMinutes:"{{count}}分後",inHours:"{{count}}時間後",lessThanMinute:"1分以内"},actions:{stopPrint:"印刷を停止",startPrint:"印刷を開始",requeue:"再キュー"},bulkEdit:{title:"{{count}}件のアイテムを編集",description:"変更した設定のみが選択されたアイテムに適用されます。",printer:"プリンター",noChange:"— 変更なし —",queueOptions:"キューオプション",staged:"ステージ済み",autoPowerOff:"印刷後に自動電源オフ",printOptions:"印刷オプション",bedLevelling:"ベッドレベリング",flowCalibration:"フローキャリブレーション",vibrationCalibration:"振動キャリブレーション",timelapse:"タイムラプス",useAms:"AMS使用",applyChanges:"変更を適用",selectAll:"すべて選択",deselectAll:"すべて選択解除",selected:"{{count}}件選択中",editSelected:"選択を編集",cancelSelected:"選択をキャンセル",title_plural:"{{count}}件のアイテムを編集",requirePrevious:"前の成功を必要とする",layerInspection:"第一層検査"},confirm:{cancelTitle:"スケジュール済み印刷をキャンセル",cancelMessage:"「{{name}}」をキャンセルしますか?",stopTitle:"印刷を停止",stopMessage:"現在の印刷「{{name}}」を停止しますか?プリンター上の印刷ジョブがキャンセルされます。",removeTitle:"履歴から削除",removeMessage:"「{{name}}」をキュー履歴から削除しますか?",clearHistoryMessage:"{{count}}件の履歴をすべて削除しますか?",cancelButton:"印刷をキャンセル",stopButton:"印刷を停止",thisPrint:"この印刷",thisItem:"このアイテム",clearHistoryTitle:"履歴をクリア"},toast:{cancelled:"キャンセル済み",removeFailed:"プロジェクトからのアーカイブ削除に失敗しました",cancelFailed:"アイテムのキャンセルに失敗しました",removed:"キューアイテムを削除しました",stopped:"印刷を停止しました",stopFailed:"印刷の停止に失敗しました",released:"印刷をキューにリリースしました",startFailed:"印刷の開始に失敗しました",reorderFailed:"キューの並べ替えに失敗しました",historyCleared:"{{count}}件の履歴をクリアしました",clearHistoryFailed:"履歴のクリアに失敗しました",updateFailed:"アイテムの更新に失敗しました",bulkCancelled:"{{count}}件のアイテムをキャンセルしました",bulkCancelFailed:"アイテムのキャンセルに失敗しました"},subtitle:"印刷ジョブのスケジュールと管理",print:"印刷",reprint:"再印刷",printToPrinters:"{{count}}台のプリンターで印刷",queueToPrinters:"{{count}}台のプリンターでキュー追加",sending:"送信中...",sendingProgress:"送信中 {{current}}/{{total}}...",addingProgress:"追加中 {{current}}/{{total}}...",savingProgress:"保存中 {{current}}/{{total}}...",itemCount_plural:"{{count}}件のアイテム",reorderHint:"順番はASAPアイテムのみに影響します。スケジュール済みアイテムは設定時刻に実行されます。",permissions:{noStopPrint:"印刷を停止する権限がありません",noStartPrint:"印刷を開始する権限がありません",noEdit:"このキューアイテムを編集する権限がありません",noCancel:"このキューアイテムをキャンセルする権限がありません",noRequeue:"アイテムを再キューする権限がありません",noRemove:"このキューアイテムを削除する権限がありません",noClearHistory:"すべての履歴をクリアする権限がありません",noEditItems:"キューアイテムを編集する権限がありません",noCancelItems:"キューアイテムをキャンセルする権限がありません"}},stats:{title:"統計",overview:"概要",totalPrints:"総印刷数",successRate:"成功率",totalPrintTime:"総印刷時間",printTime:"印刷時間",totalFilament:"総フィラメント使用量",filamentUsed:"フィラメント使用量",filamentCost:"フィラメントコスト",totalCost:"総コスト",energyUsed:"エネルギー使用量",energyCost:"エネルギーコスト",averagePrintTime:"平均印刷時間",printsPerDay:"1日あたりの印刷数",byPrinter:"プリンター別",printsByPrinter:"プリンター別印刷数",byMaterial:"素材別",byMonth:"月別",last7Days:"過去7日間",last30Days:"過去30日間",last90Days:"過去90日間",allTime:"全期間",quickStats:"クイック統計",printActivity:"印刷アクティビティ",filamentTypes:"フィラメントタイプ",timeAccuracy:"時間精度",successful:"成功",failed:"失敗",perfectEstimate:"100% = 完全な推定",noTimeAccuracyData:"時間精度データがありません",noFilamentData:"フィラメントデータがありません",noPrinterData:"プリンターデータがありません",noPrintData:"印刷データがありません",noPrintDataLast30Days:"過去30日間の印刷データがありません",failureReasons:"失敗理由",topFailureReasons:"主な失敗理由",resetLayout:"レイアウトをリセット",recalculateCosts:"コストを再計算",exportStats:"統計をエクスポート",exportAsCsv:"CSVでエクスポート",exportAsExcel:"Excelでエクスポート",hiddenCount:"{{count}}件非表示",exportDownloaded:"エクスポートをダウンロードしました",exportFailed:"エクスポートに失敗しました",layoutReset:"レイアウトをリセットしました",recalculateFailed:"コストの再計算に失敗しました",noPermissionResetLayout:"レイアウトをリセットする権限がありません",noPermissionRecalculate:"コストを再計算する権限がありません",subtitle:"ウィジェットをドラッグして並べ替え。目のアイコンをクリックして非表示。",filamentTrends:"フィラメントトレンド",failureAnalysis:"失敗分析",failedPrintsCount:"{{failed}} / {{total}} 件の印刷が失敗",lastWeekRate:"先週: {{rate}}%",recalculateCostsHint:"現在のフィラメント価格ですべてのアーカイブコストを再計算",recalculatedCosts:"{{count}}件のアーカイブのコストを再計算しました",loadingStats:"統計を読み込み中..."},maintenance:{title:"メンテナンス",overview:"概要",allOk:"すべてのメンテナンスは最新です",dueCount:"{{count}}件の期限到来",dueCount_plural:"{{count}}件の期限到来",warningCount:"{{count}}件の警告",warningCount_plural:"{{count}}件の警告",totalPrintTime:"総印刷時間",nextMaintenance:"次回メンテナンス",nothingDue:"予定なし",tasks:"タスク",lastPerformed:"前回実施日",interval:"間隔",hoursRemaining:"残り{{hours}}時間",hoursOverdue:"{{hours}}時間超過",markDone:"完了にする",performMaintenance:"メンテナンスを実施",history:"履歴",noHistory:"メンテナンス履歴がありません",editPrintHours:"印刷時間を編集",currentHours:"現在の時間",dueSoon:"まもなく期限",allGood:"問題なし",days:"日",weeks:"{{count}}週間",months:"{{count}}ヶ月",maintenanceTypes:"メンテナンスタイプ",addCustomType:"カスタムタイプを追加",intervalType:"インターバルタイプ",icon:"アイコン",documentationLink:"ドキュメントリンク(任意)",assignToPrinters:"プリンターに割り当て",selectAtLeastOnePrinter:"プリンターを1台以上選択してください",addType:"タイプを追加",custom:"カスタム",printHours:"印刷時間",calendarDays:"カレンダー日数",viewDocumentation:"ドキュメントを表示",timeBasedInterval:"時間ベースのインターバル",intervalOverrides:"インターバルのオーバーライド",assignedToPrinters:"割り当て済みプリンター:",noPrintersAssigned:"プリンター未割り当て",removeFromPrinter:"このプリンターから削除",types:{lubricateRails:"リニアレールの潤滑",cleanNozzle:"ノズル/ホットエンドの清掃",checkBelts:"ベルト張力の確認",cleanBuildPlate:"ビルドプレートの清掃",checkExtruder:"エクストルーダーギアの確認",checkCooling:"冷却ファンの確認",generalInspection:"総合点検",cleanCarbonRods:"カーボンロッドの清掃",checkPtfeTube:"PTFEチューブの確認",replaceHepaFilter:"HEPAフィルター交換",replaceCarbonFilter:"カーボンフィルター交換",lubricateLeftNozzleRail:"左ノズルレールの潤滑"},typeUpdated:"メンテナンスタイプを更新しました",typeDeleted:"メンテナンスタイプを削除しました",printerAssigned:"プリンターを割り当てました",printerRemoved:"プリンターを削除しました",deleteTypeConfirm:"「{{name}}」を削除しますか?",noPermissionUpdate:"メンテナンス記録を更新する権限がありません",noPermissionPerform:"メンテナンスを実行する権限がありません",noPermissionEditTypes:"メンテナンスタイプを編集する権限がありません",noPermissionDeleteTypes:"メンテナンスタイプを削除する権限がありません",noPermissionEditHours:"メンテナンス時間を編集する権限がありません",noPermissionEditIntervals:"メンテナンス間隔を編集する権限がありません",statusTab:"ステータス",settingsTab:"設定",overdueCount:"{{count}}件超過",dueSoonCount:"{{count}}件まもなく期限",overdueBy:"{{duration}}超過",dueIn:"あと{{duration}}",timeLeft:"残り{{duration}}",day:"1日",week:"1週間",month:"1ヶ月",year:"1年",maintenanceTypesDescription:"システムタイプとカスタムメンテナンスタスク",intervalValue:"間隔 ({{type}})",exampleName:"例: HEPAフィルター交換",intervalOverridesDescription:"特定のプリンターの間隔をカスタマイズ",addPrinterShort:"追加:",printersAssignedClick:"{{count}}台のプリンターを割り当て済み - クリックして管理",maintenanceComplete:"メンテナンスを完了としてマークしました",printHoursUpdated:"印刷時間を更新しました",noPermissionRemovePrinter:"プリンターの割り当てを解除する権限がありません",noPermissionAssignPrinter:"プリンターを割り当てる権限がありません",configureSettings:"メンテナンスタイプと間隔を設定"},settings:{title:"設定",general:"一般",tabs:{general:"一般",smartPlugs:"スマートプラグ",notifications:"通知",apiKeys:"APIキー",users:"認証",backup:"バックアップ",filament:"フィラメント",network:"ネットワーク",virtualPrinter:"仮想プリンター",emailAuth:"メール認証"},appearance:"外観",notifications:"通知",smartPlugs:"スマートプラグ",updates:"アップデート",language:"言語",languageDescription:"表示言語を選択してください",theme:"テーマ",themeLight:"ライト",themeDark:"ダーク",themeSystem:"システム設定に従う",defaultView:"デフォルト画面",defaultViewDescription:"アプリ起動時に表示するページ",checkForUpdates:"アップデートを確認",autoUpdate:"自動アップデート",currentVersion:"現在のバージョン",latestVersion:"最新バージョン",upToDate:"最新です",updateAvailable:"アップデートあり",notificationLanguage:"通知の言語",notificationLanguageDescription:"プッシュ通知の言語",notificationProviders:"通知プロバイダー",addProvider:"プロバイダーを追加",editProvider:"プロバイダーを編集",providerType:"プロバイダーの種類",testNotification:"テスト通知",testSuccess:"テスト通知を送信しました",testFailed:"テスト通知の送信に失敗しました",quietHours:"おやすみ時間",quietHoursDescription:"この時間帯は通知を送信しません",quietHoursStart:"開始",quietHoursEnd:"終了",events:{title:"通知イベント",printStart:"印刷開始",printComplete:"印刷完了",printFailed:"印刷失敗",printStopped:"印刷中止",printProgress:"進捗マイルストーン",printProgressDescription:"25%, 50%, 75%で通知",printerOffline:"プリンターオフライン",printerError:"プリンターエラー",filamentLow:"フィラメント残量低下",maintenanceDue:"メンテナンス期限",maintenanceDueDescription:"メンテナンスが必要なときに通知"},smartPlug:{title:"スマートプラグ",add:"スマートプラグを追加",edit:"スマートプラグを編集",name:"名前",ipAddress:"IPアドレス",linkedPrinter:"連携プリンター",autoOn:"自動電源オン",autoOnDescription:"印刷開始時に電源を入れる",autoOff:"自動電源オフ",autoOffDescription:"印刷完了後に電源を切る",offDelay:"オフ遅延",offDelayMinutes:"印刷後の待機時間(分)",offDelayTemp:"ノズル温度が下回ったとき",currentState:"現在の状態",turnOn:"電源オン",turnOff:"電源オフ"},email:{smtpSettings:"SMTP設定",smtpHost:"SMTPサーバー",smtpPort:"SMTPポート",security:"セキュリティ",authentication:"認証",username:"ユーザー名",password:"パスワード",fromEmail:"送信元メールアドレス",fromName:"送信者名",testConnection:"SMTP接続テスト",testRecipient:"テスト受信者メール",sendTest:"テストメール送信",sending:"送信中...",save:"設定を保存",saving:"保存中...",advancedAuth:"高度な認証",advancedAuthEnabled:"高度な認証が有効です",advancedAuthEnabledDesc:"メールベースのユーザー管理機能が有効になっています。新規ユーザーには自動生成されたパスワードがメールで送信され、ユーザーはパスワード忘れ機能でパスワードをリセットできます。",advancedAuthDisabled:"高度な認証が無効です",advancedAuthDisabledDesc:"高度な認証を有効にして、ユーザー管理のメールベース機能を有効化してください。",enable:"有効にする",disable:"無効にする",feature1:"パスワードは自動生成され、新規ユーザーにメールで送信されます",feature2:"ユーザーはユーザー名またはメールでログインできます",feature3:"パスワード忘れ機能が利用可能です",feature4:"管理者はメールでユーザーパスワードをリセットできます",errors:{requiredFields:"すべての必須フィールドに入力してください",usernameRequired:"認証が有効な場合、ユーザー名は必須です",enterTestEmail:"テストメールアドレスを入力してください",smtpServerAndEmail:"テストする前にSMTPサーバーと送信元メールを入力してください",usernamePasswordRequired:"認証が有効な場合、ユーザー名とパスワードは必須です",configureSmtpFirst:"最初にSMTP設定を構成してテストしてください"},success:{settingsSaved:"SMTP設定を保存しました"},securityOptions:{starttls:"STARTTLS (ポート 587)",ssl:"SSL/TLS (ポート 465)",none:"なし (ポート 25)"},authOptions:{enabled:"有効",disabled:"無効"}},noDefaultPrinter:"デフォルトなし(毎回選択)",sidebarOrder:"サイドバーの順序",saveThumbnails:"サムネイルを保存",captureFinishPhoto:"完了写真を撮影",noPrintersConfigured:"プリンターが設定されていません",checkPrinterFirmware:"プリンターファームウェアの確認",enableRetry:"リトライを有効化",homeAssistantDescription:"Home Assistantに接続してHA REST APIでスマートプラグを制御します。switch、light、input_booleanエンティティに対応しています。",environmentManagedLabel:"(環境変数で管理)",autoEnabledViaEnv:"環境変数により自動的に有効化されました",urlFromEnvReadOnly:"HA_URL環境変数で設定された値(読み取り専用)",tokenFromEnvReadOnly:"HA_TOKEN環境変数で設定された値(読み取り専用)",noSmartPlugsDescription:"Tasmotaベースのスマートプラグを追加して、エネルギー消費を追跡し、電源制御を自動化します。",noProvidersDescription:"アラートを受信するにはプロバイダーを追加してください。",noUsersFound:"ユーザーが見つかりません",noGroupsFound:"グループが見つかりません",noGroupsAvailable:"利用可能なグループがありません",passwordsDoNotMatch:"パスワードが一致しません",authDisabledTitle:"認証が無効です",deleteUserConfirm:"このユーザーを削除してもよろしいですか?この操作は元に戻せません。",actionCannotBeUndone:"この操作は元に戻せません",addFirstSmartPlug:"最初のスマートプラグを追加",providers:"プロバイダー",log:"ログ",testAll:"すべてテスト",testResults:"テスト結果",messageTemplates:"メッセージテンプレート",apiKeys:"APIキー",apiKeysDescription:"外部連携やWebhook用のAPIキーを作成します。",createKey:"キーを作成",apiKeyCreated:"APIキーを作成しました",apiKeyCopyWarning:"今すぐこのキーをコピーしてください - 再表示されません!",createNewApiKey:"新しいAPIキーを作成",keyName:"キー名",readStatus:"ステータスの読み取り",readStatusDescription:"プリンターのステータスとキューを表示",manageQueue:"キューの管理",manageQueueDescription:"印刷キューへのアイテムの追加と削除",controlPrinter:"プリンターの制御",controlPrinterDescription:"印刷の一時停止、再開、停止",unnamedKey:"名前なしキー",lastUsed:"最終使用:",createFirstKey:"最初のキーを作成",webhookEndpoints:"Webhookエンドポイント",webhookApiKeyHint:"X-API-KeyヘッダーでAPIキーを使用してください。",webhook:{pausePrint:"印刷を一時停止",resumePrint:"印刷を再開",getAllStatus:"全プリンターステータスを取得",getSpecificStatus:"特定のプリンターステータスを取得",addToQueue:"印刷キューに追加",stopPrint:"印刷を停止"},apiBrowser:"APIブラウザ",apiBrowserDescription:"すべての利用可能なAPIエンドポイントを探索してテストします。",apiKeyForTesting:"テスト用APIキー",apiKeyPlaceholder:"CallMeBot APIキー",deleteApiKeyTitle:"APIキーを削除",deleteApiKeyMessage:"このAPIキーを削除してもよろしいですか?このキーを使用しているすべての連携が動作しなくなります。",deleteKey:"キーを削除",amsThresholdsDescription:"AMS湿度と温度インジケーターの色しきい値を設定します。",humidity:"湿度",goodGreen:"良好(緑)≤",fairOrange:"普通(オレンジ)≤",aboveFairBad:"普通のしきい値以上は赤(悪い)で表示",temperature:"温度",goodBlue:"良好(青)≤",aboveFairHot:"普通のしきい値以上は赤(高温)で表示",historyRetention:"履歴の保持",historyRetentionDescription:"古い湿度と温度データは自動的に削除されます",printModal:"印刷ダイアログ",authentication:"認証",authDisabledDescription:"認証を有効にして、ユーザーアカウントの作成、権限の管理、Bambuddyインスタンスのセキュリティを確保しましょう。",enableAuthentication:"認証を有効にする",currentUser:"現在のユーザー",changePassword:"パスワードを変更",admin:"管理者",users:"ユーザー",addUser:"ユーザーを追加",groups:"グループ",addGroup:"グループを追加",noDescription:"説明なし",createUser:"ユーザーを作成",username:"ユーザー名",enterUsername:"ユーザー名を入力",password:"パスワード",enterPassword:"パスワードを入力(6文字以上)",confirmPassword:"パスワードの確認",confirmPasswordPlaceholder:"パスワードを確認",turnAllPlugsOn:"すべてのプラグをオン",turnAllPlugsOff:"すべてのプラグをオフ",clearLogsMessage:"30日以上前のすべての通知ログを完全に削除します。この操作は元に戻せません。",clearLogs:"通知ログを削除",resetPreferences:"設定をリセット",deleteGroup:"グループを削除",systemDefault:"システムデフォルト",archiveSettings:"アーカイブ設定",costTracking:"コスト追跡",dataManagement:"データ管理",enableMqtt:"MQTTを有効化",useTls:"TLSを使用",enableMetricsEndpoint:"メトリクスエンドポイントを有効化",availableMetrics:"利用可能なメトリクス",editUser:"ユーザーを編集",groupName:"グループ名",enterNewPassword:"新しいパスワードを入力",confirmNewPassword:"新しいパスワードを確認",enterGroupName:"グループ名を入力",enterCurrentPassword:"現在のパスワードを入力",enterNewPasswordMin6:"新しいパスワードを入力(6文字以上)",toast:{keyCopied:"キーをクリップボードにコピーしました",keyAddedToBrowser:"キーをAPIブラウザに追加しました",clearLogsFailed:"ログの削除に失敗しました",apiKeyCreated:"APIキーを作成しました",apiKeyDeleted:"APIキーを削除しました",userCreated:"ユーザーが正常に作成されました",userUpdated:"ユーザーが正常に更新されました",userDeleted:"ユーザーが正常に削除されました",fillRequiredFields:"必須項目をすべて入力してください",passwordsDoNotMatch:"パスワードが一致しません",enterGroupName:"グループ名を入力",settingsSaved:"設定を保存しました",passwordChanged:"パスワードが正常に変更されました",connectionFailed:"接続失敗",testFailed:"テスト通知の送信に失敗しました",uiPreferencesReset:"UI設定をリセットしました。更新中...",authDisabled:"認証を無効にしました",authDisableFailed:"認証の無効化に失敗しました",groupCreated:"グループを作成しました",groupUpdated:"グループを更新しました",groupDeleted:"グループを削除しました",passwordTooShort:"パスワードは6文字以上必要です",cameraConnected:"カメラ接続{{resolution}}",copyFailed:"キーのコピーに失敗しました",cameraSettingsSaved:"カメラ設定を保存しました",enterCameraUrl:"カメラURLを入力してください"},testConnection:"接続テスト",spoolman:"Spoolman",archiveMode:{always:"常にアーカイブを作成",never:"アーカイブを作成しない",ask:"毎回確認"},checkForUpdatesLabel:"アップデートを確認",mqttConnectedTo:"接続先:",prometheusDescription:"プリンターデータをPrometheus形式で公開",noSmartPlugsTitle:"スマートプラグが設定されていません",noProvidersTitle:"プロバイダーが設定されていません",noTemplatesAvailable:"テンプレートがありません。バックエンドを再起動してデフォルトテンプレートを生成してください。",apiPermissionView:"プリンターステータスとキューを表示",apiPermissionEdit:"印刷キューにアイテムを追加・削除",apiKeysEmptyTitle:"APIキーがありません",apiKeysEmptyDescription:"外部サービスと連携するためのAPIキーを作成してください。",systemGroupWarning:"システムグループ名は変更できません",authDisabledFeature1:"システムへのアクセスにログインを要求",authDisabledFeature2:"グループベースの権限で複数ユーザーを作成",authDisabledFeature3:"50以上のきめ細かな権限でアクセスを制御",userHasCreated:"このユーザーは以下を作成しています:",userItemsQuestion:"これらのアイテムをどうしますか?",testPassedCount:"{{count}}件成功",testFailedCount:"{{count}}件失敗",messageTemplatesDescription:"各イベントの通知メッセージをカスタマイズ。",useInApiBrowser:"APIブラウザーで使用",keyNamePlaceholder:"例: Home Assistant, OctoPrint",read:"読み取り",control:"制御",apiKeyHint:"このキーはX-API-Keyヘッダーとしてリクエストに送信されます。",amsDisplayThresholds:"AMS表示しきい値",keepSensorHistory:"センサー履歴の保持期間",expandCustomMapping:"カスタムマッピングをデフォルトで展開",expandCustomMappingDescription:"複数プリンターに印刷する際、プリンターごとのAMSマッピングを展開表示",authEnabledDescription:"ユーザー認証でインスタンスが保護されています",authDisabledMessage:"認証を有効にして、ユーザーアカウントの作成、権限の管理、Bambuddyインスタンスのセキュリティを確保しましょう。",system:"システム",userCount:"{{count}}人のユーザー",permissionCount:"{{count}}件の権限",viewReleaseOnGitHub:"GitHubでリリースを表示",clearNotificationLogs:"通知ログをクリア",resetUiPreferences:"UI設定をリセット",resetUiPreferencesMessage:"すべてのUI設定をデフォルトにリセットします:サイドバー順序、テーマ、ダッシュボードレイアウト、表示モード、ソート設定。プリンター、アーカイブ、サーバー設定は影響を受けません。クリア後にページがリロードされます。",deleteGroupTitle:"グループを削除",deleteGroupMessage:"このグループを削除しますか?このグループのユーザーはこれらの権限を失います。",disableAuthenticationTitle:"認証を無効化",disableAuthenticationMessage:"認証を無効にしますか?Bambuddyインスタンスにログインなしでアクセスできるようになります。ユーザーはデータベースに残りますが、認証は無効になります。",disableAuthentication:"認証を無効化",configureBambuddy:"Bambuddyを設定",newWindow:"新しいウィンドウ",embeddedOverlay:"埋め込みオーバーレイ",preferredSlicer:"優先スライサー",preferredSlicerDescription:"ファイルを開くスライサーアプリケーションを選択",externalCameras:"外部カメラ",printsOnly:"印刷のみ",totalConsumption:"総消費量",clearNotificationLogsDescription:"30日以上前の通知ログを削除",resetUiPreferencesDescription:"サイドバー順序、テーマ、表示モード、レイアウト設定をリセット。プリンター、アーカイブ、設定は影響を受けません。",enableHomeAssistant:"Home Assistantを有効化",deleteUserTitle:"ユーザーを削除",leaveEmptyForAnonymous:"匿名の場合は空のまま",leaveEmptyForNoAuth:"認証なしの場合は空のまま",enterDescriptionOptional:"説明を入力(任意)",filamentTracking:"フィラメント追跡",filamentTrackingDesc:"フィラメントスプールの追跡方法を選択してください。内蔵インベントリまたは外部Spoolmanサーバーを使用できます。",trackingModeBuiltIn:"内蔵インベントリ",trackingModeBuiltInDesc:"RFID自動検出と使用量追跡を含む",trackingModeSpoolmanDesc:"外部フィラメント管理サーバー",builtInFeatureRfid:"AMS内のBambu Lab RFIDスプールを自動検出",builtInFeatureUsage:"プリントごとのフィラメント消費量を追跡",builtInFeatureCatalog:"スプール、カラー、K値プロファイルを管理",spoolmanUrl:"Spoolman URL",spoolmanUrlHint:"Spoolmanサーバーのurl(例:http://localhost:7912)",spoolmanConnected:"接続中",spoolmanDisconnected:"未接続",status:"ステータス",connect:"接続",disconnect:"切断",howSyncWorks:"同期の仕組み",syncInfoRfidOnly:"RFIDを搭載した公式Bambu Labスプールのみ同期されます",syncInfoAutoCreate:"新しいスプールは初回同期時にSpoolmanに自動作成されます",syncInfoThirdPartySkipped:"Bambu Lab以外のスプール(サードパーティ、リフィル)はスキップされます",linkingExistingSpools:"既存スプールのリンク",linkingExistingSpoolsDesc:"既存のSpoolmanスプールをAMSにリンクするには、AMSスロットにカーソルを合わせて「Spoolmanにリンク」をクリックしてください。",syncMode:"同期モード",syncModeAuto:"自動",syncModeManual:"手動のみ",syncModeAutoDesc:"変更が検出されるとAMSデータが自動的に同期されます",syncModeManualDesc:"手動でトリガーした場合のみ同期",syncAmsData:"AMSデータを同期",syncAmsDataDesc:"プリンターのAMSデータをSpoolmanに手動同期",allPrinters:"全プリンター",catalog:{spoolCatalog:"スプールカタログ",spoolCatalogDescription:"ブランド/タイプ別の空スプール重量。スプール追加時の自動重量検索に使用されます。",searchCatalog:"カタログを検索...",addNewEntry:"新しいエントリを追加",namePlaceholder:"名前(例:Bambu Lab - プラスチック)",weight:"重量",type:"タイプ",default:"デフォルト",custom:"カスタム",noMatch:"検索に一致するエントリがありません",empty:"カタログにエントリがありません",deleteEntry:"エントリを削除",deleteConfirm:"「{{name}}」を削除してもよろしいですか?",resetCatalog:"カタログをリセット",resetConfirm:"カタログをデフォルトにリセットしますか?カスタムエントリはすべて削除されます。",loadFailed:"スプールカタログの読み込みに失敗しました",nameWeightRequired:"名前と重量は必須です",entryAdded:"エントリを追加しました",addFailed:"エントリの追加に失敗しました",entryUpdated:"エントリを更新しました",updateFailed:"エントリの更新に失敗しました",entryDeleted:"エントリを削除しました",deleteFailed:"エントリの削除に失敗しました",resetSuccess:"カタログをデフォルトにリセットしました",resetFailed:"カタログのリセットに失敗しました",exported:"{{count}}件のエントリをエクスポートしました",imported:"{{added}}件のエントリをインポートしました({{skipped}}件スキップ)",importFailed:"インポートに失敗しました:無効なJSON形式",exportTooltip:"カタログをJSONにエクスポート",importTooltip:"JSONからカタログをインポート",resetTooltip:"デフォルトにリセット"},colorCatalog:{title:"カラーカタログ",description:"メーカー/素材別のフィラメントカラー。スプール追加時の自動カラー検索に使用されます。",searchColors:"カラーを検索...",allManufacturers:"すべてのメーカー",addNewColor:"新しいカラーを追加",manufacturer:"メーカー",colorName:"カラー名",hex:"Hex",materialOptional:"素材(任意)",showing:"{{total}}件中{{filtered}}件を表示",noMatch:"検索に一致するカラーがありません",empty:"カタログにカラーがありません",deleteColor:"カラーを削除",deleteConfirm:"「{{name}}」を削除してもよろしいですか?",resetCatalog:"カラーカタログをリセット",resetConfirm:"カタログをデフォルトにリセットしますか?カスタムカラーはすべて削除されます。",sync:"同期",starting:"開始中...",syncTooltip:"FilamentColors.xyzから同期(2000+カラー)",loadFailed:"カラーカタログの読み込みに失敗しました",fieldsRequired:"メーカー、カラー名、Hexカラーは必須です",colorAdded:"カラーを追加しました",addFailed:"カラーの追加に失敗しました",colorUpdated:"カラーを更新しました",updateFailed:"カラーの更新に失敗しました",colorDeleted:"カラーを削除しました",deleteFailed:"カラーの削除に失敗しました",resetSuccess:"カラーカタログをデフォルトにリセットしました",resetFailed:"カタログのリセットに失敗しました",syncUpToDate:"最新の状態です({{count}}件のカラーを確認)",syncComplete:"{{added}}件の新しいカラーを追加しました({{skipped}}件は既に存在)",syncError:"同期エラー",syncFailed:"FilamentColors.xyzからの同期に失敗しました",exported:"{{count}}件のカラーをエクスポートしました",imported:"{{added}}件のカラーをインポートしました({{skipped}}件スキップ)",importFailed:"インポートに失敗しました:無効なJSON形式"}},notification:{printStarted:{title:"印刷開始",body:"{{printer}}: {{filename}} の印刷を開始しました"},printCompleted:{title:"印刷完了",body:"{{printer}}: {{filename}} が正常に完了しました"},printFailed:{title:"印刷失敗",body:"{{printer}}: {{filename}} が失敗しました"},printStopped:{title:"印刷中止",body:"{{printer}}: {{filename}} が中止されました"},printProgress:{title:"印刷進捗",body:"{{printer}}: {{filename}} は {{percent}}% 完了"},printerOffline:{title:"プリンターオフライン",body:"{{printer}} がオフラインです"},printerError:{title:"プリンターエラー",body:"{{printer}}: {{error}}"},filamentLow:{title:"フィラメント残量低下",body:"{{printer}}: フィラメントが残りわずかです"},maintenanceDue:{title:"メンテナンス期限",body:"{{printer}}: {{items}} の対応が必要です"}},errors:{generic:"問題が発生しました",networkError:"ネットワークエラーです。接続を確認してください。",notFound:"見つかりません",unauthorized:"認証エラー",serverError:"サーバーエラー",validationError:"入力内容を確認してください",printerConnectionFailed:"プリンターへの接続に失敗しました",saveFailed:"保存に失敗しました",deleteFailed:"削除に失敗しました",loadFailed:"データの読み込みに失敗しました"},mqttDebug:{title:"MQTTデバッグログ",searchPlaceholder:"トピックまたはペイロードで検索...",noMessages:"まだメッセージが記録されていません",incoming:"受信",outgoing:"送信",loggingStopped:"ログ記録停止",loggingActive:"ログ記録中 - メッセージは自動更新されます",startLogging:"ログ記録を開始",topic:"トピック",startLoggingHint:"「ログ開始」をクリックしてMQTTメッセージのキャプチャを開始",noMessagesMatch:"フィルターに一致するメッセージがありません",adjustFilterHint:"検索条件やフィルター条件を調整してみてください",stopLogging:"ログ停止",clearLog:"ログをクリア",timestamp:"タイムスタンプ",direction:"方向",all:"すべて"},printerFiles:{filterPlaceholder:"ファイルを検索...",deleteFileConfirm:"このファイルを削除しますか?",noFiles:"このディレクトリにファイルがありません",loadingFiles:"ファイルを読み込み中...",failedToLoad:"ファイルの読み込みに失敗しました",title:"ファイル管理",storageUsed:"使用中:",storageFree:"空き:",deleteButton:"削除",deleteFiles:"{{count}}件のファイルを削除",deleteFilesConfirm:"選択した{{count}}件のファイルを削除しますか?元に戻せません。",toast:{filesDeleted:"{{count}}件のファイルを削除しました",deleteFailed:"削除に失敗: {{error}}"}},confirm:{delete:"削除しますか?",unsavedChanges:"保存されていない変更があります。このページを離れますか?",clearQueue:"キューをクリアしますか?"},login:{title:"Bambuddy ログイン",subtitle:"アカウントにサインイン",username:"ユーザー名",usernamePlaceholder:"ユーザー名を入力",password:"パスワード",passwordPlaceholder:"パスワードを入力",signIn:"サインイン",enterCredentials:"ユーザー名とパスワードを入力してください",signingIn:"ログイン中...",forgotPassword:"パスワードをお忘れですか?",loginSuccess:"ログインしました",loginFailed:"ログインに失敗しました",forgotPasswordTitle:"パスワードを忘れた場合",forgotPasswordMessage:"パスワードを忘れた場合は、システム管理者に連絡してリセットしてもらってください。",howToReset:"パスワードのリセット方法:",resetStep1:"Bambuddy管理者に連絡",resetStep2:"ユーザー管理でパスワードリセットを依頼",resetStep3:"管理者が新しい仮パスワードを設定",resetStep4:"新しいパスワードでログインし、設定で変更",gotIt:"了解",usernameOrEmail:"ユーザー名またはメール",usernameOrEmailPlaceholder:"ユーザー名または @ メール",forgotPasswordEmailMessage:"メールアドレスを入力すると、新しいパスワードを送信します。",emailAddress:"メールアドレス",emailPlaceholder:"your.email@example.com",cancel:"キャンセル",sending:"送信中...",sendResetEmail:"リセットメールを送信"},setup:{title:"Bambuddy セットアップ",adminAccount:"管理者アカウント",adminUsername:"管理者ユーザー名",adminPassword:"管理者パスワード",confirmPassword:"パスワードの確認",confirmPasswordPlaceholder:"パスワードを確認",settingUp:"セットアップ中...",completeSetup:"セットアップを完了",toast:{authEnabledAdminCreated:"認証が有効になり、管理者ユーザーが作成されました",authEnabledExistingAdmins:"既存の管理者ユーザーを使用して認証が有効になりました",setupCompleted:"セットアップが完了しました",passwordsDoNotMatch:"パスワードが一致しません",enterBothCredentials:"管理者のユーザー名とパスワードの両方を入力するか、既存の管理者を使用する場合は両方を空にしてください",passwordTooShort:"パスワードは6文字以上必要です"},adminAccountDesc:"既に管理者ユーザーが存在する場合、既存の管理者アカウントを使用して認証が有効化されます。既存の管理者を使用する場合は下のフィールドを空のままにするか、新しい認証情報を入力して新しい管理者ユーザーを作成してください。",optionalIfAdminExists:"(管理者ユーザーが存在する場合は任意)",adminUsernamePlaceholder:"管理者ユーザー名を入力(任意)",adminPasswordPlaceholder:"管理者パスワードを入力(任意)",subtitle:"Bambuddyインスタンスの認証を設定",enableAuth:"認証を有効化"},changePassword:{currentPassword:"現在のパスワード",newPassword:"新しいパスワード",confirmPasswordPlaceholder:"パスワードを確認",title:"パスワードを変更",currentPasswordPlaceholder:"現在のパスワードを入力",newPasswordPlaceholder:"新しいパスワードを入力(6文字以上)",confirmPassword:"新しいパスワード確認",passwordsDoNotMatch:"パスワードが一致しません",passwordTooShort:"パスワードは6文字以上必要です",changing:"変更中...",success:"パスワードを変更しました",failed:"パスワードの変更に失敗しました"},camera:{invalidPrinterId:"無効なプリンターID",live:"ライブ",snapshot:"スナップショット",restartStream:"ストリームを再開",refreshSnapshot:"スナップショットを更新",fullscreen:"フルスクリーン",exitFullscreen:"フルスクリーンを終了",connectingToCamera:"カメラに接続中...",capturingSnapshot:"スナップショットを撮影中...",connectionLost:"接続が切断されました",reconnectNow:"今すぐ再接続",cameraUnavailable:"カメラが利用できません",retry:"再試行",cameraStream:"カメラストリーム",zoomOut:"ズームアウト",zoomIn:"ズームイン",resetZoom:"ズームをリセット",chamberLight:"チャンバーライト切替",title:"カメラビュー",connectionFailed:"カメラ接続に失敗しました",reconnecting:"{{countdown}}秒後に再接続... (試行 {{attempt}}/{{max}})",cameraUnavailableDesc:"プリンターの電源がオンで接続されていることを確認してください。",noCamera:"カメラがありません",recording:"録画中",startRecording:"録画開始",stopRecording:"録画停止"},groups:{backToSettings:"設定に戻る",createGroup:"グループを作成",noPermission:"このページにアクセスする権限がありません。",noDescription:"説明なし",usersCount:"{{count}}人のユーザー",permissionsCount:"{{count}}個の権限",toast:{deleted:"アーカイブを削除しました",enterGroupName:"グループ名を入力",created:"グループを作成しました",updated:"グループを更新しました"},modal:{editGroup:"グループを編集",createGroup:"グループを作成",cancel:"キャンセル",saving:"保存中...",creating:"作成中...",saveChanges:"変更を保存"},form:{groupName:"グループ名",permissions:"権限",groupNamePlaceholder:"グループ名を入力",systemGroupWarning:"システムグループ名は変更できません",description:"説明",descriptionPlaceholder:"説明を入力(任意)"},deleteModal:{confirm:"確認",title:"グループを削除",message:"このグループを削除しますか?このグループのユーザーはこれらの権限を失います。"},title:"グループ管理",subtitle:"アクセス制御の権限グループを管理",system:"システム",edit:"編集",delete:"削除"},users:{title:"ユーザー管理",backToSettings:"設定に戻る",createUser:"ユーザーを作成",noPermission:"このページにアクセスする権限がありません。",admin:"管理者",noGroups:"グループなし",inactive:"非アクティブ",edit:"編集",delete:"削除",system:"システム",noGroupsAvailable:"利用可能なグループがありません",table:{username:"ユーザー名",groups:"グループ",status:"ステータス",actions:"アクション"},toast:{deleted:"アーカイブを削除しました",passwordsDoNotMatch:"パスワードが一致しません",created:"ユーザーを作成しました",updated:"ユーザーを更新しました",fillRequired:"必須項目をすべて入力してください",passwordTooShort:"パスワードは6文字以上必要です"},modal:{createUser:"ユーザーを作成",editUser:"ユーザーを編集",cancel:"キャンセル",creating:"作成中...",saving:"保存中...",saveChanges:"変更を保存",advancedAuthSubtitle:"高度な認証を使用"},form:{username:"ユーザー名",password:"パスワード",confirmPassword:"パスワードの確認",confirmPasswordPlaceholder:"パスワードを確認",confirmNewPasswordPlaceholder:"新しいパスワードを確認",leaveBlankToKeep:"(現在のパスワードを維持する場合は空白)",groups:"グループ",usernamePlaceholder:"ユーザー名を入力",passwordPlaceholder:"パスワードを入力",newPasswordPlaceholder:"新しいパスワードを入力",email:"メール",emailPlaceholder:"user@example.com",optional:"オプション",autoGeneratedPassword:"安全なパスワードが自動的に生成され、ユーザーにメールで送信されます。",passwordManagedByAdvancedAuth:"パスワードは高度な認証によって管理されています。「パスワードのリセット」を使用して、メールで新しいパスワードをユーザーに送信してください。",resetPassword:"パスワードのリセット",resettingPassword:"パスワードをリセット中..."},deleteModal:{title:"ユーザーを削除",confirm:"ユーザーを削除",message:"このユーザーを削除してもよろしいですか?この操作は元に戻せません。"},subtitle:"ユーザーとBambuddyインスタンスへのアクセスを管理",active:"アクティブ"},streamOverlay:{invalidPrinterId:"無効なプリンターID",cameraStream:"カメラストリーム",eta:"予想時間 {{minutes}} 分",status:{printing:"印刷中",paused:"一時停止",finished:"完了",failed:"失敗",idle:"待機中",unknown:"不明"},title:"ストリームオーバーレイ",progress:"進捗",tomorrow:"明日",printerIdle:"プリンター待機中",printerOffline:"プリンターオフライン"},profiles:{title:"フィラメントプロファイル",connectedAs:"接続中:",logout:"ログアウト",failedToLoad:"ファイルの読み込みに失敗しました",time:{justNow:"たった今",hoursAgo:"{{count}}時間前",daysAgo:"{{count}}日前",minsAgo:"{{count}}分前"},toast:{loggedOut:"ログアウトしました"},login:{title:"Bambuddy ログイン",subtitle:"アカウントにサインイン",email:"メールアドレス",password:"パスワード",region:"リージョン",regionGlobal:"グローバル",regionChina:"中国",verificationCode:"認証コード",totpCode:"認証アプリコード",checkEmail:"メール ({{email}}) に届いた6桁のコードを入力してください",enterTotpHint:"認証アプリの6桁のコードを入力してください",accessToken:"アクセストークン",accessTokenHint:"Bambu Labのアクセストークンを貼り付け(Bambu Studioから取得)",back:"戻る",toast:{loggedIn:"ログインしました",enterTotp:"認証アプリのコードを入力してください",tokenSet:"トークンを設定しました",codeSent:"メールに認証コードを送信しました"},loginButton:"ログイン",verifyButton:"認証",setTokenButton:"トークンを設定",useToken:"アクセストークンを使用",useEmail:"メールでログイン"},presets:{duplicate:"複製",editable:"編集可能",failedToLoadDetails:"プリセットの詳細を読み込めませんでした",deleteConfirm:"このプロファイルを削除しますか?",noDeletePermission:"プロジェクトを削除する権限がありません",types:{filament:"フィラメント",printer:"プリンター",process:"プロセス"},toast:{deleted:"アーカイブを削除しました",fieldAdded:'フィールド "{{key}}" を追加しました',created:"プリセットを作成しました",updated:"プリセットを更新しました",duplicated:"プリセットを複製しました",exported:"プリセットをエクスポートしました"},newPreset:"新規プリセット",editPreset:"プリセットを編集",duplicatePreset:"プリセットを複製",createNewPreset:"新しいプリセットを作成",customizeSettings:"新しいプリセットの設定をカスタマイズ",compareWithBase:"ベースプリセットと比較",compare:"比較",basePreset:"ベースプリセット",selectBasePreset:"ベースプリセットを選択...",presetName:"プリセット名",inheritsFrom:"継承元:",dropJsonToImport:"JSONファイルをドロップしてインポート",availableFields:"利用可能なフィールド",noMatchingFields:"一致するフィールドがありません",allFieldsAdded:"すべてのフィールドが追加済みです",addCustomField:"カスタムフィールドを追加",yourOverrides:"オーバーライド一覧",noOverridesYet:"オーバーライドはまだありません",clickFieldsToAdd:"左のフィールドをクリックして追加",saveAsTemplate:"テンプレートとして保存",myPreset:"マイプリセット(編集可能)",deleteWarning:"「{{name}}」をBambu Cloudから完全に削除します。元に戻せません。",noDuplicatePermission:"プリセットを複製する権限がありません",noEditPermission:"プリセットを編集する権限がありません",baseLabel:"ベース: {{name}}",currentLabel:"現在: {{name}}",myCustomPreset:"カスタムプリセット",tabs:{common:"一般",allFields:"すべてのフィールド"},searchFieldsPlaceholder:"フィールドを検索...",jsonTip:"ヒント: .jsonファイルをこのモーダルにドラッグ&ドロップして設定をインポート"},cloudView:{templates:"テンプレート",refresh:"更新",newPreset:"新規プリセット",clearFilters:"フィルターをクリア",compareMode:"比較モード",selectAnotherPreset:"同じタイプ({{type}})の別のプリセットを選択",clickTwoPresets:"同じタイプのプリセットを2つクリックして比較",selectFirst:"1. 最初を選択",selectSecond:"2. 2番目を選択",compareNow:"比較を実行",lastSynced:"最終同期:",showingCount:"{{total}}件中{{shown}}件を表示",noPresetsFound:"プリセットが見つかりません",columns:{filament:"フィラメント",process:"プロセス",printer:"プリンター"},noFilamentPresets:"フィラメントプリセットなし",noProcessPresets:"プロセスプリセットなし",noPrinterPresets:"プリンタープリセットなし",filters:{type:"種類",owner:"所有者",printer:"プリンター",nozzle:"ノズル",filament:"フィラメント",layer:"レイヤー",myPresets:"マイプリセット",builtIn:"ビルトイン",process:"プロセス",all:"すべて"},noCreatePermission:"プロジェクトを作成する権限がありません",searchPlaceholder:"プリセットを検索...",noTemplatesPermission:"テンプレートを管理する権限がありません",noRefreshPermission:"プロファイルを更新する権限がありません"},templates:{title:"フィラメントプロファイル",noTemplates:"テンプレートがありません。バックエンドを再起動してデフォルトテンプレートを作成してください。",typeFilter:"タイプ:",deleteConfirm:"このプロファイルを削除しますか?",settingsJson:"設定 (JSON)",fieldsCount:"{{count}}フィールド",shownInModals:"モーダルに表示",hiddenInModals:"モーダルで非表示",apply:"適用",toast:{deleted:"アーカイブを削除しました",updated:"テンプレートを更新しました",created:"テンプレートを作成しました",applied:"テンプレートを適用しました"},createFirst:"プリセットエディタからテンプレートを作成",deleteTitle:"テンプレートを削除",deleteWarning:"この操作は元に戻せません",namePlaceholder:"テンプレート名",descriptionPlaceholder:"説明"},subtitle:"スライサープリセットと圧力キャリブレーションの管理",tabs:{cloud:"クラウドプロファイル",local:"ローカルプロファイル",kprofiles:"Kプロファイル"},localProfiles:{title:"ローカルプロファイル",subtitle:"OrcaSlicerからスライサープリセットをインポート・管理",import:"プロファイルをインポート",importDesc:".bbscfg、.bbsflmt、.orca_filament、.zip、.jsonファイルをここにドロップ",importing:"インポート中...",search:"ローカルプリセットを検索...",noPresets:"ローカルプリセットがまだありません",badge:"ローカル",edit:"編集",delete:"削除",cancel:"キャンセル",deleteConfirmTitle:"プリセットを削除",deleteConfirm:"このプリセットを削除してもよろしいですか?元に戻せません。",source:"ソース",inheritsFrom:"継承元",filamentType:"タイプ",vendor:"メーカー",compatiblePrinters:"プリンター",nozzleTemp:"ノズル温度",cost:"コスト",density:"密度",pressureAdvance:"プレッシャーアドバンス",filament:"フィラメント",process:"プロセス",printer:"プリンター",toast:{importSuccess:"{{count}}件のプリセットをインポートしました",importSkipped:"{{count}}件のプリセットをスキップしました(重複)",importError:"インポート中に{{count}}件のエラーが発生しました",deleted:"プリセットを削除しました",updated:"プリセットを更新しました"}},noLogoutPermission:"ログアウトする権限がありません",retry:"リトライ"},fileManager:{uploadFiles:"ファイルをアップロード",newFolder:"新しいフォルダ",folderName:"フォルダ名",folderNamePlaceholder:"例: 機能パーツ",renameFile:"ファイル名を変更",renameFolder:"フォルダ名を変更",rootNoFolder:"ルート(フォルダなし)",current:"(現在)",linkFolder:"フォルダをリンク",linkFolderDescription:"「{{name}}」をプロジェクトまたはアーカイブにリンクしてすばやくアクセス。",noProjectsFound:"プロジェクトが見つかりません",noArchivesFound:"アーカイブが見つかりません",unlink:"リンク解除",link:"リンク",dropFilesHere:"ここにファイルをドロップ",orClickToBrowse:"またはクリックして選択",zipFilesDetected:"ZIPファイルを検出",preserveZipStructure:"ZIPのフォルダ構造を保持",willBeExtracted:"• 展開予定",filesExtracted:"• {{count}}個のファイルを展開済み",uploadComplete:"アップロード完了: {{count}}個成功",uploadFailed:"アップロード失敗",uploading:"アップロード中...",changeLink:"リンクを変更...",linkTo:"リンク先...",linkToProjectOrArchive:"プロジェクトまたはアーカイブにリンク",addToQueue:"キューに追加",schedulePrint:"印刷をスケジュール",gridView:"グリッド表示",listView:"リスト表示",lowDiskSpaceWarning:"ディスク容量不足の警告",folders:"フォルダ",size:"サイズ",free:"空き:",allFiles:"すべてのファイル",searchFiles:"ファイルを検索...",allTypes:"すべての種類",prints:"印刷回数",ascending:"昇順",descending:"降順",selectAll:"すべて選択",deselectAll:"すべて選択解除",selected:"{{count}}件選択中",adding:"追加中...",loadingFiles:"ファイルを読み込み中...",noFilesYet:"ファイルはまだありません",noMatchingFiles:"一致するファイルがありません",noMatchingFilesDescription:"現在の検索またはフィルター条件に一致するファイルがありません。",clearFilters:"フィルターをクリア",printedCount:"{{count}}回印刷済み",deleteFolder:"フォルダを削除",deleteFile:"ファイルを削除",deleteFolderConfirm:"このフォルダを削除しますか?中のファイルもすべて削除されます。",deleteFileConfirm:"このファイルを削除しますか?",deleting:"削除中...",toast:{folderCreated:"フォルダを作成しました",folderDeleted:"フォルダを削除しました",fileDeleted:"ファイルを削除しました",filesMoved:"ファイルを移動しました",folderLinked:"フォルダをリンクしました",folderUnlinked:"フォルダのリンクを解除しました",addedToQueue:"{{count}}個のファイルをキューに追加しました",fileRenamed:"ファイル名を変更しました",folderRenamed:"フォルダ名を変更しました",filesDeleted:"{{count}}件のファイルを削除しました",addedToQueuePartial:"{{added}}件追加、{{failed}}件失敗",failedToAddToQueue:"ファイルの追加に失敗: {{error}}",thumbnailsGenerated:"{{count}}件のサムネイルを生成しました",thumbnailsGeneratedPartial:"{{succeeded}}件生成、{{failed}}件失敗",noStlMissingThumbnails:"サムネイルのないSTLファイルはありません",failedToGenerateThumbnails:"サムネイルの生成に失敗: {{error}}",thumbnailGenerated:"サムネイルを生成しました",failedToGenerateThumbnail:"サムネイルの生成に失敗: {{error}}"},title:"ファイル管理",subtitle:"印刷ファイルの整理と管理",moveFiles:"{{count}}件のファイルを移動",project:"プロジェクト",archive:"アーカイブ",dragDropFiles:"ファイルをここにドラッグ&ドロップ",allFileTypesSupported:"すべてのファイルタイプに対応。ZIPファイルは展開されます。",zipExtractOptions:"ZIPファイルは展開されます。フォルダー構造の処理方法を選択:",createFolderFromZip:"ZIPファイル名からフォルダーを作成",stlThumbnailGeneration:"STLサムネイル生成",zipMayContainStl:"ZIPファイルにSTLファイルが含まれている場合があります。展開時にサムネイルを生成できます。",thumbnailsCanBeGenerated:"STLファイルのサムネイルを生成できます。大きなモデルは処理に時間がかかる場合があります。",generateThumbnailsForStl:"STLファイルのサムネイルを生成",threemfDetected:"3MFファイルを検出",threemfExtractionInfo:"プリンターモデル、素材、色、印刷設定は3MFファイルから自動的に抽出されます。",generateThumbnail:"サムネイルを生成",generateThumbnails:"サムネイルを生成",generateThumbnailsForMissing:"サムネイルのないSTLファイルのサムネイルを生成",lowDiskSpaceDetails:"{{total}}中{{free}}の空き容量のみ。しきい値は設定で{{threshold}}GBに設定されています。",files:"ファイル",wrap:"折り返し",enableTextWrapping:"テキスト折り返しを有効化",disableTextWrapping:"テキスト折り返しを無効化",dragToResizeTooltip:"ドラッグしてリサイズ、ダブルクリックでリセット",resultsCount:"{{total}}件中{{showing}}件",folderIsEmpty:"フォルダーは空です",folderEmptyDescription:"ファイルをアップロードするか、このフォルダーにファイルを移動して開始しましょう。",noFilesDescription:"印刷関連ファイルの整理を始めるにはファイルをアップロードしてください。",uploadedBy:"アップロード者",deleteFilesCount:"{{count}}件のファイルを削除",deleteFilesConfirm:"選択した{{count}}件のファイルを削除しますか?この操作は元に戻せません。",noPermissionRenameFolder:"フォルダー名を変更する権限がありません",noPermissionLinkFolder:"フォルダーをリンクする権限がありません",noPermissionDeleteFolder:"フォルダーを削除する権限がありません",noPermissionPrint:"印刷する権限がありません",noPermissionAddToQueue:"キューに追加する権限がありません",noPermissionDownload:"ファイルをダウンロードする権限がありません",noPermissionRenameFile:"このファイル名を変更する権限がありません",noPermissionGenerateThumbnail:"サムネイルを生成する権限がありません",noPermissionDeleteFile:"このファイルを削除する権限がありません",noPermissionCreateFolder:"フォルダーを作成する権限がありません",noPermissionUpload:"ファイルをアップロードする権限がありません",noPermissionMoveFiles:"ファイルを移動する権限がありません",noPermissionDeleteFiles:"ファイルを削除する権限がありません"},projects:{title:"プロジェクト",subtitle:"印刷プロジェクトを管理",newProject:"新規プロジェクト",editProject:"プロジェクトを編集",deleteProject:"プロジェクトを削除",projectName:"プロジェクト: {{name}}",create:"作成",plates:"プレート",parts:"パーツ",viewDetails:"詳細を表示",namePlaceholder:"プロジェクト名",descriptionPlaceholder:"プロジェクトの説明(任意)",color:"色",targetPlates:"目標プレート数",targetPlatesPlaceholder:"例: 10",targetParts:"目標パーツ数",targetPartsPlaceholder:"例: 50",tagsPlaceholder:"カンマ区切りのタグ",dueDate:"期限",priorityLow:"低",priorityNormal:"通常",priorityHigh:"高",priorityUrgent:"緊急",statusArchived:"アーカイブ済み",done:"完了",completed:"完了",failed:"失敗",inQueue:"キュー内",noPrintsYet:"印刷履歴なし",printJobs:"印刷ジョブ",partsPrinted:"印刷済みパーツ",failedParts:"失敗パーツ",import:"インポート",importProject:"プロジェクトをインポート",loading:"プロジェクトを読み込み中...",noEditPermission:"プロジェクトを編集する権限がありません",noDeletePermission:"プロジェクトを削除する権限がありません",noCreatePermission:"プロジェクトを作成する権限がありません",noImportPermission:"プロジェクトをインポートする権限がありません",noExportPermission:"プロジェクトをエクスポートする権限がありません",toast:{deleted:"アーカイブを削除しました",importFailed:"インポートに失敗しました",created:"プロジェクトを作成しました",updated:"プロジェクトを更新しました",imported:"プロジェクトをインポートしました",multipleImported:"{{count}}件のプロジェクトをインポートしました",exported:"プロジェクトをエクスポートしました(メタデータのみ)"},description:"説明",noProjects:"プロジェクトはまだありません",noProjectsFiltered:"{{status}}のプロジェクトはありません",noProjectsFilteredHelp:"{{status}}のプロジェクトがありません。ステータスが変更されるとここに表示されます。",createFirst:"最初のプロジェクトを作成して、関連する印刷の整理、進捗管理、ビルドの管理を始めましょう。",createFirstButton:"最初のプロジェクトを作成",files:"ファイル",prints:"印刷",lastModified:"最終更新日",deleteConfirm:"このプロジェクトを削除しますか?アーカイブとキューアイテムはリンク解除されますが、削除されません。",addFiles:"ファイルを追加",removeFile:"ファイルを削除",targetPlatesHelp:"印刷ジョブの数",targetPartsHelp:"必要なオブジェクトの総数",tagsLabel:"タグ(カンマ区切り)",priority:"優先度",statusActive:"進行中",statusCompleted:"完了",export:"エクスポート",exportAll:"すべてのプロジェクトをエクスポート"},projectDetail:{notFound:"見つかりません",backToProjects:"プロジェクト一覧に戻る",exportProject:"プロジェクトをエクスポート",noExportPermission:"プロジェクトをエクスポートする権限がありません",noEditPermission:"このプロジェクトを編集する権限がありません",partOf:"所属先",priorityLabel:"優先度",status:{active:"進行中",completed:"完了",archived:"アーカイブ済み"},priority:{low:"低",normal:"通常",high:"高",urgent:"緊急"},dueDate:{overdue:"期限超過",daysLeft:"残り{{count}}日",today:"今日が期限"},progress:{platesProgress:"プレート進捗",partsProgress:"パーツ進捗",printJobs:"印刷ジョブ",parts:"パーツ",percentComplete:"% 完了",remaining:"残り"},stats:{printJobs:"印刷ジョブ",total:"合計",failed:"失敗",partsPrinted:"印刷済みパーツ",printTime:"印刷時間",filamentUsed:"フィラメント使用量"},cost:{filamentCost:"フィラメント",energy:"エネルギー",budget:"予算",remaining:"残り",title:"コスト追跡"},notes:{noEditPermission:"このプロジェクトを編集する権限がありません",empty:"<空>",title:"メモ",placeholder:"このプロジェクトについてメモを追加..."},files:{fileCount:"{{count}}ファイル",empty:"<空>",title:"ファイル",linkFolders:"ファイルマネージャーからフォルダーをリンク",forQuickAccess:"してクイックアクセスできるようにします。"},bom:{showAll:"すべて表示",hideDone:"完了を非表示",addPart:"パーツを追加",partNamePlaceholder:"パーツ名",qty:"数量",sourcingUrlPlaceholder:"URL(任意)",remarksPlaceholder:"備考",deletePart:"パーツを削除",noEditPermission:"このプロジェクトを編集する権限がありません",noDeletePermission:"プロジェクトを削除する権限がありません",totalCost:"合計コスト",empty:"<空>",title:"部品表",acquired:"{{completed}}/{{total}} 取得済み",noAddPermission:"パーツを追加する権限がありません",partName:"パーツ名",price:"価格 ({{currency}})",deleteConfirm:"「{{name}}」を削除しますか?",noUpdatePermission:"パーツを更新する権限がありません"},timeline:{empty:"<空>",title:"アクティビティタイムライン"},template:{saveAsTemplate:"テンプレートとして保存",noCreatePermission:"プロジェクトを作成する権限がありません"},queue:{title:"印刷キュー",viewAll:"すべて表示",printing:"印刷中",queued:"キューに追加"},toast:{projectUpdated:"プロジェクトを更新しました",partAdded:"パーツを追加しました",partRemoved:"パーツを削除しました",exportFailed:"エクスポートに失敗しました",projectExported:"プロジェクトがエクスポートされました",templateCreated:"プロジェクトからテンプレートを作成しました"},export:"エクスポート",noPrints:"このプロジェクトにはまだ印刷がありません",subProjects:{title:"サブプロジェクト ({{count}})"},prints:{title:"印刷 ({{count}})"}},system:{clearLogs:"通知ログを削除",title:"システム情報",version:"バージョン",uptime:"稼働時間",cpuUsage:"CPU使用率",memoryUsage:"メモリ使用量",diskUsage:"ディスク使用量",networkInfo:"ネットワーク情報",logs:"ログ",debugMode:"デバッグモード",enableDebug:"デバッグログを有効化",disableDebug:"デバッグログを無効化",downloadLogs:"ログをダウンロード",dockerInfo:"Docker情報",containerName:"コンテナ名",imageName:"イメージ名",platform:"プラットフォーム",architecture:"アーキテクチャ"},library:{material:"素材",temperature:"温度",title:"フィラメントライブラリ",addFilament:"フィラメントを追加",editFilament:"フィラメントを編集",deleteFilament:"フィラメントを削除",vendor:"メーカー",color:"色",kFactor:"K値",noFilaments:"ライブラリにフィラメントがありません",deleteConfirm:"このフィラメントを削除しますか?",importFromPrinter:"プリンターからインポート",exportToFile:"ファイルにエクスポート"},spoolman:{title:"Spoolman連携",url:"Spoolman URL",connected:"接続中",disconnected:"未接続",sync:"同期",linkToSpoolman:"Spoolmanに連携",noUnlinkedSpools:"Spoolmanに未連携のスプールが見つかりません。",fillSourceLabel:"(Spoolman)",remaining:"残り",disableWeightSync:"AMS推定重量同期を無効化",disableWeightSyncDesc:"AMS推定値から残量を更新しません。AMSの割合ベースの推定よりもSpoolmanの使用量追跡を優先する場合に使用してください。新しいスプールは引き続きAMS推定値を初期重量として使用します。",reportPartialUsage:"失敗した印刷の部分使用量を報告",reportPartialUsageDesc:"印刷が失敗またはキャンセルされた場合、レイヤー進捗に基づいてその時点までの推定フィラメント使用量を報告します。",testConnection:"接続テスト",syncing:"同期中...",lastSync:"最終同期",unlinkSpool:"スプールのリンクを解除",weight:"重量",enabled:"Spoolman有効",openInSpoolman:"Spoolmanで開く",selectSpool:"スプールを選択",linkSuccess:"スプールをSpoolmanにリンクしました",linkFailed:"スプールのリンクに失敗しました",spoolId:"スプールID"},inventory:{title:"スプール在庫管理",addSpool:"スプールを追加",editSpool:"スプールを編集",material:"素材",selectMaterial:"素材を選択...",subtype:"サブタイプ",brand:"ブランド",searchBrand:"ブランドを検索...",useCustomBrand:"「{{brand}}」を使用",colorName:"色名",colorNamePlaceholder:"Jade White, Fire Red...",color:"色",hexColor:"HEXカラー",pickColor:"カスタムカラーを選択",labelWeight:"表示重量",coreWeight:"空スプール重量",searchSpoolWeight:"スプール重量を検索...",weightUsed:"使用量",currentWeight:"残量",slicerFilament:"スライサーフィラメント",slicerFilamentName:"スライサープリセット名",slicerPreset:"スライサープリセット",searchPresets:"フィラメントプリセットを検索...",selectedPreset:"選択済み",noPresetsFound:"プリセットが見つかりません",tempOverrides:"温度オーバーライド",note:"メモ",notePlaceholder:"このスプールに関する追加メモ...",archive:"アーカイブ",restore:"復元",noSpools:"スプールがありません。最初のスプールを追加してください。",noManualSpools:"手動で追加されたスプールがありません。先にインベントリにスプールを追加してください。",kProfiles:"Kプロファイル",addKProfile:"Kプロファイルを追加",assignSpool:"スプールを割り当て",unassignSpool:"割り当て解除",assignSuccess:"スプールを割り当て、AMSスロットを設定しました",assignFailed:"スプールの割り当てに失敗しました",selectSpool:"このスロットに割り当てるスプールを選択",assigned:"割り当て済み",assigning:"割り当て中...",searchSpools:"スプールを検索...",allMaterials:"すべての素材",filterByBrand:"ブランドで絞り込み...",showArchived:"アーカイブ済みを表示",spoolCreated:"スプールを作成しました",spoolUpdated:"スプールを更新しました",spoolDeleted:"スプールを削除しました",spoolArchived:"スプールをアーカイブしました",spoolRestored:"スプールを復元しました",deleteConfirm:"このスプールを削除しますか?この操作は元に戻せません。",advancedSettings:"詳細設定",filamentInfoTab:"フィラメント情報",paProfileTab:"PAプロファイル",filamentInfo:"フィラメント",additional:"追加情報",loadingPresets:"クラウドプリセットを読み込み中...",cloudConnected:"クラウド接続済み",cloudNotConnected:"クラウド未接続(デフォルト使用)",recentColors:"最近",searchColors:"色を検索...",searchResults:"検索結果",allColors:"すべての色",commonColors:"一般的な色",showLess:"少なく表示",showAll:"すべて表示",noColorsFound:"一致する色がありません",noResults:"結果なし",selectMaterialFirst:"フィラメント情報タブで素材を選択してください。",noPrintersConfigured:"プリンターが設定されていません。プリンターを追加してください。",matchingFilter:"フィルター",anyBrand:"すべてのブランド",anyVariant:"すべてのバリアント",autoSelect:"自動選択",matches:"件一致",match:"件一致",noMatches:"一致なし",connected:"接続済み",offline:"オフライン",printerOffline:"プリンターがオフラインです。接続してキャリブレーションプロファイルを表示してください。",noKProfilesMatch:"選択したフィラメントに一致するKプロファイルがありません。",leftNozzle:"左ノズル",rightNozzle:"右ノズル",profilesSelected:"キャリブレーションプロファイル選択済み",totalInventory:"在庫合計",totalConsumed:"総消費量",byMaterial:"素材別",inPrinter:"プリンター内",lowStock:"残量少",sinceTracking:"追跡開始以降",loadedInAms:"AMS/Extに装填中",remaining:"残り",lowStockThreshold:"残り20%未満",search:"スプールを検索...",showing:"表示",to:"〜",of:"/",show:"表示",spools:"スプール",spool:"スプール",page:"ページ",noSpoolsMatch:"結果なし",noSpoolsMatchDesc:"検索やフィルターを調整してみてください。",active:"アクティブ",archived:"アーカイブ済み",all:"すべて",used:"使用済み",new:"新規",clearFilters:"フィルターをクリア",table:"テーブル",cards:"カード",net:"正味",columns:"列",configureColumns:"列の設定",configureColumnsDesc:"ドラッグして並べ替えるか、矢印を使用してください。目のアイコンで表示/非表示を切り替えます。",visible:"表示中",reset:"リセット",cancel:"キャンセル",applyChanges:"変更を適用",moveUp:"上へ移動",moveDown:"下へ移動",hideColumn:"列を非表示",showColumn:"列を表示",linkToSpool:"スプールにリンク",tagLinked:"タグがスプールにリンクされました",tagLinkFailed:"タグのリンクに失敗しました",tagAlreadyLinked:"タグは既に別のスプールにリンクされています",unknownTag:"不明なRFIDタグが検出されました",usageHistory:"使用履歴",noUsageHistory:"まだ使用記録がありません",printName:"プリント名",weightConsumed:"消費重量",clearHistory:"クリア",historyCleared:"使用履歴がクリアされました",fillSourceLabel:"(Inv)"},timelapse:{download:"ダウンロード",preview:"プレビュー",processing:"バックアップファイルを処理中...",title:"タイムラプス",create:"タイムラプスを作成",delete:"削除",frameRate:"フレームレート",quality:"品質",noTimelapses:"利用可能なタイムラプスがありません"},ams:{empty:"<空>",humidity:"湿度",temperature:"温度",remaining:"残り",noHistory:"メンテナンス履歴がありません",configureSlot:"フィラメントプロファイルとK値でスロットを設定",externalSpool:"外部スプール",title:"AMS",slot:"スロット",emptySlot:"空のスロット",unknown:"不明",filamentType:"フィラメントタイプ",filamentColor:"色",history:"AMS履歴",profile:"プロファイル",kFactor:"K値",fill:"充填率",configure:"設定"},printModal:{flowCalibration:"フローキャリブレーション",vibrationCalibration:"振動キャリブレーション",startPrint:"印刷を開始",noPrintersAvailable:"利用可能なプリンターがありません",title:"印刷を開始",selectPrinter:"プリンターを選択",selectPlate:"プレートを選択",filamentMapping:"フィラメントマッピング",printSettings:"印刷設定",bedLeveling:"ベッドレベリング",layerInspection:"第一層検査",timelapse:"タイムラプス",addToQueue:"キューに追加",printerBusy:"プリンターは使用中です",printerOffline:"プリンターはオフラインです",cancel:"キャンセル",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"左ノズル",rightNozzleTooltip:"右ノズル"},backup:{restoreBackup:"バックアップの復元",restoreDescription:"バックアップファイルからすべてのデータを置き換える",lastBackup:"最終バックアップ",autoBackup:"自動バックアップ",backupNow:"今すぐバックアップ",backupFailed:"バックアップに失敗しました: {{error}}",restoreNote:"復元中、仮想プリンターは停止されます",downloadBackup:"バックアップをダウンロード",uploadBackup:"バックアップをアップロード",restoreWarning:"警告: バックアップの復元は現在のすべてのデータを上書きします。",includeArchives:"アーカイブを含む",includeSettings:"設定を含む",includeProfiles:"プロファイルを含む",backupSuccess:"バックアップを作成しました",restoreSuccess:"バックアップを復元しました",restoreFailed:"復元に失敗しました",title:"バックアップと復元",createBackup:"バックアップを作成"},uploadModal:{title:"3MFファイルのアップロード",dragDrop:".3mfファイルをここにドラッグ&ドロップ",or:"または",browseFiles:"ファイルを参照",uploaded:"アップロード済み",failed:"アップロードに失敗しました",uploading:"アップロード中...",upload:"アップロード",uploadFailed:"アップロード失敗",extractionInfo:"プリンターモデルは3MFファイルのメタデータから自動的に抽出されます。"},editArchive:{title:"アーカイブを編集",name:"名前",printer:"プリンター",noPrinter:"プリンターなし",project:"プロジェクト",noProject:"プロジェクトなし",itemsPrinted:"印刷数",notes:"メモ",notesPlaceholder:"この印刷についてメモを追加...",externalLink:"外部リンク",externalLinkPlaceholder:"https://...",tags:"タグ",addMoreTags:"タグをさらに追加...",status:"ステータス",failureReason:"失敗理由",selectReason:"理由を選択...",photos:"印刷結果の写真",printResult:"印刷結果",saving:"保存中...",failureReasons:{adhesionFailure:"定着不良",spaghettiDetached:"スパゲッティ / 剥離",layerShift:"レイヤーシフト",cloggedNozzle:"ノズル詰まり",filamentRunout:"フィラメント切れ",warping:"反り",stringing:"糸引き",underExtrusion:"押出不足",powerFailure:"電源障害",userCancelled:"ユーザーによるキャンセル",other:"その他"},itemsPrintedHelp:"この印刷ジョブで製造したアイテム数",externalLinkHelp:"Printables、Thingiverse、その他のソースへのリンク",matchingTags:'"{{query}}" に一致',existingTags:"既存のタグ",clickToAdd:"(クリックして追加)",photosHelp:"+ をクリックして印刷結果の写真を追加",namePlaceholder:"印刷名",tagsPlaceholder:"タグを追加...",statuses:{completed:"完了",failed:"失敗",aborted:"キャンセル",printing:"印刷中"}},kProfiles:{noPrintersConfigured:"プリンターが設定されていません",noActivePrinters:"アクティブなプリンターがありません",loadingProfiles:"Kプロファイルを読み込み中...",printerOffline:"プリンターオフライン",noMatchingProfiles:"一致するプロファイルなし",noKProfiles:"Kプロファイルなし",createFirstProfile:"最初のプロファイルを作成",nozzle:"ノズル",refresh:"更新",addProfile:"K-プロファイルを追加",import:"インポート",select:"選択",selectAll:"すべて選択",searchPlaceholder:"名前またはフィラメントで検索...",allExtruders:"すべてのエクストルーダー",leftOnly:"左のみ",rightOnly:"右のみ",allFlow:"すべてのフロー",hfOnly:"HFのみ",sOnly:"Sのみ",sortName:"ソート: 名前",sortKValue:"ソート: K値",sortFilament:"ソート: フィラメント",leftExtruder:"左エクストルーダー",rightExtruder:"右エクストルーダー",modal:{profileName:"プロファイル名",profileNamePlaceholder:"マイPLAプロファイル",kValue:"K値",filament:"フィラメント",selectFilament:"フィラメントを選択...",flowType:"フロータイプ",highFlow:"ハイフロー",standard:"スタンダード",nozzleSize:"ノズルサイズ",extruder:"エクストルーダー",extruders:"エクストルーダー",left:"左",right:"右",notesPlaceholder:"このプロファイルのメモを追加...",pleaseWait:"お待ちください",addTitle:"Kプロファイルを追加",editTitle:"Kプロファイルを編集",kValuePlaceholder:"0.020",kValueHelp:"一般的な範囲: PLA 0.01〜0.06、PETG 0.02〜0.10",noFilamentsHelp:"フィラメントが見つかりません。Bambu Studioでまずプロファイルを作成してください。",notes:"メモ(ローカル保存)",notesHelp:"メモはBambuddyに保存され、プリンターには保存されません",syncing:"プリンターと同期中...",savingExtruder:"エクストルーダーに保存中 {{current}}/{{total}}..."},toast:{profileSaved:"Kプロファイルを保存しました",profileDeleted:"Kプロファイルを削除しました",exportedProfiles:"{{count}}件のプロファイルをエクスポートしました",importedProfiles:"{{total}}件中{{imported}}件のプロファイルをインポートしました",noProfilesToExport:"エクスポートするプロファイルがありません",invalidFileFormat:"無効なファイル形式",failedToParseImport:"インポートファイルの解析に失敗しました",failedToSaveNote:"メモの保存に失敗しました",profilesSaved:"Kプロファイルを{{count}}台のエクストルーダーに保存しました",selectAtLeastOneExtruder:"エクストルーダーを1つ以上選択してください",profilesDeleted:"{{count}}件のプロファイルを削除しました",failedToSaveBatch:"Kプロファイルの保存に失敗しました",noteSaved:"メモを保存しました"},title:"Kプロファイル",addPrinterInSettings:"Kプロファイルを管理するには設定でプリンターを追加してください",enablePrinterConnection:"Kプロファイルを表示するにはプリンター接続を有効にしてください",printerOfflineDesc:"選択したプリンターは接続されていません。電源を入れてKプロファイルを表示してください。",noMatchingProfilesDesc:"検索条件に一致するプロファイルがありません",noKProfilesDesc:"{{diameter}}mmノズル用の圧力キャリブレーションプロファイルが見つかりません",printer:"プリンター",export:"エクスポート",delete:"削除",deleteConfirm:{title:"プロファイルを削除",cannotUndo:"元に戻せません",message:"「{{name}}」をプリンターから削除しますか?"},bulkDelete:{title:"プロファイルを削除",cannotUndo:"元に戻せません",message:"選択した{{count}}件のプロファイルをプリンターから削除しますか?"},permission:{noRead:"プロファイルを更新する権限がありません",noCreate:"プロファイルを追加する権限がありません",noUpdate:"Kプロファイルを更新する権限がありません",noDelete:"Kプロファイルを削除する権限がありません",noExport:"プロファイルをエクスポートする権限がありません",noImport:"プロファイルをインポートする権限がありません"}},virtualPrinter:{running:"稼働中",enable:{visibleInSlicer:"スライサーの検出リストに「Bambuddy」として表示",proxyingTo:"{{name}}にプロキシ中",notActive:"非アクティブ",title:"仮想プリンターを有効化"},remoteInterface:{optional:"オプション — 自動検出IPが間違っている場合に使用(複数NIC、Docker、VPNなど)",title:"ネットワークインターフェース上書き",configured:"インターフェース上書き有効",placeholder:"自動検出(デフォルト)...",hint:"SSDPで広告され、TLS証明書に使用されるIPアドレスを上書きします。Bambuddyに複数のネットワークインターフェースがある場合に便利です。"},howItWorks:{step5:"設定したアクセスコードで接続する",step6:"Bambuddyに「印刷」すると、3MFファイルがアーカイブされる",proxyStep1:"ターゲットプリンターを選択(LANモードである必要があります)",proxyStep2:"クロスネットワーク時:スライサーネットワークインターフェースを選択",proxyStep3:"プロキシを有効化 - プリンターがSSDPでスライサー検出に表示されます",proxyStep4:"プリンターのアクセスコードで接続",proxyStep5:"通常通り印刷 - トラフィックはBambuddyを経由して中継されます",proxyStep6:"カメラストリーミングにはNAT/IP転送が必要です(ドキュメント参照)",title:"仕組み",titleProxy:"仕組み(プロキシモード)",step1:"プラットフォーム用のセットアップガイドを完了",step2:"仮想プリンターを有効にしてアクセスコードを設定",step3:"Bambu StudioまたはOrcaSlicerで「プリンター追加」へ",step4:"「Bambuddy」プリンターが検出リストに表示されます"},status:{mode:"モード",pendingFiles:"保留中のファイル",ftpPort:"FTPポート",mqttPort:"MQTTポート",ftpConnections:"FTP接続数",mqttConnections:"MQTT接続数",title:"ステータス詳細",printerName:"プリンター名",model:"モデル",serialNumber:"シリアル番号",targetPrinter:"ターゲットプリンター"},toast:{accessCodeRequired:"先にアクセスコードを設定してください",targetPrinterRequired:"先にターゲットプリンターを選択してください",accessCodeEmpty:"アクセスコードは空にできません",accessCodeLength:"アクセスコードは8文字である必要があります",updated:"仮想プリンター設定を更新しました",failedToUpdate:"設定の更新に失敗しました"},title:"仮想プリンター",stopped:"停止",description:{default:"Bambu StudioとOrcaSlicerに表示される仮想プリンターを有効化。このプリンターに送信されたファイルは印刷せずに直接アーカイブされます。",proxy:"スライサーのトラフィックを実際のプリンターに転送するプロキシを有効化。任意のネットワーク経由でリモート印刷が可能です。"},model:{title:"プリンターモデル",description:"エミュレートするプリンターモデルを選択。",restartWarning:"モデルを変更すると仮想プリンターが再起動されます"},accessCode:{title:"アクセスコード",isSet:"アクセスコードが設定されています",notSet:"アクセスコード未設定 - 有効化に必要です",placeholder:"8文字のコードを入力",placeholderChange:"新しいコードを入力して変更",hint:"正確に8文字必要です。スライサーの認証に使用されます。",charCount:"({{count}}/8)"},targetPrinter:{title:"ターゲットプリンター",configured:"プロキシターゲット設定済み",notConfigured:"ターゲットプリンター未選択 - プロキシモードに必要です",placeholder:"プリンターを選択...",hint:"スライサートラフィックの転送先プリンターを選択。プリンターはLANモードである必要があります。",noPrinters:"プリンターが設定されていません。プロキシモードを使用するにはまずプリンターを追加してください。"},mode:{title:"モード",archive:"アーカイブ",archiveDesc:"ファイルを即座にアーカイブ",review:"レビュー",reviewDesc:"アーカイブ前にレビュー",queue:"キュー",queueDesc:"アーカイブしてキューに追加",proxy:"プロキシ",proxyDesc:"実際のプリンターに転送"},setupRequired:{title:"セットアップが必要です",description:"仮想プリンター機能を使用するには追加のシステム設定が必要です。ポートフォワーディング、ファイアウォールルール、プラットフォーム固有の設定が含まれます。",readGuide:"有効にする前にセットアップガイドをお読みください"}},modelViewer:{openInSlicer:"スライサーで開く",tabs:{model:"3Dモデル",gcode:"G-codeプレビュー"},notAvailable:"利用不可",notSliced:"未スライス",plates:"プレート",allPlates:"全プレート",plateNumber:"プレート {{number}}",plateCount:"{{count}} プレート",plateCount_other:"{{count}} プレート",objectCount:"{{count}} オブジェクト",objectCount_other:"{{count}} オブジェクト",filamentCount:"{{count}} フィラメント",filamentCount_other:"{{count}} フィラメント",eta:"予想時間 {{minutes}} 分",noPreview:"このファイルのプレビューは利用できません",pagination:{pageOf:"ページ {{current}} / {{total}}",prev:"前へ",next:"次へ"},errors:{failedToLoad:"ファイルの読み込みに失敗しました",noMeshes:"3MFファイルにメッシュが見つかりません",unsupportedFormat:"サポートされていないファイル形式です"}},maintenanceDescriptions:{lubricateRails:"リニアレールの潤滑",cleanNozzle:"ノズル/ホットエンドの清掃",checkBelts:"ベルト張力の確認",cleanBuildPlate:"ビルドプレートの清掃",checkExtruder:"エクストルーダーギアの確認",checkCooling:"冷却ファンの確認",generalInspection:"総合点検",cleanCarbonRods:"カーボンロッドの清掃",checkPtfeTube:"PTFEチューブの確認",replaceHepaFilter:"HEPAフィルター交換",replaceCarbonFilter:"カーボンフィルター交換",lubricateLeftNozzleRail:"左ノズルレールの潤滑"},hmsErrors:{title:"エラー - {{name}}",noErrors:"エラーなし",viewOnWiki:"Bambu Lab Wikiで表示",clearInstructions:"プリンターでエラーをクリアするとここからも消えます。"},plateAlert:{title:"印刷が一時停止されました!",message:"ビルドプレート上にオブジェクトが検出されました。印刷が自動的に一時停止されました。プレートをクリアして印刷を再開してください。",understand:"了解"},tags:{title:"タグ",addTag:"タグを追加",editTag:"タグを編集",deleteTag:"タグを削除",tagName:"タグ名",tagColor:"タグの色",noTags:"タグがありません",deleteConfirm:"このタグを削除しますか?",manageTags:"タグを管理"},support:{debugLoggingActive:"デバッグログが有効です",manageLogs:"管理",collectItem7:"プリンター接続状態とファームウェアバージョン",collectItem8:"連携状態(Spoolman、MQTT、HA)",collectItem9:"ネットワークインターフェース(サブネットのみ)",collectItem10:"Pythonパッケージバージョン",collectItem11:"データベース健全性チェック",collectItem12:"Docker環境の詳細"},configureAmsSlot:{searchPresets:"プリセットを検索...",colorPlaceholder:"色名またはHex(例: 茶色、FF8800)",clearCustomColor:"カスタム色をクリア",noCloudPresets:"クラウドプリセットがありません。Bambu Cloudにログインして同期してください。",noMatchingPresets:"一致するプリセットが見つかりません。",custom:"カスタム",builtin:"内蔵",settingsSentToPrinter:"設定をプリンターに送信しました",filamentProfile:"フィラメントプロファイル"},emailSettings:{placeholders:{fromName:"BamBuddy"}},smartPlugs:{offline:"オフライン",admin:"管理",openPlugAdminPage:"プラグ管理ページを開く",deleteSmartPlug:"スマートプラグを削除",turnOnSmartPlug:"スマートプラグをオンにする",turnOffSmartPlug:"スマートプラグをオフにする",turnOn:"オンにする",turnOff:"オフにする",addSmartPlug:{scanningNetwork:"ネットワークをスキャン中...",chooseEntity:"エンティティを選択...",connectionFailed:"接続失敗",searchEntities:"エンティティを検索...",searchPowerSensors:"電力センサーを検索...",searchEnergySensors:"エネルギーセンサーを検索...",placeholders:{plugName:"リビングルームプラグ",mqttStateOnValue:"ON, true, 1",mqttSameAsPower:"電力トピックと同じ、または異なる"}}},externalLinks:{noLinksConfigured:"外部リンクが設定されていません",deleteLink:"リンクを削除",removeCustomIcon:"カスタムアイコンを削除",openInNewTab:"新しいタブで開く",placeholders:{linkName:"マイリンク"}},keyboardShortcuts:{title:"キーボードショートカット",navigation:"ナビゲーション",archivesSection:"アーカイブ",kProfilesSection:"Kプロファイル",generalSection:"全般",shortcuts:{goToPrinters:"プリンターへ移動",goToArchives:"アーカイブへ移動",goToQueue:"キューへ移動",goToStats:"統計へ移動",goToProfiles:"クラウドプロファイルへ移動",goToSettings:"設定へ移動",focusSearch:"検索にフォーカス",openUploadModal:"アップロードモーダルを開く",clearSelection:"選択をクリア / 入力をぼかす",contextMenu:"カードのコンテキストメニュー",refreshProfiles:"プロファイルを更新",newProfile:"新しいプロファイル",exitSelectionMode:"選択モードを終了",showHelp:"このヘルプを表示"},footer:"Escキーを押すか外側をクリックして閉じます"},restoreBackup:{title:"バックアップを復元",restoring:"復元中...",restoreComplete:"復元完了",restoreFailed:"復元失敗",importSettings:"バックアップファイルから設定をインポート",pleaseWait:"データの復元中です。しばらくお待ちください",clickToSelect:"クリックしてバックアップファイルを選択(.jsonまたは.zip)",howDuplicateHandling:"重複の処理方法:",categories:{printers:"プリンター",smartPlugs:"スマートプラグ",notificationProviders:"通知プロバイダー",filaments:"フィラメント",archives:"アーカイブ",pendingUploads:"保留中のアップロード",settingsTemplates:"設定とテンプレート"},matchingInfo:{printers:"シリアル番号で照合",smartPlugs:"IPアドレスで照合",notificationProviders:"名前で照合",filaments:"名前+タイプ+ブランドで照合",archives:"コンテンツハッシュで照合",pendingUploads:"ファイル名で照合",settingsTemplates:"常に上書き"},replaceExisting:"既存データを置き換え",keepExisting:"既存データを保持",replaceDescription:"既に存在するアイテムをバックアップデータで上書き",keepDescription:"まだ存在しないアイテムのみを復元",caution:"注意:",cautionText:"上書きすると現在の構成がバックアップデータに置き換えられます。セキュリティ上の理由から、プリンターのアクセスコードは上書きされません。",itemsRestored:"復元されたアイテム",itemsSkipped:"スキップされたアイテム",restored:"復元済み",skipped:"スキップ(既に存在)",filesLabel:"ファイル(3MF、サムネイルなど)",newApiKeysGenerated:"新しいAPIキーが生成されました",newApiKeysWarning:"これらのキーは一度だけ表示されます。今すぐコピーしてください!",processingBackup:"バックアップファイルを処理中...",noDataFound:"バックアップファイルに復元するデータが見つかりませんでした。",failedToRestore:"バックアップの復元に失敗しました。ファイル形式を確認してください。"},backupExport:{title:"バックアップをエクスポート",selectData:"含めるデータを選択",selectAll:"すべて選択",selectNone:"なし",categoryDescriptions:{settings:"言語、テーマ、更新設定",notifications:"ntfy、Pushover、Discordなど",templates:"カスタムメッセージテンプレート",smartPlugs:"Tasmotaプラグ設定",externalLinks:"サイドバーの外部サービスへのリンク",printers:"プリンター情報(アクセスコード除外)",plateDetection:"空プレート参照画像",filaments:"フィラメントの種類とコスト",maintenance:"カスタムメンテナンススケジュール",archives:"すべての印刷データ+ファイル(3MF、サムネイル、写真)",projects:"プロジェクト、BOMアイテム、添付ファイル",pendingUploads:"仮想プリンターアップロード待機中",apiKeys:"Webhook APIキー(インポート時に新しいキーが生成されます)"},requiresPrinters:"プリンターを選択する必要があります",zipFileWarning:"ZIPファイルが作成されます。",zipFileDescription:"すべての3MFファイル、サムネイル、タイムラプス、写真が含まれます。これには時間がかかり、大きなファイルになる可能性があります。",includeAccessCodes:"アクセスコードを含める",includeAccessCodesDescription:"別のマシンへの転送用",includeAccessCodesWarning:"アクセスコードはプレーンテキストで含まれます。このバックアップファイルを安全に保管してください!",categoriesSelected:"{{selectedCount}}カテゴリー選択済み"},tagManagement:{searchTags:"タグを検索...",renameTag:"タグ名を変更",deleteTag:"タグを削除"},notificationTemplates:{placeholders:{title:"通知タイトル...",body:"通知本文..."}},batchTag:{placeholders:{newTag:"新しいタグを入力..."}},photoGallery:{deletePhoto:"写真を削除"},filamentHoverCard:{copySpoolUuid:"スプールUUIDをコピー"},kProfilesView:{hasNote:"メモあり",copyProfile:"プロファイルをコピー"},layout:{openMenu:"メニューを開く",noPermissionSystemInfo:"システム情報を表示する権限がありません"},notificationProviderCard:{deleteNotificationProvider:"通知プロバイダーを削除"},fileManagerModal:{closeFileManager:"ファイルマネージャーを閉じる",sortFiles:"ファイルを並べ替え",goToParentFolder:"親フォルダーへ移動",threeView:"3Dビュー"},embeddedCameraViewer:{refreshStream:"ストリームを更新",close:"閉じる",zoomOut:"ズームアウト",resetZoom:"ズームをリセット",zoomIn:"ズームイン",dragToResize:"ドラッグしてサイズ変更"},timelapseViewer:{skipBack5s:"5秒戻る",skipForward5s:"5秒進む"},notificationProviders:{descriptions:{email:"SMTP電子メール通知",telegram:"Telegramボット経由の通知",discord:"Webhookを介してDiscordチャンネルに送信",ntfy:"無料でセルフホスト可能なプッシュ通知",pushover:"シンプルで信頼性の高いプッシュ通知",callmebot:"CallMeBot経由の無料WhatsApp通知",webhook:"任意のURLへのジェネリックHTTP POST"}},switchbarPopover:{noSwitchesInSwitchbar:"スイッチバーにスイッチがありません"},projectPageModal:{placeholders:{title:"タイトル",designer:"デザイナー",license:"ライセンス",description:"説明を入力...",profileTitle:"プロファイルタイトル",profileDescription:"プロファイルの説明..."}},githubBackupSettings:{},spoolmanSettings:{}},Coe={nav:{printers:"Stampanti",archives:"Archivi",queue:"Coda",stats:"Statistiche",profiles:"Profili",maintenance:"Manutenzione",projects:"Progetti",files:"File",settings:"Impostazioni",system:"Sistema",collapseSidebar:"Comprimi barra laterale",expandSidebar:"Espandi barra laterale",update:"Aggiorna",updateAvailable:"Aggiornamento disponibile: v{{version}}",updateAvailableBanner:"Versione {{version}} disponibile!",viewUpdate:"Vedi aggiornamento",viewOnGithub:"Vedi su GitHub",keyboardShortcuts:"Scorciatoie da tastiera (?)",switchToLight:"Passa a tema chiaro",switchToDark:"Passa a tema scuro",smartSwitches:"Interruttori Smart",logout:"Esci"},common:{save:"Salva",saving:"Salvataggio...",cancel:"Annulla",delete:"Elimina",edit:"Modifica",add:"Aggiungi",close:"Chiudi",confirm:"Conferma",loading:"Caricamento...",error:"Errore",success:"Successo",warning:"Avviso",enabled:"Abilitato",disabled:"Disabilitato",yes:"Si",no:"No",on:"On",off:"Off",all:"Tutti",none:"Nessuno",search:"Cerca",filter:"Filtro",sort:"Ordina",refresh:"Aggiorna",download:"Scarica",upload:"Carica",actions:"Azioni",status:"Stato",name:"Nome",description:"Descrizione",date:"Data",time:"Ora",hours:"ore",minutes:"minuti",seconds:"secondi",days:"giorni",enable:"Abilita",disable:"Disabilita",permissions:"Permessi",noPrinters:"Nessuna stampante configurata",noData:"Nessun dato disponibile",linkNotFound:"Link non trovato",required:"Obbligatorio",optional:"Opzionale",dismiss:"Chiudi",apply:"Applica",reset:"Reimposta",clear:"Pulisci",selectAll:"Seleziona tutto",deselectAll:"Deseleziona tutto",noChange:"— Nessun cambio —",unchanged:"Invariato",unassigned:"Non assegnato",unknown:"Sconosciuto",unknownError:"Errore sconosciuto",today:"Oggi",asap:"ASAP",overdue:"Scaduto",now:"Ora",collapse:"Comprimi",expand:"Espandi",viewArchive:"Vedi archivio",viewInFileManager:"Vedi nel Gestore file",addedBy:"Aggiunto da {{username}}",prints:"stampe",more:"+{{count}} altre",ascending:"Crescente",descending:"Decrescente",printer:"Stampante",remove:"Rimuovi",type:"Tipo",print:"Stampa",rename:"Rinomina",move:"Sposta",create:"Crea",duplicate:"Duplica",left:"Sinistra",right:"Destra"},printers:{title:"Stampanti",addPrinter:"Aggiungi Stampante",editPrinter:"Modifica Stampante",deletePrinter:"Elimina Stampante",printerName:"Nome Stampante",serialNumber:"Numero Seriale",ipAddress:"Indirizzo IP",accessCode:"Codice di Accesso",model:"Modello",nozzleCount:"Numero Ugelli",autoArchive:"Auto Archiviazione",status:{idle:"Inattiva",printing:"In stampa",paused:"In pausa",offline:"Offline",error:"Errore",finished:"Finita",unknown:"Sconosciuto"},temperatures:{nozzle:"Ugello",bed:"Piatto",chamber:"Camera"},progress:"{{percent}}% completato",timeRemaining:"{{time}} rimanente",deleteConfirm:'Sei sicuro di eliminare "{{name}}"?',maintenanceOk:"Manutenzione OK",maintenanceWarning:"{{count}} avviso",maintenanceWarning_plural:"{{count}} avvisi",maintenanceDue:"{{count}} in scadenza",maintenanceDue_plural:"{{count}} in scadenza",sort:{name:"Nome",status:"Stato",model:"Modello",location:"Posizione",ascending:"Ordina crescente",descending:"Ordina decrescente"},cardSize:{small:"Schede piccole",medium:"Schede medie",large:"Schede grandi",extraLarge:"Schede extra grandi"},hideOffline:"Nascondi offline",powerOn:"Accendi",offlinePrintersWithPlugs:"Stampanti offline con smart plug",noPrintersConfigured:"Nessuna stampante configurata",readyToPrint:"Pronta a stampare",external:"Esterna",deleteArchives:"Elimina archivi stampa",noLabel:"Nessuna etichetta",printPreview:"Anteprima stampa",width:"Larghezza",height:"Altezza",noObjectsFound:"Nessun oggetto trovato",objectsLoadedOnPrintStart:"Gli oggetti sono caricati quando inizia una stampa",willBeSkipped:"Verra saltato",name:"Nome",serialCannotBeChanged:"Il numero seriale non può essere cambiato",locationHelp:"Usato per raggruppare stampanti e filtrare i lavori in coda",wifiSignal:{veryWeak:"Molto debole",weak:"Debole",fair:"Discreto",good:"Buono",excellent:"Eccellente"},maintenanceUpToDate:"Tutta la manutenzione aggiornata - Clicca per vedere",chamberLightOn:"Accendi luce camera",chamberLightOff:"Spegni luce camera",browseFiles:"Sfoglia file stampante",autoOffAfterPrint:"Spegnimento automatico dopo stampa",autoOffExecuted:"Spegnimento automatico eseguito - accendi la stampante per reimpostare",hmsErrors:"Errori HMS",viewHmsErrors:"Vedi {{count}} errore(i) HMS",resume:"Riprendi",pause:"Pausa",stop:"Ferma",camera:"Camera",skipObject:"Salta Oggetto",reconnect:"Riconnetti",mqttDebug:"Debug MQTT",activeNozzle:"Attivo: ugello {{nozzle}}",nozzleRack:"Rack Ugelli",nozzleDocked:"Agganciato",nozzleMounted:"Montato",nozzleWear:"Usura",nozzleMaxTemp:"Temp Max",nozzleSerial:"Seriale",nozzleHardenedSteel:"Acciaio Temprato",nozzleStainlessSteel:"Acciaio Inox",nozzleTungstenCarbide:"Carburo di Tungsteno",nozzleFlow:"Flusso",nozzleHighFlow:"Alto Flusso",nozzleStandardFlow:"Standard",firmwareUpdate:"Aggiornamento Firmware",firmwareInstructions:"Sul touchscreen della stampante, vai a",firmwareNav:"Vai a",settings:"Impostazioni",firmware:"Firmware",discoverPrinters:"Trova Stampanti",searching:"Ricerca...",manualEntry:"Inserimento manuale",addFromCloud:"Aggiungi da Cloud",toast:{printerDeleted:"Stampante eliminata",printerAdded:"Stampante aggiunta",printerUpdated:"Stampante aggiornata",failedToDelete:"Impossibile eliminare stampante",failedToAdd:"Impossibile aggiungere stampante",failedToUpdate:"Impossibile aggiornare stampante",commandSent:"Comando inviato",failedToSendCommand:"Impossibile inviare comando",turnedOn:"{{name}} accesa",failedToPowerOn:"Impossibile accendere {{name}}",scriptTriggered:"Script avviato",printStopped:"Stampa fermata",printPaused:"Stampa in pausa",printResumed:"Stampa ripresa",referenceDeleted:"Riferimento eliminato",detectionAreaSaved:"Area rilevamento salvata",failedToRunScript:"Impossibile eseguire script",failedToStopPrint:"Impossibile fermare stampa",failedToPausePrint:"Impossibile mettere in pausa stampa",failedToResumePrint:"Impossibile riprendere stampa",failedToControlChamberLight:"Impossibile controllare luce camera",failedToUpdateSetting:"Impossibile aggiornare impostazione",failedToSkipObjects:"Impossibile saltare oggetti",failedToRereadRfid:"Impossibile rileggere RFID",failedToCheckPlate:"Impossibile controllare piatto",failedToUpdateLabel:"Impossibile aggiornare etichetta",failedToDeleteReference:"Impossibile eliminare riferimento",failedToSaveDetectionArea:"Impossibile salvare area rilevamento",plateCheckEnabled:"Controllo piatto abilitato",plateCheckDisabled:"Controllo piatto disabilitato",calibrationSaved:"Calibrazione salvata!",calibrationFailed:"Calibrazione non riuscita",rfidRereadInitiated:"Rilettura RFID avviata"},connection:{connected:"Connesso",offline:"Offline"},queue:{inQueue:"{{count}} stampa in coda",inQueue_plural:"{{count}} stampe in coda"},controls:"Controlli",rfid:{reread:"Rileggi RFID"},permission:{noAdd:"Non hai il permesso di aggiungere stampanti",noEdit:"Non hai il permesso di modificare stampanti",noDelete:"Non hai il permesso di eliminare stampanti",noControl:"Non hai il permesso di controllare stampanti",noFiles:"Non hai il permesso di accedere ai file stampante",noAmsRfid:"Non hai il permesso di rileggere AMS RFID",noSmartPlugControl:"Non hai il permesso di controllare smart plug"},modal:{addTitle:"Aggiungi Stampante",editTitle:"Modifica Stampante",myPrinter:"La mia Stampante",selectModel:"Seleziona modello...",locationGroup:"Posizione / Gruppo (opzionale)",locationPlaceholder:"es. Officina, Ufficio, Cantina",autoArchiveLabel:"Archivia automaticamente stampe completate",fromPrinterSettings:"Dalle impostazioni della stampante",modelOptional:"Modello (opzionale)",saveChanges:"Salva modifiche"},skipObjects:{tooltip:"Salta oggetti",onlyWhilePrinting:"Salta oggetti (solo durante la stampa)",requiresMultiple:"Salta oggetti (richiede 2+ oggetti)",title:"Salta Oggetti",matchIdsInfo:"Abbina gli ID con il display della stampante",printerShowsIds:"Lo schermo mostra gli ID oggetto sul piatto",skipSelected:"Salta selezionati",skipping:"Saltando...",noObjectsSelected:"Nessun oggetto selezionato",selectObjectsToSkip:"Seleziona gli oggetti da saltare nella stampa corrente",skipped:"saltato",objectsSkipped:"Oggetti saltati",activeCount:"{{count}} attivi",waitForLayer:"Attendi il layer 2+ per saltare oggetti (attualmente layer {{layer}})",skip:"Salta",confirmTitle:"Saltare oggetto?",confirmMessage:'Sei sicuro di voler saltare "{{name}}"? Questa azione non può essere annullata.'},confirm:{deleteTitle:"Elimina Stampante",deleteMessage:'Sei sicuro di eliminare "{{name}}"? Questo rimuoverà tutte le impostazioni di connessione.',deleteArchivesNote:"Tutta la cronologia di stampa sarà eliminata definitivamente.",keepArchivesNote:"La cronologia sarà mantenuta ma non più associata a questa stampante.",stopTitle:"Ferma Stampa",stopMessage:'Sei sicuro di fermare la stampa corrente su "{{name}}"? Questo annullerà il lavoro di stampa.',stopButton:"Ferma Stampa",pauseTitle:"Pausa Stampa",pauseMessage:'Sei sicuro di mettere in pausa la stampa corrente su "{{name}}"?',pauseButton:"Pausa Stampa",resumeTitle:"Riprendi Stampa",resumeMessage:'Sei sicuro di riprendere la stampa su "{{name}}"?',resumeButton:"Riprendi Stampa",powerOnTitle:"Accendi Stampante",powerOnMessage:'Sei sicuro di accendere "{{name}}"?',powerOnButton:"Accendi",powerOffTitle:"Spegni Stampante",powerOffMessage:'Sei sicuro di spegnere "{{name}}"?',powerOffWarning:'AVVISO: "{{name}}" sta stampando! Sei sicuro di spegnere? Questo interromperà la stampa e potrebbe danneggiare la stampante.',powerOffButton:"Spegni"},discovery:{title:"Trova Stampanti",searching:"Ricerca...",scanning:"Scansione...",scanProgress:"Scansione... {{scanned}}/{{total}}",foundPrinters:"Trovate {{count}} stampante(i)",noPrintersFound:"Nessuna stampante trovata",noPrintersFoundSubnet:"Nessuna stampante trovata nella sottorete specificata.",noPrintersFoundNetwork:"Nessuna stampante trovata sulla rete.",allConfigured:"Tutte le stampanti trovate sono già configurate.",alreadyAdded:"Già aggiunta",select:"Seleziona",manualEntry:"Inserimento manuale",addFromCloud:"Aggiungi da Cloud",subnetToScan:"Sottorete da scansionare",dockerNote:"Docker rilevato. Inserisci la sottorete della stampante in notazione CIDR. Richiede network_mode: host in docker-compose.yml.",scanSubnet:"Scansiona sottorete per stampanti",discoverNetwork:"Trova stampanti in rete",scanningSubnet:"Scansione sottorete per stampanti Bambu...",scanningNetwork:"Scansione rete...",serialRequired:"Seriale richiesto",unknown:"Sconosciuto",failedToStart:"Avvio ricerca non riuscito"},filaments:"Filamenti",openCameraOverlay:"Apri overlay camera",openCameraWindow:"Apri camera in nuova finestra",firmwareUpdateAvailable:"Aggiornamento firmware disponibile: {{current}} → {{latest}}",firmwareUpToDate:"Firmware {{version}} — Aggiornato",firmwareUpdateButton:"Aggiorna",plateDetection:{noPermission:"Non hai il permesso di aggiornare le stampanti",enabledClick:"Controllo piatto abilitato - Clicca per disabilitare",disabledClick:"Controllo piatto disabilitato - Clicca per abilitare",manageCalibration:"Gestisci calibrazione rilevamento piatto",calibrationRequired:"Calibrazione richiesta",calibrationInstructions:"Assicurati che il piatto sia <strong>completamente vuoto</strong>, poi clicca Calibra.",calibrationDescription:"La calibrazione salva un'immagine di riferimento del piatto vuoto. I controlli futuri confronteranno con questo riferimento per rilevare oggetti.",calibrationTip:"<strong>Suggerimento:</strong> Puoi salvare fino a 5 calibrazioni per piatti diversi. Il sistema usa automaticamente la migliore corrispondenza durante il controllo.",plateEmpty:"Il piatto sembra vuoto",objectsDetected:"Oggetti rilevati sul piatto",confidence:"Confidenza",difference:"Differenza",analysisPreview:"Anteprima analisi:",analysisLegend:"Riquadro verde = area rilevamento, overlay rosso = differenze dalla calibrazione",savedReferences:"Riferimenti salvati ({{count}}/{{max}})",deleteReference:"Elimina riferimento",labelPlaceholder:"Etichetta...",clickToEdit:"{{label}} - Clicca per modificare",clickToAddLabel:"Clicca per aggiungere etichetta"},fans:{partCooling:"Ventola raffreddamento parte",auxiliary:"Ventola ausiliaria",chamber:"Ventola camera"},clickToViewHmsErrors:"Clicca per vedere errori HMS",estimatedCompletion:"Tempo completamento stimato",slotOptions:"Opzioni slot",firmwareModal:{title:"Aggiornamento Firmware",titleUpToDate:"Info Firmware",currentVersion:"Corrente:",latestVersion:"Ultima:",releaseNotes:"Note di rilascio",checkingPrereqs:"Controllo prerequisiti...",sdCardReady:"SD pronta. Clicca sotto per caricare firmware.",uploadedSuccess:"Firmware caricato su SD!",applyInstructions:"Per applicare l'aggiornamento sulla stampante:",step1:"Sul touchscreen della stampante, vai a <strong>Impostazioni</strong>",step2:"Vai a <strong>Firmware</strong>",step3:"Seleziona <strong>Aggiorna da SD</strong>",step4:"L'aggiornamento richiede 10-20 minuti",done:"Fatto",starting:"Avvio...",uploadFirmware:"Carica Firmware",uploadFailed:"Avvio caricamento fallito: {{error}}",uploadedToast:"Firmware caricato! Avvia aggiornamento dal display."},accessCodePlaceholder:"Lascia vuoto per mantenere quello attuale",roi:{title:"Area di rilevamento (ROI)",xStart:"X Inizio",yStart:"Y Inizio",width:"Larghezza",height:"Altezza",instruction:"Regola l'area di rilevamento per focalizzare il piatto. Il riquadro verde mostra l'area corrente."}},archives:{title:"Archivi di stampa",searchPlaceholder:"Cerca archivi...",filterByPrinter:"Filtra per stampante",filterByStatus:"Filtra per stato",sortBy:"Ordina per",sortNewest:"Più recenti",sortOldest:"Meno recenti",sortName:"Nome",sortDuration:"Durata",sortLargest:"Più grandi",sortSmallest:"Più piccoli",sortSize:"Dimensione",noArchives:"Nessun archivio trovato",noArchivesSearch:"Nessun archivio corrisponde alla ricerca",noArchivesYet:"Nessun archivio ancora",loadingArchives:"Caricamento archivi...",releaseToUpload:"Rilascia per caricare",showAll:"Mostra tutti",showFavoritesOnly:"Solo preferiti",gridView:"Vista griglia",listView:"Vista elenco",calendarView:"Vista calendario",manageTags:"Gestisci tag",showFailedPrints:"Mostra stampe fallite",hideFailedPrints:"Nascondi stampe fallite",printTime:"Tempo di stampa",filamentUsed:"Filamento usato",cost:"Costo",reprint:"Ristampa",preview:"Anteprima",deleteArchive:"Elimina archivio",deleteConfirm:"Sei sicuro di eliminare questo archivio?",favorite:"Preferito",unfavorite:"Rimuovi dai preferiti",viewDetails:"Vedi dettagli",status:{completed:"Completato",failed:"Fallito",stopped:"Fermato"},toast:{source3mfAttached:"Sorgente 3MF allegata: {{filename}}",failedUploadSource3mf:"Caricamento sorgente 3MF non riuscito",source3mfRemoved:"Sorgente 3MF rimossa",failedRemoveSource3mf:"Rimozione sorgente 3MF non riuscita",f3dAttached:"F3D allegato: {{filename}}",failedUploadF3d:"Caricamento F3D non riuscito",f3dRemoved:"F3D rimosso",failedRemoveF3d:"Rimozione F3D non riuscita",timelapseAttached:"Timelapse allegato: {{filename}}",timelapseAlreadyAttached:"Timelapse già allegato",noMatchingTimelapse:"Nessun timelapse corrispondente",failedScanTimelapse:"Scansione timelapse non riuscita",failedAttachTimelapse:"Allegato timelapse non riuscito",archiveDeleted:"Archivio eliminato",failedDeleteArchive:"Eliminazione archivio non riuscita",addedToFavorites:"Aggiunto ai preferiti",removedFromFavorites:"Rimosso dai preferiti",projectUpdated:"Progetto aggiornato",failedUpdateProject:"Aggiornamento progetto non riuscito",linkCopied:"Link copiato negli appunti",failedCopyLink:"Copia link non riuscita",photoDeleted:"Foto eliminata",failedDeletePhoto:"Eliminazione foto non riuscita",failedDeleteArchives:"Eliminazione archivi non riuscita",failedUpdateFavorites:"Aggiornamento preferiti non riuscito",exportDownloaded:"Export scaricato",exportFailed:"Export non riuscito"},menu:{print:"Stampa",schedule:"Programma",openInBambuStudio:"Apri nello slicer",slice:"Slice",externalLink:"Link esterno",viewOnMakerWorld:"Vedi su MakerWorld",preview3d:"Anteprima 3D",viewTimelapse:"Vedi Timelapse",scanForTimelapse:"Cerca Timelapse",downloadSource3mf:"Scarica Sorgente 3MF",uploadSource3mf:"Carica Sorgente 3MF",replaceSource3mf:"Sostituisci Sorgente 3MF",removeSource3mf:"Rimuovi Sorgente 3MF",uploadF3d:"Carica F3D",replaceF3d:"Sostituisci F3D",downloadF3d:"Scarica F3D",removeF3d:"Rimuovi F3D",download:"Scarica",copyDownloadLink:"Copia link download",qrCode:"QR Code",viewPhotos:"Vedi foto",viewPhotosCount:"Vedi foto ({{count}})",projectPage:"Pagina progetto",addToFavorites:"Aggiungi ai preferiti",removeFromFavorites:"Rimuovi dai preferiti",edit:"Modifica",goToProject:"Vai al progetto: {{name}}",addToProject:"Aggiungi al progetto",removeFromProject:"Rimuovi dal progetto",loading:"Caricamento...",noProjectsAvailable:"Nessun progetto disponibile",select:"Seleziona",deselect:"Deseleziona",delete:"Elimina"},permission:{noReprint:"Non hai il permesso di ristampare questo archivio",noAddToQueue:"Non hai il permesso di aggiungere alla coda",noUpdateArchives:"Non hai il permesso di aggiornare archivi",noUploadFiles:"Non hai il permesso di caricare file",noDownload:"Non hai il permesso di scaricare archivi",noCopyLink:"Non hai il permesso di copiare link download",noDelete:"Non hai il permesso di eliminare questo archivio",noCreate:"Non hai il permesso di creare archivi"},card:{previousPlate:"Piatto precedente",nextPlate:"Piatto successivo",plateNumber:"Piatto {{index}}",moreOptions:"Clic destro per altre opzioni",addToFavorites:"Aggiungi ai preferiti",removeFromFavorites:"Rimuovi dai preferiti",cancelled:"annullato",failed:"fallito",duplicate:"duplicato",duplicateTitle:"Questo modello è stato stampato prima",openSource3mf:"Apri sorgente 3MF in Bambu Studio (clic destro per altre opzioni)",downloadF3d:"Scarica file design Fusion 360",viewTimelapse:"Vedi timelapse",viewPhoto:"Vedi 1 foto",viewPhotos:"Vedi {{count}} foto",openFolder:"Apri cartella: {{name}}",slicedFile:"File slice - pronto a stampare",sourceFile:"Solo file sorgente - nessuna mappatura AMS disponibile",gcode:"GCODE",source:"SOURCE",project:"Progetto: {{name}}",estimated:"Stimato: {{time}}",actual:"Reale: {{time}}",accuracy:"Accuratezza: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} strato",layers:"{{count}} strati",object:"{{count}} oggetto",objects:"{{count}} oggetti",slicedFor:"Sliced per {{model}}",uploadedBy:"Caricato da",noPermissionReprint:"Non hai il permesso di ristampare",noPermissionEdit:"Non hai il permesso di modificare archivi",noPermissionDelete:"Non hai il permesso di eliminare archivi",reprint:"Ristampa",schedulePrint:"Programma Stampa",schedule:"Programma",openInBambuStudio:"Apri nello slicer",openInBambuStudioToSlice:"Apri nello slicer per slicing",slice:"Slice",externalLink:"Link esterno",makerWorld:"MakerWorld: {{designer}}",viewProject:"Vedi progetto",noExternalLink:"Nessun link esterno",preview3d:"Anteprima 3D",download:"Scarica",edit:"Modifica",delete:"Elimina"},modal:{deleteArchive:"Elimina Archivio",deleteConfirm:'Sei sicuro di eliminare "{{name}}"? Questa azione non può essere annullata.',deleteButton:"Elimina",removeSource3mf:"Rimuovi Sorgente 3MF",removeSource3mfConfirm:'Sei sicuro di rimuovere il file sorgente 3MF da "{{name}}"? Questo eliminerà il progetto slicer originale.',removeButton:"Rimuovi",removeF3d:"Rimuovi F3D",removeF3dConfirm:'Sei sicuro di rimuovere il file Fusion 360 da "{{name}}"?',timelapse:"{{name}} - Timelapse",selectTimelapse:"Seleziona Timelapse",selectTimelapseDesc:"Nessun abbinamento automatico trovato. Seleziona il timelapse per questa stampa:",deleteArchives:"Elimina Archivi",deleteArchivesConfirm:"Sei sicuro di eliminare {{count}} archivio(i)? Questa azione non può essere annullata.",deleteCount:"Elimina {{count}}"},page:{title:"Archivi",printsCount:"{{filtered}} di {{total}} stampe",dropFilesHere:"Rilascia file .3mf qui",releaseToUpload:"Rilascia per caricare",only3mfSupported:"Solo file .3mf supportati",close:"Chiudi",selected:"{{count}} selezionati",selectAll:"Seleziona tutto",tags:"Tag",project:"Progetto",favorite:"Preferito",delete:"Elimina",toggledFavorites:"Preferiti aggiornati per {{count}} archivio(i)",failedUpdateFavorites:"Aggiornamento preferiti non riuscito",archivesDeleted:"{{count}} archivio(i) eliminati",failedDeleteArchives:"Eliminazione archivi non riuscita",photoDeleted:"Foto eliminata",failedDeletePhoto:"Eliminazione foto non riuscita"},list:{name:"Nome",printer:"Stampante",date:"Data",size:"Dimensione",actions:"Azioni",hasTimelapse:"Ha timelapse"}},queue:{title:"Coda di stampa",subtitle:"Programma e gestisci i tuoi lavori di stampa",addToQueue:"Aggiungi alla coda",print:"Stampa",reprint:"Ristampa",schedulePrint:"Programma Stampa",editQueueItem:"Modifica elemento coda",printToPrinters:"Stampa su {{count}} Stampanti",queueToPrinters:"Metti in coda su {{count}} Stampanti",sending:"Invio...",sendingProgress:"Invio {{current}}/{{total}}...",adding:"Aggiunta...",addingProgress:"Aggiunta {{current}}/{{total}}...",savingProgress:"Salvataggio {{current}}/{{total}}...",clearQueue:"Svuota coda",clearHistory:"Svuota cronologia",emptyQueue:"La coda è vuota",position:"Posizione",scheduledTime:"Ora programmata",moveUp:"Sposta su",moveDown:"Sposta giù",startNow:"Avvia ora",printingInProgress:"Stampa in corso...",viewArchive:"Vedi archivio",viewInFileManager:"Vedi nel Gestore file",itemCount:"{{count}} elemento",itemCount_plural:"{{count}} elementi",dragToReorder:"Trascina per riordinare (solo ASAP)",reorderHint:"La posizione influisce solo sugli elementi ASAP. Quelli programmati partono all'orario.",addedBy:"Aggiunto da {{name}}",sections:{currentlyPrinting:"In stampa",queued:"In coda",history:"Cronologia"},status:{pending:"In attesa",waiting:"In attesa",printing:"In stampa",paused:"In pausa",completed:"Completato",failed:"Fallito",skipped:"Saltato",cancelled:"Annullato"},summary:{printing:"In stampa",queued:"In coda",totalTime:"Tempo totale coda",history:"Cronologia"},filter:{allPrinters:"Tutte le stampanti",unassigned:"Non assegnato",allStatus:"Tutti gli stati",allLocations:"Tutte le posizioni",any:"Qualsiasi"},sort:{byPosition:"Ordina per posizione",byName:"Ordina per nome",byPrinter:"Ordina per stampante",bySchedule:"Ordina per programma",byDate:"Ordina per data",ascendingOldest:"Crescente (più vecchi)",descendingNewest:"Decrescente (più recenti)"},badges:{staged:"In staging",requiresPrevious:"Richiede successo precedente",autoPowerOff:"Spegnimento automatico"},empty:{title:"Nessuna stampa programmata",description:`Programma una stampa dalla pagina Archivi usando l'opzione "Programma" nel menu contestuale, o trascina i file per iniziare.`},time:{asap:"ASAP",overdue:"Scaduto",now:"Ora",lessThanMinute:"Tra meno di un minuto",inMinutes:"Tra {{count}} min",inHours:"Tra {{count}} ore"},actions:{stopPrint:"Ferma Stampa",startPrint:"Avvia Stampa",requeue:"Rimetti in coda"},bulkEdit:{title:"Modifica {{count}} elemento",title_plural:"Modifica {{count}} elementi",description:"Solo le impostazioni modificate saranno applicate agli elementi selezionati.",printer:"Stampante",noChange:"— Nessun cambio —",queueOptions:"Opzioni coda",staged:"In staging (avvio manuale)",autoPowerOff:"Spegnimento automatico dopo stampa",requirePrevious:"Richiede successo precedente",printOptions:"Opzioni stampa",bedLevelling:"Livellamento piatto",flowCalibration:"Calibrazione flusso",vibrationCalibration:"Calibrazione vibrazioni",layerInspection:"Controllo primo layer",timelapse:"Timelapse",useAms:"Usa AMS",applyChanges:"Applica modifiche",selectAll:"Seleziona tutto",deselectAll:"Deseleziona tutto",selected:"{{count}} selezionati",editSelected:"Modifica selezionati",cancelSelected:"Annulla selezionati"},confirm:{cancelTitle:"Annulla stampa programmata",cancelMessage:'Sei sicuro di annullare "{{name}}"?',stopTitle:"Ferma Stampa",stopMessage:'Sei sicuro di fermare la stampa corrente "{{name}}"? Questo annullerà il lavoro sulla stampante.',removeTitle:"Rimuovi dalla cronologia",removeMessage:'Sei sicuro di rimuovere "{{name}}" dalla cronologia coda?',clearHistoryTitle:"Svuota cronologia",clearHistoryMessage:"Sei sicuro di rimuovere {{count}} elemento(i) dalla cronologia?",cancelButton:"Annulla Stampa",stopButton:"Ferma Stampa",thisPrint:"questa stampa",thisItem:"questo elemento"},toast:{cancelled:"Elemento coda annullato",cancelFailed:"Annullamento non riuscito",removed:"Elemento coda rimosso",removeFailed:"Rimozione non riuscita",stopped:"Stampa fermata",stopFailed:"Impossibile fermare stampa",released:"Stampa rilasciata in coda",startFailed:"Avvio stampa non riuscito",reorderFailed:"Riordino coda non riuscito",historyCleared:"Cancellati {{count}} elementi cronologia",clearHistoryFailed:"Svuotamento cronologia non riuscito",updateFailed:"Aggiornamento elementi non riuscito",bulkCancelled:"Annullati {{count}} elementi",bulkCancelFailed:"Annullamento elementi non riuscito"},permissions:{noStopPrint:"Non hai il permesso di fermare stampe",noStartPrint:"Non hai il permesso di avviare stampe",noEdit:"Non hai il permesso di modificare questo elemento coda",noCancel:"Non hai il permesso di annullare questo elemento coda",noRequeue:"Non hai il permesso di rimettere in coda elementi",noRemove:"Non hai il permesso di rimuovere questo elemento coda",noClearHistory:"Non hai il permesso di svuotare tutta la cronologia",noEditItems:"Non hai il permesso di modificare elementi coda",noCancelItems:"Non hai il permesso di annullare elementi coda"}},stats:{title:"Dashboard",subtitle:"Trascina i widget per riordinare. Clicca l'icona occhio per nascondere.",overview:"Panoramica",totalPrints:"Stampe totali",successRate:"Tasso di successo",totalPrintTime:"Tempo totale di stampa",printTime:"Tempo di stampa",totalFilament:"Filamento totale usato",filamentUsed:"Filamento usato",filamentCost:"Costo filamento",totalCost:"Costo totale",energyUsed:"Energia usata",energyCost:"Costo energia",averagePrintTime:"Tempo medio di stampa",printsPerDay:"Stampe al giorno",byPrinter:"Per stampante",printsByPrinter:"Stampe per stampante",byMaterial:"Per materiale",byMonth:"Per mese",last7Days:"Ultimi 7 giorni",last30Days:"Ultimi 30 giorni",last90Days:"Ultimi 90 giorni",allTime:"Sempre",quickStats:"Statistiche rapide",printActivity:"Attivita di stampa",filamentTypes:"Tipi di filamento",filamentTrends:"Trend filamento",failureAnalysis:"Analisi guasti",timeAccuracy:"Accuratezza tempo",successful:"Riuscite:",failed:"Fallite:",perfectEstimate:"100% = stima perfetta",noTimeAccuracyData:"Nessun dato accuratezza tempo",noFilamentData:"Nessun dato filamento",noPrinterData:"Nessun dato stampante",noPrintData:"Nessun dato stampa",noPrintDataLast30Days:"Nessun dato stampa negli ultimi 30 giorni",failureReasons:"Cause guasto",topFailureReasons:"Cause principali",failedPrintsCount:"{{failed}} / {{total}} stampe fallite",lastWeekRate:"Settimana scorsa: {{rate}}%",resetLayout:"Reimposta layout",recalculateCosts:"Ricalcola costi",recalculateCostsHint:"Ricalcola tutti i costi archivi usando i prezzi filamento correnti",exportStats:"Esporta statistiche",exportAsCsv:"Esporta come CSV",exportAsExcel:"Esporta come Excel",hiddenCount:"{{count}} Nascosti",exportDownloaded:"Export scaricato",exportFailed:"Export non riuscito",layoutReset:"Layout reimpostato",recalculatedCosts:"Costi ricalcolati per {{count}} archivi",recalculateFailed:"Ricalcolo costi non riuscito",loadingStats:"Caricamento statistiche...",noPermissionResetLayout:"Non hai il permesso di reimpostare il layout",noPermissionRecalculate:"Non hai il permesso di ricalcolare i costi"},maintenance:{title:"Manutenzione",overview:"Panoramica",allOk:"Tutta la manutenzione aggiornata",dueCount:"{{count}} elemento in scadenza",dueCount_plural:"{{count}} elementi in scadenza",warningCount:"{{count}} avviso",warningCount_plural:"{{count}} avvisi",totalPrintTime:"Tempo totale di stampa",nextMaintenance:"Prossima manutenzione",nothingDue:"Niente in scadenza",tasks:"Attivita",lastPerformed:"Ultima esecuzione",interval:"Intervallo",hoursRemaining:"{{hours}}h rimanenti",hoursOverdue:"{{hours}}h in ritardo",markDone:"Segna come fatto",performMaintenance:"Esegui manutenzione",history:"Cronologia",noHistory:"Nessuna cronologia manutenzione",editPrintHours:"Modifica ore stampa",currentHours:"Ore attuali",statusTab:"Stato",settingsTab:"Impostazioni",overdueCount:"{{count}} in ritardo",dueSoonCount:"{{count}} in scadenza",dueSoon:"In scadenza",allGood:"Tutto ok",overdueBy:"In ritardo di {{duration}}",dueIn:"Scade tra {{duration}}",timeLeft:"{{duration}} rimanenti",day:"1 giorno",days:"{{count}} giorni",week:"1 settimana",weeks:"{{count}} settimane",month:"1 mese",months:"{{count}} mesi",year:"1 anno",maintenanceTypes:"Tipi di manutenzione",maintenanceTypesDescription:"Tipi di sistema e tue attivita personalizzate",addCustomType:"Aggiungi tipo personalizzato",intervalType:"Tipo intervallo",intervalValue:"Intervallo ({{type}})",icon:"Icona",documentationLink:"Link documentazione (opzionale)",assignToPrinters:"Assegna alle stampanti",selectAtLeastOnePrinter:"Seleziona almeno una stampante",addType:"Aggiungi tipo",custom:"Personalizzato",printHours:"Ore di stampa",calendarDays:"Giorni calendario",exampleName:"es. Sostituisci filtro HEPA",viewDocumentation:"Vedi documentazione",timeBasedInterval:"Intervallo basato sul tempo",intervalOverrides:"Override intervallo",intervalOverridesDescription:"Personalizza intervalli per stampanti specifiche",assignedToPrinters:"Assegnato alle stampanti:",noPrintersAssigned:"Nessuna stampante assegnata",addPrinterShort:"Aggiungi:",printersAssignedClick:"{{count}} stampante(i) assegnata - clicca per gestire",removeFromPrinter:"Rimuovi da questa stampante",types:{lubricateRails:"Lubrifica guide lineari",cleanNozzle:"Pulisci ugello/Hotend",checkBelts:"Controlla tensione cinghie",cleanBuildPlate:"Pulisci piatto",checkExtruder:"Controlla ingranaggi estrusore",checkCooling:"Controlla ventole raffreddamento",generalInspection:"Ispezione generale",cleanCarbonRods:"Pulisci aste in carbonio",checkPtfeTube:"Controlla tubo PTFE",replaceHepaFilter:"Sostituisci filtro HEPA",replaceCarbonFilter:"Sostituisci filtro carbone",lubricateLeftNozzleRail:"Lubrifica guida ugello sinistro"},maintenanceComplete:"Manutenzione segnata come completata",typeUpdated:"Tipo manutenzione aggiornato",typeDeleted:"Tipo manutenzione eliminato",printHoursUpdated:"Ore di stampa aggiornate",printerAssigned:"Stampante assegnata",printerRemoved:"Stampante rimossa",deleteTypeConfirm:'Eliminare "{{name}}"?',noPermissionUpdate:"Non hai il permesso di aggiornare elementi manutenzione",noPermissionPerform:"Non hai il permesso di eseguire manutenzione",noPermissionEditTypes:"Non hai il permesso di modificare tipi manutenzione",noPermissionDeleteTypes:"Non hai il permesso di eliminare tipi manutenzione",noPermissionEditHours:"Non hai il permesso di modificare ore stampa",noPermissionRemovePrinter:"Non hai il permesso di rimuovere assegnazioni stampanti",noPermissionAssignPrinter:"Non hai il permesso di assegnare stampanti",noPermissionEditIntervals:"Non hai il permesso di modificare intervalli",configureSettings:"Configura tipi e intervalli manutenzione"},settings:{title:"Impostazioni",general:"Generale",tabs:{general:"Generale",smartPlugs:"Prese smart",notifications:"Notifiche",filament:"Filamento",network:"Rete",apiKeys:"Chiavi API",virtualPrinter:"Stampante virtuale",users:"Utenti",backup:"Backup"},appearance:"Aspetto",notifications:"Notifiche",smartPlugs:"Prese smart",spoolman:"Spoolman",updates:"Aggiornamenti",language:"Lingua",languageDescription:"Seleziona la lingua preferita",theme:"Tema",themeLight:"Chiaro",themeDark:"Scuro",themeSystem:"Sistema",defaultView:"Vista predefinita",defaultViewDescription:"Pagina da mostrare all'apertura dell'app",checkForUpdates:"Controlla aggiornamenti",autoUpdate:"Aggiornamento automatico",currentVersion:"Versione attuale",latestVersion:"Ultima versione",upToDate:"Sei aggiornato",updateAvailable:"Aggiornamento disponibile",notificationLanguage:"Lingua notifiche",notificationLanguageDescription:"Lingua per notifiche push",notificationProviders:"Provider notifiche",addProvider:"Aggiungi provider",editProvider:"Modifica provider",providerType:"Tipo provider",testNotification:"Notifica di test",testSuccess:"Notifica di test inviata",testFailed:"Invio notifica di test fallito",quietHours:"Ore silenziose",quietHoursDescription:"Non disturbare in queste ore",quietHoursStart:"Inizio",quietHoursEnd:"Fine",events:{title:"Eventi notifica",printStart:"Stampa avviata",printComplete:"Stampa completata",printFailed:"Stampa fallita",printStopped:"Stampa interrotta",printProgress:"Avanzamento",printProgressDescription:"Notifica al 25%, 50%, 75%",printerOffline:"Stampante offline",printerError:"Errore stampante",filamentLow:"Filamento in esaurimento",maintenanceDue:"Manutenzione dovuta",maintenanceDueDescription:"Notifica quando serve manutenzione"},smartPlug:{title:"Prese smart",add:"Aggiungi presa smart",edit:"Modifica presa smart",name:"Nome",ipAddress:"Indirizzo IP",linkedPrinter:"Stampante collegata",autoOn:"Accensione automatica",autoOnDescription:"Accendi all'avvio stampa",autoOff:"Spegnimento automatico",autoOffDescription:"Spegni dopo il completamento",offDelay:"Ritardo spegnimento",offDelayMinutes:"Minuti dopo la stampa",offDelayTemp:"Quando ugello sotto temperatura",currentState:"Stato attuale",turnOn:"Accendi",turnOff:"Spegni"},spoolmanEnabled:"Abilita integrazione Spoolman",spoolmanUrl:"URL Spoolman",spoolmanConnected:"Connesso",spoolmanDisconnected:"Disconnesso",noDefaultPrinter:"Nessuna predefinita (chiedi ogni volta)",sidebarOrder:"Ordine barra laterale",saveThumbnails:"Salva miniature",captureFinishPhoto:"Acquisisci foto finale",noPrintersConfigured:"Nessuna stampante configurata",archiveMode:{always:"Crea sempre voce archivio",never:"Non creare mai voce archivio",ask:"Chiedi ogni volta"},checkForUpdatesLabel:"Controlla aggiornamenti",checkPrinterFirmware:"Controlla firmware stampante",enableRetry:"Abilita retry",homeAssistantDescription:"Controlla prese smart tramite Home Assistant",environmentManagedLabel:"(Gestito dall'ambiente)",autoEnabledViaEnv:"Abilitato automaticamente tramite variabili d'ambiente",urlFromEnvReadOnly:"Valore impostato dalla variabile d'ambiente HA_URL (sola lettura)",tokenFromEnvReadOnly:"Valore impostato dalla variabile d'ambiente HA_TOKEN (sola lettura)",mqttConnectedTo:"Connesso a",prometheusDescription:"Esponi dati stampante in formato Prometheus",noSmartPlugsTitle:"Nessuna presa smart configurata",noSmartPlugsDescription:"Aggiungi una presa smart Tasmota per monitorare energia e automatizzare il controllo.",noProvidersTitle:"Nessun provider configurato",noProvidersDescription:"Aggiungi un provider per ricevere avvisi.",noTemplatesAvailable:"Nessun template disponibile. Riavvia il backend per generare i template predefiniti.",apiPermissionView:"Visualizza stato stampante e coda",apiPermissionEdit:"Aggiungi e rimuovi elementi dalla coda di stampa",apiKeysEmptyTitle:"Nessuna chiave API",apiKeysEmptyDescription:"Crea una chiave API per integrare servizi esterni.",noUsersFound:"Nessun utente trovato",noGroupsFound:"Nessun gruppo trovato",noGroupsAvailable:"Nessun gruppo disponibile",passwordsDoNotMatch:"Le password non coincidono",systemGroupWarning:"I nomi dei gruppi di sistema non possono essere modificati",authDisabledTitle:"Autenticazione disabilitata",authDisabledFeature1:"Richiedi accesso per usare il sistema",authDisabledFeature2:"Crea più utenti con permessi basati sui gruppi",authDisabledFeature3:"Controlla accesso con 50+ permessi granulari",userHasCreated:"Questo utente ha creato:",userItemsQuestion:"Cosa vuoi fare con questi elementi?",deleteUserConfirm:"Sei sicuro di voler eliminare questo utente?",actionCannotBeUndone:"Questa azione non può essere annullata.",addFirstSmartPlug:"Aggiungi la tua prima presa smart",providers:"Provider",log:"Log",testAll:"Testa tutto",testResults:"Risultati test",testPassedCount:"{{count}} riusciti",testFailedCount:"{{count}} falliti",messageTemplates:"Template messaggi",messageTemplatesDescription:"Personalizza i messaggi per ogni evento.",apiKeys:"Chiavi API",apiKeysDescription:"Crea chiavi API per integrazioni esterne e webhook.",createKey:"Crea chiave",apiKeyCreated:"Chiave API creata con successo",apiKeyCopyWarning:"Copia questa chiave ora - non verra mostrata di nuovo!",useInApiBrowser:"Usa nel Browser API",createNewApiKey:"Crea nuova chiave API",keyName:"Nome chiave",keyNamePlaceholder:"es., Home Assistant, OctoPrint",readStatus:"Leggi stato",readStatusDescription:"Visualizza stato stampante e coda",manageQueue:"Gestisci coda",manageQueueDescription:"Aggiungi e rimuovi elementi dalla coda di stampa",controlPrinter:"Controlla stampante",controlPrinterDescription:"Metti in pausa, riprendi e ferma stampe",unnamedKey:"Chiave senza nome",lastUsed:"Ultimo uso",read:"Lettura",control:"Controllo",createFirstKey:"Crea la tua prima chiave",webhookEndpoints:"Endpoint webhook",webhookApiKeyHint:"Usa la tua chiave API nell'header X-API-Key.",webhook:{getAllStatus:"Ottieni stato di tutte le stampanti",getSpecificStatus:"Ottieni stato di una stampante",addToQueue:"Aggiungi alla coda di stampa",pausePrint:"Metti in pausa stampa",resumePrint:"Riprendi stampa",stopPrint:"Ferma stampa"},apiBrowser:"Browser API",apiBrowserDescription:"Esplora e testa tutti gli endpoint API disponibili.",apiKeyForTesting:"Chiave API per test",apiKeyPlaceholder:"Incolla qui la tua chiave API per testare gli endpoint autenticati...",apiKeyHint:"Questa chiave verra inviata come header X-API-Key.",deleteApiKeyTitle:"Elimina chiave API",deleteApiKeyMessage:"Sei sicuro di voler eliminare questa chiave API? Le integrazioni che la usano non funzioneranno più.",deleteKey:"Elimina chiave",amsDisplayThresholds:"Soglie visualizzazione AMS",amsThresholdsDescription:"Configura soglie colore per umidità e temperatura AMS.",humidity:"Umidità",goodGreen:"Buono (verde)",fairOrange:"Discreto (arancione)",aboveFairBad:"Sopra soglia discreta mostra rosso (scarso)",temperature:"Temperatura",goodBlue:"Buono (blu)",aboveFairHot:"Sopra soglia discreta mostra rosso (caldo)",historyRetention:"Conservazione cronologia",keepSensorHistory:"Mantieni cronologia sensori per",historyRetentionDescription:"I dati più vecchi saranno eliminati automaticamente",printModal:"Modale stampa",expandCustomMapping:"Espandi mapping personalizzato di default",expandCustomMappingDescription:"Quando stampi su più stampanti, mostra mapping AMS per stampante espanso",authentication:"Autenticazione",authEnabledDescription:"La tua istanza è protetta con autenticazione",authDisabledDescription:"Abilita per richiedere accesso e gestire utenti",authDisabledMessage:"Abilita autenticazione per creare account, gestire permessi e proteggere la tua istanza Bambuddy.",enableAuthentication:"Abilita autenticazione",currentUser:"Utente corrente",changePassword:"Cambia password",admin:"Admin",users:"Utenti",addUser:"Aggiungi utente",groups:"Gruppi",addGroup:"Aggiungi gruppo",system:"Sistema",noDescription:"Nessuna descrizione",userCount:"{{count}} utenti",permissionCount:"{{count}} permessi",createUser:"Crea utente",username:"Nome utente",enterUsername:"Inserisci nome utente",password:"Password",enterPassword:"Inserisci password (min 6 caratteri)",confirmPassword:"Conferma password",confirmPasswordPlaceholder:"Conferma password",viewReleaseOnGitHub:"Vedi release su GitHub",turnAllPlugsOn:"Accendi tutte le prese",turnAllPlugsOff:"Spegni tutte le prese",clearNotificationLogs:"Cancella log notifiche",clearLogsMessage:"Questo eliminerà definitivamente tutti i log notifiche più vecchi di 30 giorni. Questa azione non può essere annullata.",clearLogs:"Cancella log",resetUiPreferences:"Reimposta preferenze UI",resetUiPreferencesMessage:"Questo reimposterà le preferenze UI ai valori predefiniti: ordine barra laterale, tema, layout dashboard, modalità vista e preferenze ordinamento. Stampanti, archivi e impostazioni server NON saranno modificati. La pagina si ricaricherà dopo la cancellazione.",resetPreferences:"Reimposta preferenze",deleteGroupTitle:"Elimina gruppo",deleteGroupMessage:"Sei sicuro di voler eliminare questo gruppo? Gli utenti in questo gruppo perderanno questi permessi.",deleteGroup:"Elimina gruppo",disableAuthenticationTitle:"Disabilita autenticazione",disableAuthenticationMessage:"Sei sicuro di voler disabilitare l'autenticazione? Questo renderà la tua istanza Bambuddy accessibile senza login. Tutti gli utenti resteranno nel database ma l'autenticazione sarà disabilitata.",disableAuthentication:"Disabilita autenticazione",configureBambuddy:"Configura Bambuddy",systemDefault:"Predefinito di sistema",archiveSettings:"Impostazioni archivio",newWindow:"Nuova finestra",embeddedOverlay:"Overlay incorporato",preferredSlicer:"Slicer preferito",preferredSlicerDescription:"Scegli quale applicazione slicer usare per aprire i file",externalCameras:"Camere esterne",costTracking:"Tracciamento costi",printsOnly:"Solo stampe",totalConsumption:"Consumo totale",dataManagement:"Gestione dati",clearNotificationLogsDescription:"Elimina log notifiche più vecchi di 30 giorni",resetUiPreferencesDescription:"Reimposta ordine barra laterale, tema, modalità vista e preferenze layout. Stampanti, archivi e impostazioni non vengono modificati.",enableHomeAssistant:"Abilita Home Assistant",enableMqtt:"Abilita MQTT",useTls:"Usa TLS",enableMetricsEndpoint:"Abilita endpoint metriche",availableMetrics:"Metriche disponibili",editUser:"Modifica utente",deleteUserTitle:"Elimina utente",groupName:"Nome gruppo",leaveEmptyForAnonymous:"Lascia vuoto per anonimo",leaveEmptyForNoAuth:"Lascia vuoto per nessuna autenticazione",enterNewPassword:"Inserisci nuova password",confirmNewPassword:"Conferma nuova password",enterGroupName:"Inserisci nome gruppo",enterDescriptionOptional:"Inserisci descrizione (opzionale)",enterCurrentPassword:"Inserisci password attuale",enterNewPasswordMin6:"Inserisci nuova password (min 6 caratteri)",toast:{keyCopied:"Chiave copiata negli appunti",copyFailed:"Copia chiave fallita",keyAddedToBrowser:"Chiave aggiunta al Browser API",clearLogsFailed:"Eliminazione log fallita",uiPreferencesReset:"Preferenze UI reimpostate. Aggiornamento...",authDisabled:"Autenticazione disabilitata con successo",authDisableFailed:"Disabilitazione autenticazione fallita",apiKeyCreated:"Chiave API creata",apiKeyDeleted:"Chiave API eliminata",userCreated:"Utente creato con successo",userUpdated:"Utente aggiornato con successo",userDeleted:"Utente eliminato con successo",groupCreated:"Gruppo creato con successo",groupUpdated:"Gruppo aggiornato con successo",groupDeleted:"Gruppo eliminato con successo",fillRequiredFields:"Compila tutti i campi obbligatori",passwordsDoNotMatch:"Le password non coincidono",passwordTooShort:"La password deve essere di almeno 6 caratteri",enterGroupName:"Inserisci un nome gruppo",settingsSaved:"Impostazioni salvate",cameraSettingsSaved:"Impostazioni camera salvate",enterCameraUrl:"Inserisci un URL camera",passwordChanged:"Password cambiata con successo",connectionFailed:"Connessione fallita",testFailed:"Test fallito",cameraConnected:"Camera connessa{{resolution}}"},testConnection:"Testa connessione"},notification:{printStarted:{title:"Stampa avviata",body:"{{printer}}: {{filename}} ha iniziato a stampare"},printCompleted:{title:"Stampa completata",body:"{{printer}}: {{filename}} completata con successo"},printFailed:{title:"Stampa fallita",body:"{{printer}}: {{filename}} fallita"},printStopped:{title:"Stampa interrotta",body:"{{printer}}: {{filename}} interrotta"},printProgress:{title:"Avanzamento stampa",body:"{{printer}}: {{filename}} al {{percent}}% completamento"},printerOffline:{title:"Stampante offline",body:"{{printer}} e offline"},printerError:{title:"Errore stampante",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filamento in esaurimento",body:"{{printer}}: Filamento in esaurimento"},maintenanceDue:{title:"Manutenzione dovuta",body:"{{printer}}: {{items}} richiedono attenzione"}},errors:{generic:"Qualcosa e andato storto",networkError:"Errore di rete. Controlla la connessione.",notFound:"Non trovato",unauthorized:"Non autorizzato",serverError:"Errore server",validationError:"Controlla i dati inseriti",printerConnectionFailed:"Connessione alla stampante fallita",saveFailed:"Salvataggio modifiche fallito",deleteFailed:"Eliminazione fallita",loadFailed:"Caricamento dati fallito"},hmsErrors:{title:"Errori - {{name}}",noErrors:"Nessun errore",viewOnWiki:"Vedi su Bambu Lab Wiki",clearInstructions:"Cancella gli errori sulla stampante per rimuoverli qui."},mqttDebug:{title:"Log debug MQTT",searchPlaceholder:"Cerca topic o payload...",noMessages:"Nessun messaggio registrato",startLoggingHint:'Clicca "Avvia logging" per iniziare a catturare messaggi MQTT',noMessagesMatch:"Nessun messaggio corrisponde al filtro",adjustFilterHint:"Prova a modificare la ricerca o i filtri",incoming:"In ingresso",outgoing:"In uscita",loggingStopped:"Logging fermato",loggingActive:"Logging attivo - i messaggi si aggiornano automaticamente",startLogging:"Avvia logging",stopLogging:"Ferma logging",clearLog:"Pulisci log",topic:"Topic",timestamp:"Timestamp",direction:"Direzione",all:"Tutti"},printerFiles:{title:"Gestore file",storageUsed:"Usato:",storageFree:"Libero:",filterPlaceholder:"Filtra file...",deleteButton:"Elimina",deleteFiles:"Elimina {{count}} file",deleteFileConfirm:'Eliminare "{{name}}"? Questa azione non può essere annullata.',deleteFilesConfirm:"Eliminare {{count}} file selezionati? Questa azione non può essere annullata.",noFiles:"Nessun file sulla stampante",loadingFiles:"Caricamento file...",failedToLoad:"Caricamento file fallito",toast:{filesDeleted:"Eliminati {{count}} file",deleteFailed:"Eliminazione fallita: {{error}}"}},confirm:{delete:"Sei sicuro di voler eliminare questo?",unsavedChanges:"Hai modifiche non salvate. Sei sicuro di voler uscire?",clearQueue:"Sei sicuro di voler svuotare la coda?"},login:{title:"Login Bambuddy",subtitle:"Accedi al tuo account",username:"Nome utente",usernamePlaceholder:"Inserisci il nome utente",password:"Password",passwordPlaceholder:"Inserisci la password",signIn:"Accedi",signingIn:"Accesso in corso...",forgotPassword:"Hai dimenticato la password?",loginSuccess:"Accesso riuscito",loginFailed:"Accesso fallito",enterCredentials:"Inserisci nome utente e password",forgotPasswordTitle:"Password dimenticata",forgotPasswordMessage:"Se hai dimenticato la password, contatta il tuo amministratore di sistema per reimpostarla.",howToReset:"Come reimpostare la password:",resetStep1:"Contatta il tuo amministratore Bambuddy",resetStep2:"Chiedi di reimpostare la password in Gestione utenti",resetStep3:"Possono impostare una nuova password temporanea",resetStep4:"Accedi con la nuova password e cambiala in Impostazioni",gotIt:"Capito"},setup:{title:"Configurazione Bambuddy",subtitle:"Configura autenticazione per la tua istanza Bambuddy",enableAuth:"Abilita autenticazione",adminAccount:"Account admin",adminAccountDesc:"Se esistono già admin, l'autenticazione verrà abilitata usando gli account esistenti. Lascia i campi sotto vuoti per usare gli admin esistenti, oppure inserisci nuove credenziali per creare un nuovo utente admin.",adminUsername:"Nome utente admin",adminPassword:"Password admin",optionalIfAdminExists:"(opzionale se esistono admin)",adminUsernamePlaceholder:"Inserisci nome utente admin (opzionale)",adminPasswordPlaceholder:"Inserisci password admin (opzionale)",confirmPassword:"Conferma password",confirmPasswordPlaceholder:"Conferma password admin",settingUp:"Configurazione...",completeSetup:"Completa configurazione",toast:{authEnabledAdminCreated:"Autenticazione abilitata e utente admin creato",authEnabledExistingAdmins:"Autenticazione abilitata usando admin esistenti",setupCompleted:"Configurazione completata",enterBothCredentials:"Inserisci nome utente e password admin, oppure lascia entrambi vuoti per usare admin esistenti",passwordsDoNotMatch:"Le password non coincidono",passwordTooShort:"La password deve essere di almeno 6 caratteri"}},changePassword:{title:"Cambia password",currentPassword:"Password attuale",currentPasswordPlaceholder:"Inserisci password attuale",newPassword:"Nuova password",newPasswordPlaceholder:"Inserisci nuova password (min 6 caratteri)",confirmPassword:"Conferma nuova password",confirmPasswordPlaceholder:"Conferma nuova password",passwordsDoNotMatch:"Le password non coincidono",passwordTooShort:"La password deve essere di almeno 6 caratteri",changing:"Modifica in corso...",success:"Password cambiata con successo",failed:"Modifica password fallita"},plateAlert:{title:"Stampa in pausa!",message:"Oggetti rilevati sul piatto. La stampa è stata messa automaticamente in pausa. Svuota il piatto e riprendi la stampa.",understand:"Ho capito"},camera:{title:"Vista camera",invalidPrinterId:"ID stampante non valido",live:"Live",snapshot:"Snapshot",restartStream:"Riavvia stream",refreshSnapshot:"Aggiorna snapshot",fullscreen:"Schermo intero",exitFullscreen:"Esci da schermo intero",connectingToCamera:"Connessione alla camera...",capturingSnapshot:"Acquisizione snapshot...",connectionLost:"Connessione persa",connectionFailed:"Connessione camera fallita",reconnecting:"Riconnessione tra {{countdown}}s... (tentativo {{attempt}}/{{max}})",reconnectNow:"Riconnetti ora",cameraUnavailable:"Camera non disponibile",cameraUnavailableDesc:"Assicurati che la stampante sia accesa e connessa.",noCamera:"Nessuna camera disponibile",retry:"Riprova",cameraStream:"Stream camera",zoomOut:"Zoom indietro",zoomIn:"Zoom avanti",resetZoom:"Reset zoom",recording:"Registrazione",startRecording:"Avvia registrazione",stopRecording:"Ferma registrazione",chamberLight:"Accendi/Spegni luce camera"},groups:{title:"Gestione gruppi",subtitle:"Gestisci gruppi permessi per controllo accesso",backToSettings:"Torna a Impostazioni",createGroup:"Crea gruppo",noPermission:"Non hai il permesso di accedere a questa pagina.",system:"Sistema",noDescription:"Nessuna descrizione",usersCount:"{{count}} utenti",permissionsCount:"{{count}} permessi",edit:"Modifica",delete:"Elimina",toast:{created:"Gruppo creato con successo",updated:"Gruppo aggiornato con successo",deleted:"Gruppo eliminato con successo",enterGroupName:"Inserisci un nome gruppo"},modal:{editGroup:"Modifica gruppo",createGroup:"Crea gruppo",cancel:"Annulla",saving:"Salvataggio...",creating:"Creazione...",saveChanges:"Salva modifiche"},form:{groupName:"Nome gruppo",groupNamePlaceholder:"Inserisci nome gruppo",systemGroupWarning:"I nomi dei gruppi di sistema non possono essere modificati",description:"Descrizione",descriptionPlaceholder:"Inserisci descrizione (opzionale)",permissions:"Permessi ({{count}} selezionati)"},deleteModal:{title:"Elimina gruppo",message:"Sei sicuro di voler eliminare questo gruppo? Gli utenti in questo gruppo perderanno questi permessi.",confirm:"Elimina gruppo"}},users:{title:"Gestione utenti",subtitle:"Gestisci utenti e accesso alla tua istanza Bambuddy",backToSettings:"Torna a Impostazioni",createUser:"Crea utente",noPermission:"Non hai il permesso di accedere a questa pagina.",admin:"Admin",noGroups:"Nessun gruppo",active:"Attivo",inactive:"Inattivo",edit:"Modifica",delete:"Elimina",system:"Sistema",noGroupsAvailable:"Nessun gruppo disponibile",table:{username:"Nome utente",groups:"Gruppi",status:"Stato",actions:"Azioni"},toast:{created:"Utente creato con successo",updated:"Utente aggiornato con successo",deleted:"Utente eliminato con successo",fillRequired:"Compila tutti i campi obbligatori",passwordsDoNotMatch:"Le password non coincidono",passwordTooShort:"La password deve essere di almeno 6 caratteri"},modal:{createUser:"Crea utente",editUser:"Modifica utente",cancel:"Annulla",creating:"Creazione...",saving:"Salvataggio...",saveChanges:"Salva modifiche"},form:{username:"Nome utente",usernamePlaceholder:"Inserisci nome utente",password:"Password",passwordPlaceholder:"Inserisci password",confirmPassword:"Conferma password",confirmPasswordPlaceholder:"Conferma password",newPasswordPlaceholder:"Inserisci nuova password",confirmNewPasswordPlaceholder:"Conferma nuova password",leaveBlankToKeep:"lascia vuoto per mantenere attuale",groups:"Gruppi"},deleteModal:{title:"Elimina utente",message:"Sei sicuro di voler eliminare questo utente? Questa azione non può essere annullata.",confirm:"Elimina utente"}},streamOverlay:{title:"Overlay stream",invalidPrinterId:"ID stampante non valido",cameraStream:"Stream camera",progress:"Avanzamento",eta:"ETA",tomorrow:"Domani",printerIdle:"Stampante inattiva",printerOffline:"Stampante offline",status:{printing:"In stampa",paused:"In pausa",finished:"Completata",failed:"Fallita",idle:"Inattiva",unknown:"Sconosciuto"}},profiles:{title:"Profili",subtitle:"Gestisci preset slicer e calibrazioni pressure advance",tabs:{cloud:"Profili cloud",local:"Profili locali",kprofiles:"K-Profiles"},localProfiles:{title:"Profili locali",subtitle:"Importa e gestisci preset slicer da OrcaSlicer",import:"Importa profili",importDesc:"Trascina file .bbscfg, .bbsflmt, .orca_filament, .zip o .json qui",importing:"Importazione...",search:"Cerca preset locali...",noPresets:"Nessun preset locale ancora",badge:"Locale",edit:"Modifica",delete:"Elimina",cancel:"Annulla",deleteConfirmTitle:"Elimina preset",deleteConfirm:"Sei sicuro di voler eliminare questo preset? Questa azione non può essere annullata.",source:"Fonte",inheritsFrom:"Eredita da",filamentType:"Tipo",vendor:"Produttore",compatiblePrinters:"Stampanti",nozzleTemp:"Temp. ugello",cost:"Costo",density:"Densità",pressureAdvance:"Pressure Advance",filament:"Filamento",process:"Processo",printer:"Stampante",toast:{importSuccess:"{{count}} preset importati",importSkipped:"{{count}} preset saltati (duplicati)",importError:"{{count}} errori durante l'importazione",deleted:"Preset eliminato",updated:"Preset aggiornato"}},connectedAs:"Connesso come",logout:"Esci",noLogoutPermission:"Non hai il permesso di disconnetterti",failedToLoad:"Caricamento profili fallito",retry:"Riprova",time:{justNow:"Proprio ora",minsAgo:"{{count}}m fa",hoursAgo:"{{count}}h fa",daysAgo:"{{count}}g fa"},toast:{loggedOut:"Disconnesso"},login:{title:"Connetti a Bambu Cloud",subtitle:"Sincronizza i preset del slicer tra dispositivi",email:"Email",password:"Password",region:"Regione",regionGlobal:"Globale",regionChina:"Cina",verificationCode:"Codice di verifica",totpCode:"Codice autenticatore",checkEmail:"Controlla la tua email ({{email}}) per un codice a 6 cifre",enterTotpHint:"Inserisci il codice a 6 cifre dalla tua app autenticatore",accessToken:"Access Token",accessTokenHint:"Incolla il tuo access token Bambu Lab (da Bambu Studio)",back:"Indietro",loginButton:"Accedi",verifyButton:"Verifica",setTokenButton:"Imposta token",useToken:"Usa access token invece",useEmail:"Accedi con email invece",toast:{loggedIn:"Accesso riuscito",codeSent:"Codice di verifica inviato via email",enterTotp:"Inserisci il codice dalla tua app autenticatore",tokenSet:"Token impostato con successo"}},presets:{myPreset:"Il mio preset (modificabile)",duplicate:"Duplica",editable:"Modificabile",failedToLoadDetails:"Caricamento dettagli preset fallito",deleteConfirm:"Eliminare questo preset?",deleteWarning:'Questo eliminerà definitivamente "{{name}}" da Bambu Cloud. Questa azione non può essere annullata.',noDuplicatePermission:"Non hai il permesso di duplicare preset",noEditPermission:"Non hai il permesso di modificare preset",noDeletePermission:"Non hai il permesso di eliminare preset",types:{filament:"Preset filamento",printer:"Preset stampante",process:"Preset processo"},toast:{deleted:"Preset eliminato",created:"Preset creato",updated:"Preset aggiornato",duplicated:"Preset duplicato",fieldAdded:'Campo "{{key}}" aggiunto',exported:"Preset esportato"},baseLabel:"Base: {{name}}",currentLabel:"Corrente: {{name}}",newPreset:"Nuovo preset",editPreset:"Modifica preset",duplicatePreset:"Duplica preset",createNewPreset:"Crea nuovo preset",customizeSettings:"Personalizza le impostazioni per il nuovo preset",compareWithBase:"Confronta con base",compare:"Confronta",basePreset:"Preset base",selectBasePreset:"Seleziona preset base...",presetName:"Nome preset",myCustomPreset:"Il mio preset personalizzato",inheritsFrom:"Deriva da",dropJsonToImport:"Rilascia JSON per importare",tabs:{common:"Comune",allFields:"Tutti i campi"},availableFields:"Campi disponibili",searchFieldsPlaceholder:"Cerca campi...",noMatchingFields:"Nessun campo corrispondente",allFieldsAdded:"Tutti i campi aggiunti",addCustomField:"Aggiungi campo personalizzato",yourOverrides:"Le tue override",noOverridesYet:"Nessun override ancora",clickFieldsToAdd:"Clicca i campi a sinistra per aggiungerli",saveAsTemplate:"Salva come template",jsonTip:"Suggerimento: trascina e rilascia un file .json ovunque in questa modale per importare impostazioni"},cloudView:{searchPlaceholder:"Cerca preset...",templates:"Template",refresh:"Aggiorna",newPreset:"Nuovo preset",clearFilters:"Pulisci filtri",compareMode:"Modalita confronto",selectAnotherPreset:"Seleziona un altro preset {{type}}",clickTwoPresets:"Clicca due preset dello stesso tipo per confrontare",selectFirst:"1. Seleziona il primo",selectSecond:"2. Seleziona il secondo",compareNow:"Confronta ora",lastSynced:"Ultima sincronizzazione:",showingCount:"Mostrati {{showing}} di {{total}} preset",noPresetsFound:"Nessun preset trovato",columns:{filament:"Filamento",process:"Processo",printer:"Stampante"},noFilamentPresets:"Nessun preset filamento",noProcessPresets:"Nessun preset processo",noPrinterPresets:"Nessun preset stampante",filters:{type:"Tipo",owner:"Proprietario",printer:"Stampante",nozzle:"Ugello",filament:"Filamento",layer:"Layer",all:"Tutti",myPresets:"I miei preset",builtIn:"Integrati",process:"Processo"},noTemplatesPermission:"Non hai il permesso di gestire i template",noRefreshPermission:"Non hai il permesso di aggiornare i profili",noCreatePermission:"Non hai il permesso di creare preset"},templates:{title:"Template rapidi",noTemplates:"Nessun template ancora",createFirst:"Crea template dall'editor preset",typeFilter:"Tipo:",deleteTitle:"Elimina template",deleteWarning:"Questa azione non può essere annullata",deleteConfirm:'Sei sicuro di voler eliminare "{{name}}"?',namePlaceholder:"Nome template",descriptionPlaceholder:"Descrizione",settingsJson:"Impostazioni (JSON)",fieldsCount:"{{count}} campi",shownInModals:"Mostrati nelle modali",hiddenInModals:"Nascosti nelle modali",apply:"Applica",toast:{deleted:"Template eliminato",updated:"Template aggiornato",created:"Template creato",applied:"Template applicato"}}},support:{debugLoggingActive:"Log debug attivo",manageLogs:"Gestisci",collectItem7:"Connettività stampante e versioni firmware",collectItem8:"Stato integrazioni (Spoolman, MQTT, HA)",collectItem9:"Interfacce di rete (solo subnet)",collectItem10:"Versioni dei pacchetti Python",collectItem11:"Controlli di integrità del database",collectItem12:"Dettagli dell'ambiente Docker"},fileManager:{title:"Gestore file",subtitle:"Organizza e gestisci i tuoi file di stampa",uploadFiles:"Carica file",newFolder:"Nuova cartella",folderName:"Nome cartella",folderNamePlaceholder:"es., Parti funzionali",renameFile:"Rinomina file",renameFolder:"Rinomina cartella",moveFiles:"Sposta {{count}} file",rootNoFolder:"Root (nessuna cartella)",current:"corrente",linkFolder:"Collega cartella",linkFolderDescription:'Collega "{{name}}" a un progetto o archivio per accesso rapido.',project:"Progetto",archive:"Archivio",noProjectsFound:"Nessun progetto trovato",noArchivesFound:"Nessun archivio trovato",unlink:"Scollega",link:"Collega",dragDropFiles:"Trascina e rilascia file qui",dropFilesHere:"Rilascia file qui",orClickToBrowse:"oppure clicca per sfogliare",allFileTypesSupported:"Tutti i tipi di file supportati. I file ZIP saranno estratti.",zipFilesDetected:"File ZIP rilevati",zipExtractOptions:"I file ZIP saranno estratti. Scegli come gestire la struttura cartelle:",preserveZipStructure:"Mantieni struttura cartelle dal ZIP",createFolderFromZip:"Crea cartella dal nome ZIP",stlThumbnailGeneration:"Generazione miniature STL",zipMayContainStl:"I file ZIP possono contenere STL. Le miniature possono essere generate durante l'estrazione.",thumbnailsCanBeGenerated:"Le miniature possono essere generate per file STL. I modelli grandi possono richiedere più tempo.",generateThumbnailsForStl:"Genera miniature per file STL",threemfDetected:"File 3MF rilevati",threemfExtractionInfo:"Modello stampante, materiale, colore e impostazioni stampa saranno estratti automaticamente dai file 3MF.",willBeExtracted:"Sara estratto",filesExtracted:"{{count}} file estratti",uploadComplete:"Caricamento completato: {{succeeded}} riusciti",uploadFailed:"{{count}} falliti",uploading:"Caricamento...",changeLink:"Cambia collegamento...",linkTo:"Collega a...",linkToProjectOrArchive:"Collega a progetto o archivio",addToQueue:"Aggiungi alla coda",schedulePrint:"Pianifica",generateThumbnail:"Genera miniatura",generateThumbnails:"Genera miniature",generateThumbnailsForMissing:"Genera miniature per STL senza miniatura",gridView:"Vista griglia",listView:"Vista elenco",lowDiskSpaceWarning:"Avviso spazio disco basso",lowDiskSpaceDetails:"Solo {{free}} liberi su {{total}} totali. La soglia e {{threshold}} GB nelle impostazioni.",files:"File",folders:"Cartelle",size:"Dimensione",free:"Libero",allFiles:"Tutti i file",wrap:"A capo",enableTextWrapping:"Abilita a capo testo",disableTextWrapping:"Disabilita a capo testo",dragToResizeTooltip:"Trascina per ridimensionare, doppio clic per reset",searchFiles:"Cerca file...",allTypes:"Tutti i tipi",prints:"Stampe",ascending:"Crescente",descending:"Decrescente",resultsCount:"{{showing}} di {{total}} file",selectAll:"Seleziona tutto",deselectAll:"Deseleziona tutto",selected:"{{count}} selezionati",adding:"Aggiunta...",loadingFiles:"Caricamento file...",folderIsEmpty:"La cartella e vuota",noFilesYet:"Nessun file ancora",folderEmptyDescription:"Carica file o sposta file in questa cartella per iniziare.",noFilesDescription:"Carica file per iniziare a organizzare i file di stampa.",noMatchingFiles:"Nessun file corrispondente",noMatchingFilesDescription:"Nessun file corrisponde ai criteri di ricerca o filtro.",clearFilters:"Pulisci filtri",printedCount:"Stampato {{count}}x",uploadedBy:"Caricato da",deleteFolder:"Elimina cartella",deleteFile:"Elimina file",deleteFilesCount:"Elimina {{count}} file",deleteFolderConfirm:"Sei sicuro di voler eliminare questa cartella? Tutti i file dentro saranno eliminati.",deleteFileConfirm:"Sei sicuro di voler eliminare questo file?",deleteFilesConfirm:"Sei sicuro di voler eliminare {{count}} file selezionati? Questa azione non può essere annullata.",deleting:"Eliminazione...",noPermissionRenameFolder:"Non hai il permesso di rinominare cartelle",noPermissionLinkFolder:"Non hai il permesso di collegare cartelle",noPermissionDeleteFolder:"Non hai il permesso di eliminare cartelle",noPermissionPrint:"Non hai il permesso di stampare",noPermissionAddToQueue:"Non hai il permesso di aggiungere alla coda",noPermissionDownload:"Non hai il permesso di scaricare file",noPermissionRenameFile:"Non hai il permesso di rinominare questo file",noPermissionGenerateThumbnail:"Non hai il permesso di generare miniature",noPermissionDeleteFile:"Non hai il permesso di eliminare questo file",noPermissionCreateFolder:"Non hai il permesso di creare cartelle",noPermissionUpload:"Non hai il permesso di caricare file",noPermissionMoveFiles:"Non hai il permesso di spostare file",noPermissionDeleteFiles:"Non hai il permesso di eliminare file",toast:{folderCreated:"Cartella creata",folderDeleted:"Cartella eliminata",fileDeleted:"File eliminato",filesDeleted:"Eliminati {{count}} file",filesMoved:"File spostati",folderLinked:"Cartella collegata",folderUnlinked:"Cartella scollegata",addedToQueue:"Aggiunti {{count}} file alla coda",addedToQueuePartial:"Aggiunti {{added}} file, {{failed}} falliti",failedToAddToQueue:"Aggiunta file fallita: {{error}}",fileRenamed:"File rinominato",folderRenamed:"Cartella rinominata",thumbnailsGenerated:"Generate {{count}} miniature",thumbnailsGeneratedPartial:"Generate {{succeeded}} miniature, {{failed}} fallite",noStlMissingThumbnails:"Nessun file STL senza miniature",failedToGenerateThumbnails:"Generazione miniature fallita: {{error}}",thumbnailGenerated:"Miniatura generata",failedToGenerateThumbnail:"Generazione miniatura fallita: {{error}}"}},projects:{title:"Progetti",subtitle:"Organizza e traccia i tuoi progetti di stampa 3D",newProject:"Nuovo progetto",editProject:"Modifica progetto",deleteProject:"Elimina progetto",projectName:"Nome progetto",description:"Descrizione",noProjects:"Nessun progetto ancora",noProjectsFiltered:"Nessun progetto {{status}}",noProjectsFilteredHelp:"Non hai progetti {{status}}. I progetti appariranno qui quando il loro stato cambia.",createFirst:"Crea il tuo primo progetto per organizzare stampe correlate, tracciare progressi e gestire i tuoi build.",createFirstButton:"Crea il tuo primo progetto",create:"Crea",files:"File",prints:"Stampe",plates:"piatti",parts:"parti",lastModified:"Ultima modifica",deleteConfirm:"Sei sicuro di voler eliminare questo progetto? Archivi e elementi in coda saranno scollegati ma non eliminati.",addFiles:"Aggiungi file",removeFile:"Rimuovi file",viewDetails:"Vedi dettagli",namePlaceholder:"es., Build Voron 2.4",descriptionPlaceholder:"Descrizione opzionale...",color:"Colore",targetPlates:"Piatti target",targetPlatesPlaceholder:"es., 25",targetPlatesHelp:"Numero di job di stampa",targetParts:"Parti target",targetPartsPlaceholder:"es., 150",targetPartsHelp:"Totale oggetti necessari",tagsLabel:"Tag (separati da virgola)",tagsPlaceholder:"es., voron, funzionale, regalo",dueDate:"Data scadenza",priority:"Priorita",priorityLow:"Bassa",priorityNormal:"Normale",priorityHigh:"Alta",priorityUrgent:"Urgente",statusActive:"Attivo",statusCompleted:"Completato",statusArchived:"Archiviato",done:"Fatto",completed:"completato",failed:"fallito",inQueue:"in coda",noPrintsYet:"Nessuna stampa ancora",printJobs:"Job di stampa (piatti)",partsPrinted:"Parti stampate",failedParts:"Parti fallite",import:"Importa",export:"Esporta",importProject:"Importa progetto",exportAll:"Esporta tutti i progetti",loading:"Caricamento progetti...",noEditPermission:"Non hai il permesso di modificare progetti",noDeletePermission:"Non hai il permesso di eliminare progetti",noCreatePermission:"Non hai il permesso di creare progetti",noImportPermission:"Non hai il permesso di importare progetti",noExportPermission:"Non hai il permesso di esportare progetti",toast:{created:"Progetto creato",updated:"Progetto aggiornato",deleted:"Progetto eliminato",imported:"Progetto importato",multipleImported:"{{count}} progetti importati",importFailed:"Import fallito",exported:"Progetti esportati (solo metadati)"}},projectDetail:{notFound:"Progetto non trovato",backToProjects:"Torna a Progetti",export:"Esporta",exportProject:"Esporta progetto",noExportPermission:"Non hai il permesso di esportare progetti",noEditPermission:"Non hai il permesso di modificare progetti",partOf:"Parte di:",priorityLabel:"Priorita:",noPrints:"Nessuna stampa in questo progetto ancora",status:{active:"Attivo",completed:"Completato",archived:"Archiviato"},priority:{low:"Bassa",normal:"Normale",high:"Alta",urgent:"Urgente"},dueDate:{overdue:"Scaduto",today:"Scade oggi",daysLeft:"{{count}} giorni rimanenti"},progress:{platesProgress:"Avanzamento piatti",partsProgress:"Avanzamento parti",printJobs:"job di stampa",parts:"parti",percentComplete:"{{percent}}% completato",remaining:"{{count}} rimanenti"},stats:{printJobs:"Job di stampa",total:"totale",failed:"{{count}} falliti",partsPrinted:"{{count}} parti stampate",printTime:"Tempo di stampa",filamentUsed:"Filamento usato"},cost:{title:"Tracciamento costi",filamentCost:"Costo filamento",energy:"Energia",budget:"Budget",remaining:"Rimanente"},subProjects:{title:"Sotto-progetti ({{count}})"},notes:{title:"Note",noEditPermission:"Non hai il permesso di modificare le note",placeholder:"Aggiungi note su questo progetto...",empty:"Nessuna nota ancora. Clicca Modifica per aggiungere note."},files:{title:"File",linkFolders:"Collega cartelle dal Gestore file",forQuickAccess:"a questo progetto per accesso rapido.",fileCount:"{{count}} file",empty:"Nessuna cartella collegata. Vai a Gestore file e collega una cartella a questo progetto."},bom:{title:"Distinta materiali",acquired:"{{completed}}/{{total}} acquisiti",showAll:"Mostra tutti",hideDone:"Nascondi completati",addPart:"Aggiungi parte",noAddPermission:"Non hai il permesso di aggiungere parti",partNamePlaceholder:"Nome parte (es., viti M3x8)",partName:"Nome parte",qty:"Qta",price:"Prezzo ({{currency}})",sourcingUrlPlaceholder:"URL fornitura (opzionale)",remarksPlaceholder:"Note (opzionale)",deletePart:"Elimina parte",deleteConfirm:'Sei sicuro di voler eliminare "{{name}}"?',noUpdatePermission:"Non hai il permesso di aggiornare parti",noEditPermission:"Non hai il permesso di modificare parti",noDeletePermission:"Non hai il permesso di eliminare parti",totalCost:"Costo totale:",empty:"Nessuna parte nella distinta materiali. Aggiungi hardware, elettronica o altri componenti da reperire."},timeline:{title:"Timeline attivita",empty:"Nessuna attivita ancora."},template:{saveAsTemplate:"Salva come template",noCreatePermission:"Non hai il permesso di creare template"},queue:{title:"Coda",viewAll:"Vedi tutto",printing:"{{count}} in stampa",queued:"{{count}} in coda"},prints:{title:"Stampe ({{count}})"},toast:{projectUpdated:"Progetto aggiornato",partAdded:"Parte aggiunta",partRemoved:"Parte rimossa",exportFailed:"Export fallito",projectExported:"Progetto esportato",templateCreated:"Template creato"}},system:{title:"Informazioni sistema",version:"Versione",uptime:"Tempo attivo",cpuUsage:"Uso CPU",memoryUsage:"Uso memoria",diskUsage:"Uso disco",networkInfo:"Info rete",logs:"Log",debugMode:"Modalita debug",enableDebug:"Abilita log debug",disableDebug:"Disabilita log debug",downloadLogs:"Scarica log",clearLogs:"Cancella log",dockerInfo:"Info Docker",containerName:"Nome container",imageName:"Nome immagine",platform:"Piattaforma",architecture:"Architettura"},library:{title:"Libreria filamenti",addFilament:"Aggiungi filamento",editFilament:"Modifica filamento",deleteFilament:"Elimina filamento",vendor:"Produttore",material:"Materiale",color:"Colore",kFactor:"K Factor",temperature:"Temperatura",noFilaments:"Nessun filamento in libreria",deleteConfirm:"Sei sicuro di voler eliminare questo filamento?",importFromPrinter:"Importa da stampante",exportToFile:"Esporta su file"},spoolman:{title:"Integrazione Spoolman",enabled:"Spoolman abilitato",url:"URL Spoolman",connected:"Connesso",disconnected:"Non connesso",testConnection:"Testa connessione",sync:"Sincronizza",syncing:"Sincronizzazione...",lastSync:"Ultima sincronizzazione",linkToSpoolman:"Collega a Spoolman",openInSpoolman:"Apri in Spoolman",unlinkSpool:"Scollega bobina",selectSpool:"Seleziona bobina",noUnlinkedSpools:"Nessuna bobina scollegata disponibile",linkSuccess:"Bobina collegata a Spoolman con successo",linkFailed:"Collegamento bobina fallito",spoolId:"ID bobina",fillSourceLabel:"(Spoolman)",weight:"Peso",remaining:"Rimanente",disableWeightSync:"Disabilita sync peso stimato AMS",disableWeightSyncDesc:"Non aggiornare la capacità rimanente dalle stime AMS. Usalo se preferisci il tracciamento di Spoolman rispetto alle stime AMS. Le nuove bobine useranno comunque la stima AMS come peso iniziale.",reportPartialUsage:"Segnala uso parziale per stampe fallite",reportPartialUsageDesc:"Quando una stampa fallisce o viene annullata, segnala il filamento stimato usato fino a quel punto in base all'avanzamento layer."},timelapse:{title:"Timelapse",create:"Crea timelapse",download:"Scarica",delete:"Elimina",preview:"Anteprima",frameRate:"Frame rate",quality:"Qualità",processing:"Elaborazione...",noTimelapses:"Nessun timelapse disponibile"},ams:{title:"AMS",slot:"Slot",empty:"Vuoto",emptySlot:"Slot vuoto",unknown:"Sconosciuto",humidity:"Umidità",temperature:"Temperatura",filamentType:"Tipo filamento",filamentColor:"Colore",remaining:"Rimanente",history:"Cronologia AMS",noHistory:"Nessuna cronologia disponibile",configureSlot:"Configura slot",externalSpool:"Bobina esterna",profile:"Profilo",kFactor:"K Factor",fill:"Riempi",configure:"Configura"},printModal:{title:"Avvia stampa",selectPrinter:"Seleziona stampante",selectPlate:"Seleziona piatto",filamentMapping:"Mappatura filamento",printSettings:"Impostazioni stampa",bedLeveling:"Livellamento piatto",flowCalibration:"Calibrazione flusso",vibrationCalibration:"Calibrazione vibrazioni",layerInspection:"Ispezione primo layer",timelapse:"Timelapse",startPrint:"Avvia stampa",addToQueue:"Aggiungi alla coda",cancel:"Annulla",noPrintersAvailable:"Nessuna stampante disponibile",printerBusy:"Stampante occupata",printerOffline:"Stampante offline",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"Ugello sinistro",rightNozzleTooltip:"Ugello destro"},backup:{title:"Backup e ripristino",createBackup:"Crea backup",restoreBackup:"Ripristina backup",restoreDescription:"Sostituisci tutti i dati da un file di backup",downloadBackup:"Scarica backup",uploadBackup:"Carica backup",lastBackup:"Ultimo backup",autoBackup:"Backup automatico",backupNow:"Esegui backup ora",restoreWarning:"Avviso: il ripristino sovrascriverà tutti i dati attuali.",includeArchives:"Includi archivi",includeSettings:"Includi impostazioni",includeProfiles:"Includi profili",backupSuccess:"Backup creato con successo",restoreSuccess:"Backup ripristinato con successo",backupFailed:"Backup fallito",restoreFailed:"Ripristino fallito",restoreNote:"La stampante virtuale verrà fermata durante il ripristino"},tags:{title:"Tag",addTag:"Aggiungi tag",editTag:"Modifica tag",deleteTag:"Elimina tag",tagName:"Nome tag",tagColor:"Colore tag",noTags:"Nessun tag",deleteConfirm:"Sei sicuro di voler eliminare questo tag?",manageTags:"Gestisci tag"},uploadModal:{title:"Carica file 3MF",dragDrop:"Trascina e rilascia file .3mf qui",or:"o",browseFiles:"Sfoglia file",extractionInfo:"Il modello stampante sarà estratto automaticamente dai metadati del file 3MF.",uploaded:"caricati",failed:"falliti",uploading:"Caricamento...",upload:"Carica",uploadFailed:"Caricamento fallito"},editArchive:{title:"Modifica archivio",name:"Nome",namePlaceholder:"Nome stampa",printer:"Stampante",noPrinter:"Nessuna stampante",project:"Progetto",noProject:"Nessun progetto",itemsPrinted:"Elementi stampati",itemsPrintedHelp:"Numero di elementi prodotti in questo job di stampa",notes:"Note",notesPlaceholder:"Aggiungi note su questa stampa...",externalLink:"Link esterno",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link a Printables, Thingiverse o altra fonte",tags:"Tag",tagsPlaceholder:"Aggiungi tag...",addMoreTags:"Aggiungi altri tag...",matchingTags:'Tag corrispondenti "{{query}}"',existingTags:"Tag esistenti",clickToAdd:"(clicca per aggiungere)",status:"Stato",failureReason:"Motivo fallimento",selectReason:"Seleziona motivo...",photos:"Foto del risultato stampato",photosHelp:"Clicca + per aggiungere foto del risultato stampato",printResult:"Risultato stampa",saving:"Salvataggio...",failureReasons:{adhesionFailure:"Fallimento adesione",spaghettiDetached:"Spaghetti / staccato",layerShift:"Spostamento layer",cloggedNozzle:"Ugello intasato",filamentRunout:"Filamento esaurito",warping:"Warping",stringing:"Stringing",underExtrusion:"Sotto-estrusione",powerFailure:"Mancanza corrente",userCancelled:"Annullato dall'utente",other:"Altro"},statuses:{completed:"Completato",failed:"Fallito",aborted:"Annullato",printing:"In stampa"}},kProfiles:{title:"K-Profiles",noPrintersConfigured:"Nessuna stampante configurata",addPrinterInSettings:"Aggiungi una stampante in Impostazioni per gestire i K-profiles",noActivePrinters:"Nessuna stampante attiva",enablePrinterConnection:"Abilita una connessione stampante per vedere i K-profiles",loadingProfiles:"Caricamento K-Profiles...",printerOffline:"Stampante offline",printerOfflineDesc:"La stampante selezionata non e connessa. Accendila per vedere i K-profiles.",noMatchingProfiles:"Nessun profilo corrispondente",noMatchingProfilesDesc:"Nessun profilo corrisponde ai criteri di ricerca",noKProfiles:"Nessun K-Profile",noKProfilesDesc:"Nessun profilo pressure advance per ugello da {{diameter}}mm",createFirstProfile:"Crea primo profilo",printer:"Stampante",nozzle:"Ugello",refresh:"Aggiorna",addProfile:"Aggiungi profilo",export:"Esporta",import:"Importa",select:"Seleziona",selectAll:"Seleziona tutto",delete:"Elimina",searchPlaceholder:"Cerca per nome o filamento...",allExtruders:"Tutti gli estrusori",leftOnly:"Solo sinistro",rightOnly:"Solo destro",allFlow:"Tutto flow",hfOnly:"Solo HF",sOnly:"Solo S",sortName:"Ordina: Nome",sortKValue:"Ordina: K-Value",sortFilament:"Ordina: Filamento",leftExtruder:"Estrusore sinistro",rightExtruder:"Estrusore destro",modal:{addTitle:"Aggiungi K-Profile",editTitle:"Modifica K-Profile",profileName:"Nome profilo",profileNamePlaceholder:"Il mio profilo PLA",kValue:"K-Value",kValuePlaceholder:"0.020",kValueHelp:"Intervallo tipico: 0.01 - 0.06 per PLA, 0.02 - 0.10 per PETG",filament:"Filamento",selectFilament:"Seleziona filamento...",noFilamentsHelp:"Nessun filamento trovato. Crea prima un K-profile in Bambu Studio.",flowType:"Tipo flow",highFlow:"High Flow",standard:"Standard",nozzleSize:"Dimensione ugello",extruder:"Estrusore",extruders:"Estrusori",left:"Sinistra",right:"Destra",notes:"Note (salvate localmente)",notesPlaceholder:"Aggiungi note su questo profilo...",notesHelp:"Le note sono salvate in Bambuddy, non sulla stampante",syncing:"Sincronizzazione con stampante...",savingExtruder:"Salvataggio su estrusore {{current}}/{{total}}...",pleaseWait:"Attendere"},deleteConfirm:{title:"Elimina profilo",cannotUndo:"Questo non può essere annullato",message:'Sei sicuro di voler eliminare "{{name}}" dalla stampante?'},bulkDelete:{title:"Elimina profili",cannotUndo:"Questo non può essere annullato",message:"Sei sicuro di voler eliminare {{count}} profili selezionati dalla stampante?"},toast:{profileSaved:"K-profile salvato",profilesSaved:"K-profile salvato su {{count}} estrusori",selectAtLeastOneExtruder:"Seleziona almeno un estrusore",profileDeleted:"K-profile eliminato",profilesDeleted:"Eliminati {{count}} profili",exportedProfiles:"Esportati {{count}} profili",importedProfiles:"Importati {{count}} di {{total}} profili",noProfilesToExport:"Nessun profilo da esportare",invalidFileFormat:"Formato file non valido",failedToParseImport:"Parsing file import fallito",failedToSaveBatch:"Salvataggio K-profiles fallito",noteSaved:"Nota salvata",failedToSaveNote:"Salvataggio nota fallito"},permission:{noRead:"Non hai il permesso di aggiornare i profili",noCreate:"Non hai il permesso di aggiungere profili",noUpdate:"Non hai il permesso di aggiornare K-profiles",noDelete:"Non hai il permesso di eliminare K-profiles",noExport:"Non hai il permesso di esportare profili",noImport:"Non hai il permesso di importare profili"}},virtualPrinter:{title:"Stampante virtuale",running:"In esecuzione",stopped:"Ferma",description:{default:"Abilita una stampante virtuale che appare in Bambu Studio e OrcaSlicer. I file inviati a questa stampante saranno archiviati senza stampare.",proxy:"Abilita un proxy che inoltra il traffico slicer a una stampante reale, permettendo la stampa remota su qualsiasi rete."},enable:{title:"Abilita stampante virtuale",visibleInSlicer:'Visibile come "Bambuddy" nella ricerca slicer',proxyingTo:"In proxy verso {{name}}",notActive:"Non attivo"},model:{title:"Modello stampante",description:"Seleziona il modello stampante da emulare.",restartWarning:"Cambiare il modello riavviera la stampante virtuale"},accessCode:{title:"Codice accesso",isSet:"Codice accesso impostato",notSet:"Nessun codice accesso impostato - richiesto per abilitare",placeholder:"Inserisci codice 8 caratteri",placeholderChange:"Inserisci nuovo codice per cambiare",hint:"Deve essere esattamente 8 caratteri. Usato dagli slicer per autenticarsi.",charCount:"({{count}}/8)"},targetPrinter:{title:"Stampante target",configured:"Target proxy configurato",notConfigured:"Nessuna stampante target selezionata - richiesta per modalita proxy",placeholder:"Seleziona una stampante...",hint:"Seleziona la stampante a cui fare proxy. La stampante deve essere in modalita LAN.",noPrinters:"Nessuna stampante configurata. Aggiungi una stampante per usare la modalita proxy."},remoteInterface:{title:"Sovrascrittura interfaccia di rete",configured:"Sovrascrittura interfaccia attiva",optional:"Opzionale - usare se l'IP rilevato automaticamente e sbagliato (es. piu NIC, Docker, VPN)",placeholder:"Rilevamento automatico (predefinito)...",hint:"Sovrascrive l'indirizzo IP pubblicizzato via SSDP e usato nel certificato TLS. Utile quando Bambuddy ha piu interfacce di rete."},mode:{title:"Modalita",archive:"Archivio",archiveDesc:"Archivia subito i file",review:"Revisione",reviewDesc:"Rivedi prima di archiviare",queue:"Coda",queueDesc:"Archivia e aggiungi alla coda",proxy:"Proxy",proxyDesc:"Inoltra a stampante reale"},setupRequired:{title:"Configurazione necessaria",description:"La stampante virtuale richiede configurazioni di sistema aggiuntive prima di funzionare. Include port forwarding, regole firewall e impostazioni specifiche della piattaforma.",readGuide:"Leggi la guida prima di abilitare"},howItWorks:{title:"Come funziona",titleProxy:"Come funziona (Modalita proxy)",step1:"Completa la guida di configurazione per la tua piattaforma",step2:"Abilita la stampante virtuale e imposta un codice accesso",step3:'In Bambu Studio o OrcaSlicer, vai su "Aggiungi stampante"',step4:'La stampante "Bambuddy" dovrebbe apparire nella lista',step5:"Connettiti usando il codice accesso impostato",step6:'Quando "stampi" su Bambuddy, il file 3MF viene archiviato',proxyStep1:"Seleziona la stampante target (deve essere in modalita LAN)",proxyStep2:"Per rete diversa: seleziona l'interfaccia rete slicer",proxyStep3:"Abilita il proxy - la stampante appare via SSDP",proxyStep4:"Connettiti usando il codice accesso della stampante",proxyStep5:"Stampa normalmente - il traffico è inoltrato via Bambuddy",proxyStep6:"Lo streaming della camera richiede NAT/IP forwarding (vedi docs)"},status:{title:"Dettagli stato",printerName:"Nome stampante",model:"Modello",serialNumber:"Numero seriale",mode:"Modalita",pendingFiles:"File in sospeso",targetPrinter:"Stampante target",ftpPort:"Porta FTP",mqttPort:"Porta MQTT",ftpConnections:"Connessioni FTP",mqttConnections:"Connessioni MQTT"},toast:{updated:"Impostazioni stampante virtuale aggiornate",failedToUpdate:"Aggiornamento impostazioni fallito",accessCodeRequired:"Imposta prima un codice accesso",targetPrinterRequired:"Seleziona prima una stampante target",accessCodeEmpty:"Il codice accesso non può essere vuoto",accessCodeLength:"Il codice accesso deve essere esattamente 8 caratteri"}},modelViewer:{openInSlicer:"Apri nello slicer",tabs:{model:"Modello 3D",gcode:"Anteprima G-code"},notAvailable:"non disponibile",notSliced:"non sezionato",plates:"Piatti",allPlates:"Tutti i piatti",plateNumber:"Piatto {{number}}",plateCount:"{{count}} piatto",plateCount_other:"{{count}} piatti",objectCount:"{{count}} oggetto",objectCount_other:"{{count}} oggetti",filamentCount:"{{count}} filamento",filamentCount_other:"{{count}} filamenti",eta:"ETA {{minutes}} min",noPreview:"Nessuna anteprima disponibile per questo file",pagination:{pageOf:"Pagina {{current}} di {{total}}",prev:"Prec",next:"Succ"},errors:{failedToLoad:"Caricamento file fallito",noMeshes:"Nessuna mesh trovata nel file 3MF",unsupportedFormat:"Formato file non supportato"}},maintenanceDescriptions:{lubricateRails:"Applica lubrificante alle guide lineari per un movimento fluido",cleanNozzle:"Pulisci hotend e ugello per prevenire intasamenti",checkBelts:"Verifica tensione cinghie per stampe accurate",cleanBuildPlate:"Pulisci il piatto per migliorare l'adesione",checkExtruder:"Ispeziona ingranaggi estrusore per usura",checkCooling:"Assicurati che le ventole di raffreddamento funzionino",generalInspection:"Ispezione generale stampante",cleanCarbonRods:"Pulisci le aste in carbonio per ridurre attrito",checkPtfeTube:"Ispeziona il tubo PTFE per usura o danni",replaceHepaFilter:"Sostituisci filtro HEPA per qualità aria",replaceCarbonFilter:"Sostituisci filtro a carbone attivo",lubricateLeftNozzleRail:"Lubrifica guida ugello sinistro (serie H2)"}},Eoe={en:{translation:Noe},de:{translation:koe},ja:{translation:Moe},it:{translation:Coe}};Fs.use(hW).use(noe).init({resources:Eoe,fallbackLng:"en",supportedLngs:["en","de","ja","it"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const qU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"},{code:"ja",name:"Japanese",nativeName:"日本語"},{code:"it",name:"Italian",nativeName:"Italiano"}];var WU="popstate";function Aoe(t={}){function e(r,i){let{pathname:s,search:o,hash:l}=r.location;return MP("",{pathname:s,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:Jy(i)}return joe(e,n,null,t)}function di(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function To(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Toe(){return Math.random().toString(36).substring(2,10)}function KU(t,e){return{usr:t.state,key:t.key,idx:e}}function MP(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Eb(e):e,state:n,key:e&&e.key||r||Toe()}}function Jy({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 Eb(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 joe(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!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 h(){l="POP";let b=d(),v=b==null?null:b-u;u=b,c&&c({action:l,location:y.location,delta:v})}function p(b,v){l="PUSH";let S=MP(y.location,b,v);u=d()+1;let k=KU(S,u),E=y.createHref(S);try{o.pushState(k,"",E)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;i.location.assign(E)}s&&c&&c({action:l,location:y.location,delta:1})}function m(b,v){l="REPLACE";let S=MP(y.location,b,v);u=d();let k=KU(S,u),E=y.createHref(S);o.replaceState(k,"",E),s&&c&&c({action:l,location:y.location,delta:0})}function x(b){return Poe(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(WU,h),c=b,()=>{i.removeEventListener(WU,h),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:p,replace:m,go(b){return o.go(b)}};return y}function Poe(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),di(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:Jy(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function fW(t,e,n="/"){return Doe(t,e,n,!1)}function Doe(t,e,n,r){let i=typeof e=="string"?Eb(e):e,s=Xu(i.pathname||"/",n);if(s==null)return null;let o=mW(t);Roe(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Goe(s);l=Hoe(o[c],u,r)}return l}function mW(t,e=[],n=[],r="",i=!1){let s=(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;di(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 h=Uu([r,d.relativePath]),p=n.concat(d);o.children&&o.children.length>0&&(di(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),mW(o.children,e,p,h,c)),!(o.path==null&&!o.index)&&e.push({path:h,score:Boe(h,o.index),routesMeta:p})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))s(o,l);else for(let c of pW(o.path))s(o,l,!0,c)}),e}function pW(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let o=pW(r.join("/")),l=[];return l.push(...o.map(c=>c===""?s:[s,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function Roe(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:$oe(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Loe=/^:[\w-]+$/,Ooe=3,Foe=2,Ioe=1,zoe=10,Uoe=-2,XU=t=>t==="*";function Boe(t,e){let n=t.split("/"),r=n.length;return n.some(XU)&&(r+=Uoe),e&&(r+=Foe),n.filter(i=>!XU(i)).reduce((i,s)=>i+(Loe.test(s)?Ooe:s===""?Ioe:zoe),r)}function $oe(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 Hoe(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=s==="/"?e:e.slice(s.length)||"/",h=o1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=o1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(i,h.params),o.push({params:i,pathname:Uu([s,h.pathname]),pathnameBase:Xoe(Uu([s,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(s=Uu([s,h.pathnameBase]))}return o}function o1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Voe(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],o=s.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:h},p)=>{if(d==="*"){let x=l[p]||"";o=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const m=l[p];return h&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:t}}function Voe(t,e=!1,n=!0){To(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 Goe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return To(!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 Xu(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 gW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qoe=t=>gW.test(t);function Woe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Eb(t):t,s;if(n)if(qoe(n))s=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),To(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?s=YU(n.substring(1),"/"):s=YU(n,e)}else s=e;return{pathname:s,search:Yoe(r),hash:Qoe(i)}}function YU(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 yE(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 Koe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function HR(t){let e=Koe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function VR(t,e,n,r=!1){let i;typeof t=="string"?i=Eb(t):(i={...t},di(!i.pathname||!i.pathname.includes("?"),yE("?","pathname","search",i)),di(!i.pathname||!i.pathname.includes("#"),yE("#","pathname","hash",i)),di(!i.search||!i.search.includes("#"),yE("#","search","hash",i)));let s=t===""||i.pathname==="",o=s?"/":i.pathname,l;if(o==null)l=n;else{let h=e.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),h-=1;i.pathname=p.join("/")}l=h>=0?e[h]:"/"}let c=Woe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Uu=t=>t.join("/").replace(/\/\/+/g,"/"),Xoe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Yoe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Qoe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Zoe=class{constructor(t,e,n,r=!1){this.status=t,this.statusText=e||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Joe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function ele(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var bW=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function xW(t,e){let n=t;if(typeof n!="string"||!gW.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(bW)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=Xu(o.pathname,e);o.origin===s.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{To(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var yW=["POST","PUT","PATCH","DELETE"];new Set(yW);var tle=["GET",...yW];new Set(tle);var Ab=w.createContext(null);Ab.displayName="DataRouter";var Sk=w.createContext(null);Sk.displayName="DataRouterState";var nle=w.createContext(!1),vW=w.createContext({isTransitioning:!1});vW.displayName="ViewTransition";var rle=w.createContext(new Map);rle.displayName="Fetchers";var ile=w.createContext(null);ile.displayName="Await";var Lo=w.createContext(null);Lo.displayName="Navigation";var G0=w.createContext(null);G0.displayName="Location";var _l=w.createContext({outlet:null,matches:[],isDataRoute:!1});_l.displayName="Route";var GR=w.createContext(null);GR.displayName="RouteError";var wW="REACT_ROUTER_ERROR",ale="REDIRECT",sle="ROUTE_ERROR_RESPONSE";function ole(t){if(t.startsWith(`${wW}:${ale}:{`))try{let e=JSON.parse(t.slice(28));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.location=="string"&&typeof e.reloadDocument=="boolean"&&typeof e.replace=="boolean")return e}catch{}}function lle(t){if(t.startsWith(`${wW}:${sle}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new Zoe(e.status,e.statusText,e.data)}catch{}}function cle(t,{relative:e}={}){di(Tb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(Lo),{hash:i,pathname:s,search:o}=q0(t,{relative:e}),l=s;return n!=="/"&&(l=s==="/"?n:Uu([n,s])),r.createHref({pathname:l,search:o,hash:i})}function Tb(){return w.useContext(G0)!=null}function zc(){return di(Tb(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(G0).location}var _W="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function SW(t){w.useContext(Lo).static||w.useLayoutEffect(t)}function Uc(){let{isDataRoute:t}=w.useContext(_l);return t?Nle():ule()}function ule(){di(Tb(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(Ab),{basename:e,navigator:n}=w.useContext(Lo),{matches:r}=w.useContext(_l),{pathname:i}=zc(),s=JSON.stringify(HR(r)),o=w.useRef(!1);return SW(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(To(o.current,_W),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=VR(c,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Uu([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var dle=w.createContext(null);function hle(t){let e=w.useContext(_l).outlet;return w.useMemo(()=>e&&w.createElement(dle.Provider,{value:t},e),[e,t])}function Nk(){let{matches:t}=w.useContext(_l),e=t[t.length-1];return e?e.params:{}}function q0(t,{relative:e}={}){let{matches:n}=w.useContext(_l),{pathname:r}=zc(),i=JSON.stringify(HR(n));return w.useMemo(()=>VR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function fle(t,e){return NW(t,e)}function NW(t,e,n,r,i){di(Tb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=w.useContext(Lo),{matches:o}=w.useContext(_l),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",h=l&&l.route;{let S=h&&h.path||"";MW(u,!h||S.endsWith("*")||S.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${S}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
  10. Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let p=zc(),m;if(e){let S=typeof e=="string"?Eb(e):e;di(d==="/"||S.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${S.pathname}" was given in the \`location\` prop.`),m=S}else m=p;let x=m.pathname||"/",y=x;if(d!=="/"){let S=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(S.length).join("/")}let b=fW(t,{pathname:y});To(h||b!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),To(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 "${m.pathname}${m.search}${m.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=xle(b&&b.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:Uu([d,s.encodeLocation?s.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:Uu([d,s.encodeLocation?s.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&v?w.createElement(G0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},v):v}function mle(){let t=Sle(),e=Joe(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},s={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:s},"ErrorBoundary")," or"," ",w.createElement("code",{style:s},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},e),n?w.createElement("pre",{style:i},n):null,o)}var ple=w.createElement(mle,null),kW=class extends w.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=lle(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(_l.Provider,{value:this.props.routeContext},w.createElement(GR.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(gle,{error:t},e):e}};kW.contextType=nle;var vE=new WeakMap;function gle({children:t,error:e}){let{basename:n}=w.useContext(Lo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=ole(e.digest);if(r){let i=vE.get(e);if(i)throw i;let s=xW(r.location,n);if(bW&&!vE.get(e))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw vE.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return t}function ble({routeContext:t,match:e,children:n}){let r=w.useContext(Ab);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(_l.Provider,{value:t},n)}function xle(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 s=t,o=n?.errors;if(o!=null){let d=s.findIndex(h=>h.route.id&&o?.[h.route.id]!==void 0);di(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),s=s.slice(0,Math.min(s.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<s.length;d++){let h=s[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(c=d),h.route.id){let{loaderData:p,errors:m}=n,x=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!m||m[h.route.id]===void 0);if(h.route.lazy||x){l=!0,c>=0?s=s.slice(0,c+1):s=[s[0]];break}}}let u=n&&r?(d,h)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:ele(n.matches),errorInfo:h})}:void 0;return s.reduceRight((d,h,p)=>{let m,x=!1,y=null,b=null;n&&(m=o&&h.route.id?o[h.route.id]:void 0,y=h.route.errorElement||ple,l&&(c<0&&p===0?(MW("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,b=null):c===p&&(x=!0,b=h.route.hydrateFallbackElement||null)));let v=e.concat(s.slice(0,p+1)),S=()=>{let k;return m?k=y:x?k=b:h.route.Component?k=w.createElement(h.route.Component,null):h.route.element?k=h.route.element:k=d,w.createElement(ble,{match:h,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:k})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?w.createElement(kW,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:S(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):S()},null)}function qR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yle(t){let e=w.useContext(Ab);return di(e,qR(t)),e}function vle(t){let e=w.useContext(Sk);return di(e,qR(t)),e}function wle(t){let e=w.useContext(_l);return di(e,qR(t)),e}function WR(t){let e=wle(t),n=e.matches[e.matches.length-1];return di(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function _le(){return WR("useRouteId")}function Sle(){let t=w.useContext(GR),e=vle("useRouteError"),n=WR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Nle(){let{router:t}=yle("useNavigate"),e=WR("useNavigate"),n=w.useRef(!1);return SW(()=>{n.current=!0}),w.useCallback(async(i,s={})=>{To(n.current,_W),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var QU={};function MW(t,e,n){!e&&!QU[t]&&(QU[t]=!0,To(!1,n))}w.memo(kle);function kle({routes:t,future:e,state:n,onError:r}){return NW(t,void 0,n,r,e)}function Xg({to:t,replace:e,state:n,relative:r}){di(Tb(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(Lo);To(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=w.useContext(_l),{pathname:o}=zc(),l=Uc(),c=VR(t,HR(s),o,r==="path"),u=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function Mle(t){return hle(t.context)}function Fi(t){di(!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 Cle({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1,unstable_useTransitions:o}){di(!Tb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:l,navigator:i,static:s,unstable_useTransitions:o,future:{}}),[l,i,s,o]);typeof n=="string"&&(n=Eb(n));let{pathname:u="/",search:d="",hash:h="",state:p=null,key:m="default"}=n,x=w.useMemo(()=>{let y=Xu(u,l);return y==null?null:{location:{pathname:y,search:d,hash:h,state:p,key:m},navigationType:r}},[l,u,d,h,p,m,r]);return To(x!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${h}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:w.createElement(Lo.Provider,{value:c},w.createElement(G0.Provider,{children:e,value:x}))}function Ele({children:t,location:e}){return fle(CP(t),e)}function CP(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let s=[...e,i];if(r.type===w.Fragment){n.push.apply(n,CP(r.props.children,s));return}di(r.type===Fi,`[${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>`),di(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||s.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=CP(r.props.children,s)),n.push(o)}),n}var TS="get",jS="application/x-www-form-urlencoded";function kk(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Ale(t){return kk(t)&&t.tagName.toLowerCase()==="button"}function Tle(t){return kk(t)&&t.tagName.toLowerCase()==="form"}function jle(t){return kk(t)&&t.tagName.toLowerCase()==="input"}function Ple(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Dle(t,e){return t.button===0&&(!e||e==="_self")&&!Ple(t)}function EP(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function Rle(t,e){let n=EP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(s=>{n.append(i,s)})}),n}var Ww=null;function Lle(){if(Ww===null)try{new FormData(document.createElement("form"),0),Ww=!1}catch{Ww=!0}return Ww}var Ole=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function wE(t){return t!=null&&!Ole.has(t)?(To(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${jS}"`),null):t}function Fle(t,e){let n,r,i,s,o;if(Tle(t)){let l=t.getAttribute("action");r=l?Xu(l,e):null,n=t.getAttribute("method")||TS,i=wE(t.getAttribute("enctype"))||jS,s=new FormData(t)}else if(Ale(t)||jle(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?Xu(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||TS,i=wE(t.getAttribute("formenctype"))||wE(l.getAttribute("enctype"))||jS,s=new FormData(l,t),!Lle()){let{name:u,type:d,value:h}=t;if(d==="image"){let p=u?`${u}.`:"";s.append(`${p}x`,"0"),s.append(`${p}y`,"0")}else u&&s.append(u,h)}}else{if(kk(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=TS,r=null,i=jS,o=t}return s&&i==="text/plain"&&(o=s,s=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:s,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function KR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Ile(t,e,n,r){let i=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname==="/"?i.pathname=`_root.${r}`:e&&Xu(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function zle(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 Ule(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 Ble(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let o=await zle(s,n);return o.links?o.links():[]}return[]}));return Gle(r.flat(1).filter(Ule).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function ZU(t,e,n,r,i,s){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 s==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):s==="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 h=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 h=="boolean")return h}return!0}):[]}function $le(t,e,{includeHydrateFallback:n}={}){return Hle(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let s=[i.module];return i.clientActionModule&&(s=s.concat(i.clientActionModule)),i.clientLoaderModule&&(s=s.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(s=s.concat(i.hydrateFallbackModule)),i.imports&&(s=s.concat(i.imports)),s}).flat(1))}function Hle(t){return[...new Set(t)]}function Vle(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Gle(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(Vle(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function CW(){let t=w.useContext(Ab);return KR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function qle(){let t=w.useContext(Sk);return KR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var XR=w.createContext(void 0);XR.displayName="FrameworkContext";function EW(){let t=w.useContext(XR);return KR(t,"You must render this element inside a <HydratedRouter> element"),t}function Wle(t,e){let n=w.useContext(XR),[r,i]=w.useState(!1),[s,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:h}=e,p=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=v=>{v.forEach(S=>{o(S.isIntersecting)})},b=new IntersectionObserver(y,{threshold:.5});return p.current&&b.observe(p.current),()=>{b.disconnect()}}},[t]),w.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[s,p,{}]:[s,p,{onFocus:$x(l,m),onBlur:$x(c,x),onMouseEnter:$x(u,m),onMouseLeave:$x(d,x),onTouchStart:$x(h,m)}]:[!1,p,{}]}function $x(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Kle({page:t,...e}){let{router:n}=CW(),r=w.useMemo(()=>fW(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(Yle,{page:t,matches:r,...e}):null}function Xle(t){let{manifest:e,routeModules:n}=EW(),[r,i]=w.useState([]);return w.useEffect(()=>{let s=!1;return Ble(t,e,n).then(o=>{s||i(o)}),()=>{s=!0}},[t,e,n]),r}function Yle({page:t,matches:e,...n}){let r=zc(),{future:i,manifest:s,routeModules:o}=EW(),{basename:l}=CW(),{loaderData:c,matches:u}=qle(),d=w.useMemo(()=>ZU(t,e,u,s,r,"data"),[t,e,u,s,r]),h=w.useMemo(()=>ZU(t,e,u,s,r,"assets"),[t,e,u,s,r]),p=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let y=new Set,b=!1;if(e.forEach(S=>{let k=s.routes[S.route.id];!k||!k.hasLoader||(!d.some(E=>E.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||k.hasClientLoader?b=!0:y.add(S.route.id))}),y.size===0)return[];let v=Ile(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return b&&y.size>0&&v.searchParams.set("_routes",e.filter(S=>y.has(S.route.id)).map(S=>S.route.id).join(",")),[v.pathname+v.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,s,d,e,t,o]),m=w.useMemo(()=>$le(h,s),[h,s]),x=Xle(h);return w.createElement(w.Fragment,null,p.map(y=>w.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),m.map(y=>w.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),x.map(({key:y,link:b})=>w.createElement("link",{key:y,nonce:n.nonce,...b})))}function Qle(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var Zle=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Zle&&(window.__reactRouterVersion="7.12.0")}catch{}function Jle({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=Aoe({window:r,v5Compat:!0}));let s=i.current,[o,l]=w.useState({action:s.action,location:s.location}),c=w.useCallback(u=>{n===!1?l(u):w.startTransition(()=>l(u))},[n]);return w.useLayoutEffect(()=>s.listen(c),[s,c]),w.createElement(Cle,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:s,unstable_useTransitions:n})}var AW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qs=w.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:p,...m},x){let{basename:y,unstable_useTransitions:b}=w.useContext(Lo),v=typeof u=="string"&&AW.test(u),S=xW(u,y);u=S.to;let k=cle(u,{relative:i}),[E,N,A]=Wle(r,m),M=nce(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:h,unstable_defaultShouldRevalidate:p,unstable_useTransitions:b});function P(j){e&&e(j),j.defaultPrevented||M(j)}let T=w.createElement("a",{...m,...A,href:S.absoluteURL||k,onClick:S.isExternal||s?e:P,ref:Qle(x,N),target:c,"data-discover":!v&&n==="render"?"true":void 0});return E&&!v?w.createElement(w.Fragment,null,T,w.createElement(Kle,{page:k})):T});qs.displayName="Link";var my=w.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:o,viewTransition:l,children:c,...u},d){let h=q0(o,{relative:u.relative}),p=zc(),m=w.useContext(Sk),{navigator:x,basename:y}=w.useContext(Lo),b=m!=null&&oce(h)&&l===!0,v=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,S=p.pathname,k=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(S=S.toLowerCase(),k=k?k.toLowerCase():null,v=v.toLowerCase()),k&&y&&(k=Xu(k,y)||k);const E=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let N=S===v||!i&&S.startsWith(v)&&S.charAt(E)==="/",A=k!=null&&(k===v||!i&&k.startsWith(v)&&k.charAt(v.length)==="/"),M={isActive:N,isPending:A,isTransitioning:b},P=N?e:void 0,T;typeof r=="function"?T=r(M):T=[r,N?"active":null,A?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let j=typeof s=="function"?s(M):s;return w.createElement(qs,{...u,"aria-current":P,className:T,ref:d,style:j,to:o,viewTransition:l},typeof c=="function"?c(M):c)});my.displayName="NavLink";var ece=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:o=TS,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:p,...m},x)=>{let{unstable_useTransitions:y}=w.useContext(Lo),b=ace(),v=sce(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",k=typeof l=="string"&&AW.test(l),E=N=>{if(c&&c(N),N.defaultPrevented)return;N.preventDefault();let A=N.nativeEvent.submitter,M=A?.getAttribute("formmethod")||o,P=()=>b(A||N.currentTarget,{fetcherKey:e,method:M,navigate:n,replace:i,state:s,relative:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:p});y&&n!==!1?w.startTransition(()=>P()):P()};return w.createElement("form",{ref:x,method:S,action:v,onSubmit:r?c:E,...m,"data-discover":!k&&t==="render"?"true":void 0})});ece.displayName="Form";function tce(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function TW(t){let e=w.useContext(Ab);return di(e,tce(t)),e}function nce(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=Uc(),d=zc(),h=q0(t,{relative:s});return w.useCallback(p=>{if(Dle(p,e)){p.preventDefault();let m=n!==void 0?n:Jy(d)===Jy(h),x=()=>u(t,{replace:m,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>x()):x()}},[d,u,h,n,r,e,t,i,s,o,l,c])}function YR(t){To(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=w.useRef(EP(t)),n=w.useRef(!1),r=zc(),i=w.useMemo(()=>Rle(r.search,n.current?null:e.current),[r.search]),s=Uc(),o=w.useCallback((l,c)=>{const u=EP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,s("?"+u,c)},[s,i]);return[i,o]}var rce=0,ice=()=>`__${String(++rce)}__`;function ace(){let{router:t}=TW("useSubmit"),{basename:e}=w.useContext(Lo),n=_le(),r=t.fetch,i=t.navigate;return w.useCallback(async(s,o={})=>{let{action:l,method:c,encType:u,formData:d,body:h}=Fle(s,e);if(o.navigate===!1){let p=o.fetcherKey||ice();await r(p,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:h,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await i(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:h,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,i,e,n])}function sce(t,{relative:e}={}){let{basename:n}=w.useContext(Lo),r=w.useContext(_l);di(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...q0(t||".",{relative:e})},o=zc();if(t==null){s.search=o.search;let l=new URLSearchParams(s.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let d=l.toString();s.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:Uu([n,s.pathname])),Jy(s)}function oce(t,{relative:e}={}){let n=w.useContext(vW);di(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=TW("useViewTransitionState"),i=q0(t,{relative:e});if(!n.isTransitioning)return!1;let s=Xu(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Xu(n.nextLocation.pathname,r)||n.nextLocation.pathname;return o1(i.pathname,o)!=null||o1(i.pathname,s)!=null}var Pu=nW();const lce=wl(Pu);var Vm=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(){}},cce={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},uce=class{#t=cce;#e=!1;setTimeoutProvider(t){this.#t=t}setTimeout(t,e){return this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},Xf=new uce;function dce(t){setTimeout(t,0)}var vm=typeof window>"u"||"Deno"in globalThis;function ds(){}function hce(t,e){return typeof t=="function"?t(e):t}function AP(t){return typeof t=="number"&&t>=0&&t!==1/0}function jW(t,e){return Math.max(t+(e||0)-Date.now(),0)}function wh(t,e){return typeof t=="function"?t(e):t}function el(t,e){return typeof t=="function"?t(e):t}function JU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==QR(o,e.options))return!1}else if(!e0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||s&&!s(e))}function eB(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(wm(e.options.mutationKey)!==wm(s))return!1}else if(!e0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function QR(t,e){return(e?.queryKeyHashFn||wm)(t)}function wm(t){return JSON.stringify(t,(e,n)=>TP(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function e0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>e0(t[n],e[n])):!1}var fce=Object.prototype.hasOwnProperty;function ZR(t,e){if(t===e)return t;const n=tB(t)&&tB(e);if(!n&&!(TP(t)&&TP(e)))return e;const i=(n?t:Object.keys(t)).length,s=n?e:Object.keys(e),o=s.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:s[u],h=t[d],p=e[d];if(h===p){l[d]=h,(n?u<i:fce.call(t,d))&&c++;continue}if(h===null||p===null||typeof h!="object"||typeof p!="object"){l[d]=p;continue}const m=ZR(h,p);l[d]=m,m===h&&c++}return i===o&&c===i?t:l}function t0(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 tB(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function TP(t){if(!nB(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!nB(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function nB(t){return Object.prototype.toString.call(t)==="[object Object]"}function mce(t){return new Promise(e=>{Xf.setTimeout(e,t)})}function jP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?ZR(t,e):e}function pce(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function gce(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var JR=Symbol();function PW(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===JR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function DW(t,e){return typeof t=="function"?t(...e):!!t}var bce=class extends Vm{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!vm&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},e4=new bce;function PP(){let t,e;const n=new Promise((i,s)=>{t=i,e=s});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 xce=dce;function yce(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=xce;const s=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)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var ji=yce(),vce=class extends Vm{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!vm&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#t}},l1=new vce;function wce(t){return Math.min(1e3*2**t,3e4)}function RW(t){return(t??"online")==="online"?l1.isOnline():!0}var DP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function LW(t){let e=!1,n=0,r;const i=PP(),s=()=>i.status!=="pending",o=y=>{if(!s()){const b=new DP(y);p(b),t.onCancel?.(b)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>e4.isFocused()&&(t.networkMode==="always"||l1.isOnline())&&t.canRun(),d=()=>RW(t.networkMode)&&t.canRun(),h=y=>{s()||(r?.(),i.resolve(y))},p=y=>{s()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=b=>{(s()||u())&&y(b)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),x=()=>{if(s())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(h).catch(v=>{if(s())return;const S=t.retry??(vm?0:3),k=t.retryDelay??wce,E=typeof k=="function"?k(n,v):k,N=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,v);if(e||!N){p(v);return}n++,t.onFail?.(n,v),mce(E).then(()=>u()?void 0:m()).then(()=>{e?p(v):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():m().then(x),i)}}var OW=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),AP(this.gcTime)&&(this.#t=Xf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(vm?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Xf.clearTimeout(this.#t),this.#t=void 0)}},_ce=class extends OW{#t;#e;#n;#i;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=iB(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=iB(this.options);e.data!==void 0&&(this.setState(rB(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=jP(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(ds).catch(ds):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>el(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===JR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>wh(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:!jW(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const l=PW(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(l,u,this):l(u)},o=(()=>{const l={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(o,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#s({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=LW({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof DP&&l.revert&&this.setState({...this.#e,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#s({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof DP){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#s({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...FW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...rB(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),ji.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function FW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:RW(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function rB(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function iB(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 t4=class extends Vm{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=PP(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#f;#d;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),aB(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return RP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return RP(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#w(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof el(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#_(),this.#e.setOptions(this.options),e._defaulted&&!t0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&sB(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||el(this.options.enabled,this.#e)!==el(e.enabled,this.#e)||wh(this.options.staleTime,this.#e)!==wh(e.staleTime,this.#e))&&this.#g();const i=this.#b();r&&(this.#e!==n||el(this.options.enabled,this.#e)!==el(e.enabled,this.#e)||i!==this.#l)&&this.#x(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return Nce(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#e.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#t.defaultQueryOptions(t),n=this.#t.getQueryCache().build(this.#t,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#m({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#m(t){this.#_();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(ds)),e}#g(){this.#v();const t=wh(this.options.staleTime,this.#e);if(vm||this.#i.isStale||!AP(t))return;const n=jW(this.#i.dataUpdatedAt,t)+1;this.#c=Xf.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#x(t){this.#w(),this.#l=t,!(vm||el(this.options.enabled,this.#e)===!1||!AP(this.#l)||this.#l===0)&&(this.#u=Xf.setInterval(()=>{(this.options.refetchIntervalInBackground||e4.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#x(this.#b())}#v(){this.#c&&(Xf.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Xf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,s=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},h=!1,p;if(e._optimisticResults){const P=this.hasListeners(),T=!P&&aB(t,e),j=P&&sB(t,n,e,r);(T||j)&&(d={...d,...FW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:x,status:y}=d;p=d.data;let b=!1;if(e.placeholderData!==void 0&&p===void 0&&y==="pending"){let P;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(P=i.data,b=!0):P=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,P!==void 0&&(y="success",p=jP(i?.data,P,e),h=!0)}if(e.select&&p!==void 0&&!b)if(i&&p===s?.data&&e.select===this.#f)p=this.#d;else try{this.#f=e.select,p=e.select(p),p=jP(i?.data,p,e),this.#d=p,this.#s=null}catch(P){this.#s=P}this.#s&&(m=this.#s,p=this.#d,x=Date.now(),y="error");const v=d.fetchStatus==="fetching",S=y==="pending",k=y==="error",E=S&&v,N=p!==void 0,M={status:y,fetchStatus:d.fetchStatus,isPending:S,isSuccess:y==="success",isError:k,isInitialLoading:E,isLoading:E,data:p,dataUpdatedAt:d.dataUpdatedAt,error:m,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&&!S,isLoadingError:k&&!N,isPaused:d.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:k&&N,isStale:n4(t,e),refetch:this.refetch,promise:this.#o,isEnabled:el(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const P=z=>{M.status==="error"?z.reject(M.error):M.data!==void 0&&z.resolve(M.data)},T=()=>{const z=this.#o=M.promise=PP();P(z)},j=this.#o;switch(j.status){case"pending":t.queryHash===n.queryHash&&P(j);break;case"fulfilled":(M.status==="error"||M.data!==j.value)&&T();break;case"rejected":(M.status!=="error"||M.error!==j.reason)&&T();break}}return M}updateResult(){const t=this.#i,e=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#a=this.options,this.#r.data!==void 0&&(this.#h=this.#e),t0(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.#p.size)return!0;const s=new Set(i??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&s.has(l)})};this.#S({listeners:n()})}#_(){const t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;const e=this.#e;this.#e=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){ji.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Sce(t,e){return el(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function aB(t,e){return Sce(t,e)||t.state.data!==void 0&&RP(t,e,e.refetchOnMount)}function RP(t,e,n){if(el(e.enabled,t)!==!1&&wh(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&n4(t,e)}return!1}function sB(t,e,n,r){return(t!==e||el(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&n4(t,n)}function n4(t,e){return el(e.enabled,t)!==!1&&t.isStaleByTime(wh(e.staleTime,t))}function Nce(t,e){return!t0(t.getCurrentResult(),e)}function oB(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const h=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},p=PW(e.options,e.fetchOptions),m=async(x,y,b)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const S=(()=>{const A={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return h(A),A})(),k=await p(S),{maxPages:E}=e.options,N=b?gce:pce;return{pages:N(x.pages,k,E),pageParams:N(x.pageParams,y,E)}};if(i&&s.length){const x=i==="backward",y=x?kce:lB,b={pages:s,pageParams:o},v=y(r,b);l=await m(b,v,x)}else{const x=t??s.length;do{const y=c===0?o[0]??r.initialPageParam:lB(r,l);if(c>0&&y==null)break;l=await m(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 lB(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 kce(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Mce=class extends OW{#t;#e;#n;#i;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#e=[],this.state=t.state||IW(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#r({type:"continue"})},n={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=LW({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,o)=>{this.#r({type:"failed",failureCount:s,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 s=await this.#i.start();return await this.#n.config.onSuccess?.(s,t,this.state.context,this,n),await this.options.onSuccess?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,t,this.state.context,n),this.#r({type:"success",data:s}),s}catch(s){try{throw await this.#n.config.onError?.(s,t,this.state.context,this,n),await this.options.onError?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,s,t,this.state.context,n),s}finally{this.#r({type:"error",error:s})}}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),ji.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function IW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Cce=class extends Vm{constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(t,e,n){const r=new Mce({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#t.add(t);const e=Kw(t);if(typeof e=="string"){const n=this.#e.get(e);n?n.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){const e=Kw(t);if(typeof e=="string"){const n=this.#e.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=Kw(t);if(typeof e=="string"){const r=this.#e.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=Kw(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ji.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>eB(e,n))}findAll(t={}){return this.getAll().filter(e=>eB(t,e))}notify(t){ji.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ji.batch(()=>Promise.all(t.map(e=>e.continue().catch(ds))))}};function Kw(t){return t.options.scope?.id}var Ece=class extends Vm{#t;#e=void 0;#n;#i;constructor(e,n){super(),this.#t=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#t.defaultMutationOptions(e),t0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&wm(n.mutationKey)!==wm(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#e}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#t.getMutationCache().build(this.#t,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??IW();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){ji.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context,i={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};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.#e)})})}};function cB(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function Ace(t,e,n){const r=t.slice(0);return r[e]=n,r}var Tce=class extends Vm{#t;#e;#n;#i;#r;#a;#o;#s;#f=[];constructor(t,e,n){super(),this.#t=t,this.#i=n,this.#n=[],this.#r=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#r.forEach(t=>{t.subscribe(e=>{this.#u(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#r.forEach(t=>{t.destroy()})}setQueries(t,e){this.#n=t,this.#i=e,ji.batch(()=>{const n=this.#r,r=this.#c(this.#n);this.#f=r,r.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=r.map(d=>d.observer),s=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,h)=>d!==n[h]),c=o||l,u=c?!0:s.some((d,h)=>{const p=this.#e[h];return!p||!t0(d,p)});!c&&!u||(c&&(this.#r=i),this.#e=s,this.hasListeners()&&(c&&(cB(n,i).forEach(d=>{d.destroy()}),cB(i,n).forEach(d=>{d.subscribe(h=>{this.#u(d,h)})})),this.#l()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#c(t),r=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions));return[r,i=>this.#h(i??r,e),()=>this.#d(r,n)]}#d(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,s=>{e.forEach(o=>{o.observer.trackProp(s)})})})}#h(t,e){return e?((!this.#a||this.#e!==this.#s||e!==this.#o)&&(this.#o=e,this.#s=this.#e,this.#a=ZR(this.#a,e(t))),this.#a):t}#c(t){const e=new Map;this.#r.forEach(r=>{const i=r.options.queryHash;if(!i)return;const s=e.get(i);s?s.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#t.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new t4(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=Ace(this.#e,n,e),this.#l())}#l(){if(this.hasListeners()){const t=this.#a,e=this.#d(this.#e,this.#f),n=this.#h(e,this.#i?.combine);t!==n&&ji.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},jce=class extends Vm{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??QR(r,e);let s=this.get(i);return s||(s=new _ce({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(s)),s}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ji.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>JU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>JU(t,n)):e}notify(t){ji.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ji.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ji.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Pce=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new jce,this.#e=t.mutationCache||new Cce,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=e4.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=l1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#t.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(wh(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),s=this.#t.get(r.queryHash)?.state.data,o=hce(e,s);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return ji.batch(()=>this.#t.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){const e=this.#t;ji.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return ji.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=ji.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(ds).catch(ds)}invalidateQueries(t,e={}){return ji.batch(()=>(this.#t.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=ji.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(ds)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(ds)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(wh(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ds).catch(ds)}fetchInfiniteQuery(t){return t.behavior=oB(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ds).catch(ds)}ensureInfiniteQueryData(t){return t.behavior=oB(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return l1.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(wm(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{e0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(wm(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{e0(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=QR(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===JR&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},zW=w.createContext(void 0),Zt=t=>{const e=w.useContext(zW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Dce=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),a.jsx(zW.Provider,{value:t,children:e})),UW=w.createContext(!1),BW=()=>w.useContext(UW);UW.Provider;function Rce(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Lce=w.createContext(Rce()),$W=()=>w.useContext(Lce),HW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},VW=t=>{w.useEffect(()=>{t.clearReset()},[t])},GW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||DW(n,[t.error,r])),qW=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))}},WW=(t,e)=>t.isLoading&&t.isFetching&&!e,LP=(t,e)=>t?.suspense&&e.isPending,c1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function r4({queries:t,...e},n){const r=Zt(),i=BW(),s=$W(),o=w.useMemo(()=>t.map(y=>{const b=r.defaultQueryOptions(y);return b._optimisticResults=i?"isRestoring":"optimistic",b}),[t,r,i]);o.forEach(y=>{qW(y),HW(y,s)}),VW(s);const[l]=w.useState(()=>new Tce(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),h=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(y=>h?l.subscribe(ji.batchCalls(y)):ds,[l,h]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const m=c.some((y,b)=>LP(o[b],y))?c.flatMap((y,b)=>{const v=o[b];if(v){const S=new t4(r,v);if(LP(v,y))return c1(v,S,s);WW(y,i)&&c1(v,S,s)}return[]}):[];if(m.length>0)throw Promise.all(m);const x=c.find((y,b)=>{const v=o[b];return v&&GW({result:y,errorResetBoundary:s,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(x?.error)throw x.error;return u(d())}function Oce(t,e,n){const r=BW(),i=$W(),s=Zt(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",qW(o),HW(o,i),VW(i);const l=!s.getQueryCache().get(o.queryHash),[c]=w.useState(()=>new e(s,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(h=>{const p=d?c.subscribe(ji.batchCalls(h)):ds;return c.updateResult(),p},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),w.useEffect(()=>{c.setOptions(o)},[o,c]),LP(o,u))throw c1(o,c,i);if(GW({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!vm&&WW(u,r)&&(l?c1(o,c,i):s.getQueryCache().get(o.queryHash)?.promise)?.catch(ds).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function et(t,e){return Oce(t,t4)}function st(t,e){const n=Zt(),[r]=w.useState(()=>new Ece(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(ji.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=w.useCallback((o,l)=>{r.mutate(o,l).catch(ds)},[r]);if(i.error&&DW(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const Fce=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ice=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),uB=t=>{const e=Ice(t);return e.charAt(0).toUpperCase()+e.slice(1)},KW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zce=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Uce={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 Bce=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},c)=>w.createElement("svg",{ref:c,...Uce,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:KW("lucide",i),...!s&&!zce(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(s)?s:[s]]));const Ye=(t,e)=>{const n=w.forwardRef(({className:r,...i},s)=>w.createElement(Bce,{ref:s,iconNode:e,className:KW(`lucide-${Fce(uB(t))}`,`lucide-${t}`,r),...i}));return n.displayName=uB(t),n};const $ce=[["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"}]],Hce=Ye("air-vent",$ce);const Vce=[["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"}]],As=Ye("archive",Vce);const Gce=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],qce=Ye("arrow-down-wide-narrow",Gce);const Wce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Yg=Ye("arrow-down",Wce);const Kce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Xce=Ye("arrow-left",Kce);const Yce=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],dB=Ye("arrow-right-left",Yce);const Qce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],OP=Ye("arrow-right",Qce);const Zce=[["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"}]],i4=Ye("arrow-up-down",Zce);const Jce=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],eue=Ye("arrow-up-narrow-wide",Jce);const tue=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],_m=Ye("arrow-up",tue);const nue=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],rue=Ye("beaker",nue);const iue=[["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"}]],Dg=Ye("bell",iue);const aue=[["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"}]],sue=Ye("bold",aue);const oue=[["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"}]],lue=Ye("book",oue);const cue=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],uue=Ye("bookmark",cue);const due=[["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"}]],Yi=Ye("box",due);const hue=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],XW=Ye("briefcase",hue);const fue=[["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"}]],Mk=Ye("bug",fue);const mue=[["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"}]],pue=Ye("cable",mue);const gue=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],bue=Ye("calculator",gue);const xue=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],yue=Ye("calendar-days",xue);const vue=[["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"}]],ri=Ye("calendar",vue);const wue=[["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"}]],Qg=Ye("camera",wue);const _ue=[["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"}]],Sue=Ye("chart-column",_ue);const Nue=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Kr=Ye("check",Nue);const kue=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],tr=Ye("chevron-down",kue);const Mue=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],La=Ye("chevron-right",Mue);const Cue=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Tc=Ye("chevron-left",Cue);const Eue=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Kl=Ye("chevron-up",Eue);const Aue=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],YW=Ye("chevrons-left",Aue);const Tue=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],QW=Ye("chevrons-right",Tue);const jue=[["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"}]],Ui=Ye("circle-alert",jue);const Pue=[["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"}]],_E=Ye("circle-arrow-up",Pue);const Due=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],mr=Ye("circle-check-big",Due);const Rue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Zg=Ye("circle-check",Rue);const Lue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Oue=Ye("circle-dot",Lue);const Fue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Iue=Ye("circle-stop",Fue);const zue=[["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"}]],ua=Ye("circle-x",zue);const Uue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],FP=Ye("circle",Uue);const Bue=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],qn=Ye("clock",Bue);const $ue=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]],Hue=Ye("cloud-off",$ue);const Vue=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],jb=Ye("cloud",Vue);const Gue=[["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"}]],que=Ye("code-xml",Gue);const Wue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],ZW=Ye("code",Wue);const Kue=[["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"}]],Xue=Ye("coffee",Kue);const Yue=[["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"}]],Que=Ye("cog",Yue);const Zue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Jue=Ye("columns-2",Zue);const ede=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],tde=Ye("compass",ede);const nde=[["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"}]],Xl=Ye("copy",nde);const rde=[["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"}]],Xw=Ye("cpu",rde);const ide=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],ade=Ye("cylinder",ide);const sde=[["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"}]],kc=Ye("database",sde);const ode=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],IP=Ye("dollar-sign",ode);const lde=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],hi=Ye("download",lde);const cde=[["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"}]],Ck=Ye("droplet",cde);const ude=[["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"}]],a4=Ye("droplets",ude);const dde=[["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"}]],_h=Ye("ellipsis-vertical",dde);const hde=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],SE=Ye("equal",hde);const fde=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Wr=Ye("external-link",fde);const mde=[["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"}]],W0=Ye("eye-off",mde);const pde=[["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"}]],Yl=Ye("eye",pde);const gde=[["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"}]],JW=Ye("fan",gde);const bde=[["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"}]],am=Ye("file-box",bde);const xde=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],u1=Ye("file-code",xde);const yde=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],vde=Ye("file-exclamation-point",yde);const wde=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],d1=Ye("file-spreadsheet",wde);const _de=[["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"}]],Ms=Ye("file-text",_de);const Sde=[["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"}]],Ek=Ye("file",Sde);const Nde=[["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"}]],Sh=Ye("film",Nde);const kde=[["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"}]],Mde=Ye("flame",kde);const Cde=[["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"}]],ps=Ye("folder-kanban",Cde);const Ede=[["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"}]],Ql=Ye("folder-open",Ede);const Ade=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Tde=Ye("folder-plus",Ade);const jde=[["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"}]],Pde=Ye("folder-tree",jde);const Dde=[["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"}]],eK=Ye("folder",Dde);const Rde=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],Lde=Ye("fullscreen",Rde);const Ode=[["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"}]],Ak=Ye("funnel",Ode);const Fde=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Tk=Ye("gauge",Fde);const Ide=[["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"}]],zde=Ye("gift",Ide);const Ude=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],Rg=Ye("git-compare",Ude);const Bde=[["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"}]],zP=Ye("github",Bde);const $de=[["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"}]],Nh=Ye("globe",$de);const Hde=[["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"}]],kh=Ye("grip-vertical",Hde);const Vde=[["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"}]],tK=Ye("hand",Vde);const Gde=[["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"}]],Pb=Ye("hard-drive",Gde);const qde=[["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"}]],Wde=Ye("hash",qde);const Kde=[["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"}]],Xde=Ye("headphones",Kde);const Yde=[["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"}]],Qde=Ye("heart",Yde);const Zde=[["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"}]],n0=Ye("history",Zde);const Jde=[["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"}]],K0=Ye("house",Jde);const ehe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Yu=Ye("image",ehe);const the=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Xs=Ye("info",the);const nhe=[["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"}]],rhe=Ye("italic",nhe);const ihe=[["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"}]],tl=Ye("key",ihe);const ahe=[["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"}]],UP=Ye("keyboard",ahe);const she=[["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"}]],Ja=Ye("layers",she);const ohe=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],X0=Ye("layout-grid",ohe);const lhe=[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],che=Ye("link-2-off",lhe);const uhe=[["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"}]],Mh=Ye("link-2",uhe);const dhe=[["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"}]],Db=Ye("link",dhe);const hhe=[["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"}]],nK=Ye("list-ordered",hhe);const fhe=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],BP=Ye("list-todo",fhe);const mhe=[["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"}]],jk=Ye("list",mhe);const phe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],it=Ye("loader-circle",phe);const ghe=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],PS=Ye("lock-open",ghe);const bhe=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Lf=Ye("lock",bhe);const xhe=[["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"}]],hB=Ye("log-in",xhe);const yhe=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],$P=Ye("log-out",yhe);const vhe=[["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"}]],r0=Ye("mail",vhe);const whe=[["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"}]],_he=Ye("map",whe);const She=[["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"}]],s4=Ye("maximize-2",She);const Nhe=[["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"}]],khe=Ye("maximize",Nhe);const Mhe=[["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"}]],Che=Ye("memory-stick",Mhe);const Ehe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Ahe=Ye("menu",Ehe);const The=[["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"}]],o4=Ye("minimize-2",The);const jhe=[["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"}]],rK=Ye("minimize",jhe);const Phe=[["path",{d:"M5 12h14",key:"1ays0h"}]],HP=Ye("minus",Phe);const Dhe=[["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"}]],Rhe=Ye("monitor",Dhe);const Lhe=[["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"}]],h1=Ye("moon",Lhe);const Ohe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Fhe=Ye("move-right",Ohe);const Ihe=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],VP=Ye("music",Ihe);const zhe=[["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"}]],ta=Ye("package",zhe);const Uhe=[["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"}]],Pk=Ye("palette",Uhe);const Bhe=[["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"}]],Dk=Ye("pause",Bhe);const $he=[["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"}]],Sm=Ye("pen-line",$he);const Hhe=[["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"}]],Yf=Ye("pen",Hhe);const Vhe=[["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"}]],$i=Ye("pencil",Vhe);const Ghe=[["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"}]],qhe=Ye("phone",Ghe);const Whe=[["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"}]],jo=Ye("play",Whe);const Khe=[["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"}]],dl=Ye("plug",Khe);const Xhe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],nr=Ye("plus",Xhe);const Yhe=[["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"}]],Rk=Ye("power-off",Yhe);const Qhe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],cd=Ye("power",Qhe);const Zhe=[["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"}]],Nr=Ye("printer",Zhe);const Jhe=[["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"}]],iK=Ye("qr-code",Jhe);const efe=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],l4=Ye("radio",efe);const tfe=[["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"}]],Ir=Ye("refresh-cw",tfe);const nfe=[["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"}]],Po=Ye("rotate-ccw",nfe);const rfe=[["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"}]],ife=Ye("ruler",rfe);const afe=[["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"}]],fs=Ye("save",afe);const sfe=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]],ofe=Ye("scale",sfe);const lfe=[["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"}]],f1=Ye("scan-search",lfe);const cfe=[["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"}]],ufe=Ye("scissors",cfe);const dfe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],zr=Ye("search",dfe);const hfe=[["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"}]],Lk=Ye("send",hfe);const ffe=[["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"}]],Of=Ye("server",ffe);const mfe=[["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"}]],Qu=Ye("settings-2",mfe);const pfe=[["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"}]],Ok=Ye("settings",pfe);const gfe=[["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"}]],NE=Ye("shield",gfe);const bfe=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],aK=Ye("shopping-cart",bfe);const xfe=[["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"}]],yfe=Ye("signal",xfe);const vfe=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],wfe=Ye("skip-back",vfe);const _fe=[["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"}]],c4=Ye("skip-forward",_fe);const Sfe=[["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"}]],fB=Ye("sliders-vertical",Sfe);const Nfe=[["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"}]],Jg=Ye("sparkles",Nfe);const kfe=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],to=Ye("square-check-big",kfe);const Mfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Cfe=Ye("square-minus",Mfe);const Efe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],pl=Ye("square",Efe);const Afe=[["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"}]],Nm=Ye("star",Afe);const Tfe=[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]],sK=Ye("sticky-note",Tfe);const jfe=[["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"}]],mB=Ye("sun",jfe);const Pfe=[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],Dfe=Ye("table-properties",Pfe);const Rfe=[["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"}]],Fh=Ye("tag",Rfe);const Lfe=[["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"}]],oK=Ye("target",Lfe);const Ofe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],lK=Ye("terminal",Ofe);const Ffe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ife=Ye("text-align-center",Ffe);const zfe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Ufe=Ye("text-align-end",zfe);const Bfe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],$fe=Ye("text-align-start",Bfe);const Hfe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Fk=Ye("thermometer",Hfe);const Vfe=[["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"}]],Du=Ye("timer",Vfe);const Gfe=[["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"}]],en=Ye("trash-2",Gfe);const qfe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],u4=Ye("trending-down",qfe);const Wfe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],GP=Ye("trending-up",Wfe);const Kfe=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],kn=Ye("triangle-alert",Kfe);const Xfe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Yfe=Ye("underline",Xfe);const Qfe=[["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"}]],Ik=Ye("unlink",Qfe);const Zfe=[["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"}]],ia=Ye("upload",Zfe);const Jfe=[["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"}]],Zu=Ye("user",Jfe);const eme=[["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"}]],uh=Ye("users",eme);const tme=[["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"}]],d4=Ye("video",tme);const nme=[["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"}]],rme=Ye("volume-2",nme);const ime=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],ame=Ye("volume-x",ime);const sme=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],ome=Ye("wand-sparkles",sme);const lme=[["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"}]],km=Ye("wifi-off",lme);const cme=[["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"}]],Lg=Ye("wifi",cme);const ume=[["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"}]],cK=Ye("wind",ume);const dme=[["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"}]],Mm=Ye("wrench",dme);const hme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Rt=Ye("x",hme);const fme=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],h4=Ye("zoom-in",fme);const mme=[["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"}]],Ih=Ye("zap",mme);const pme=[["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"}]],f4=Ye("zoom-out",pme),ln="/api/v1";let sn=localStorage.getItem("auth_token");function py(t){sn=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Ju(){return sn}function Ff(t){if(!t)return null;const e=t.match(/filename\*=(?:UTF-8|utf-8)''(.+?)(?:;|$)/);if(e)try{return decodeURIComponent(e[1])}catch{}return t.match(/filename="?([^";\n]+)"?/)?.[1]||null}async function Te(t,e={}){const n={"Content-Type":"application/json",...e.headers};sn&&(n.Authorization=`Bearer ${sn}`);const r=await fetch(`${ln}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){const o=(await r.json().catch(()=>({}))).detail,l=typeof o=="string"?o:o?JSON.stringify(o):`HTTP ${r.status}`;throw r.status===401&&["Could not validate credentials","Token has expired","User not found or inactive","Invalid API key","API key has expired"].some(u=>l.includes(u))&&py(null),new Error(l)}const i=r.headers.get("content-length");if(!(r.status===204||i==="0"))return await r.json()}const ae={getAuthStatus:()=>Te("/auth/status"),setupAuth:t=>Te("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Te("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Te("/auth/logout",{method:"POST"}),getCurrentUser:()=>Te("/auth/me"),disableAuth:()=>Te("/auth/disable",{method:"POST"}),testSMTP:t=>Te("/auth/smtp/test",{method:"POST",body:JSON.stringify(t)}),getSMTPSettings:()=>Te("/auth/smtp"),saveSMTPSettings:t=>Te("/auth/smtp",{method:"POST",body:JSON.stringify(t)}),enableAdvancedAuth:()=>Te("/auth/advanced-auth/enable",{method:"POST"}),disableAdvancedAuth:()=>Te("/auth/advanced-auth/disable",{method:"POST"}),getAdvancedAuthStatus:()=>Te("/auth/advanced-auth/status"),forgotPassword:t=>Te("/auth/forgot-password",{method:"POST",body:JSON.stringify(t)}),resetUserPassword:t=>Te("/auth/reset-password",{method:"POST",body:JSON.stringify(t)}),getUsers:()=>Te("/users/"),getUser:t=>Te(`/users/${t}`),createUser:t=>Te("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Te(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:(t,e=!1)=>Te(`/users/${t}?delete_items=${e}`,{method:"DELETE"}),getUserItemsCount:t=>Te(`/users/${t}/items-count`),changePassword:(t,e)=>Te("/users/me/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:e})}),getPermissions:()=>Te("/groups/permissions"),getGroups:()=>Te("/groups/"),getGroup:t=>Te(`/groups/${t}`),createGroup:t=>Te("/groups/",{method:"POST",body:JSON.stringify(t)}),updateGroup:(t,e)=>Te(`/groups/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteGroup:t=>Te(`/groups/${t}`,{method:"DELETE"}),addUserToGroup:(t,e)=>Te(`/groups/${t}/users/${e}`,{method:"POST"}),removeUserFromGroup:(t,e)=>Te(`/groups/${t}/users/${e}`,{method:"DELETE"}),getPrinters:()=>Te("/printers/"),getPrinter:t=>Te(`/printers/${t}`),createPrinter:t=>Te("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Te(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Te(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Te(`/printers/${t}/status`),refreshPrinterStatus:t=>Te(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Te(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Te(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Te(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Te(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Te(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Te(`/printers/${t}/print/resume`,{method:"POST"}),clearPlate:t=>Te(`/printers/${t}/clear-plate`,{method:"POST"}),getCurrentPrintUser:t=>Te(`/printers/${t}/current-print-user`),setChamberLight:(t,e)=>Te(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Te(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Te(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Te(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Te(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Te(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Te(`/printers/${t}/logging`),clearMQTTLogs:t=>Te(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Te(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${ln}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,getPrinterFileGcodeUrl:(t,e)=>`${ln}/printers/${t}/files/gcode?path=${encodeURIComponent(e)}`,getPrinterFilePlates:(t,e)=>Te(`/printers/${t}/files/plates?path=${encodeURIComponent(e)}`),getPrinterFilePlateThumbnail:(t,e,n)=>`${ln}/printers/${t}/files/plate-thumbnail/${e}?path=${encodeURIComponent(n)}`,downloadPrinterFile:async(t,e)=>{const n={};sn&&(n.Authorization=`Bearer ${sn}`);const r=await fetch(`${ln}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,{headers:n});if(!r.ok){const u=await r.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Ff(i)||e.split("/").pop()||"download",o=await r.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},downloadPrinterFilesAsZip:async(t,e)=>{const n={"Content-Type":"application/json"};sn&&(n.Authorization=`Bearer ${sn}`);const r=await fetch(`${ln}/printers/${t}/files/download-zip`,{method:"POST",headers:n,body:JSON.stringify({paths:e})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.blob()},deletePrinterFile:(t,e)=>Te(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Te(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),Te(`/archives/?${i}`)},getArchive:t=>Te(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),Te(`/archives/search?${n}`)},rebuildSearchIndex:()=>Te("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Te(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Te(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Te(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Te("/archives/stats"),getTags:()=>Te("/archives/tags"),renameTag:(t,e)=>Te(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>Te(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>Te("/archives/recalculate-costs",{method:"POST"}),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),Te(`/archives/analysis/failures?${e}`)},compareArchives:t=>Te(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Te(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n={};sn&&(n.Authorization=`Bearer ${sn}`);const r=await fetch(`${ln}/archives/export?${e}`,{headers:n});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition");let s=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(s=l[1])}return{blob:await r.blob(),filename:s}},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={};sn&&(n.Authorization=`Bearer ${sn}`);const r=await fetch(`${ln}/archives/stats/export?${e}`,{headers:n});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition");let s=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(s=l[1])}return{blob:await r.blob(),filename:s}},getArchiveDuplicates:t=>Te(`/archives/${t}/duplicates`),backfillContentHashes:()=>Te("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${ln}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${ln}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${ln}/archives/${t}/download`,downloadArchive:async(t,e)=>{const n={};sn&&(n.Authorization=`Bearer ${sn}`);const r=await fetch(`${ln}/archives/${t}/download`,{headers:n});if(!r.ok){const u=await r.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Ff(i)||e||`archive_${t}.3mf`,o=await r.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},getArchiveGcode:t=>`${ln}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${ln}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${ln}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Te(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Te(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};sn&&(r.Authorization=`Bearer ${sn}`);const i=await fetch(`${ln}/archives/${t}/timelapse/upload`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getTimelapseInfo:t=>Te(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Te(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i={};sn&&(i.Authorization=`Bearer ${sn}`);const s=await fetch(`${ln}/archives/${t}/timelapse/process`,{method:"POST",headers:i,body:r});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},getArchivePhotoUrl:(t,e)=>`${ln}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};sn&&(r.Authorization=`Bearer ${sn}`);const i=await fetch(`${ln}/archives/${t}/photos`,{headers:r,method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteArchivePhoto:(t,e)=>Te(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${ln}/archives/${t}/source`,downloadSource3mf:async t=>{const e={};sn&&(e.Authorization=`Bearer ${sn}`);const n=await fetch(`${ln}/archives/${t}/source`,{headers:e});if(!n.ok){const c=await n.json().catch(()=>({}));throw new Error(c.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition"),i=Ff(r)||`source_${t}.3mf`,s=await n.blob(),o=window.URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=i,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.URL.revokeObjectURL(o)},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={};sn&&(r.Authorization=`Bearer ${sn}`);const i=await fetch(`${ln}/archives/${t}/source`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteSource3mf:t=>Te(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${ln}/archives/${t}/f3d`,downloadF3d:async t=>{const e={};sn&&(e.Authorization=`Bearer ${sn}`);const n=await fetch(`${ln}/archives/${t}/f3d`,{headers:e});if(!n.ok){const c=await n.json().catch(()=>({}));throw new Error(c.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition"),i=Ff(r)||`archive_${t}.f3d`,s=await n.blob(),o=window.URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=i,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.URL.revokeObjectURL(o)},uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};sn&&(r.Authorization=`Bearer ${sn}`);const i=await fetch(`${ln}/archives/${t}/f3d`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteF3d:t=>Te(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${ln}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Te(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Te(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Te(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${ln}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${ln}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Te(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Te(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Te(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${ln}/archives/upload?printer_id=${e}`:`${ln}/archives/upload`,i={};sn&&(i.Authorization=`Bearer ${sn}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(o=>n.append("files",o));const r=e?`${ln}/archives/upload-bulk?printer_id=${e}`:`${ln}/archives/upload-bulk`,i={};sn&&(i.Authorization=`Bearer ${sn}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},getSettings:()=>Te("/settings/"),updateSettings:t=>Te("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Te("/settings/mqtt/status"),resetSettings:()=>Te("/settings/reset",{method:"POST"}),exportBackup:async()=>{const t=`${ln}/settings/backup`,e={};sn&&(e.Authorization=`Bearer ${sn}`);const n=await fetch(t,{headers:e});if(!n.ok){const o=await n.text();throw new Error(o||`Backup failed with status ${n.status}`)}const r=n.headers.get("Content-Disposition");let i="bambuddy-backup.zip";if(r){const o=r.match(/filename=([^;]+)/);o&&(i=o[1].trim())}return{blob:await n.blob(),filename:i}},importBackup:async t=>{const e=new FormData;e.append("file",t);const n=`${ln}/settings/restore`,r={};return sn&&(r.Authorization=`Bearer ${sn}`),(await fetch(n,{method:"POST",headers:r,body:e})).json()},checkFfmpeg:()=>Te("/settings/check-ffmpeg"),getNetworkInterfaces:()=>Te("/settings/network-interfaces"),getCloudStatus:()=>Te("/cloud/status"),cloudLogin:(t,e,n="global")=>Te("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e,n)=>Te("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e,tfa_key:n})}),cloudSetToken:t=>Te("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Te("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Te(`/cloud/settings?version=${t}`),getBuiltinFilaments:()=>Te("/cloud/builtin-filaments"),getCloudSettingDetail:t=>Te(`/cloud/settings/${t}`),createCloudSetting:t=>Te("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Te(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Te(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Te("/cloud/devices"),getCloudFields:t=>Te(`/cloud/fields/${t}`),getAllCloudFields:()=>Te("/cloud/fields"),getFilamentInfo:t=>Te("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Te("/smart-plugs/"),getSmartPlug:t=>Te(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Te(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>Te(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>Te("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Te(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Te(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Te(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Te(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Te("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>Te("/smart-plugs/discover/scan",{method:"POST"}),getTasmotaScanStatus:()=>Te("/smart-plugs/discover/status"),stopTasmotaScan:()=>Te("/smart-plugs/discover/stop",{method:"POST"}),getDiscoveredTasmotaDevices:()=>Te("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Te("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Te(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Te("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Te(`/queue/?${n}`)},getQueueItem:t=>Te(`/queue/${t}`),addToQueue:t=>Te("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Te(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Te(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Te("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Te(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Te(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Te(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Te("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Te(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Te(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Te(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Te(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Te(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Te(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Te(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Te(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Te(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i,s="cloud")=>Te(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}&preset_source=${encodeURIComponent(s)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Te(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),Te(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Te(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Te("/filaments/"),getFilament:t=>Te(`/filaments/${t}`),getFilamentsByType:t=>Te(`/filaments/by-type/${t}`),getNotificationProviders:()=>Te("/notifications/"),getNotificationProvider:t=>Te(`/notifications/${t}`),createNotificationProvider:t=>Te("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Te(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Te(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Te(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Te("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Te("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Te("/notification-templates"),getNotificationTemplate:t=>Te(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Te(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Te(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Te("/notification-templates/variables"),previewTemplate:t=>Te("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),Te(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Te(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Te(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Te("/spoolman/status"),connectSpoolman:()=>Te("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Te("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Te(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Te("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Te("/spoolman/spools"),getSpoolmanFilaments:()=>Te("/spoolman/filaments"),getUnlinkedSpools:()=>Te("/spoolman/spools/unlinked"),getLinkedSpools:()=>Te("/spoolman/spools/linked"),linkSpool:(t,e)=>Te(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getSpoolmanSettings:()=>Te("/settings/spoolman"),updateSpoolmanSettings:t=>Te("/settings/spoolman",{method:"PUT",body:JSON.stringify(t)}),getSpools:(t=!1)=>Te(`/inventory/spools?include_archived=${t}`),getSpool:t=>Te(`/inventory/spools/${t}`),createSpool:t=>Te("/inventory/spools",{method:"POST",body:JSON.stringify(t)}),updateSpool:(t,e)=>Te(`/inventory/spools/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSpool:t=>Te(`/inventory/spools/${t}`,{method:"DELETE"}),archiveSpool:t=>Te(`/inventory/spools/${t}/archive`,{method:"POST"}),restoreSpool:t=>Te(`/inventory/spools/${t}/restore`,{method:"POST"}),getSpoolKProfiles:t=>Te(`/inventory/spools/${t}/k-profiles`),saveSpoolKProfiles:(t,e)=>Te(`/inventory/spools/${t}/k-profiles`,{method:"PUT",body:JSON.stringify(e)}),getAssignments:t=>Te(`/inventory/assignments${t?`?printer_id=${t}`:""}`),assignSpool:t=>Te("/inventory/assignments",{method:"POST",body:JSON.stringify(t)}),unassignSpool:(t,e,n)=>Te(`/inventory/assignments/${t}/${e}/${n}`,{method:"DELETE"}),getSpoolCatalog:()=>Te("/inventory/catalog"),addCatalogEntry:t=>Te("/inventory/catalog",{method:"POST",body:JSON.stringify(t)}),updateCatalogEntry:(t,e)=>Te(`/inventory/catalog/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCatalogEntry:t=>Te(`/inventory/catalog/${t}`,{method:"DELETE"}),resetSpoolCatalog:()=>Te("/inventory/catalog/reset",{method:"POST"}),getColorCatalog:()=>Te("/inventory/colors"),addColorEntry:t=>Te("/inventory/colors",{method:"POST",body:JSON.stringify(t)}),updateColorEntry:(t,e)=>Te(`/inventory/colors/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteColorEntry:t=>Te(`/inventory/colors/${t}`,{method:"DELETE"}),resetColorCatalog:()=>Te("/inventory/colors/reset",{method:"POST"}),lookupColor:(t,e,n)=>Te(`/inventory/colors/lookup?manufacturer=${encodeURIComponent(t)}&color_name=${encodeURIComponent(e)}${n?`&material=${encodeURIComponent(n)}`:""}`),linkTagToSpool:(t,e)=>Te(`/inventory/spools/${t}/link-tag`,{method:"PATCH",body:JSON.stringify(e)}),getSpoolUsageHistory:(t,e=50)=>Te(`/inventory/spools/${t}/usage?limit=${e}`),getAllUsageHistory:(t=100,e)=>Te(`/inventory/usage?limit=${t}${e?`&printer_id=${e}`:""}`),clearSpoolUsageHistory:t=>Te(`/inventory/spools/${t}/usage`,{method:"DELETE"}),getFilamentPresets:()=>Te("/cloud/filaments"),getVersion:()=>Te("/updates/version"),checkForUpdates:()=>Te("/updates/check"),applyUpdate:()=>Te("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Te("/updates/status"),getMaintenanceTypes:()=>Te("/maintenance/types"),createMaintenanceType:t=>Te("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Te(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Te(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Te("/maintenance/overview"),getPrinterMaintenance:t=>Te(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Te(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Te(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Te(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Te("/maintenance/summary"),setPrinterHours:(t,e)=>Te(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Te(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Te(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${ln}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${ln}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Te(`/printers/${t}/camera/test`),getCameraStatus:t=>Te(`/printers/${t}/camera/status`),checkPlateEmpty:(t,e)=>{const n=new URLSearchParams;return n.set("use_external",String(e?.useExternal??!1)),n.set("include_debug_image",String(e?.includeDebugImage??!1)),Te(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Te(`/printers/${t}/camera/plate-detection/status`),calibratePlateDetection:(t,e)=>{const n=new URLSearchParams;return e?.label&&n.set("label",e.label),n.set("use_external",String(e?.useExternal??!1)),Te(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Te(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Te(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${ln}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Te(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Te(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Te("/external-links/"),getExternalLink:t=>Te(`/external-links/${t}`),createExternalLink:t=>Te("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Te(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Te(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Te("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};sn&&(r.Authorization=`Bearer ${sn}`);const i=await fetch(`${ln}/external-links/${t}/icon`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteExternalLinkIcon:t=>Te(`/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),Te(`/projects/?${e}`)},getProject:t=>Te(`/projects/${t}`),createProject:t=>Te("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Te(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Te(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Te(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Te(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Te(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Te(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};sn&&(r.Authorization=`Bearer ${sn}`);const i=await fetch(`${ln}/projects/${t}/attachments`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getProjectAttachmentUrl:(t,e)=>`${ln}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Te(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Te(`/projects/${t}/bom`),createBOMItem:(t,e)=>Te(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Te(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Te(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Te("/projects/templates/"),createTemplateFromProject:t=>Te(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Te(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Te(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Te(`/projects/${t}/export?format=json`),importProject:t=>Te("/projects/import",{method:"POST",body:JSON.stringify(t)}),importProjectFile:async t=>{const e=new FormData;e.append("file",t);const n={};sn&&(n.Authorization=`Bearer ${sn}`);const r=await fetch(`${ln}/projects/import/file`,{method:"POST",headers:n,body:e});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},exportProjectZip:async t=>{const e={};sn&&(e.Authorization=`Bearer ${sn}`);const n=await fetch(`${ln}/projects/${t}/export`,{headers: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"),i=Ff(r)||`project_${t}.zip`;return{blob:await n.blob(),filename:i}},getAPIKeys:()=>Te("/api-keys/"),createAPIKey:t=>Te("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Te(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Te(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Te(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Te("/system/info"),getLibraryFolders:()=>Te("/library/folders"),createLibraryFolder:t=>Te("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Te(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Te(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Te(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Te(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),Te(`/library/files?${n}`)},getLibraryFile:t=>Te(`/library/files/${t}`),uploadLibraryFile:async(t,e,n=!0)=>{const r=new FormData;r.append("file",t);const i=new URLSearchParams;e&&i.set("folder_id",String(e)),i.set("generate_stl_thumbnails",String(n));const s={};sn&&(s.Authorization=`Bearer ${sn}`);const o=await fetch(`${ln}/library/files?${i}`,{method:"POST",headers:s,body:r});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},extractZipFile:async(t,e,n=!0,r=!1,i=!0)=>{const s=new FormData;s.append("file",t);const o=new URLSearchParams;e&&o.set("folder_id",String(e)),o.set("preserve_structure",String(n)),o.set("create_folder_from_zip",String(r)),o.set("generate_stl_thumbnails",String(i));const l={};sn&&(l.Authorization=`Bearer ${sn}`);const c=await fetch(`${ln}/library/files/extract-zip?${o}`,{method:"POST",headers:l,body:s});if(!c.ok){const u=await c.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${c.status}`)}return c.json()},updateLibraryFile:(t,e)=>Te(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Te(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${ln}/library/files/${t}/download`,downloadLibraryFile:async(t,e)=>{const n={};sn&&(n.Authorization=`Bearer ${sn}`);const r=await fetch(`${ln}/library/files/${t}/download`,{headers:n});if(!r.ok){const u=await r.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Ff(i)||e||`file_${t}`,o=await r.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},getLibraryFileThumbnailUrl:t=>`${ln}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${ln}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${ln}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Te("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Te("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Te("/library/stats"),batchGenerateStlThumbnails:t=>Te("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>Te("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Te(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Te(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Te(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Te("/github-backup/config"),saveGitHubBackupConfig:t=>Te("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Te("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Te("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Te(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Te("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Te("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Te("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Te(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Te(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"}),getLocalPresets:()=>Te("/local-presets/"),getLocalPresetDetail:t=>Te(`/local-presets/${t}`),importLocalPresets:t=>fetch(`${ln}/local-presets/import`,{method:"POST",headers:sn?{Authorization:`Bearer ${sn}`}:{},body:t}).then(async e=>{if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.detail||`HTTP ${e.status}`)}return e.json()}),createLocalPreset:t=>Te("/local-presets/",{method:"POST",body:JSON.stringify(t)}),updateLocalPreset:(t,e)=>Te(`/local-presets/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLocalPreset:t=>Te(`/local-presets/${t}`,{method:"DELETE"}),refreshBaseProfileCache:()=>Te("/local-presets/base-cache/refresh",{method:"POST"})},cc={getInfo:()=>Te("/discovery/info"),getStatus:()=>Te("/discovery/status"),startDiscovery:(t=10)=>Te(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Te("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Te("/discovery/printers"),startSubnetScan:(t,e=1)=>Te("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Te("/discovery/scan/status"),stopSubnetScan:()=>Te("/discovery/scan/stop",{method:"POST"})},DS={getSettings:()=>Te("/settings/virtual-printer"),getModels:()=>Te("/settings/virtual-printer/models"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),t.model!==void 0&&e.set("model",t.model),t.target_printer_id!==void 0&&e.set("target_printer_id",String(t.target_printer_id)),t.remote_interface_ip!==void 0&&e.set("remote_interface_ip",t.remote_interface_ip),Te(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},xg={list:()=>Te("/pending-uploads/"),getCount:()=>Te("/pending-uploads/count"),get:t=>Te(`/pending-uploads/${t}`),archive:(t,e)=>Te(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Te(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Te("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Te("/pending-uploads/discard-all",{method:"DELETE"})},RS={checkUpdates:()=>Te("/firmware/updates"),checkPrinterUpdate:t=>Te(`/firmware/updates/${t}`),prepareUpload:t=>Te(`/firmware/updates/${t}/prepare`),startUpload:t=>Te(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Te(`/firmware/updates/${t}/upload/status`)},Og={getDebugLoggingState:()=>Te("/support/debug-logging"),setDebugLogging:t=>Te("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t={};sn&&(t.Authorization=`Bearer ${sn}`);const e=await fetch(`${ln}/support/bundle`,{headers:t});if(!e.ok){const l=await e.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${e.status}`)}const n=e.headers.get("Content-Disposition"),r=Ff(n)||"bambuddy-support.zip",i=await e.blob(),s=window.URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(s)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return Te(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Te("/support/logs",{method:"DELETE"})},uK=w.createContext(void 0);function gme({children:t}){const[e,n]=w.useState(()=>{const M=localStorage.getItem("theme-mode"),P=localStorage.getItem("theme");return M||P||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[s,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[h,p]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[m,x]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{ae.getSettings().then(M=>{M.dark_style&&(i(M.dark_style),localStorage.setItem("dark-style",M.dark_style)),M.dark_background&&(o(M.dark_background),localStorage.setItem("dark-background",M.dark_background)),M.dark_accent&&(c(M.dark_accent),localStorage.setItem("dark-accent",M.dark_accent)),M.light_style&&(d(M.light_style),localStorage.setItem("light-style",M.light_style)),M.light_background&&(p(M.light_background),localStorage.setItem("light-background",M.light_background)),M.light_accent&&(x(M.light_accent),localStorage.setItem("light-accent",M.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const M=document.documentElement;M.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"?(M.classList.add("dark"),M.classList.add(`style-${r}`),M.classList.add(`bg-${s}`),M.classList.add(`accent-${l}`)):(M.classList.add(`style-${u}`),M.classList.add(`bg-${h}`),M.classList.add(`accent-${m}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,s,l,u,h,m]);const y=()=>n(M=>M==="dark"?"light":"dark"),b=M=>n(M),v=M=>{i(M),localStorage.setItem("dark-style",M),ae.updateSettings({dark_style:M}).catch(()=>{})},S=M=>{o(M),localStorage.setItem("dark-background",M),ae.updateSettings({dark_background:M}).catch(()=>{})},k=M=>{c(M),localStorage.setItem("dark-accent",M),ae.updateSettings({dark_accent:M}).catch(()=>{})},E=M=>{d(M),localStorage.setItem("light-style",M),ae.updateSettings({light_style:M}).catch(()=>{})},N=M=>{p(M),localStorage.setItem("light-background",M),ae.updateSettings({light_background:M}).catch(()=>{})},A=M=>{x(M),localStorage.setItem("light-accent",M),ae.updateSettings({light_accent:M}).catch(()=>{})};return a.jsx(uK.Provider,{value:{mode:e,darkStyle:r,darkBackground:s,darkAccent:l,lightStyle:u,lightBackground:h,lightAccent:m,toggleMode:y,setMode:b,setDarkStyle:v,setDarkBackground:S,setDarkAccent:k,setLightStyle:E,setLightBackground:N,setLightAccent:A},children:t})}function Gm(){const t=w.useContext(uK);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function _t({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return a.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 Mn({children:t,className:e=""}){return a.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Nt({children:t,className:e=""}){return a.jsx("div",{className:`p-6 ${e}`,children:t})}function bme(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,s)=>({keys:[String(s+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,s)=>({keys:[String(s+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 pB({children:t}){return a.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 xme({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Ut(),i=bme(n,e,r);return w.useEffect(()=>{const s=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:a.jsx(_t,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:a.jsxs(Nt,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(UP,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(s=>a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:s.category}),a.jsx("div",{className:"space-y-2",children:s.items.map(o=>a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&a.jsx(Wr,{className:"w-3 h-3 text-bambu-gray"})]}),a.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>a.jsx(pB,{children:l},l))})]},o.description))})]},s.category))}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",a.jsx(pB,{children:"Esc"})," or click outside to close"]})})]})})})}function Me({variant:t="primary",size:e="md",className:n="",children:r,...i}){const s="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 a.jsx("button",{className:`${s} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function On({title:t,message:e,confirmText:n,cancelText:r,variant:i="default",isLoading:s=!1,loadingText:o,onConfirm:l,onCancel:c}){const{t:u}=Ut(),d=n??u("common.confirm"),h=r??u("common.cancel"),p=o??u("common.loading");w.useEffect(()=>{const y=b=>{b.key==="Escape"&&!s&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c,s]);const x={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 a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s?void 0:c,children:a.jsx(_t,{className:"w-full max-w-md",onClick:y=>y.stopPropagation(),children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-start gap-4",children:[a.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${x.icon}`,children:a.jsx(kn,{className:"w-6 h-6"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),a.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),a.jsxs("div",{className:"flex gap-3 mt-6",children:[a.jsx(Me,{variant:"secondary",onClick:c,className:"flex-1",disabled:s,children:h}),a.jsx(Me,{onClick:l,className:`flex-1 ${x.button}`,disabled:s,children:s?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}),p]}):d})]})]})})})}function yme({plug:t}){const e=Zt(),[n,r]=w.useState(null),{data:i,isLoading:s}=et({queryKey:["smart-plug-status",t.id],queryFn:()=>ae.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=st({mutationFn:m=>ae.controlSmartPlug(t.id,m),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=t.plug_type==="mqtt"&&i?.energy?.power!==null&&i?.energy?.power!==void 0,u=(i?.reachable??!1)||c,d=o.isPending,h=t.plug_type==="mqtt",p=()=>{n&&(o.mutate(n),r(null))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`p-1.5 rounded ${h?u?"bg-teal-500/20":"bg-red-500/20":u?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:h?a.jsx(l4,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):a.jsx(dl,{className:`w-4 h-4 ${u?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),a.jsx("div",{className:"flex items-center gap-1 text-xs",children:s?a.jsx(it,{className:"w-3 h-3 text-bambu-gray animate-spin"}):h?u?a.jsxs(a.Fragment,{children:[a.jsx(Ih,{className:"w-3 h-3 text-teal-400"}),a.jsxs("span",{className:"text-teal-400",children:[Math.round(i?.energy?.power??0),"W"]}),a.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),a.jsx(Yl,{className:"w-3 h-3 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):a.jsxs(a.Fragment,{children:[a.jsx(km,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Waiting"})]}):u?a.jsxs(a.Fragment,{children:[a.jsx(Lg,{className:"w-3 h-3 text-status-ok"}),a.jsx("span",{className:l?"text-status-ok":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),a.jsx(Ih,{className:"w-3 h-3 text-yellow-400"}),a.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(km,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),!h&&a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>r("on"),disabled:!u||d,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:d?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(cd,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("off"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${!l&&u?"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:d?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Rk,{className:"w-4 h-4"})})]})]}),n&&a.jsx(On,{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:p,onCancel:()=>r(null)})]})}function gB({onClose:t}){const{data:e,isLoading:n}=et({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return a.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:[a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:a.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[a.jsx(dl,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),a.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?a.jsxs("div",{className:"text-center py-6 px-4",children:[a.jsx(dl,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):a.jsx("div",{className:"space-y-1",children:r.map(i=>a.jsx(yme,{plug:i},i.id))})})]})}const dK=[{name:"globe",icon:Nh},{name:"link",icon:Db},{name:"external-link",icon:Wr},{name:"book",icon:lue},{name:"file-text",icon:Ms},{name:"home",icon:K0},{name:"star",icon:Nm},{name:"heart",icon:Qde},{name:"bookmark",icon:uue},{name:"shopping-cart",icon:aK},{name:"music",icon:VP},{name:"video",icon:d4},{name:"image",icon:Yu},{name:"camera",icon:Qg},{name:"map",icon:_he},{name:"compass",icon:tde},{name:"coffee",icon:Xue},{name:"gift",icon:zde},{name:"wrench",icon:Mm},{name:"zap",icon:Ih},{name:"cloud",icon:jb},{name:"database",icon:kc},{name:"folder",icon:eK},{name:"mail",icon:r0},{name:"phone",icon:qhe},{name:"user",icon:Zu},{name:"users",icon:uh},{name:"server",icon:Of},{name:"terminal",icon:lK},{name:"code",icon:ZW}];function zk(t){return dK.find(n=>n.name===t)?.icon||Db}function vme({value:t,onChange:e}){const[n,r]=w.useState(!1),i=zk(t);return a.jsxs("div",{className:"relative",children:[a.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:[a.jsx(i,{className:"w-5 h-5"}),a.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),a.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:a.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:dK.map(({name:s,icon:o})=>a.jsx("button",{type:"button",onClick:()=>{e(s),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===s?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:s,children:a.jsx(o,{className:"w-5 h-5"})},s))})})]})]})}const bB=768;function m4(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<bB:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${bB-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const hK=w.createContext(void 0);function wme({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(!0),u=w.useRef(!1),d=w.useRef(!0),h=async()=>{try{const A=await ae.getAuthStatus();if(!d.current)return;if(i(A.auth_enabled),o(A.requires_setup),A.auth_enabled)if(Ju())try{const P=await ae.getCurrentUser();if(!d.current)return;n(P)}catch{if(py(null),!d.current)return;n(null)}else n(null);else n(null)}catch{if(!d.current)return;i(!1),n(null)}finally{d.current&&c(!1)}};w.useEffect(()=>(d.current=!0,h(),()=>{d.current=!1}),[]),w.useEffect(()=>{if(!l&&s&&!r){const A=window.location.pathname;A!=="/setup"&&!A.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else s||(u.current=!1)},[l,s,r]);const p=async(A,M)=>{const P=await ae.login({username:A,password:M});py(P.access_token),n(P.user)},m=()=>{py(null),n(null),ae.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&Ju())try{const A=await ae.getCurrentUser();d.current&&n(A)}catch{py(null),d.current&&n(null)}},y=async()=>{await h()},b=w.useMemo(()=>new Set(e?.permissions??[]),[e?.permissions]),v=w.useMemo(()=>r?e?.is_admin??!1:!0,[r,e?.is_admin]),S=w.useCallback(A=>!r||v?!0:b.has(A),[r,v,b]),k=w.useCallback((...A)=>!r||v?!0:A.some(M=>b.has(M)),[r,v,b]),E=w.useCallback((...A)=>!r||v?!0:A.every(M=>b.has(M)),[r,v,b]),N=w.useCallback((A,M,P)=>{if(!r||v)return!0;const T=`${A}:${M}_all`,j=`${A}:${M}_own`;return b.has(T)?!0:b.has(j)?P==null?!1:P===e?.id:!1},[r,v,b,e?.id]);return a.jsx(hK.Provider,{value:{user:e,authEnabled:r,requiresSetup:s,loading:l,isAdmin:v,login:p,logout:m,refreshUser:x,refreshAuth:y,hasPermission:S,hasAnyPermission:k,hasAllPermissions:E,canModify:N},children:t})}function Rr(){const t=w.useContext(hK);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const fK=w.createContext(void 0);function hn(){const t=w.useContext(fK);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const _me={success:a.jsx(mr,{className:"w-5 h-5 text-green-400"}),error:a.jsx(ua,{className:"w-5 h-5 text-red-400"}),warning:a.jsx(Ui,{className:"w-5 h-5 text-yellow-400"}),info:a.jsx(Xs,{className:"w-5 h-5 text-blue-400"}),loading:a.jsx(it,{className:"w-5 h-5 text-bambu-green animate-spin"})},Sme={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 Nme({children:t}){const[e,n]=w.useState([]),r=w.useRef(new Map);w.useEffect(()=>{const l=r.current;return()=>{l.forEach(c=>clearTimeout(c)),l.clear()}},[]);const i=w.useCallback((l,c="success")=>{const u=Math.random().toString(36).substr(2,9);n(h=>[...h,{id:u,message:l,type:c}]);const d=setTimeout(()=>{n(h=>h.filter(p=>p.id!==u)),r.current.delete(u)},3e3);r.current.set(u,d)},[]),s=w.useCallback((l,c,u="info")=>{n(d=>d.find(p=>p.id===l)?d.map(p=>p.id===l?{...p,message:c,type:u,persistent:!0}:p):[...d,{id:l,message:c,type:u,persistent:!0}])},[]),o=w.useCallback(l=>{const c=r.current.get(l);c&&(clearTimeout(c),r.current.delete(l)),n(u=>u.filter(d=>d.id!==l))},[]);return a.jsxs(fK.Provider,{value:{showToast:i,showPersistentToast:s,dismissToast:o},children:[t,a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(l=>a.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Sme[l.type]}`,children:[_me[l.type],a.jsx("span",{className:"text-white text-sm",children:l.message}),a.jsx("button",{onClick:()=>o(l.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-4 h-4"})})]},l.id))})]})}const i0=[{id:"printers",to:"/",icon:Nr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:As,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:ri,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Sue,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:jb,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Mm,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:ps,labelKey:"nav.projects"},{id:"inventory",to:"/inventory",icon:ta,labelKey:"nav.inventory"},{id:"files",to:"/files",icon:Ql,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:Ok,labelKey:"nav.settings"}];function kme(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return i0.map(e=>e.id)}return i0.map(e=>e.id)}function Mme(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function kE(t){return t.startsWith("ext-")}function mK(){return localStorage.getItem("defaultView")||"/"}function Cme(t){localStorage.setItem("defaultView",t)}function Eme(){const t=Uc(),e=zc(),{mode:n,toggleMode:r}=Gm(),{t:i}=Ut(),s=m4(),{user:o,authEnabled:l,logout:c,hasPermission:u}=Rr(),{showToast:d}=hn(),[h,p]=w.useState(!1),[m,x]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[y,b]=w.useState(!1),[v,S]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[k,E]=w.useState(!1),[N,A]=w.useState(!1),[M,P]=w.useState(!1),[T,j]=w.useState(kme),[z,F]=w.useState(null),[$,D]=w.useState(null),H=w.useRef(!1),[q,I]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[K,Z]=w.useState(null),{data:se}=et({queryKey:["version"],queryFn:ae.getVersion,staleTime:1/0}),{data:V}=et({queryKey:["settings"],queryFn:ae.getSettings,staleTime:300*1e3}),{data:W}=et({queryKey:["updateCheck"],queryFn:ae.checkForUpdates,enabled:V?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:ie}=et({queryKey:["spoolman-settings"],queryFn:ae.getSpoolmanSettings,staleTime:300*1e3}),{data:J}=et({queryKey:["external-links"],queryFn:ae.getExternalLinks}),{data:pe}=et({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs,staleTime:30*1e3}),fe=pe?.some(X=>X.show_in_switchbar)??!1,{data:ve}=et({queryKey:["debugLogging"],queryFn:Og.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:Le}=et({queryKey:["queue","pending"],queryFn:()=>ae.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),de=Le?.length??0,{data:ce}=et({queryKey:["pending-uploads","count"],queryFn:xg.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Ae=ce?.count??0,[re,Ie]=w.useState(null);w.useEffect(()=>{if(!ve?.enabled||!ve.enabled_at){Ie(null);return}const X=new Date(ve.enabled_at).getTime(),ge=()=>{Ie(Math.floor((Date.now()-X)/1e3))};ge();const _e=setInterval(ge,1e3);return()=>clearInterval(_e)},[ve?.enabled,ve?.enabled_at]);const G=w.useMemo(()=>new Map(i0.map(X=>[X.id,X])),[]),Y=w.useMemo(()=>new Map((J||[]).map(X=>[`ext-${X.id}`,X])),[J]),ue=(()=>{const X=[],ge=new Set,_e=l&&o?.role==="user",Ee=ie?.spoolman_enabled==="true";for(const $e of T)_e&&$e==="settings"||Ee&&$e==="inventory"||(G.has($e)||Y.has($e))&&(X.push($e),ge.add($e));for(const $e of i0)_e&&$e.id==="settings"||Ee&&$e.id==="inventory"||ge.has($e.id)||(X.push($e.id),ge.add($e.id));for(const $e of J||[]){const Ce=`ext-${$e.id}`;ge.has(Ce)||(X.push(Ce),ge.add(Ce))}return X})(),B=(X,ge)=>{F(ge),X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("text/plain",ge)},ee=(X,ge)=>{X.preventDefault(),X.dataTransfer.dropEffect="move",D(ge)},Q=()=>{D(null)},le=(X,ge)=>{if(X.preventDefault(),z===null||z===ge){F(null),D(null);return}const _e=[...ue],Ee=_e.indexOf(z),$e=_e.indexOf(ge);if(Ee===-1||$e===-1){F(null),D(null);return}_e.splice(Ee,1),_e.splice($e,0,z),j(_e),Mme(_e),F(null),D(null)},he=()=>{F(null),D(null)},te=W?.update_available&&W.latest_version&&W.latest_version!==q,U=()=>{W?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",W.latest_version),I(W.latest_version))};w.useEffect(()=>{if(!H.current&&e.pathname==="/"){const X=mK();X!=="/"&&(H.current=!0,t(X,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(v))},[v]),w.useEffect(()=>{s&&E(!1)},[e.pathname,s]),w.useEffect(()=>{const X=ge=>{if(!u("printers:control"))return;const _e=ge.detail;Z({printer_id:_e.printer_id,printer_name:_e.printer_name,message:_e.message})};return window.addEventListener("plate-not-empty",X),()=>window.removeEventListener("plate-not-empty",X)},[u]);const L=w.useCallback(X=>{const ge=X.target;if(!(ge.tagName==="INPUT"||ge.tagName==="TEXTAREA"||ge.isContentEditable)&&!X.metaKey&&!X.ctrlKey&&!X.altKey){const _e=parseInt(X.key);if(_e>=1&&_e<=ue.length&&_e<=9){const Ee=ue[_e-1];if(X.preventDefault(),kE(Ee)){const $e=Y.get(Ee);if($e?.open_in_new_tab)window.open($e.url,"_blank","noopener,noreferrer");else{const Ce=Ee.replace("ext-","");t(`/external/${Ce}`)}}else{const $e=G.get(Ee);$e&&t($e.to)}return}switch(X.key){case"?":X.preventDefault(),A(!0);break;case"Escape":A(!1);break}}},[t,ue,G,Y]);return w.useEffect(()=>(document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)),[L]),a.jsxs("div",{className:"flex min-h-screen",children:[s&&a.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:[a.jsx("button",{onClick:()=>E(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:a.jsx(Ahe,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),s&&k&&a.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>E(!1)}),a.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${s?`fixed inset-y-0 left-0 z-50 w-72 transform ${k?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${v?"w-64":"w-16"}`}`,children:[a.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||v?"p-4":"p-2"}`,children:a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:s||v?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),a.jsx("nav",{className:"flex-1 p-2",children:a.jsx("ul",{className:"space-y-2",children:ue.map(X=>{if(kE(X)){const _e=Y.get(X);if(!_e)return null;const Ee=_e.custom_icon?null:zk(_e.icon);return a.jsx("li",{draggable:!0,onDragStart:$e=>B($e,X),onDragOver:$e=>ee($e,X),onDragLeave:Q,onDrop:$e=>le($e,X),onDragEnd:he,className:`relative ${z===X?"opacity-50":""} ${$===X&&z!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:_e.open_in_new_tab?a.jsxs("a",{href:_e.url,target:"_blank",rel:"noopener noreferrer",className:`flex items-center ${s||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white`,title:!s&&!v?_e.name:void 0,children:[v&&!s&&a.jsx(kh,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),_e.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${_e.id}/icon`,alt:"",className:"w-5 h-5 flex-shrink-0"}):Ee&&a.jsx(Ee,{className:"w-5 h-5 flex-shrink-0"}),(s||v)&&a.jsx("span",{children:_e.name})]}):a.jsxs(my,{to:`/external/${_e.id}`,className:({isActive:$e})=>`flex items-center ${s||v?"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:!s&&!v?_e.name:void 0,children:[v&&!s&&a.jsx(kh,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),_e.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${_e.id}/icon`,alt:"",className:"w-5 h-5 flex-shrink-0"}):Ee&&a.jsx(Ee,{className:"w-5 h-5 flex-shrink-0"}),(s||v)&&a.jsx("span",{children:_e.name})]})},X)}else{const _e=G.get(X);if(!_e)return null;const{to:Ee,icon:$e,labelKey:Ce}=_e,He=X==="queue"&&de>0,Qe=X==="archives"&&Ae>0,xe=He?de:Qe?Ae:0,ye=He||Qe;return a.jsx("li",{draggable:!0,onDragStart:we=>B(we,X),onDragOver:we=>ee(we,X),onDragLeave:Q,onDrop:we=>le(we,X),onDragEnd:he,className:`relative ${z===X?"opacity-50":""} ${$===X&&z!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(my,{to:Ee,className:({isActive:we})=>`flex items-center ${s||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${we?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!v?i(Ce):void 0,children:[v&&!s&&a.jsx(kh,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),a.jsxs("div",{className:"relative",children:[a.jsx($e,{className:"w-5 h-5 flex-shrink-0"}),ye&&a.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${Qe?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:xe>99?"99+":xe})]}),(s||v)&&a.jsx("span",{children:i(Ce)})]})},X)}})})}),!s&&a.jsx("button",{onClick:()=>S(!v),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(v?"nav.collapseSidebar":"nav.expandSidebar"),children:v?a.jsx(Tc,{className:"w-5 h-5"}):a.jsx(La,{className:"w-5 h-5"})}),a.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||v?a.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[fe&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>P(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${M?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(dl,{className:"w-5 h-5"})}),M&&a.jsx(gB,{onClose:()=>P(!1)})]}),u("system:read")?a.jsx(my,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(Xs,{className:"w-5 h-5"})}):a.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:a.jsx(Xs,{className:"w-5 h-5"})}),a.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:a.jsx(zP,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>A(!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:a.jsx(UP,{className:"w-5 h-5"})}),a.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"?a.jsx(mB,{className:"w-5 h-5"}):a.jsx(h1,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>p(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:a.jsx(tl,{className:"w-5 h-5"})}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx($P,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",se?.version||"..."]}),W?.update_available&&a.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:W.latest_version}),children:[a.jsx(_E,{className:"w-4 h-4"}),a.jsx("span",{children:i("nav.update")})]})]})]}):a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[W?.update_available&&a.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:W.latest_version}),children:a.jsx(_E,{className:"w-5 h-5"})}),fe&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>P(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${M?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(dl,{className:"w-5 h-5"})}),M&&a.jsx(gB,{onClose:()=>P(!1)})]}),u("system:read")?a.jsx(my,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(Xs,{className:"w-5 h-5"})}):a.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:a.jsx(Xs,{className:"w-5 h-5"})}),a.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:a.jsx(zP,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>A(!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:a.jsx(UP,{className:"w-5 h-5"})}),a.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"?a.jsx(mB,{className:"w-5 h-5"}):a.jsx(h1,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>p(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:a.jsx(tl,{className:"w-5 h-5"})}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx($P,{className:"w-5 h-5"})})]})]})})]}),a.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":v?"ml-64":"ml-16"}`,children:[ve?.enabled&&a.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Mk,{className:"w-4 h-4 text-amber-500 animate-pulse"}),a.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),re!==null&&a.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(re/60),"m ",re%60,"s)"]})]}),a.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),te&&a.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(_E,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{children:i("nav.updateAvailableBanner",{version:W?.latest_version,defaultValue:`Version ${W?.latest_version} is available!`})}),a.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),a.jsx("button",{onClick:U,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsx(Mle,{})]}),N&&a.jsx(xme,{onClose:()=>A(!1),sidebarItems:ue.map(X=>{if(kE(X)){const ge=Y.get(X);return ge?{type:"external",label:ge.name}:null}else{const ge=G.get(X);return ge?{type:"nav",label:ge.labelKey,labelKey:ge.labelKey}:null}}).filter(Boolean)}),K&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:a.jsx("div",{className:"bg-bambu-dark-secondary border-2 border-yellow-500 rounded-xl shadow-2xl max-w-md w-full animate-in fade-in zoom-in duration-200",children:a.jsxs("div",{className:"p-6 text-center",children:[a.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:a.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),a.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:i("plateAlert.title")}),a.jsx("p",{className:"text-lg text-white mb-2",children:K.printer_name}),a.jsx("p",{className:"text-bambu-gray mb-6",children:i("plateAlert.message")}),a.jsx("button",{onClick:()=>Z(null),className:"w-full py-3 px-6 bg-yellow-500 hover:bg-yellow-600 text-black font-semibold rounded-lg transition-colors",children:i("plateAlert.understand")})]})})}),h&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:X=>X.stopPropagation(),children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(tl,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("changePassword.title")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.currentPassword")}),a.jsx("input",{type:"password",value:m.currentPassword,onChange:X=>x({...m,currentPassword:X.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("changePassword.currentPasswordPlaceholder"),autoComplete:"current-password"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.newPassword")}),a.jsx("input",{type:"password",value:m.newPassword,onChange:X=>x({...m,newPassword:X.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("changePassword.newPasswordPlaceholder"),autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.confirmPassword")}),a.jsx("input",{type:"password",value:m.confirmPassword,onChange:X=>x({...m,confirmPassword:X.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${m.confirmPassword&&m.newPassword!==m.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("changePassword.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),m.confirmPassword&&m.newPassword!==m.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("changePassword.passwordsDoNotMatch")})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:i("common.cancel")}),a.jsx(Me,{onClick:async()=>{if(m.newPassword!==m.confirmPassword){d(i("changePassword.passwordsDoNotMatch"),"error");return}if(m.newPassword.length<6){d(i("changePassword.passwordTooShort"),"error");return}b(!0);try{await ae.changePassword(m.currentPassword,m.newPassword),d(i("changePassword.success"),"success"),p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})}catch(X){const ge=X instanceof Error?X.message:i("changePassword.failed");d(ge,"error")}finally{b(!1)}},disabled:y||!m.currentPassword||!m.newPassword||m.newPassword!==m.confirmPassword||m.newPassword.length<6,children:y?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("changePassword.changing")]}):a.jsxs(a.Fragment,{children:[a.jsx(tl,{className:"w-4 h-4"}),i("changePassword.title")]})})]})]})]})})]})}function Ame(t="system"){switch(t){case"us":return"MM/DD/YYYY";case"eu":return"DD/MM/YYYY";case"iso":return"YYYY-MM-DD";case"system":default:{const n=new Date(2e3,11,31).toLocaleDateString();return n.startsWith("12")?"MM/DD/YYYY":n.startsWith("31")?"DD/MM/YYYY":"YYYY-MM-DD"}}}function Tme(t="system"){switch(t){case"12h":return"HH:MM AM/PM";case"24h":return"HH:MM";case"system":default:{const n=new Date(2e3,0,1,14,30).toLocaleTimeString();return n.includes("PM")||n.includes("AM")?"HH:MM AM/PM":"HH:MM"}}}function xB(t,e="system"){const n=String(t.getDate()).padStart(2,"0"),r=String(t.getMonth()+1).padStart(2,"0"),i=t.getFullYear();switch(e){case"us":return`${r}/${n}/${i}`;case"eu":return`${n}/${r}/${i}`;case"iso":return`${i}-${r}-${n}`;case"system":default:return t.toLocaleDateString()}}function yB(t,e="system"){const n=t.getHours(),r=String(t.getMinutes()).padStart(2,"0");switch(e){case"12h":{const i=n%12||12,s=n<12?"AM":"PM";return`${i}:${r} ${s}`}case"24h":return`${String(n).padStart(2,"0")}:${r}`;case"system":default:return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}function Yw(t){for(const e of["/",".","-"]){const n=t.split(e);if(n.length===3)return n}return null}function jme(t,e="system"){if(!t)return null;let n,r,i;try{switch(e){case"us":{const s=Yw(t);if(!s)return null;r=parseInt(s[0],10),n=parseInt(s[1],10),i=parseInt(s[2],10);break}case"eu":{const s=Yw(t);if(!s)return null;n=parseInt(s[0],10),r=parseInt(s[1],10),i=parseInt(s[2],10);break}case"iso":{const s=Yw(t);if(!s)return null;i=parseInt(s[0],10),r=parseInt(s[1],10),n=parseInt(s[2],10);break}case"system":default:{const o=new Date(2e3,11,31).toLocaleDateString(),l=Yw(t);if(l){o.startsWith("12")?(r=parseInt(l[0],10),n=parseInt(l[1],10),i=parseInt(l[2],10)):o.startsWith("31")?(n=parseInt(l[0],10),r=parseInt(l[1],10),i=parseInt(l[2],10)):(i=parseInt(l[0],10),r=parseInt(l[1],10),n=parseInt(l[2],10));break}return null}}return isNaN(n)||isNaN(r)||isNaN(i)||r<1||r>12||n<1||n>31||i<1900||i>2100?null:new Date(i,r-1,n)}catch{return null}}function Pme(t){if(!t)return null;try{const e=t.trim().toUpperCase(),n=e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)?$/i);if(n){let i=parseInt(n[1],10);const s=parseInt(n[2],10),o=n[3]?.toUpperCase();return o==="PM"&&i<12&&(i+=12),o==="AM"&&i===12&&(i=0),i<0||i>23||s<0||s>59?null:{hours:i,minutes:s}}const r=e.match(/^(\d{1,2}):(\d{2})$/);if(r){const i=parseInt(r[1],10),s=parseInt(r[2],10);return i<0||i>23||s<0||s>59?null:{hours:i,minutes:s}}return null}catch{return null}}function qP(t){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${e}-${n}-${r}T${i}:${s}`}function Ty(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Qi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function eb(t,e){const n=Qi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function tb(t,e="system",n){const r=Qi(t);if(!r)return"";const s=Ty(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,s)}function Dme(t,e="system",n){const i=Ty({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const p4="181",Fg={ROTATE:0,DOLLY:1,PAN:2},Mg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Rme=0,vB=1,Lme=2,pK=1,Ome=2,_u=3,zh=0,Qs=1,xc=2,Bu=0,Ig=1,wB=2,_B=3,SB=4,Fme=5,$f=100,Ime=101,zme=102,Ume=103,Bme=104,$me=200,Hme=201,Vme=202,Gme=203,WP=204,KP=205,qme=206,Wme=207,Kme=208,Xme=209,Yme=210,Qme=211,Zme=212,Jme=213,epe=214,XP=0,YP=1,QP=2,nb=3,ZP=4,JP=5,e3=6,t3=7,g4=0,tpe=1,npe=2,Ch=0,rpe=1,ipe=2,ape=3,spe=4,ope=5,lpe=6,cpe=7,gK=300,rb=301,ib=302,n3=303,r3=304,Uk=306,i3=1e3,Ru=1001,a3=1002,ko=1003,upe=1004,Qw=1005,cl=1006,ME=1007,Qf=1008,jc=1009,bK=1010,xK=1011,a0=1012,b4=1013,Cm=1014,Lu=1015,Rb=1016,x4=1017,y4=1018,s0=1020,yK=35902,vK=35899,wK=1021,_K=1022,Vl=1023,o0=1026,l0=1027,SK=1028,v4=1029,w4=1030,_4=1031,S4=1033,LS=33776,OS=33777,FS=33778,IS=33779,s3=35840,o3=35841,l3=35842,c3=35843,u3=36196,d3=37492,h3=37496,f3=37808,m3=37809,p3=37810,g3=37811,b3=37812,x3=37813,y3=37814,v3=37815,w3=37816,_3=37817,S3=37818,N3=37819,k3=37820,M3=37821,C3=36492,E3=36494,A3=36495,T3=36283,j3=36284,P3=36285,D3=36286,dpe=3200,hpe=3201,NK=0,fpe=1,dh="",yo="srgb",ab="srgb-linear",m1="linear",Ar="srgb",Tp=7680,NB=519,mpe=512,ppe=513,gpe=514,kK=515,bpe=516,xpe=517,ype=518,vpe=519,kB=35044,MB="300 es",_c=2e3,p1=2001;function MK(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function g1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function wpe(){const t=g1("canvas");return t.style.display="block",t}const CB={};function EB(...t){const e="THREE."+t.shift();console.log(e,...t)}function vn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function zi(...t){const e="THREE."+t.shift();console.error(e,...t)}function c0(...t){const e=t.join(" ");e in CB||(CB[e]=!0,vn(...t))}function _pe(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}let qm=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 s=i.indexOf(n);s!==-1&&i.splice(s,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 s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}};const rs=["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"],zS=Math.PI/180,R3=180/Math.PI;function Y0(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(rs[t&255]+rs[t>>8&255]+rs[t>>16&255]+rs[t>>24&255]+"-"+rs[e&255]+rs[e>>8&255]+"-"+rs[e>>16&15|64]+rs[e>>24&255]+"-"+rs[n&63|128]+rs[n>>8&255]+"-"+rs[n>>16&255]+rs[n>>24&255]+rs[r&255]+rs[r>>8&255]+rs[r>>16&255]+rs[r>>24&255]).toLowerCase()}function Gn(t,e,n){return Math.max(e,Math.min(n,t))}function Spe(t,e){return(t%e+e)%e}function CE(t,e,n){return(1-n)*t+n*e}function Hx(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 Hs(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 Npe={DEG2RAD:zS};let Rn=class CK{constructor(e=0,n=0){CK.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=Gn(this.x,e.x,n.x),this.y=Gn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Gn(this.x,e,n),this.y=Gn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Gn(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(Gn(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),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*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}},Em=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,s,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],h=r[i+3],p=s[o+0],m=s[o+1],x=s[o+2],y=s[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h;return}if(l>=1){e[n+0]=p,e[n+1]=m,e[n+2]=x,e[n+3]=y;return}if(h!==y||c!==p||u!==m||d!==x){let b=c*p+u*m+d*x+h*y;b<0&&(p=-p,m=-m,x=-x,y=-y,b=-b);let v=1-l;if(b<.9995){const S=Math.acos(b),k=Math.sin(S);v=Math.sin(v*S)/k,l=Math.sin(l*S)/k,c=c*v+p*l,u=u*v+m*l,d=d*v+x*l,h=h*v+y*l}else{c=c*v+p*l,u=u*v+m*l,d=d*v+x*l,h=h*v+y*l;const S=1/Math.sqrt(c*c+u*u+d*d+h*h);c*=S,u*=S,d*=S,h*=S}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],h=s[o],p=s[o+1],m=s[o+2],x=s[o+3];return e[n]=l*x+d*h+c*m-u*p,e[n+1]=c*x+d*p+u*h-l*m,e[n+2]=u*x+d*m+l*p-c*h,e[n+3]=d*x-l*h-c*p-u*m,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,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),h=l(s/2),p=c(r/2),m=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=p*d*h+u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h-p*m*x;break;case"YXZ":this._x=p*d*h+u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h+p*m*x;break;case"ZXY":this._x=p*d*h-u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h-p*m*x;break;case"ZYX":this._x=p*d*h-u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h+p*m*x;break;case"YZX":this._x=p*d*h+u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h-p*m*x;break;case"XZY":this._x=p*d*h-u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h+p*m*x;break;default:vn("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],s=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],h=n[10],p=r+l+h;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(s-u)*m,this._z=(o-i)*m}else if(r>l&&r>h){const m=2*Math.sqrt(1+r-l-h);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(s+u)/m}else if(l>h){const m=2*Math.sqrt(1+l-r-h);this._w=(s-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+h-r-l);this._w=(o-i)/m,this._x=(s+u)/m,this._y=(c+d)/m,this._z=.25*m}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(Gn(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,s=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-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*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,s=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,s=-s,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+s*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+s*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),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*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}},mt=class EK{constructor(e=0,n=0,r=0){EK.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(AB.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(AB.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-s*i),h=2*(s*r-o*n);return this.x=n+c*u+o*h-l*d,this.y=r+c*d+l*u-s*h,this.z=i+c*h+s*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,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[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=Gn(this.x,e.x,n.x),this.y=Gn(this.y,e.y,n.y),this.z=Gn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Gn(this.x,e,n),this.y=Gn(this.y,e,n),this.z=Gn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Gn(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,s=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-s*l,this.y=s*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 EE.copy(this).projectOnVector(e),this.sub(EE)}reflect(e){return this.sub(EE.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(Gn(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 EE=new mt,AB=new Em;let Fn=class AK{constructor(e,n,r,i,s,o,l,c,u){AK.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u)}set(e,n,r,i,s,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=s,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,s=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],h=r[7],p=r[2],m=r[5],x=r[8],y=i[0],b=i[3],v=i[6],S=i[1],k=i[4],E=i[7],N=i[2],A=i[5],M=i[8];return s[0]=o*y+l*S+c*N,s[3]=o*b+l*k+c*A,s[6]=o*v+l*E+c*M,s[1]=u*y+d*S+h*N,s[4]=u*b+d*k+h*A,s[7]=u*v+d*E+h*M,s[2]=p*y+m*S+x*N,s[5]=p*b+m*k+x*A,s[8]=p*v+m*E+x*M,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],s=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*s*d+r*l*c+i*s*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=d*o-l*u,p=l*c-d*s,m=u*s-o*c,x=n*h+r*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=h*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=p*y,e[4]=(d*n-i*c)*y,e[5]=(i*s-l*n)*y,e[6]=m*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*s)*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,s,o,l){const c=Math.cos(s),u=Math.sin(s);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(AE.makeScale(e,n)),this}rotate(e){return this.premultiply(AE.makeRotation(-e)),this}translate(e,n){return this.premultiply(AE.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 AE=new Fn,TB=new Fn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),jB=new Fn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function kpe(){const t={enabled:!0,workingColorSpace:ab,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Ar&&(i.r=$u(i.r),i.g=$u(i.g),i.b=$u(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Ar&&(i.r=zg(i.r),i.g=zg(i.g),i.b=zg(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===dh?m1:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].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,s){return c0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return c0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[ab]:{primaries:e,whitePoint:r,transfer:m1,toXYZ:TB,fromXYZ:jB,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:yo},outputColorSpaceConfig:{drawingBufferColorSpace:yo}},[yo]:{primaries:e,whitePoint:r,transfer:Ar,toXYZ:TB,fromXYZ:jB,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:yo}}}),t}const cr=kpe();function $u(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function zg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let jp,Mpe=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{jp===void 0&&(jp=g1("canvas")),jp.width=e.width,jp.height=e.height;const i=jp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=jp}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=g1("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),s=i.data;for(let o=0;o<s.length;o++)s[o]=$u(s[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($u(n[r]/255)*255):n[r]=$u(n[r]);return{data:n,width:e.width,height:e.height}}else return vn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Cpe=0,N4=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Cpe++}),this.uuid=Y0(),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 s;if(Array.isArray(i)){s=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(TE(i[o].image)):s.push(TE(i[o]))}else s=TE(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function TE(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Mpe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(vn("Texture: Unable to serialize Texture."),{})}let Epe=0;const jE=new mt;let ec=class US extends qm{constructor(e=US.DEFAULT_IMAGE,n=US.DEFAULT_MAPPING,r=Ru,i=Ru,s=cl,o=Qf,l=Vl,c=jc,u=US.DEFAULT_ANISOTROPY,d=dh){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Epe++}),this.uuid=Y0(),this.name="",this.source=new N4(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new Rn(0,0),this.repeat=new Rn(1,1),this.center=new Rn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fn,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(jE).x}get height(){return this.source.getSize(jE).y}get depth(){return this.source.getSize(jE).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){vn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){vn(`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!==gK)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case i3:e.x=e.x-Math.floor(e.x);break;case Ru:e.x=e.x<0?0:1;break;case a3:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case i3:e.y=e.y-Math.floor(e.y);break;case Ru:e.y=e.y<0?0:1;break;case a3: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++}};ec.DEFAULT_IMAGE=null;ec.DEFAULT_MAPPING=gK;ec.DEFAULT_ANISOTROPY=1;let Zi=class TK{constructor(e=0,n=0,r=0,i=1){TK.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,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,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,s;const c=e.elements,u=c[0],d=c[4],h=c[8],p=c[1],m=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-p)<.01&&Math.abs(h-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+m+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const k=(u+1)/2,E=(m+1)/2,N=(v+1)/2,A=(d+p)/4,M=(h+y)/4,P=(x+b)/4;return k>E&&k>N?k<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(k),i=A/r,s=M/r):E>N?E<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(E),r=A/i,s=P/i):N<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(N),r=M/s,i=P/s),this.set(r,i,s,n),this}let S=Math.sqrt((b-x)*(b-x)+(h-y)*(h-y)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(b-x)/S,this.y=(h-y)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+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=Gn(this.x,e.x,n.x),this.y=Gn(this.y,e.y,n.y),this.z=Gn(this.z,e.z,n.z),this.w=Gn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Gn(this.x,e,n),this.y=Gn(this.y,e,n),this.z=Gn(this.z,e,n),this.w=Gn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Gn(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}},Ape=class extends qm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:cl,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 Zi(0,0,e,n),this.scissorTest=!1,this.viewport=new Zi(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new ec(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=s.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:cl,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,s=this.textures.length;i<s;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 N4(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"})}},Am=class extends Ape{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},jK=class extends ec{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=ko,this.minFilter=ko,this.wrapR=Ru,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Tpe=class extends ec{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=ko,this.minFilter=ko,this.wrapR=Ru,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Eh=class{constructor(e=new mt(1/0,1/0,1/0),n=new mt(-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(Pl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Pl.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=Pl.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 s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=s.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Pl):Pl.fromBufferAttribute(s,o),Pl.applyMatrix4(e.matrixWorld),this.expandByPoint(Pl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Zw.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Zw.copy(r.boundingBox)),Zw.applyMatrix4(e.matrixWorld),this.union(Zw)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],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,Pl),Pl.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(Vx),Jw.subVectors(this.max,Vx),Pp.subVectors(e.a,Vx),Dp.subVectors(e.b,Vx),Rp.subVectors(e.c,Vx),zd.subVectors(Dp,Pp),Ud.subVectors(Rp,Dp),Sf.subVectors(Pp,Rp);let n=[0,-zd.z,zd.y,0,-Ud.z,Ud.y,0,-Sf.z,Sf.y,zd.z,0,-zd.x,Ud.z,0,-Ud.x,Sf.z,0,-Sf.x,-zd.y,zd.x,0,-Ud.y,Ud.x,0,-Sf.y,Sf.x,0];return!PE(n,Pp,Dp,Rp,Jw)||(n=[1,0,0,0,1,0,0,0,1],!PE(n,Pp,Dp,Rp,Jw))?!1:(e_.crossVectors(zd,Ud),n=[e_.x,e_.y,e_.z],PE(n,Pp,Dp,Rp,Jw))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Pl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Pl).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:(su[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),su[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),su[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),su[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),su[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),su[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),su[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),su[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(su),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 su=[new mt,new mt,new mt,new mt,new mt,new mt,new mt,new mt],Pl=new mt,Zw=new Eh,Pp=new mt,Dp=new mt,Rp=new mt,zd=new mt,Ud=new mt,Sf=new mt,Vx=new mt,Jw=new mt,e_=new mt,Nf=new mt;function PE(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){Nf.fromArray(t,s);const l=i.x*Math.abs(Nf.x)+i.y*Math.abs(Nf.y)+i.z*Math.abs(Nf.z),c=e.dot(Nf),u=n.dot(Nf),d=r.dot(Nf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const jpe=new Eh,Gx=new mt,DE=new mt;let Bk=class{constructor(e=new mt,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):jpe.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));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;Gx.subVectors(e,this.center);const n=Gx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Gx,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):(DE.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gx.copy(e.center).add(DE)),this.expandByPoint(Gx.copy(e.center).sub(DE))),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 ou=new mt,RE=new mt,t_=new mt,Bd=new mt,LE=new mt,n_=new mt,OE=new mt;let k4=class{constructor(e=new mt,n=new mt(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,ou)),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=ou.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(ou.copy(this.origin).addScaledVector(this.direction,n),ou.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){RE.copy(e).add(n).multiplyScalar(.5),t_.copy(n).sub(e).normalize(),Bd.copy(this.origin).sub(RE);const s=e.distanceTo(n)*.5,o=-this.direction.dot(t_),l=Bd.dot(this.direction),c=-Bd.dot(t_),u=Bd.lengthSq(),d=Math.abs(1-o*o);let h,p,m,x;if(d>0)if(h=o*c-l,p=o*l-c,x=s*d,h>=0)if(p>=-x)if(p<=x){const y=1/d;h*=y,p*=y,m=h*(h+o*p+2*l)+p*(o*h+p+2*c)+u}else p=s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p=-s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p<=-x?(h=Math.max(0,-(-o*s+l)),p=h>0?-s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u):p<=x?(h=0,p=Math.min(Math.max(-s,-c),s),m=p*(p+2*c)+u):(h=Math.max(0,-(o*s+l)),p=h>0?s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u);else p=o>0?-s:s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(RE).addScaledVector(t_,p),m}intersectSphere(e,n){ou.subVectors(e.center,this.origin);const r=ou.dot(this.direction),i=ou.dot(ou)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-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,s,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(s=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(l=(e.min.z-p.z)*h,c=(e.max.z-p.z)*h):(l=(e.max.z-p.z)*h,c=(e.min.z-p.z)*h),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,ou)!==null}intersectTriangle(e,n,r,i,s){LE.subVectors(n,e),n_.subVectors(r,e),OE.crossVectors(LE,n_);let o=this.direction.dot(OE),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Bd.subVectors(this.origin,e);const c=l*this.direction.dot(n_.crossVectors(Bd,n_));if(c<0)return null;const u=l*this.direction.dot(LE.cross(Bd));if(u<0||c+u>o)return null;const d=-l*Bd.dot(OE);return d<0?null:this.at(d/o,s)}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)}},na=class L3{constructor(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,b){L3.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,s,o,l,c,u,d,h,p,m,x,y,b)}set(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,b){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=s,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=h,v[14]=p,v[3]=m,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 L3().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/Lp.setFromMatrixColumn(e,0).length(),s=1/Lp.setFromMatrixColumn(e,1).length(),o=1/Lp.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]*s,n[5]=r[5]*s,n[6]=r[6]*s,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,s=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=o*d,m=o*h,x=l*d,y=l*h;n[0]=c*d,n[4]=-c*h,n[8]=u,n[1]=m+x*u,n[5]=p-y*u,n[9]=-l*c,n[2]=y-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*h,x=u*d,y=u*h;n[0]=p+y*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*h,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=y+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*h,x=u*d,y=u*h;n[0]=p-y*l,n[4]=-o*h,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=y-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*h,x=l*d,y=l*h;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+y,n[1]=c*h,n[5]=y*u+p,n[9]=m*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-p*h,n[8]=x*h+m,n[1]=h,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*h+x,n[10]=p-y*h}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-h,n[8]=u*d,n[1]=p*h+y,n[5]=o*d,n[9]=m*h-x,n[2]=x*h-m,n[6]=l*d,n[10]=y*h+p}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(Ppe,e,Dpe)}lookAt(e,n,r){const i=this.elements;return po.subVectors(e,n),po.lengthSq()===0&&(po.z=1),po.normalize(),$d.crossVectors(r,po),$d.lengthSq()===0&&(Math.abs(r.z)===1?po.x+=1e-4:po.z+=1e-4,po.normalize(),$d.crossVectors(r,po)),$d.normalize(),r_.crossVectors(po,$d),i[0]=$d.x,i[4]=r_.x,i[8]=po.x,i[1]=$d.y,i[5]=r_.y,i[9]=po.y,i[2]=$d.z,i[6]=r_.z,i[10]=po.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,s=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],h=r[5],p=r[9],m=r[13],x=r[2],y=r[6],b=r[10],v=r[14],S=r[3],k=r[7],E=r[11],N=r[15],A=i[0],M=i[4],P=i[8],T=i[12],j=i[1],z=i[5],F=i[9],$=i[13],D=i[2],H=i[6],q=i[10],I=i[14],K=i[3],Z=i[7],se=i[11],V=i[15];return s[0]=o*A+l*j+c*D+u*K,s[4]=o*M+l*z+c*H+u*Z,s[8]=o*P+l*F+c*q+u*se,s[12]=o*T+l*$+c*I+u*V,s[1]=d*A+h*j+p*D+m*K,s[5]=d*M+h*z+p*H+m*Z,s[9]=d*P+h*F+p*q+m*se,s[13]=d*T+h*$+p*I+m*V,s[2]=x*A+y*j+b*D+v*K,s[6]=x*M+y*z+b*H+v*Z,s[10]=x*P+y*F+b*q+v*se,s[14]=x*T+y*$+b*I+v*V,s[3]=S*A+k*j+E*D+N*K,s[7]=S*M+k*z+E*H+N*Z,s[11]=S*P+k*F+E*q+N*se,s[15]=S*T+k*$+E*I+N*V,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],s=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],h=e[6],p=e[10],m=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+s*c*h-i*u*h-s*l*p+r*u*p+i*l*m-r*c*m)+y*(+n*c*m-n*u*p+s*o*p-i*o*m+i*u*d-s*c*d)+b*(+n*u*h-n*l*m-s*o*h+r*o*m+s*l*d-r*u*d)+v*(-i*l*d-n*c*h+n*l*p+i*o*h-r*o*p+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],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=e[9],p=e[10],m=e[11],x=e[12],y=e[13],b=e[14],v=e[15],S=h*b*u-y*p*u+y*c*m-l*b*m-h*c*v+l*p*v,k=x*p*u-d*b*u-x*c*m+o*b*m+d*c*v-o*p*v,E=d*y*u-x*h*u+x*l*m-o*y*m-d*l*v+o*h*v,N=x*h*c-d*y*c-x*l*p+o*y*p+d*l*b-o*h*b,A=n*S+r*k+i*E+s*N;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/A;return e[0]=S*M,e[1]=(y*p*s-h*b*s-y*i*m+r*b*m+h*i*v-r*p*v)*M,e[2]=(l*b*s-y*c*s+y*i*u-r*b*u-l*i*v+r*c*v)*M,e[3]=(h*c*s-l*p*s-h*i*u+r*p*u+l*i*m-r*c*m)*M,e[4]=k*M,e[5]=(d*b*s-x*p*s+x*i*m-n*b*m-d*i*v+n*p*v)*M,e[6]=(x*c*s-o*b*s-x*i*u+n*b*u+o*i*v-n*c*v)*M,e[7]=(o*p*s-d*c*s+d*i*u-n*p*u-o*i*m+n*c*m)*M,e[8]=E*M,e[9]=(x*h*s-d*y*s-x*r*m+n*y*m+d*r*v-n*h*v)*M,e[10]=(o*y*s-x*l*s+x*r*u-n*y*u-o*r*v+n*l*v)*M,e[11]=(d*l*s-o*h*s-d*r*u+n*h*u+o*r*m-n*l*m)*M,e[12]=N*M,e[13]=(d*y*i-x*h*i+x*r*p-n*y*p-d*r*b+n*h*b)*M,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*M,e[15]=(o*h*i-d*l*i+d*r*c-n*h*c-o*r*p+n*l*p)*M,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,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),s=1-r,o=e.x,l=e.y,c=e.z,u=s*o,d=s*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,s*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,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,l=n._z,c=n._w,u=s+s,d=o+o,h=l+l,p=s*u,m=s*d,x=s*h,y=o*d,b=o*h,v=l*h,S=c*u,k=c*d,E=c*h,N=r.x,A=r.y,M=r.z;return i[0]=(1-(y+v))*N,i[1]=(m+E)*N,i[2]=(x-k)*N,i[3]=0,i[4]=(m-E)*A,i[5]=(1-(p+v))*A,i[6]=(b+S)*A,i[7]=0,i[8]=(x+k)*M,i[9]=(b-S)*M,i[10]=(1-(p+y))*M,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 s=Lp.set(i[0],i[1],i[2]).length();const o=Lp.set(i[4],i[5],i[6]).length(),l=Lp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Dl.copy(this);const u=1/s,d=1/o,h=1/l;return Dl.elements[0]*=u,Dl.elements[1]*=u,Dl.elements[2]*=u,Dl.elements[4]*=d,Dl.elements[5]*=d,Dl.elements[6]*=d,Dl.elements[8]*=h,Dl.elements[9]*=h,Dl.elements[10]*=h,n.setFromRotationMatrix(Dl),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=_c,c=!1){const u=this.elements,d=2*s/(n-e),h=2*s/(r-i),p=(n+e)/(n-e),m=(r+i)/(r-i);let x,y;if(c)x=s/(o-s),y=o*s/(o-s);else if(l===_c)x=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(l===p1)x=-o/(o-s),y=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=p,u[12]=0,u[1]=0,u[5]=h,u[9]=m,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,s,o,l=_c,c=!1){const u=this.elements,d=2/(n-e),h=2/(r-i),p=-(n+e)/(n-e),m=-(r+i)/(r-i);let x,y;if(c)x=1/(o-s),y=o/(o-s);else if(l===_c)x=-2/(o-s),y=-(o+s)/(o-s);else if(l===p1)x=-1/(o-s),y=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=p,u[1]=0,u[5]=h,u[9]=0,u[13]=m,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 Lp=new mt,Dl=new na,Ppe=new mt(0,0,0),Dpe=new mt(1,1,1),$d=new mt,r_=new mt,po=new mt,PB=new na,DB=new Em;let Uh=class PK{constructor(e=0,n=0,r=0,i=PK.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,s=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],h=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Gn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Gn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Gn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Gn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Gn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Gn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:vn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return PB.makeRotationFromQuaternion(e),this.setFromRotationMatrix(PB,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return DB.setFromEuler(this),this.setFromQuaternion(DB,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}};Uh.DEFAULT_ORDER="XYZ";let DK=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}},Rpe=0;const RB=new mt,Op=new Em,lu=new na,i_=new mt,qx=new mt,Lpe=new mt,Ope=new Em,LB=new mt(1,0,0),OB=new mt(0,1,0),FB=new mt(0,0,1),IB={type:"added"},Fpe={type:"removed"},Fp={type:"childadded",child:null},FE={type:"childremoved",child:null};let Do=class BS extends qm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Rpe++}),this.uuid=Y0(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=BS.DEFAULT_UP.clone();const e=new mt,n=new Uh,r=new Em,i=new mt(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),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 na},normalMatrix:{value:new Fn}}),this.matrix=new na,this.matrixWorld=new na,this.matrixAutoUpdate=BS.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=BS.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new DK,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 Op.setFromAxisAngle(e,n),this.quaternion.multiply(Op),this}rotateOnWorldAxis(e,n){return Op.setFromAxisAngle(e,n),this.quaternion.premultiply(Op),this}rotateX(e){return this.rotateOnAxis(LB,e)}rotateY(e){return this.rotateOnAxis(OB,e)}rotateZ(e){return this.rotateOnAxis(FB,e)}translateOnAxis(e,n){return RB.copy(e).applyQuaternion(this.quaternion),this.position.add(RB.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(LB,e)}translateY(e){return this.translateOnAxis(OB,e)}translateZ(e){return this.translateOnAxis(FB,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(lu.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?i_.copy(e):i_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),qx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?lu.lookAt(qx,i_,this.up):lu.lookAt(i_,qx,this.up),this.quaternion.setFromRotationMatrix(lu),i&&(lu.extractRotation(i.matrixWorld),Op.setFromRotationMatrix(lu),this.quaternion.premultiply(Op.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(zi("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(IB),Fp.child=e,this.dispatchEvent(Fp),Fp.child=null):zi("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(Fpe),FE.child=e,this.dispatchEvent(FE),FE.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),lu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),lu.multiply(e.parent.matrixWorld)),e.applyMatrix4(lu),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(IB),Fp.child=e,this.dispatchEvent(Fp),Fp.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 s=0,o=i.length;s<o;s++)i[s].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(qx,e,Lpe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qx,Ope,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 s=0,o=i.length;s<o;s++)i[s].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 s(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=s(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 h=c[u];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(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(s(e.materials,this.material[c]));i.material=l}else i.material=s(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(s(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),h=o(e.shapes),p=o(e.skeletons),m=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),h.length>0&&(r.shapes=h),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),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}};Do.DEFAULT_UP=new mt(0,1,0);Do.DEFAULT_MATRIX_AUTO_UPDATE=!0;Do.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Rl=new mt,cu=new mt,IE=new mt,uu=new mt,Ip=new mt,zp=new mt,zB=new mt,zE=new mt,UE=new mt,BE=new mt,$E=new Zi,HE=new Zi,VE=new Zi;let Wx=class yg{constructor(e=new mt,n=new mt,r=new mt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Rl.subVectors(e,n),i.cross(Rl);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){Rl.subVectors(i,n),cu.subVectors(r,n),IE.subVectors(e,n);const o=Rl.dot(Rl),l=Rl.dot(cu),c=Rl.dot(IE),u=cu.dot(cu),d=cu.dot(IE),h=o*u-l*l;if(h===0)return s.set(0,0,0),null;const p=1/h,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,uu)===null?!1:uu.x>=0&&uu.y>=0&&uu.x+uu.y<=1}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,uu)===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(s,uu.x),c.addScaledVector(o,uu.y),c.addScaledVector(l,uu.z),c)}static getInterpolatedAttribute(e,n,r,i,s,o){return $E.setScalar(0),HE.setScalar(0),VE.setScalar(0),$E.fromBufferAttribute(e,n),HE.fromBufferAttribute(e,r),VE.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector($E,s.x),o.addScaledVector(HE,s.y),o.addScaledVector(VE,s.z),o}static isFrontFacing(e,n,r,i){return Rl.subVectors(r,n),cu.subVectors(e,n),Rl.cross(cu).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 Rl.subVectors(this.c,this.b),cu.subVectors(this.a,this.b),Rl.cross(cu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yg.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return yg.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return yg.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return yg.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yg.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let o,l;Ip.subVectors(i,r),zp.subVectors(s,r),zE.subVectors(e,r);const c=Ip.dot(zE),u=zp.dot(zE);if(c<=0&&u<=0)return n.copy(r);UE.subVectors(e,i);const d=Ip.dot(UE),h=zp.dot(UE);if(d>=0&&h<=d)return n.copy(i);const p=c*h-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Ip,o);BE.subVectors(e,s);const m=Ip.dot(BE),x=zp.dot(BE);if(x>=0&&m<=x)return n.copy(s);const y=m*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(zp,l);const b=d*x-m*h;if(b<=0&&h-d>=0&&m-x>=0)return zB.subVectors(s,i),l=(h-d)/(h-d+(m-x)),n.copy(i).addScaledVector(zB,l);const v=1/(b+y+p);return o=y*v,l=p*v,n.copy(r).addScaledVector(Ip,o).addScaledVector(zp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const RK={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},Hd={h:0,s:0,l:0},a_={h:0,s:0,l:0};function GE(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 In=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=yo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,cr.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=cr.workingColorSpace){return this.r=e,this.g=n,this.b=r,cr.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=cr.workingColorSpace){if(e=Spe(e,1),n=Gn(n,0,1),r=Gn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=GE(o,s,e+1/3),this.g=GE(o,s,e),this.b=GE(o,s,e-1/3)}return cr.colorSpaceToWorking(this,i),this}setStyle(e,n=yo){function r(s){s!==void 0&&parseFloat(s)<1&&vn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:vn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);vn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=yo){const r=RK[e.toLowerCase()];return r!==void 0?this.setHex(r,n):vn("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=$u(e.r),this.g=$u(e.g),this.b=$u(e.b),this}copyLinearToSRGB(e){return this.r=zg(e.r),this.g=zg(e.g),this.b=zg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yo){return cr.workingToColorSpace(is.copy(this),e),Math.round(Gn(is.r*255,0,255))*65536+Math.round(Gn(is.g*255,0,255))*256+Math.round(Gn(is.b*255,0,255))}getHexString(e=yo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=cr.workingColorSpace){cr.workingToColorSpace(is.copy(this),n);const r=is.r,i=is.g,s=is.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const h=o-l;switch(u=d<=.5?h/(o+l):h/(2-o-l),o){case r:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-r)/h+2;break;case s:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=cr.workingColorSpace){return cr.workingToColorSpace(is.copy(this),n),e.r=is.r,e.g=is.g,e.b=is.b,e}getStyle(e=yo){cr.workingToColorSpace(is.copy(this),e);const n=is.r,r=is.g,i=is.b;return e!==yo?`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(Hd),this.setHSL(Hd.h+e,Hd.s+n,Hd.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(Hd),e.getHSL(a_);const r=CE(Hd.h,a_.h,n),i=CE(Hd.s,a_.s,n),s=CE(Hd.l,a_.l,n);return this.setHSL(r,i,s),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,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[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 is=new In;In.NAMES=RK;let Ipe=0,Lb=class extends qm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ipe++}),this.uuid=Y0(),this.name="",this.type="Material",this.blending=Ig,this.side=zh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=WP,this.blendDst=KP,this.blendEquation=$f,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new In(0,0,0),this.blendAlpha=0,this.depthFunc=nb,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=NB,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Tp,this.stencilZFail=Tp,this.stencilZPass=Tp,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){vn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){vn(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Ig&&(r.blending=this.blending),this.side!==zh&&(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!==WP&&(r.blendSrc=this.blendSrc),this.blendDst!==KP&&(r.blendDst=this.blendDst),this.blendEquation!==$f&&(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!==nb&&(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!==NB&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Tp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Tp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Tp&&(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(s){const o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),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 s=0;s!==i;++s)r[s]=n[s].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++}},M4=class extends Lb{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new In(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 Uh,this.combine=g4,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const Wi=new mt,s_=new Rn;let zpe=0,Ts=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:zpe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=kB,this.updateRanges=[],this.gpuType=Lu,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,s=this.itemSize;i<s;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++)s_.fromBufferAttribute(this,n),s_.applyMatrix3(e),this.setXY(n,s_.x,s_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Wi.fromBufferAttribute(this,n),Wi.applyMatrix3(e),this.setXYZ(n,Wi.x,Wi.y,Wi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Wi.fromBufferAttribute(this,n),Wi.applyMatrix4(e),this.setXYZ(n,Wi.x,Wi.y,Wi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Wi.fromBufferAttribute(this,n),Wi.applyNormalMatrix(e),this.setXYZ(n,Wi.x,Wi.y,Wi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Wi.fromBufferAttribute(this,n),Wi.transformDirection(e),this.setXYZ(n,Wi.x,Wi.y,Wi.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=Hx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Hs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Hx(n,this.array)),n}setX(e,n){return this.normalized&&(n=Hs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Hx(n,this.array)),n}setY(e,n){return this.normalized&&(n=Hs(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=Hx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Hs(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=Hx(n,this.array)),n}setW(e,n){return this.normalized&&(n=Hs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Hs(n,this.array),r=Hs(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=Hs(n,this.array),r=Hs(r,this.array),i=Hs(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Hs(n,this.array),r=Hs(r,this.array),i=Hs(i,this.array),s=Hs(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,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!==kB&&(e.usage=this.usage),e}},LK=class extends Ts{constructor(e,n,r){super(new Uint16Array(e),n,r)}},OK=class extends Ts{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Mo=class extends Ts{constructor(e,n,r){super(new Float32Array(e),n,r)}},Upe=0;const qo=new na,qE=new Do,Up=new mt,go=new Eh,Kx=new Eh,ka=new mt;let gl=class FK extends qm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Upe++}),this.uuid=Y0(),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(MK(e)?OK:LK)(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 s=new Fn().getNormalMatrix(e);r.applyNormalMatrix(s),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 qo.makeRotationFromQuaternion(e),this.applyMatrix4(qo),this}rotateX(e){return qo.makeRotationX(e),this.applyMatrix4(qo),this}rotateY(e){return qo.makeRotationY(e),this.applyMatrix4(qo),this}rotateZ(e){return qo.makeRotationZ(e),this.applyMatrix4(qo),this}translate(e,n,r){return qo.makeTranslation(e,n,r),this.applyMatrix4(qo),this}scale(e,n,r){return qo.makeScale(e,n,r),this.applyMatrix4(qo),this}lookAt(e){return qE.lookAt(e),qE.updateMatrix(),this.applyMatrix4(qE.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Up).negate(),this.translate(Up.x,Up.y,Up.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Mo(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&vn("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 Eh);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){zi("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new mt(-1/0,-1/0,-1/0),new mt(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 s=n[r];go.setFromBufferAttribute(s),this.morphTargetsRelative?(ka.addVectors(this.boundingBox.min,go.min),this.boundingBox.expandByPoint(ka),ka.addVectors(this.boundingBox.max,go.max),this.boundingBox.expandByPoint(ka)):(this.boundingBox.expandByPoint(go.min),this.boundingBox.expandByPoint(go.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&zi('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 Bk);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){zi("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new mt,1/0);return}if(e){const r=this.boundingSphere.center;if(go.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];Kx.setFromBufferAttribute(l),this.morphTargetsRelative?(ka.addVectors(go.min,Kx.min),go.expandByPoint(ka),ka.addVectors(go.max,Kx.max),go.expandByPoint(ka)):(go.expandByPoint(Kx.min),go.expandByPoint(Kx.max))}go.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)ka.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(ka));if(n)for(let s=0,o=n.length;s<o;s++){const l=n[s],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)ka.fromBufferAttribute(l,u),c&&(Up.fromBufferAttribute(e,u),ka.add(Up)),i=Math.max(i,r.distanceToSquared(ka))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&zi('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){zi("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ts(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let P=0;P<r.count;P++)l[P]=new mt,c[P]=new mt;const u=new mt,d=new mt,h=new mt,p=new Rn,m=new Rn,x=new Rn,y=new mt,b=new mt;function v(P,T,j){u.fromBufferAttribute(r,P),d.fromBufferAttribute(r,T),h.fromBufferAttribute(r,j),p.fromBufferAttribute(s,P),m.fromBufferAttribute(s,T),x.fromBufferAttribute(s,j),d.sub(u),h.sub(u),m.sub(p),x.sub(p);const z=1/(m.x*x.y-x.x*m.y);isFinite(z)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(h,-m.y).multiplyScalar(z),b.copy(h).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(z),l[P].add(y),l[T].add(y),l[j].add(y),c[P].add(b),c[T].add(b),c[j].add(b))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let P=0,T=S.length;P<T;++P){const j=S[P],z=j.start,F=j.count;for(let $=z,D=z+F;$<D;$+=3)v(e.getX($+0),e.getX($+1),e.getX($+2))}const k=new mt,E=new mt,N=new mt,A=new mt;function M(P){N.fromBufferAttribute(i,P),A.copy(N);const T=l[P];k.copy(T),k.sub(N.multiplyScalar(N.dot(T))).normalize(),E.crossVectors(A,T);const z=E.dot(c[P])<0?-1:1;o.setXYZW(P,k.x,k.y,k.z,z)}for(let P=0,T=S.length;P<T;++P){const j=S[P],z=j.start,F=j.count;for(let $=z,D=z+F;$<D;$+=3)M(e.getX($+0)),M(e.getX($+1)),M(e.getX($+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 Ts(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,m=r.count;p<m;p++)r.setXYZ(p,0,0,0);const i=new mt,s=new mt,o=new mt,l=new mt,c=new mt,u=new mt,d=new mt,h=new mt;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),y=e.getX(p+1),b=e.getX(p+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),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 p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),s.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+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++)ka.fromBufferAttribute(e,n),ka.normalize(),e.setXYZ(n,ka.x,ka.y,ka.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,h=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?m=c[y]*l.data.stride+l.offset:m=c[y]*d;for(let v=0;v<d;v++)p[x++]=u[m++]}return new Ts(p,d,h)}if(this.index===null)return vn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new FK,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 s=this.morphAttributes;for(const l in s){const c=[],u=s[l];for(let d=0,h=u.length;d<h;d++){const p=u[d],m=e(p,r);c.push(m)}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 s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let h=0,p=u.length;h<p;h++){const m=u[h];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(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 s=e.morphAttributes;for(const u in s){const d=[],h=s[u];for(let p=0,m=h.length;p<m;p++)d.push(h[p].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 h=o[u];this.addGroup(h.start,h.count,h.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 UB=new na,kf=new k4,o_=new Bk,BB=new mt,l_=new mt,c_=new mt,u_=new mt,WE=new mt,d_=new mt,$B=new mt,h_=new mt;let bl=class extends Do{constructor(e=new gl,n=new M4){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 s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(s&&l){d_.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],h=s[c];d!==0&&(WE.fromBufferAttribute(h,e),o?d_.addScaledVector(WE,d):d_.addScaledVector(WE.sub(n),d))}n.add(d_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),o_.copy(r.boundingSphere),o_.applyMatrix4(s),kf.copy(e.ray).recast(e.near),!(o_.containsPoint(kf.origin)===!1&&(kf.intersectSphere(o_,BB)===null||kf.origin.distanceToSquared(BB)>(e.far-e.near)**2))&&(UB.copy(s).invert(),kf.copy(e.ray).applyMatrix4(UB),!(r.boundingBox!==null&&kf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,kf)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,p=s.groups,m=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=p.length;x<y;x++){const b=p[x],v=o[b.materialIndex],S=Math.max(b.start,m.start),k=Math.min(l.count,Math.min(b.start+b.count,m.start+m.count));for(let E=S,N=k;E<N;E+=3){const A=l.getX(E),M=l.getX(E+1),P=l.getX(E+2);i=f_(this,v,e,r,u,d,h,A,M,P),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let b=x,v=y;b<v;b+=3){const S=l.getX(b),k=l.getX(b+1),E=l.getX(b+2);i=f_(this,o,e,r,u,d,h,S,k,E),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=p.length;x<y;x++){const b=p[x],v=o[b.materialIndex],S=Math.max(b.start,m.start),k=Math.min(c.count,Math.min(b.start+b.count,m.start+m.count));for(let E=S,N=k;E<N;E+=3){const A=E,M=E+1,P=E+2;i=f_(this,v,e,r,u,d,h,A,M,P),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let b=x,v=y;b<v;b+=3){const S=b,k=b+1,E=b+2;i=f_(this,o,e,r,u,d,h,S,k,E),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function Bpe(t,e,n,r,i,s,o,l){let c;if(e.side===Qs?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===zh,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 f_(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,l_),t.getVertexPosition(c,c_),t.getVertexPosition(u,u_);const d=Bpe(t,e,n,r,l_,c_,u_,$B);if(d){const h=new mt;Wx.getBarycoord($B,l_,c_,u_,h),i&&(d.uv=Wx.getInterpolatedAttribute(i,l,c,u,h,new Rn)),s&&(d.uv1=Wx.getInterpolatedAttribute(s,l,c,u,h,new Rn)),o&&(d.normal=Wx.getInterpolatedAttribute(o,l,c,u,h,new mt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:c,c:u,normal:new mt,materialIndex:0};Wx.getNormal(l_,c_,u_,p.normal),d.face=p,d.barycoord=h}return d}let C4=class IK extends gl{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const l=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],u=[],d=[],h=[];let p=0,m=0;x("z","y","x",-1,-1,r,n,e,o,s,0),x("z","y","x",1,-1,r,n,-e,o,s,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,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new Mo(u,3)),this.setAttribute("normal",new Mo(d,3)),this.setAttribute("uv",new Mo(h,2));function x(y,b,v,S,k,E,N,A,M,P,T){const j=E/M,z=N/P,F=E/2,$=N/2,D=A/2,H=M+1,q=P+1;let I=0,K=0;const Z=new mt;for(let se=0;se<q;se++){const V=se*z-$;for(let W=0;W<H;W++){const ie=W*j-F;Z[y]=ie*S,Z[b]=V*k,Z[v]=D,u.push(Z.x,Z.y,Z.z),Z[y]=0,Z[b]=0,Z[v]=A>0?1:-1,d.push(Z.x,Z.y,Z.z),h.push(W/M),h.push(1-se/P),I+=1}}for(let se=0;se<P;se++)for(let V=0;V<M;V++){const W=p+V+H*se,ie=p+V+H*(se+1),J=p+(V+1)+H*(se+1),pe=p+(V+1)+H*se;c.push(W,ie,pe),c.push(ie,J,pe),K+=6}l.addGroup(m,K,T),m+=K,p+=I}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new IK(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function sb(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?(vn("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 Ss(t){const e={};for(let n=0;n<t.length;n++){const r=sb(t[n]);for(const i in r)e[i]=r[i]}return e}function $pe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function zK(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:cr.workingColorSpace}const Hpe={clone:sb,merge:Ss};var Vpe=`void main() {
  11. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  12. }`,Gpe=`void main() {
  13. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  14. }`;let ed=class extends Lb{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Vpe,this.fragmentShader=Gpe,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=sb(e.uniforms),this.uniformsGroups=$pe(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}},UK=class extends Do{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new na,this.projectionMatrix=new na,this.projectionMatrixInverse=new na,this.coordinateSystem=_c,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 Vd=new mt,HB=new Rn,VB=new Rn;let il=class extends UK{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=R3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(zS*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return R3*2*Math.atan(Math.tan(zS*.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){Vd.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Vd.x,Vd.y).multiplyScalar(-e/Vd.z),Vd.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Vd.x,Vd.y).multiplyScalar(-e/Vd.z)}getViewSize(e,n){return this.getViewBounds(e,HB,VB),n.subVectors(VB,HB)}setViewOffset(e,n,r,i,s,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=s,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(zS*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+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 Bp=-90,$p=1;let qpe=class extends Do{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new il(Bp,$p,e,n);i.layers=this.layers,this.add(i);const s=new il(Bp,$p,e,n);s.layers=this.layers,this.add(s);const o=new il(Bp,$p,e,n);o.layers=this.layers,this.add(o);const l=new il(Bp,$p,e,n);l.layers=this.layers,this.add(l);const c=new il(Bp,$p,e,n);c.layers=this.layers,this.add(c);const u=new il(Bp,$p,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const u of n)this.remove(u);if(e===_c)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.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===p1)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.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[s,o,l,c,u,d]=this.children,h=e.getRenderTarget(),p=e.getActiveCubeFace(),m=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,s),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(h,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},BK=class extends ec{constructor(e=[],n=rb,r,i,s,o,l,c,u,d){super(e,n,r,i,s,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Wpe=class extends Am{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 BK(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:`
  15. varying vec3 vWorldDirection;
  16. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  17. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  18. }
  19. void main() {
  20. vWorldDirection = transformDirection( position, modelMatrix );
  21. #include <begin_vertex>
  22. #include <project_vertex>
  23. }
  24. `,fragmentShader:`
  25. uniform sampler2D tEquirect;
  26. varying vec3 vWorldDirection;
  27. #include <common>
  28. void main() {
  29. vec3 direction = normalize( vWorldDirection );
  30. vec2 sampleUV = equirectUv( direction );
  31. gl_FragColor = texture2D( tEquirect, sampleUV );
  32. }
  33. `},i=new C4(5,5,5),s=new ed({name:"CubemapFromEquirect",uniforms:sb(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Qs,blending:Bu});s.uniforms.tEquirect.value=n;const o=new bl(i,s),l=n.minFilter;return n.minFilter===Qf&&(n.minFilter=cl),new qpe(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 s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}},Cg=class extends Do{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Kpe={type:"move"};let KE=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Cg,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 Cg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new mt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new mt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Cg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new mt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new mt),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,s=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"],h=u.joints["thumb-tip"],p=d.position.distanceTo(h.position),m=.02,x=.005;u.inputState.pinching&&p>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),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(Kpe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Cg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},Xpe=class extends Do{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 Uh,this.environmentIntensity=1,this.environmentRotation=new Uh,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}},Ype=class extends ec{constructor(e=null,n=1,r=1,i,s,o,l,c,u=ko,d=ko,h,p){super(null,o,l,c,u,d,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const XE=new mt,Qpe=new mt,Zpe=new Fn;let nh=class{constructor(e=new mt(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=XE.subVectors(r,n).cross(Qpe.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(XE),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}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||Zpe.getNormalMatrix(e),i=this.coplanarPoint(XE).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),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 Mf=new Bk,Jpe=new Rn(.5,.5),m_=new mt;let E4=class{constructor(e=new nh,n=new nh,r=new nh,i=new nh,s=new nh,o=new nh){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,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(s),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=_c,r=!1){const i=this.planes,s=e.elements,o=s[0],l=s[1],c=s[2],u=s[3],d=s[4],h=s[5],p=s[6],m=s[7],x=s[8],y=s[9],b=s[10],v=s[11],S=s[12],k=s[13],E=s[14],N=s[15];if(i[0].setComponents(u-o,m-d,v-x,N-S).normalize(),i[1].setComponents(u+o,m+d,v+x,N+S).normalize(),i[2].setComponents(u+l,m+h,v+y,N+k).normalize(),i[3].setComponents(u-l,m-h,v-y,N-k).normalize(),r)i[4].setComponents(c,p,b,E).normalize(),i[5].setComponents(u-c,m-p,v-b,N-E).normalize();else if(i[4].setComponents(u-c,m-p,v-b,N-E).normalize(),n===_c)i[5].setComponents(u+c,m+p,v+b,N+E).normalize();else if(n===p1)i[5].setComponents(c,p,b,E).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Mf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Mf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Mf)}intersectsSprite(e){Mf.center.set(0,0,0);const n=Jpe.distanceTo(e.center);return Mf.radius=.7071067811865476+n,Mf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mf)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].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(m_.x=i.normal.x>0?e.max.x:e.min.x,m_.y=i.normal.y>0?e.max.y:e.min.y,m_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(m_)<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)}},$K=class extends Lb{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new In(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 b1=new mt,x1=new mt,GB=new na,Xx=new k4,p_=new Bk,YE=new mt,qB=new mt;let ege=class extends Do{constructor(e=new gl,n=new $K){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,s=n.count;i<s;i++)b1.fromBufferAttribute(n,i-1),x1.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=b1.distanceTo(x1);e.setAttribute("lineDistance",new Mo(r,1))}else vn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),p_.copy(r.boundingSphere),p_.applyMatrix4(i),p_.radius+=s,e.ray.intersectsSphere(p_)===!1)return;GB.copy(i).invert(),Xx.copy(e.ray).applyMatrix4(GB);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,p=r.attributes.position;if(d!==null){const m=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let y=m,b=x-1;y<b;y+=u){const v=d.getX(y),S=d.getX(y+1),k=g_(this,e,Xx,c,v,S,y);k&&n.push(k)}if(this.isLineLoop){const y=d.getX(x-1),b=d.getX(m),v=g_(this,e,Xx,c,y,b,x-1);v&&n.push(v)}}else{const m=Math.max(0,o.start),x=Math.min(p.count,o.start+o.count);for(let y=m,b=x-1;y<b;y+=u){const v=g_(this,e,Xx,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=g_(this,e,Xx,c,x-1,m,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 s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}};function g_(t,e,n,r,i,s,o){const l=t.geometry.attributes.position;if(b1.fromBufferAttribute(l,i),x1.fromBufferAttribute(l,s),n.distanceSqToSegment(b1,x1,YE,qB)>r)return;YE.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(YE);if(!(u<e.near||u>e.far))return{distance:u,point:qB.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const WB=new mt,KB=new mt;let tge=class extends ege{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,s=n.count;i<s;i+=2)WB.fromBufferAttribute(n,i),KB.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+WB.distanceTo(KB);e.setAttribute("lineDistance",new Mo(r,1))}else vn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},HK=class extends ec{constructor(e,n,r=Cm,i,s,o,l=ko,c=ko,u,d=o0,h=1){if(d!==o0&&d!==l0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:n,depth:h};super(p,i,s,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 N4(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 VK extends ec{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let A4=class GK extends gl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,h=e/l,p=n/c,m=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const S=v*p-o;for(let k=0;k<u;k++){const E=k*h-s;x.push(E,-S,0),y.push(0,0,1),b.push(k/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const k=S+u*v,E=S+u*(v+1),N=S+1+u*(v+1),A=S+1+u*v;m.push(k,E,A),m.push(E,N,A)}this.setIndex(m),this.setAttribute("position",new Mo(x,3)),this.setAttribute("normal",new Mo(y,3)),this.setAttribute("uv",new Mo(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new GK(e.width,e.height,e.widthSegments,e.heightSegments)}};class qK extends Lb{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new In(16777215),this.specular=new In(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new In(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=NK,this.normalScale=new Rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Uh,this.combine=g4,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 nge=class extends Lb{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=dpe,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}},rge=class extends Lb{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 XB={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class ige{constructor(e,n,r){const i=this;let s=!1,o=0,l=0,c;const u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=n,this.onError=r,this._abortController=null,this.itemStart=function(d){l++,s===!1&&i.onStart!==void 0&&i.onStart(d,o,l),s=!0},this.itemEnd=function(d){o++,i.onProgress!==void 0&&i.onProgress(d,o,l),o===l&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return c?c(d):d},this.setURLModifier=function(d){return c=d,this},this.addHandler=function(d,h){return u.push(d,h),this},this.removeHandler=function(d){const h=u.indexOf(d);return h!==-1&&u.splice(h,2),this},this.getHandler=function(d){for(let h=0,p=u.length;h<p;h+=2){const m=u[h],x=u[h+1];if(m.global&&(m.lastIndex=0),m.test(d))return x}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const age=new ige;class T4{constructor(e){this.manager=e!==void 0?e:age,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,n){const r=this;return new Promise(function(i,s){r.load(e,i,n,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}T4.DEFAULT_MATERIAL_NAME="__DEFAULT";const du={};class sge extends Error{constructor(e,n){super(e),this.response=n}}class oge extends T4{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,n,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=XB.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{n&&n(s),this.manager.itemEnd(e)},0),s;if(du[e]!==void 0){du[e].push({onLoad:n,onProgress:r,onError:i});return}du[e]=[],du[e].push({onLoad:n,onProgress:r,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),l=this.mimeType,c=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&vn("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;const d=du[e],h=u.body.getReader(),p=u.headers.get("X-File-Size")||u.headers.get("Content-Length"),m=p?parseInt(p):0,x=m!==0;let y=0;const b=new ReadableStream({start(v){S();function S(){h.read().then(({done:k,value:E})=>{if(k)v.close();else{y+=E.byteLength;const N=new ProgressEvent("progress",{lengthComputable:x,loaded:y,total:m});for(let A=0,M=d.length;A<M;A++){const P=d[A];P.onProgress&&P.onProgress(N)}v.enqueue(E),S()}},k=>{v.error(k)})}}});return new Response(b)}else throw new sge(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(c){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(d=>new DOMParser().parseFromString(d,l));case"json":return u.json();default:if(l==="")return u.text();{const h=/charset="?([^;"\s]*)"?/i.exec(l),p=h&&h[1]?h[1].toLowerCase():void 0,m=new TextDecoder(p);return u.arrayBuffer().then(x=>m.decode(x))}}}).then(u=>{XB.add(`file:${e}`,u);const d=du[e];delete du[e];for(let h=0,p=d.length;h<p;h++){const m=d[h];m.onLoad&&m.onLoad(u)}}).catch(u=>{const d=du[e];if(d===void 0)throw this.manager.itemError(e),u;delete du[e];for(let h=0,p=d.length;h<p;h++){const m=d[h];m.onError&&m.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let WK=class extends Do{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new In(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 QE=new na,YB=new mt,QB=new mt;let lge=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Rn(512,512),this.mapType=jc,this.map=null,this.mapPass=null,this.matrix=new na,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new E4,this._frameExtents=new Rn(1,1),this._viewportCount=1,this._viewports=[new Zi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;YB.setFromMatrixPosition(e.matrixWorld),n.position.copy(YB),QB.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(QB),n.updateMatrixWorld(),QE.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(QE,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(QE)}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}},KK=class extends UK{constructor(e=-1,n=1,r=1,i=-1,s=.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=s,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,s,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=s,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 s=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;s+=u*this.view.offsetX,o=s+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(s,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 cge extends lge{constructor(){super(new KK(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class ZB extends WK{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Do.DEFAULT_UP),this.updateMatrix(),this.target=new Do,this.shadow=new cge}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let uge=class extends WK{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},dge=class extends il{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},JB=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=Gn(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(Gn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class hge extends tge{constructor(e=10,n=10,r=4473924,i=8947848){r=new In(r),i=new In(i);const s=n/2,o=e/n,l=e/2,c=[],u=[];for(let p=0,m=0,x=-l;p<=n;p++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const y=p===s?r:i;y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3}const d=new gl;d.setAttribute("position",new Mo(c,3)),d.setAttribute("color",new Mo(u,3));const h=new $K({vertexColors:!0,toneMapped:!1});super(d,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class fge extends qm{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){vn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function e8(t,e,n,r){const i=mge(r);switch(n){case wK:return t*e;case SK:return t*e/i.components*i.byteLength;case v4:return t*e/i.components*i.byteLength;case w4:return t*e*2/i.components*i.byteLength;case _4:return t*e*2/i.components*i.byteLength;case _K:return t*e*3/i.components*i.byteLength;case Vl:return t*e*4/i.components*i.byteLength;case S4:return t*e*4/i.components*i.byteLength;case LS:case OS:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case FS:case IS:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case o3:case c3:return Math.max(t,16)*Math.max(e,8)/4;case s3:case l3:return Math.max(t,8)*Math.max(e,8)/2;case u3:case d3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case h3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case f3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case m3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case p3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case g3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case b3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case x3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case y3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case v3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case w3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case _3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case S3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case N3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case k3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case M3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case C3:case E3:case A3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case T3:case j3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case P3:case D3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function mge(t){switch(t){case jc:case bK:return{byteLength:1,components:1};case a0:case xK:case Rb:return{byteLength:2,components:1};case x4:case y4:return{byteLength:2,components:4};case Cm:case b4:case Lu:return{byteLength:4,components:1};case yK:case vK:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:p4}}));typeof window<"u"&&(window.__THREE__?vn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=p4);function XK(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,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(s){n=s},setContext:function(s){t=s}}}function pge(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,h=u.byteLength,p=t.createBuffer();t.bindBuffer(c,p),t.bufferData(c,u,d),l.onUploadCallback();let m;if(u instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)m=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)m=t.SHORT;else if(u instanceof Uint32Array)m=t.UNSIGNED_INT;else if(u instanceof Int32Array)m=t.INT;else if(u instanceof Int8Array)m=t.BYTE;else if(u instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:p,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:h}}function r(l,c,u){const d=c.array,h=c.updateRanges;if(t.bindBuffer(u,l),h.length===0)t.bufferSubData(u,0,d);else{h.sort((m,x)=>m.start-x.start);let p=0;for(let m=1;m<h.length;m++){const x=h[p],y=h[m];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++p,h[p]=y)}h.length=p+1;for(let m=0,x=h.length;m<x;m++){const y=h[m];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 s(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:s,update:o}}var gge=`#ifdef USE_ALPHAHASH
  34. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  35. #endif`,bge=`#ifdef USE_ALPHAHASH
  36. const float ALPHA_HASH_SCALE = 0.05;
  37. float hash2D( vec2 value ) {
  38. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  39. }
  40. float hash3D( vec3 value ) {
  41. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  42. }
  43. float getAlphaHashThreshold( vec3 position ) {
  44. float maxDeriv = max(
  45. length( dFdx( position.xyz ) ),
  46. length( dFdy( position.xyz ) )
  47. );
  48. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  49. vec2 pixScales = vec2(
  50. exp2( floor( log2( pixScale ) ) ),
  51. exp2( ceil( log2( pixScale ) ) )
  52. );
  53. vec2 alpha = vec2(
  54. hash3D( floor( pixScales.x * position.xyz ) ),
  55. hash3D( floor( pixScales.y * position.xyz ) )
  56. );
  57. float lerpFactor = fract( log2( pixScale ) );
  58. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  59. float a = min( lerpFactor, 1.0 - lerpFactor );
  60. vec3 cases = vec3(
  61. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  62. ( x - 0.5 * a ) / ( 1.0 - a ),
  63. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  64. );
  65. float threshold = ( x < ( 1.0 - a ) )
  66. ? ( ( x < a ) ? cases.x : cases.y )
  67. : cases.z;
  68. return clamp( threshold , 1.0e-6, 1.0 );
  69. }
  70. #endif`,xge=`#ifdef USE_ALPHAMAP
  71. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  72. #endif`,yge=`#ifdef USE_ALPHAMAP
  73. uniform sampler2D alphaMap;
  74. #endif`,vge=`#ifdef USE_ALPHATEST
  75. #ifdef ALPHA_TO_COVERAGE
  76. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  77. if ( diffuseColor.a == 0.0 ) discard;
  78. #else
  79. if ( diffuseColor.a < alphaTest ) discard;
  80. #endif
  81. #endif`,wge=`#ifdef USE_ALPHATEST
  82. uniform float alphaTest;
  83. #endif`,_ge=`#ifdef USE_AOMAP
  84. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  85. reflectedLight.indirectDiffuse *= ambientOcclusion;
  86. #if defined( USE_CLEARCOAT )
  87. clearcoatSpecularIndirect *= ambientOcclusion;
  88. #endif
  89. #if defined( USE_SHEEN )
  90. sheenSpecularIndirect *= ambientOcclusion;
  91. #endif
  92. #if defined( USE_ENVMAP ) && defined( STANDARD )
  93. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  94. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  95. #endif
  96. #endif`,Sge=`#ifdef USE_AOMAP
  97. uniform sampler2D aoMap;
  98. uniform float aoMapIntensity;
  99. #endif`,Nge=`#ifdef USE_BATCHING
  100. #if ! defined( GL_ANGLE_multi_draw )
  101. #define gl_DrawID _gl_DrawID
  102. uniform int _gl_DrawID;
  103. #endif
  104. uniform highp sampler2D batchingTexture;
  105. uniform highp usampler2D batchingIdTexture;
  106. mat4 getBatchingMatrix( const in float i ) {
  107. int size = textureSize( batchingTexture, 0 ).x;
  108. int j = int( i ) * 4;
  109. int x = j % size;
  110. int y = j / size;
  111. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  112. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  113. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  114. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  115. return mat4( v1, v2, v3, v4 );
  116. }
  117. float getIndirectIndex( const in int i ) {
  118. int size = textureSize( batchingIdTexture, 0 ).x;
  119. int x = i % size;
  120. int y = i / size;
  121. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  122. }
  123. #endif
  124. #ifdef USE_BATCHING_COLOR
  125. uniform sampler2D batchingColorTexture;
  126. vec3 getBatchingColor( const in float i ) {
  127. int size = textureSize( batchingColorTexture, 0 ).x;
  128. int j = int( i );
  129. int x = j % size;
  130. int y = j / size;
  131. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  132. }
  133. #endif`,kge=`#ifdef USE_BATCHING
  134. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  135. #endif`,Mge=`vec3 transformed = vec3( position );
  136. #ifdef USE_ALPHAHASH
  137. vPosition = vec3( position );
  138. #endif`,Cge=`vec3 objectNormal = vec3( normal );
  139. #ifdef USE_TANGENT
  140. vec3 objectTangent = vec3( tangent.xyz );
  141. #endif`,Ege=`float G_BlinnPhong_Implicit( ) {
  142. return 0.25;
  143. }
  144. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  145. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  146. }
  147. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  148. vec3 halfDir = normalize( lightDir + viewDir );
  149. float dotNH = saturate( dot( normal, halfDir ) );
  150. float dotVH = saturate( dot( viewDir, halfDir ) );
  151. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  152. float G = G_BlinnPhong_Implicit( );
  153. float D = D_BlinnPhong( shininess, dotNH );
  154. return F * ( G * D );
  155. } // validated`,Age=`#ifdef USE_IRIDESCENCE
  156. const mat3 XYZ_TO_REC709 = mat3(
  157. 3.2404542, -0.9692660, 0.0556434,
  158. -1.5371385, 1.8760108, -0.2040259,
  159. -0.4985314, 0.0415560, 1.0572252
  160. );
  161. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  162. vec3 sqrtF0 = sqrt( fresnel0 );
  163. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  164. }
  165. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  166. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  167. }
  168. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  169. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  170. }
  171. vec3 evalSensitivity( float OPD, vec3 shift ) {
  172. float phase = 2.0 * PI * OPD * 1.0e-9;
  173. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  174. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  175. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  176. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  177. 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 ) );
  178. xyz /= 1.0685e-7;
  179. vec3 rgb = XYZ_TO_REC709 * xyz;
  180. return rgb;
  181. }
  182. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  183. vec3 I;
  184. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  185. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  186. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  187. if ( cosTheta2Sq < 0.0 ) {
  188. return vec3( 1.0 );
  189. }
  190. float cosTheta2 = sqrt( cosTheta2Sq );
  191. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  192. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  193. float T121 = 1.0 - R12;
  194. float phi12 = 0.0;
  195. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  196. float phi21 = PI - phi12;
  197. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  198. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  199. vec3 phi23 = vec3( 0.0 );
  200. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  201. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  202. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  203. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  204. vec3 phi = vec3( phi21 ) + phi23;
  205. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  206. vec3 r123 = sqrt( R123 );
  207. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  208. vec3 C0 = R12 + Rs;
  209. I = C0;
  210. vec3 Cm = Rs - T121;
  211. for ( int m = 1; m <= 2; ++ m ) {
  212. Cm *= r123;
  213. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  214. I += Cm * Sm;
  215. }
  216. return max( I, vec3( 0.0 ) );
  217. }
  218. #endif`,Tge=`#ifdef USE_BUMPMAP
  219. uniform sampler2D bumpMap;
  220. uniform float bumpScale;
  221. vec2 dHdxy_fwd() {
  222. vec2 dSTdx = dFdx( vBumpMapUv );
  223. vec2 dSTdy = dFdy( vBumpMapUv );
  224. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  225. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  226. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  227. return vec2( dBx, dBy );
  228. }
  229. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  230. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  231. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  232. vec3 vN = surf_norm;
  233. vec3 R1 = cross( vSigmaY, vN );
  234. vec3 R2 = cross( vN, vSigmaX );
  235. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  236. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  237. return normalize( abs( fDet ) * surf_norm - vGrad );
  238. }
  239. #endif`,jge=`#if NUM_CLIPPING_PLANES > 0
  240. vec4 plane;
  241. #ifdef ALPHA_TO_COVERAGE
  242. float distanceToPlane, distanceGradient;
  243. float clipOpacity = 1.0;
  244. #pragma unroll_loop_start
  245. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  246. plane = clippingPlanes[ i ];
  247. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  248. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  249. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  250. if ( clipOpacity == 0.0 ) discard;
  251. }
  252. #pragma unroll_loop_end
  253. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  254. float unionClipOpacity = 1.0;
  255. #pragma unroll_loop_start
  256. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  257. plane = clippingPlanes[ i ];
  258. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  259. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  260. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  261. }
  262. #pragma unroll_loop_end
  263. clipOpacity *= 1.0 - unionClipOpacity;
  264. #endif
  265. diffuseColor.a *= clipOpacity;
  266. if ( diffuseColor.a == 0.0 ) discard;
  267. #else
  268. #pragma unroll_loop_start
  269. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  270. plane = clippingPlanes[ i ];
  271. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  272. }
  273. #pragma unroll_loop_end
  274. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  275. bool clipped = true;
  276. #pragma unroll_loop_start
  277. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  278. plane = clippingPlanes[ i ];
  279. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  280. }
  281. #pragma unroll_loop_end
  282. if ( clipped ) discard;
  283. #endif
  284. #endif
  285. #endif`,Pge=`#if NUM_CLIPPING_PLANES > 0
  286. varying vec3 vClipPosition;
  287. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  288. #endif`,Dge=`#if NUM_CLIPPING_PLANES > 0
  289. varying vec3 vClipPosition;
  290. #endif`,Rge=`#if NUM_CLIPPING_PLANES > 0
  291. vClipPosition = - mvPosition.xyz;
  292. #endif`,Lge=`#if defined( USE_COLOR_ALPHA )
  293. diffuseColor *= vColor;
  294. #elif defined( USE_COLOR )
  295. diffuseColor.rgb *= vColor;
  296. #endif`,Oge=`#if defined( USE_COLOR_ALPHA )
  297. varying vec4 vColor;
  298. #elif defined( USE_COLOR )
  299. varying vec3 vColor;
  300. #endif`,Fge=`#if defined( USE_COLOR_ALPHA )
  301. varying vec4 vColor;
  302. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  303. varying vec3 vColor;
  304. #endif`,Ige=`#if defined( USE_COLOR_ALPHA )
  305. vColor = vec4( 1.0 );
  306. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  307. vColor = vec3( 1.0 );
  308. #endif
  309. #ifdef USE_COLOR
  310. vColor *= color;
  311. #endif
  312. #ifdef USE_INSTANCING_COLOR
  313. vColor.xyz *= instanceColor.xyz;
  314. #endif
  315. #ifdef USE_BATCHING_COLOR
  316. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  317. vColor.xyz *= batchingColor.xyz;
  318. #endif`,zge=`#define PI 3.141592653589793
  319. #define PI2 6.283185307179586
  320. #define PI_HALF 1.5707963267948966
  321. #define RECIPROCAL_PI 0.3183098861837907
  322. #define RECIPROCAL_PI2 0.15915494309189535
  323. #define EPSILON 1e-6
  324. #ifndef saturate
  325. #define saturate( a ) clamp( a, 0.0, 1.0 )
  326. #endif
  327. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  328. float pow2( const in float x ) { return x*x; }
  329. vec3 pow2( const in vec3 x ) { return x*x; }
  330. float pow3( const in float x ) { return x*x*x; }
  331. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  332. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  333. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  334. highp float rand( const in vec2 uv ) {
  335. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  336. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  337. return fract( sin( sn ) * c );
  338. }
  339. #ifdef HIGH_PRECISION
  340. float precisionSafeLength( vec3 v ) { return length( v ); }
  341. #else
  342. float precisionSafeLength( vec3 v ) {
  343. float maxComponent = max3( abs( v ) );
  344. return length( v / maxComponent ) * maxComponent;
  345. }
  346. #endif
  347. struct IncidentLight {
  348. vec3 color;
  349. vec3 direction;
  350. bool visible;
  351. };
  352. struct ReflectedLight {
  353. vec3 directDiffuse;
  354. vec3 directSpecular;
  355. vec3 indirectDiffuse;
  356. vec3 indirectSpecular;
  357. };
  358. #ifdef USE_ALPHAHASH
  359. varying vec3 vPosition;
  360. #endif
  361. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  362. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  363. }
  364. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  365. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  366. }
  367. bool isPerspectiveMatrix( mat4 m ) {
  368. return m[ 2 ][ 3 ] == - 1.0;
  369. }
  370. vec2 equirectUv( in vec3 dir ) {
  371. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  372. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  373. return vec2( u, v );
  374. }
  375. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  376. return RECIPROCAL_PI * diffuseColor;
  377. }
  378. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  379. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  380. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  381. }
  382. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  383. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  384. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  385. } // validated`,Uge=`#ifdef ENVMAP_TYPE_CUBE_UV
  386. #define cubeUV_minMipLevel 4.0
  387. #define cubeUV_minTileSize 16.0
  388. float getFace( vec3 direction ) {
  389. vec3 absDirection = abs( direction );
  390. float face = - 1.0;
  391. if ( absDirection.x > absDirection.z ) {
  392. if ( absDirection.x > absDirection.y )
  393. face = direction.x > 0.0 ? 0.0 : 3.0;
  394. else
  395. face = direction.y > 0.0 ? 1.0 : 4.0;
  396. } else {
  397. if ( absDirection.z > absDirection.y )
  398. face = direction.z > 0.0 ? 2.0 : 5.0;
  399. else
  400. face = direction.y > 0.0 ? 1.0 : 4.0;
  401. }
  402. return face;
  403. }
  404. vec2 getUV( vec3 direction, float face ) {
  405. vec2 uv;
  406. if ( face == 0.0 ) {
  407. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  408. } else if ( face == 1.0 ) {
  409. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  410. } else if ( face == 2.0 ) {
  411. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  412. } else if ( face == 3.0 ) {
  413. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  414. } else if ( face == 4.0 ) {
  415. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  416. } else {
  417. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  418. }
  419. return 0.5 * ( uv + 1.0 );
  420. }
  421. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  422. float face = getFace( direction );
  423. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  424. mipInt = max( mipInt, cubeUV_minMipLevel );
  425. float faceSize = exp2( mipInt );
  426. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  427. if ( face > 2.0 ) {
  428. uv.y += faceSize;
  429. face -= 3.0;
  430. }
  431. uv.x += face * faceSize;
  432. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  433. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  434. uv.x *= CUBEUV_TEXEL_WIDTH;
  435. uv.y *= CUBEUV_TEXEL_HEIGHT;
  436. #ifdef texture2DGradEXT
  437. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  438. #else
  439. return texture2D( envMap, uv ).rgb;
  440. #endif
  441. }
  442. #define cubeUV_r0 1.0
  443. #define cubeUV_m0 - 2.0
  444. #define cubeUV_r1 0.8
  445. #define cubeUV_m1 - 1.0
  446. #define cubeUV_r4 0.4
  447. #define cubeUV_m4 2.0
  448. #define cubeUV_r5 0.305
  449. #define cubeUV_m5 3.0
  450. #define cubeUV_r6 0.21
  451. #define cubeUV_m6 4.0
  452. float roughnessToMip( float roughness ) {
  453. float mip = 0.0;
  454. if ( roughness >= cubeUV_r1 ) {
  455. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  456. } else if ( roughness >= cubeUV_r4 ) {
  457. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  458. } else if ( roughness >= cubeUV_r5 ) {
  459. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  460. } else if ( roughness >= cubeUV_r6 ) {
  461. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  462. } else {
  463. mip = - 2.0 * log2( 1.16 * roughness ); }
  464. return mip;
  465. }
  466. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  467. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  468. float mipF = fract( mip );
  469. float mipInt = floor( mip );
  470. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  471. if ( mipF == 0.0 ) {
  472. return vec4( color0, 1.0 );
  473. } else {
  474. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  475. return vec4( mix( color0, color1, mipF ), 1.0 );
  476. }
  477. }
  478. #endif`,Bge=`vec3 transformedNormal = objectNormal;
  479. #ifdef USE_TANGENT
  480. vec3 transformedTangent = objectTangent;
  481. #endif
  482. #ifdef USE_BATCHING
  483. mat3 bm = mat3( batchingMatrix );
  484. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  485. transformedNormal = bm * transformedNormal;
  486. #ifdef USE_TANGENT
  487. transformedTangent = bm * transformedTangent;
  488. #endif
  489. #endif
  490. #ifdef USE_INSTANCING
  491. mat3 im = mat3( instanceMatrix );
  492. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  493. transformedNormal = im * transformedNormal;
  494. #ifdef USE_TANGENT
  495. transformedTangent = im * transformedTangent;
  496. #endif
  497. #endif
  498. transformedNormal = normalMatrix * transformedNormal;
  499. #ifdef FLIP_SIDED
  500. transformedNormal = - transformedNormal;
  501. #endif
  502. #ifdef USE_TANGENT
  503. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  504. #ifdef FLIP_SIDED
  505. transformedTangent = - transformedTangent;
  506. #endif
  507. #endif`,$ge=`#ifdef USE_DISPLACEMENTMAP
  508. uniform sampler2D displacementMap;
  509. uniform float displacementScale;
  510. uniform float displacementBias;
  511. #endif`,Hge=`#ifdef USE_DISPLACEMENTMAP
  512. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  513. #endif`,Vge=`#ifdef USE_EMISSIVEMAP
  514. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  515. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  516. emissiveColor = sRGBTransferEOTF( emissiveColor );
  517. #endif
  518. totalEmissiveRadiance *= emissiveColor.rgb;
  519. #endif`,Gge=`#ifdef USE_EMISSIVEMAP
  520. uniform sampler2D emissiveMap;
  521. #endif`,qge="gl_FragColor = linearToOutputTexel( gl_FragColor );",Wge=`vec4 LinearTransferOETF( in vec4 value ) {
  522. return value;
  523. }
  524. vec4 sRGBTransferEOTF( in vec4 value ) {
  525. 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 );
  526. }
  527. vec4 sRGBTransferOETF( in vec4 value ) {
  528. 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 );
  529. }`,Kge=`#ifdef USE_ENVMAP
  530. #ifdef ENV_WORLDPOS
  531. vec3 cameraToFrag;
  532. if ( isOrthographic ) {
  533. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  534. } else {
  535. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  536. }
  537. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  538. #ifdef ENVMAP_MODE_REFLECTION
  539. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  540. #else
  541. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  542. #endif
  543. #else
  544. vec3 reflectVec = vReflect;
  545. #endif
  546. #ifdef ENVMAP_TYPE_CUBE
  547. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  548. #else
  549. vec4 envColor = vec4( 0.0 );
  550. #endif
  551. #ifdef ENVMAP_BLENDING_MULTIPLY
  552. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  553. #elif defined( ENVMAP_BLENDING_MIX )
  554. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  555. #elif defined( ENVMAP_BLENDING_ADD )
  556. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  557. #endif
  558. #endif`,Xge=`#ifdef USE_ENVMAP
  559. uniform float envMapIntensity;
  560. uniform float flipEnvMap;
  561. uniform mat3 envMapRotation;
  562. #ifdef ENVMAP_TYPE_CUBE
  563. uniform samplerCube envMap;
  564. #else
  565. uniform sampler2D envMap;
  566. #endif
  567. #endif`,Yge=`#ifdef USE_ENVMAP
  568. uniform float reflectivity;
  569. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  570. #define ENV_WORLDPOS
  571. #endif
  572. #ifdef ENV_WORLDPOS
  573. varying vec3 vWorldPosition;
  574. uniform float refractionRatio;
  575. #else
  576. varying vec3 vReflect;
  577. #endif
  578. #endif`,Qge=`#ifdef USE_ENVMAP
  579. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  580. #define ENV_WORLDPOS
  581. #endif
  582. #ifdef ENV_WORLDPOS
  583. varying vec3 vWorldPosition;
  584. #else
  585. varying vec3 vReflect;
  586. uniform float refractionRatio;
  587. #endif
  588. #endif`,Zge=`#ifdef USE_ENVMAP
  589. #ifdef ENV_WORLDPOS
  590. vWorldPosition = worldPosition.xyz;
  591. #else
  592. vec3 cameraToVertex;
  593. if ( isOrthographic ) {
  594. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  595. } else {
  596. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  597. }
  598. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  599. #ifdef ENVMAP_MODE_REFLECTION
  600. vReflect = reflect( cameraToVertex, worldNormal );
  601. #else
  602. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  603. #endif
  604. #endif
  605. #endif`,Jge=`#ifdef USE_FOG
  606. vFogDepth = - mvPosition.z;
  607. #endif`,ebe=`#ifdef USE_FOG
  608. varying float vFogDepth;
  609. #endif`,tbe=`#ifdef USE_FOG
  610. #ifdef FOG_EXP2
  611. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  612. #else
  613. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  614. #endif
  615. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  616. #endif`,nbe=`#ifdef USE_FOG
  617. uniform vec3 fogColor;
  618. varying float vFogDepth;
  619. #ifdef FOG_EXP2
  620. uniform float fogDensity;
  621. #else
  622. uniform float fogNear;
  623. uniform float fogFar;
  624. #endif
  625. #endif`,rbe=`#ifdef USE_GRADIENTMAP
  626. uniform sampler2D gradientMap;
  627. #endif
  628. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  629. float dotNL = dot( normal, lightDirection );
  630. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  631. #ifdef USE_GRADIENTMAP
  632. return vec3( texture2D( gradientMap, coord ).r );
  633. #else
  634. vec2 fw = fwidth( coord ) * 0.5;
  635. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  636. #endif
  637. }`,ibe=`#ifdef USE_LIGHTMAP
  638. uniform sampler2D lightMap;
  639. uniform float lightMapIntensity;
  640. #endif`,abe=`LambertMaterial material;
  641. material.diffuseColor = diffuseColor.rgb;
  642. material.specularStrength = specularStrength;`,sbe=`varying vec3 vViewPosition;
  643. struct LambertMaterial {
  644. vec3 diffuseColor;
  645. float specularStrength;
  646. };
  647. 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 ) {
  648. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  649. vec3 irradiance = dotNL * directLight.color;
  650. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  651. }
  652. 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 ) {
  653. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  654. }
  655. #define RE_Direct RE_Direct_Lambert
  656. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,obe=`uniform bool receiveShadow;
  657. uniform vec3 ambientLightColor;
  658. #if defined( USE_LIGHT_PROBES )
  659. uniform vec3 lightProbe[ 9 ];
  660. #endif
  661. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  662. float x = normal.x, y = normal.y, z = normal.z;
  663. vec3 result = shCoefficients[ 0 ] * 0.886227;
  664. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  665. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  666. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  667. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  668. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  669. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  670. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  671. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  672. return result;
  673. }
  674. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  675. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  676. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  677. return irradiance;
  678. }
  679. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  680. vec3 irradiance = ambientLightColor;
  681. return irradiance;
  682. }
  683. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  684. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  685. if ( cutoffDistance > 0.0 ) {
  686. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  687. }
  688. return distanceFalloff;
  689. }
  690. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  691. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  692. }
  693. #if NUM_DIR_LIGHTS > 0
  694. struct DirectionalLight {
  695. vec3 direction;
  696. vec3 color;
  697. };
  698. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  699. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  700. light.color = directionalLight.color;
  701. light.direction = directionalLight.direction;
  702. light.visible = true;
  703. }
  704. #endif
  705. #if NUM_POINT_LIGHTS > 0
  706. struct PointLight {
  707. vec3 position;
  708. vec3 color;
  709. float distance;
  710. float decay;
  711. };
  712. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  713. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  714. vec3 lVector = pointLight.position - geometryPosition;
  715. light.direction = normalize( lVector );
  716. float lightDistance = length( lVector );
  717. light.color = pointLight.color;
  718. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  719. light.visible = ( light.color != vec3( 0.0 ) );
  720. }
  721. #endif
  722. #if NUM_SPOT_LIGHTS > 0
  723. struct SpotLight {
  724. vec3 position;
  725. vec3 direction;
  726. vec3 color;
  727. float distance;
  728. float decay;
  729. float coneCos;
  730. float penumbraCos;
  731. };
  732. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  733. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  734. vec3 lVector = spotLight.position - geometryPosition;
  735. light.direction = normalize( lVector );
  736. float angleCos = dot( light.direction, spotLight.direction );
  737. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  738. if ( spotAttenuation > 0.0 ) {
  739. float lightDistance = length( lVector );
  740. light.color = spotLight.color * spotAttenuation;
  741. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  742. light.visible = ( light.color != vec3( 0.0 ) );
  743. } else {
  744. light.color = vec3( 0.0 );
  745. light.visible = false;
  746. }
  747. }
  748. #endif
  749. #if NUM_RECT_AREA_LIGHTS > 0
  750. struct RectAreaLight {
  751. vec3 color;
  752. vec3 position;
  753. vec3 halfWidth;
  754. vec3 halfHeight;
  755. };
  756. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  757. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  758. #endif
  759. #if NUM_HEMI_LIGHTS > 0
  760. struct HemisphereLight {
  761. vec3 direction;
  762. vec3 skyColor;
  763. vec3 groundColor;
  764. };
  765. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  766. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  767. float dotNL = dot( normal, hemiLight.direction );
  768. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  769. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  770. return irradiance;
  771. }
  772. #endif`,lbe=`#ifdef USE_ENVMAP
  773. vec3 getIBLIrradiance( const in vec3 normal ) {
  774. #ifdef ENVMAP_TYPE_CUBE_UV
  775. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  776. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  777. return PI * envMapColor.rgb * envMapIntensity;
  778. #else
  779. return vec3( 0.0 );
  780. #endif
  781. }
  782. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  783. #ifdef ENVMAP_TYPE_CUBE_UV
  784. vec3 reflectVec = reflect( - viewDir, normal );
  785. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  786. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  787. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  788. return envMapColor.rgb * envMapIntensity;
  789. #else
  790. return vec3( 0.0 );
  791. #endif
  792. }
  793. #ifdef USE_ANISOTROPY
  794. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  795. #ifdef ENVMAP_TYPE_CUBE_UV
  796. vec3 bentNormal = cross( bitangent, viewDir );
  797. bentNormal = normalize( cross( bentNormal, bitangent ) );
  798. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  799. return getIBLRadiance( viewDir, bentNormal, roughness );
  800. #else
  801. return vec3( 0.0 );
  802. #endif
  803. }
  804. #endif
  805. #endif`,cbe=`ToonMaterial material;
  806. material.diffuseColor = diffuseColor.rgb;`,ube=`varying vec3 vViewPosition;
  807. struct ToonMaterial {
  808. vec3 diffuseColor;
  809. };
  810. 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 ) {
  811. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  812. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  813. }
  814. 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 ) {
  815. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  816. }
  817. #define RE_Direct RE_Direct_Toon
  818. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,dbe=`BlinnPhongMaterial material;
  819. material.diffuseColor = diffuseColor.rgb;
  820. material.specularColor = specular;
  821. material.specularShininess = shininess;
  822. material.specularStrength = specularStrength;`,hbe=`varying vec3 vViewPosition;
  823. struct BlinnPhongMaterial {
  824. vec3 diffuseColor;
  825. vec3 specularColor;
  826. float specularShininess;
  827. float specularStrength;
  828. };
  829. 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 ) {
  830. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  831. vec3 irradiance = dotNL * directLight.color;
  832. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  833. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  834. }
  835. 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 ) {
  836. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  837. }
  838. #define RE_Direct RE_Direct_BlinnPhong
  839. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,fbe=`PhysicalMaterial material;
  840. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  841. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  842. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  843. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  844. material.roughness = min( material.roughness, 1.0 );
  845. #ifdef IOR
  846. material.ior = ior;
  847. #ifdef USE_SPECULAR
  848. float specularIntensityFactor = specularIntensity;
  849. vec3 specularColorFactor = specularColor;
  850. #ifdef USE_SPECULAR_COLORMAP
  851. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  852. #endif
  853. #ifdef USE_SPECULAR_INTENSITYMAP
  854. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  855. #endif
  856. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  857. #else
  858. float specularIntensityFactor = 1.0;
  859. vec3 specularColorFactor = vec3( 1.0 );
  860. material.specularF90 = 1.0;
  861. #endif
  862. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  863. #else
  864. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  865. material.specularF90 = 1.0;
  866. #endif
  867. #ifdef USE_CLEARCOAT
  868. material.clearcoat = clearcoat;
  869. material.clearcoatRoughness = clearcoatRoughness;
  870. material.clearcoatF0 = vec3( 0.04 );
  871. material.clearcoatF90 = 1.0;
  872. #ifdef USE_CLEARCOATMAP
  873. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  874. #endif
  875. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  876. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  877. #endif
  878. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  879. material.clearcoatRoughness += geometryRoughness;
  880. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  881. #endif
  882. #ifdef USE_DISPERSION
  883. material.dispersion = dispersion;
  884. #endif
  885. #ifdef USE_IRIDESCENCE
  886. material.iridescence = iridescence;
  887. material.iridescenceIOR = iridescenceIOR;
  888. #ifdef USE_IRIDESCENCEMAP
  889. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  890. #endif
  891. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  892. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  893. #else
  894. material.iridescenceThickness = iridescenceThicknessMaximum;
  895. #endif
  896. #endif
  897. #ifdef USE_SHEEN
  898. material.sheenColor = sheenColor;
  899. #ifdef USE_SHEEN_COLORMAP
  900. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  901. #endif
  902. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  903. #ifdef USE_SHEEN_ROUGHNESSMAP
  904. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  905. #endif
  906. #endif
  907. #ifdef USE_ANISOTROPY
  908. #ifdef USE_ANISOTROPYMAP
  909. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  910. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  911. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  912. #else
  913. vec2 anisotropyV = anisotropyVector;
  914. #endif
  915. material.anisotropy = length( anisotropyV );
  916. if( material.anisotropy == 0.0 ) {
  917. anisotropyV = vec2( 1.0, 0.0 );
  918. } else {
  919. anisotropyV /= material.anisotropy;
  920. material.anisotropy = saturate( material.anisotropy );
  921. }
  922. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  923. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  924. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  925. #endif`,mbe=`uniform sampler2D dfgLUT;
  926. struct PhysicalMaterial {
  927. vec3 diffuseColor;
  928. float roughness;
  929. vec3 specularColor;
  930. float specularF90;
  931. float dispersion;
  932. #ifdef USE_CLEARCOAT
  933. float clearcoat;
  934. float clearcoatRoughness;
  935. vec3 clearcoatF0;
  936. float clearcoatF90;
  937. #endif
  938. #ifdef USE_IRIDESCENCE
  939. float iridescence;
  940. float iridescenceIOR;
  941. float iridescenceThickness;
  942. vec3 iridescenceFresnel;
  943. vec3 iridescenceF0;
  944. #endif
  945. #ifdef USE_SHEEN
  946. vec3 sheenColor;
  947. float sheenRoughness;
  948. #endif
  949. #ifdef IOR
  950. float ior;
  951. #endif
  952. #ifdef USE_TRANSMISSION
  953. float transmission;
  954. float transmissionAlpha;
  955. float thickness;
  956. float attenuationDistance;
  957. vec3 attenuationColor;
  958. #endif
  959. #ifdef USE_ANISOTROPY
  960. float anisotropy;
  961. float alphaT;
  962. vec3 anisotropyT;
  963. vec3 anisotropyB;
  964. #endif
  965. };
  966. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  967. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  968. vec3 sheenSpecularDirect = vec3( 0.0 );
  969. vec3 sheenSpecularIndirect = vec3(0.0 );
  970. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  971. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  972. float x2 = x * x;
  973. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  974. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  975. }
  976. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  977. float a2 = pow2( alpha );
  978. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  979. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  980. return 0.5 / max( gv + gl, EPSILON );
  981. }
  982. float D_GGX( const in float alpha, const in float dotNH ) {
  983. float a2 = pow2( alpha );
  984. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  985. return RECIPROCAL_PI * a2 / pow2( denom );
  986. }
  987. #ifdef USE_ANISOTROPY
  988. 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 ) {
  989. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  990. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  991. float v = 0.5 / ( gv + gl );
  992. return saturate(v);
  993. }
  994. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  995. float a2 = alphaT * alphaB;
  996. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  997. highp float v2 = dot( v, v );
  998. float w2 = a2 / v2;
  999. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1000. }
  1001. #endif
  1002. #ifdef USE_CLEARCOAT
  1003. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1004. vec3 f0 = material.clearcoatF0;
  1005. float f90 = material.clearcoatF90;
  1006. float roughness = material.clearcoatRoughness;
  1007. float alpha = pow2( roughness );
  1008. vec3 halfDir = normalize( lightDir + viewDir );
  1009. float dotNL = saturate( dot( normal, lightDir ) );
  1010. float dotNV = saturate( dot( normal, viewDir ) );
  1011. float dotNH = saturate( dot( normal, halfDir ) );
  1012. float dotVH = saturate( dot( viewDir, halfDir ) );
  1013. vec3 F = F_Schlick( f0, f90, dotVH );
  1014. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1015. float D = D_GGX( alpha, dotNH );
  1016. return F * ( V * D );
  1017. }
  1018. #endif
  1019. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1020. vec3 f0 = material.specularColor;
  1021. float f90 = material.specularF90;
  1022. float roughness = material.roughness;
  1023. float alpha = pow2( roughness );
  1024. vec3 halfDir = normalize( lightDir + viewDir );
  1025. float dotNL = saturate( dot( normal, lightDir ) );
  1026. float dotNV = saturate( dot( normal, viewDir ) );
  1027. float dotNH = saturate( dot( normal, halfDir ) );
  1028. float dotVH = saturate( dot( viewDir, halfDir ) );
  1029. vec3 F = F_Schlick( f0, f90, dotVH );
  1030. #ifdef USE_IRIDESCENCE
  1031. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1032. #endif
  1033. #ifdef USE_ANISOTROPY
  1034. float dotTL = dot( material.anisotropyT, lightDir );
  1035. float dotTV = dot( material.anisotropyT, viewDir );
  1036. float dotTH = dot( material.anisotropyT, halfDir );
  1037. float dotBL = dot( material.anisotropyB, lightDir );
  1038. float dotBV = dot( material.anisotropyB, viewDir );
  1039. float dotBH = dot( material.anisotropyB, halfDir );
  1040. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1041. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1042. #else
  1043. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1044. float D = D_GGX( alpha, dotNH );
  1045. #endif
  1046. return F * ( V * D );
  1047. }
  1048. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1049. const float LUT_SIZE = 64.0;
  1050. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1051. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1052. float dotNV = saturate( dot( N, V ) );
  1053. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1054. uv = uv * LUT_SCALE + LUT_BIAS;
  1055. return uv;
  1056. }
  1057. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1058. float l = length( f );
  1059. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1060. }
  1061. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1062. float x = dot( v1, v2 );
  1063. float y = abs( x );
  1064. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1065. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1066. float v = a / b;
  1067. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1068. return cross( v1, v2 ) * theta_sintheta;
  1069. }
  1070. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1071. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1072. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1073. vec3 lightNormal = cross( v1, v2 );
  1074. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1075. vec3 T1, T2;
  1076. T1 = normalize( V - N * dot( V, N ) );
  1077. T2 = - cross( N, T1 );
  1078. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1079. vec3 coords[ 4 ];
  1080. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1081. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1082. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1083. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1084. coords[ 0 ] = normalize( coords[ 0 ] );
  1085. coords[ 1 ] = normalize( coords[ 1 ] );
  1086. coords[ 2 ] = normalize( coords[ 2 ] );
  1087. coords[ 3 ] = normalize( coords[ 3 ] );
  1088. vec3 vectorFormFactor = vec3( 0.0 );
  1089. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1090. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1091. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1092. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1093. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1094. return vec3( result );
  1095. }
  1096. #if defined( USE_SHEEN )
  1097. float D_Charlie( float roughness, float dotNH ) {
  1098. float alpha = pow2( roughness );
  1099. float invAlpha = 1.0 / alpha;
  1100. float cos2h = dotNH * dotNH;
  1101. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1102. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1103. }
  1104. float V_Neubelt( float dotNV, float dotNL ) {
  1105. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1106. }
  1107. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1108. vec3 halfDir = normalize( lightDir + viewDir );
  1109. float dotNL = saturate( dot( normal, lightDir ) );
  1110. float dotNV = saturate( dot( normal, viewDir ) );
  1111. float dotNH = saturate( dot( normal, halfDir ) );
  1112. float D = D_Charlie( sheenRoughness, dotNH );
  1113. float V = V_Neubelt( dotNV, dotNL );
  1114. return sheenColor * ( D * V );
  1115. }
  1116. #endif
  1117. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1118. float dotNV = saturate( dot( normal, viewDir ) );
  1119. float r2 = roughness * roughness;
  1120. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1121. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1122. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1123. return saturate( DG * RECIPROCAL_PI );
  1124. }
  1125. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1126. float dotNV = saturate( dot( normal, viewDir ) );
  1127. vec2 uv = vec2( roughness, dotNV );
  1128. return texture2D( dfgLUT, uv ).rg;
  1129. }
  1130. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1131. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1132. return specularColor * fab.x + specularF90 * fab.y;
  1133. }
  1134. #ifdef USE_IRIDESCENCE
  1135. 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 ) {
  1136. #else
  1137. 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 ) {
  1138. #endif
  1139. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1140. #ifdef USE_IRIDESCENCE
  1141. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1142. #else
  1143. vec3 Fr = specularColor;
  1144. #endif
  1145. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1146. float Ess = fab.x + fab.y;
  1147. float Ems = 1.0 - Ess;
  1148. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1149. singleScatter += FssEss;
  1150. multiScatter += Fms * Ems;
  1151. }
  1152. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1153. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1154. float dotNL = saturate( dot( normal, lightDir ) );
  1155. float dotNV = saturate( dot( normal, viewDir ) );
  1156. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1157. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1158. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1159. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1160. float Ess_V = dfgV.x + dfgV.y;
  1161. float Ess_L = dfgL.x + dfgL.y;
  1162. float Ems_V = 1.0 - Ess_V;
  1163. float Ems_L = 1.0 - Ess_L;
  1164. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1165. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1166. float compensationFactor = Ems_V * Ems_L;
  1167. vec3 multiScatter = Fms * compensationFactor;
  1168. return singleScatter + multiScatter;
  1169. }
  1170. #if NUM_RECT_AREA_LIGHTS > 0
  1171. 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 ) {
  1172. vec3 normal = geometryNormal;
  1173. vec3 viewDir = geometryViewDir;
  1174. vec3 position = geometryPosition;
  1175. vec3 lightPos = rectAreaLight.position;
  1176. vec3 halfWidth = rectAreaLight.halfWidth;
  1177. vec3 halfHeight = rectAreaLight.halfHeight;
  1178. vec3 lightColor = rectAreaLight.color;
  1179. float roughness = material.roughness;
  1180. vec3 rectCoords[ 4 ];
  1181. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1182. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1183. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1184. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1185. vec4 t1 = texture2D( ltc_1, uv );
  1186. vec4 t2 = texture2D( ltc_2, uv );
  1187. mat3 mInv = mat3(
  1188. vec3( t1.x, 0, t1.y ),
  1189. vec3( 0, 1, 0 ),
  1190. vec3( t1.z, 0, t1.w )
  1191. );
  1192. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1193. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1194. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1195. }
  1196. #endif
  1197. 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 ) {
  1198. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1199. vec3 irradiance = dotNL * directLight.color;
  1200. #ifdef USE_CLEARCOAT
  1201. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1202. vec3 ccIrradiance = dotNLcc * directLight.color;
  1203. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1204. #endif
  1205. #ifdef USE_SHEEN
  1206. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1207. #endif
  1208. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1209. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1210. }
  1211. 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 ) {
  1212. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1213. }
  1214. 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) {
  1215. #ifdef USE_CLEARCOAT
  1216. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1217. #endif
  1218. #ifdef USE_SHEEN
  1219. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1220. #endif
  1221. vec3 singleScattering = vec3( 0.0 );
  1222. vec3 multiScattering = vec3( 0.0 );
  1223. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1224. #ifdef USE_IRIDESCENCE
  1225. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1226. #else
  1227. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1228. #endif
  1229. vec3 totalScattering = singleScattering + multiScattering;
  1230. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1231. reflectedLight.indirectSpecular += radiance * singleScattering;
  1232. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1233. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1234. }
  1235. #define RE_Direct RE_Direct_Physical
  1236. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1237. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1238. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1239. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1240. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1241. }`,pbe=`
  1242. vec3 geometryPosition = - vViewPosition;
  1243. vec3 geometryNormal = normal;
  1244. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1245. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1246. #ifdef USE_CLEARCOAT
  1247. geometryClearcoatNormal = clearcoatNormal;
  1248. #endif
  1249. #ifdef USE_IRIDESCENCE
  1250. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1251. if ( material.iridescenceThickness == 0.0 ) {
  1252. material.iridescence = 0.0;
  1253. } else {
  1254. material.iridescence = saturate( material.iridescence );
  1255. }
  1256. if ( material.iridescence > 0.0 ) {
  1257. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1258. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1259. }
  1260. #endif
  1261. IncidentLight directLight;
  1262. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1263. PointLight pointLight;
  1264. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1265. PointLightShadow pointLightShadow;
  1266. #endif
  1267. #pragma unroll_loop_start
  1268. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1269. pointLight = pointLights[ i ];
  1270. getPointLightInfo( pointLight, geometryPosition, directLight );
  1271. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1272. pointLightShadow = pointLightShadows[ i ];
  1273. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1274. #endif
  1275. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1276. }
  1277. #pragma unroll_loop_end
  1278. #endif
  1279. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1280. SpotLight spotLight;
  1281. vec4 spotColor;
  1282. vec3 spotLightCoord;
  1283. bool inSpotLightMap;
  1284. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1285. SpotLightShadow spotLightShadow;
  1286. #endif
  1287. #pragma unroll_loop_start
  1288. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1289. spotLight = spotLights[ i ];
  1290. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1291. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1292. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1293. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1294. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1295. #else
  1296. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1297. #endif
  1298. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1299. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1300. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1301. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1302. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1303. #endif
  1304. #undef SPOT_LIGHT_MAP_INDEX
  1305. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1306. spotLightShadow = spotLightShadows[ i ];
  1307. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1308. #endif
  1309. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1310. }
  1311. #pragma unroll_loop_end
  1312. #endif
  1313. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1314. DirectionalLight directionalLight;
  1315. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1316. DirectionalLightShadow directionalLightShadow;
  1317. #endif
  1318. #pragma unroll_loop_start
  1319. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1320. directionalLight = directionalLights[ i ];
  1321. getDirectionalLightInfo( directionalLight, directLight );
  1322. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1323. directionalLightShadow = directionalLightShadows[ i ];
  1324. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1325. #endif
  1326. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1327. }
  1328. #pragma unroll_loop_end
  1329. #endif
  1330. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1331. RectAreaLight rectAreaLight;
  1332. #pragma unroll_loop_start
  1333. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1334. rectAreaLight = rectAreaLights[ i ];
  1335. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1336. }
  1337. #pragma unroll_loop_end
  1338. #endif
  1339. #if defined( RE_IndirectDiffuse )
  1340. vec3 iblIrradiance = vec3( 0.0 );
  1341. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1342. #if defined( USE_LIGHT_PROBES )
  1343. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1344. #endif
  1345. #if ( NUM_HEMI_LIGHTS > 0 )
  1346. #pragma unroll_loop_start
  1347. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1348. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1349. }
  1350. #pragma unroll_loop_end
  1351. #endif
  1352. #endif
  1353. #if defined( RE_IndirectSpecular )
  1354. vec3 radiance = vec3( 0.0 );
  1355. vec3 clearcoatRadiance = vec3( 0.0 );
  1356. #endif`,gbe=`#if defined( RE_IndirectDiffuse )
  1357. #ifdef USE_LIGHTMAP
  1358. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1359. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1360. irradiance += lightMapIrradiance;
  1361. #endif
  1362. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1363. iblIrradiance += getIBLIrradiance( geometryNormal );
  1364. #endif
  1365. #endif
  1366. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1367. #ifdef USE_ANISOTROPY
  1368. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1369. #else
  1370. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1371. #endif
  1372. #ifdef USE_CLEARCOAT
  1373. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1374. #endif
  1375. #endif`,bbe=`#if defined( RE_IndirectDiffuse )
  1376. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1377. #endif
  1378. #if defined( RE_IndirectSpecular )
  1379. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1380. #endif`,xbe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1381. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1382. #endif`,ybe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1383. uniform float logDepthBufFC;
  1384. varying float vFragDepth;
  1385. varying float vIsPerspective;
  1386. #endif`,vbe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1387. varying float vFragDepth;
  1388. varying float vIsPerspective;
  1389. #endif`,wbe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1390. vFragDepth = 1.0 + gl_Position.w;
  1391. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1392. #endif`,_be=`#ifdef USE_MAP
  1393. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1394. #ifdef DECODE_VIDEO_TEXTURE
  1395. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1396. #endif
  1397. diffuseColor *= sampledDiffuseColor;
  1398. #endif`,Sbe=`#ifdef USE_MAP
  1399. uniform sampler2D map;
  1400. #endif`,Nbe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1401. #if defined( USE_POINTS_UV )
  1402. vec2 uv = vUv;
  1403. #else
  1404. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1405. #endif
  1406. #endif
  1407. #ifdef USE_MAP
  1408. diffuseColor *= texture2D( map, uv );
  1409. #endif
  1410. #ifdef USE_ALPHAMAP
  1411. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1412. #endif`,kbe=`#if defined( USE_POINTS_UV )
  1413. varying vec2 vUv;
  1414. #else
  1415. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1416. uniform mat3 uvTransform;
  1417. #endif
  1418. #endif
  1419. #ifdef USE_MAP
  1420. uniform sampler2D map;
  1421. #endif
  1422. #ifdef USE_ALPHAMAP
  1423. uniform sampler2D alphaMap;
  1424. #endif`,Mbe=`float metalnessFactor = metalness;
  1425. #ifdef USE_METALNESSMAP
  1426. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1427. metalnessFactor *= texelMetalness.b;
  1428. #endif`,Cbe=`#ifdef USE_METALNESSMAP
  1429. uniform sampler2D metalnessMap;
  1430. #endif`,Ebe=`#ifdef USE_INSTANCING_MORPH
  1431. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1432. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1433. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1434. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1435. }
  1436. #endif`,Abe=`#if defined( USE_MORPHCOLORS )
  1437. vColor *= morphTargetBaseInfluence;
  1438. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1439. #if defined( USE_COLOR_ALPHA )
  1440. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1441. #elif defined( USE_COLOR )
  1442. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1443. #endif
  1444. }
  1445. #endif`,Tbe=`#ifdef USE_MORPHNORMALS
  1446. objectNormal *= morphTargetBaseInfluence;
  1447. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1448. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1449. }
  1450. #endif`,jbe=`#ifdef USE_MORPHTARGETS
  1451. #ifndef USE_INSTANCING_MORPH
  1452. uniform float morphTargetBaseInfluence;
  1453. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1454. #endif
  1455. uniform sampler2DArray morphTargetsTexture;
  1456. uniform ivec2 morphTargetsTextureSize;
  1457. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1458. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1459. int y = texelIndex / morphTargetsTextureSize.x;
  1460. int x = texelIndex - y * morphTargetsTextureSize.x;
  1461. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1462. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1463. }
  1464. #endif`,Pbe=`#ifdef USE_MORPHTARGETS
  1465. transformed *= morphTargetBaseInfluence;
  1466. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1467. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1468. }
  1469. #endif`,Dbe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1470. #ifdef FLAT_SHADED
  1471. vec3 fdx = dFdx( vViewPosition );
  1472. vec3 fdy = dFdy( vViewPosition );
  1473. vec3 normal = normalize( cross( fdx, fdy ) );
  1474. #else
  1475. vec3 normal = normalize( vNormal );
  1476. #ifdef DOUBLE_SIDED
  1477. normal *= faceDirection;
  1478. #endif
  1479. #endif
  1480. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1481. #ifdef USE_TANGENT
  1482. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1483. #else
  1484. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1485. #if defined( USE_NORMALMAP )
  1486. vNormalMapUv
  1487. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1488. vClearcoatNormalMapUv
  1489. #else
  1490. vUv
  1491. #endif
  1492. );
  1493. #endif
  1494. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1495. tbn[0] *= faceDirection;
  1496. tbn[1] *= faceDirection;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_CLEARCOAT_NORMALMAP
  1500. #ifdef USE_TANGENT
  1501. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1502. #else
  1503. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1504. #endif
  1505. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1506. tbn2[0] *= faceDirection;
  1507. tbn2[1] *= faceDirection;
  1508. #endif
  1509. #endif
  1510. vec3 nonPerturbedNormal = normal;`,Rbe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1511. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1512. #ifdef FLIP_SIDED
  1513. normal = - normal;
  1514. #endif
  1515. #ifdef DOUBLE_SIDED
  1516. normal = normal * faceDirection;
  1517. #endif
  1518. normal = normalize( normalMatrix * normal );
  1519. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1520. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1521. mapN.xy *= normalScale;
  1522. normal = normalize( tbn * mapN );
  1523. #elif defined( USE_BUMPMAP )
  1524. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1525. #endif`,Lbe=`#ifndef FLAT_SHADED
  1526. varying vec3 vNormal;
  1527. #ifdef USE_TANGENT
  1528. varying vec3 vTangent;
  1529. varying vec3 vBitangent;
  1530. #endif
  1531. #endif`,Obe=`#ifndef FLAT_SHADED
  1532. varying vec3 vNormal;
  1533. #ifdef USE_TANGENT
  1534. varying vec3 vTangent;
  1535. varying vec3 vBitangent;
  1536. #endif
  1537. #endif`,Fbe=`#ifndef FLAT_SHADED
  1538. vNormal = normalize( transformedNormal );
  1539. #ifdef USE_TANGENT
  1540. vTangent = normalize( transformedTangent );
  1541. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1542. #endif
  1543. #endif`,Ibe=`#ifdef USE_NORMALMAP
  1544. uniform sampler2D normalMap;
  1545. uniform vec2 normalScale;
  1546. #endif
  1547. #ifdef USE_NORMALMAP_OBJECTSPACE
  1548. uniform mat3 normalMatrix;
  1549. #endif
  1550. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1551. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1552. vec3 q0 = dFdx( eye_pos.xyz );
  1553. vec3 q1 = dFdy( eye_pos.xyz );
  1554. vec2 st0 = dFdx( uv.st );
  1555. vec2 st1 = dFdy( uv.st );
  1556. vec3 N = surf_norm;
  1557. vec3 q1perp = cross( q1, N );
  1558. vec3 q0perp = cross( N, q0 );
  1559. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1560. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1561. float det = max( dot( T, T ), dot( B, B ) );
  1562. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1563. return mat3( T * scale, B * scale, N );
  1564. }
  1565. #endif`,zbe=`#ifdef USE_CLEARCOAT
  1566. vec3 clearcoatNormal = nonPerturbedNormal;
  1567. #endif`,Ube=`#ifdef USE_CLEARCOAT_NORMALMAP
  1568. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1569. clearcoatMapN.xy *= clearcoatNormalScale;
  1570. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1571. #endif`,Bbe=`#ifdef USE_CLEARCOATMAP
  1572. uniform sampler2D clearcoatMap;
  1573. #endif
  1574. #ifdef USE_CLEARCOAT_NORMALMAP
  1575. uniform sampler2D clearcoatNormalMap;
  1576. uniform vec2 clearcoatNormalScale;
  1577. #endif
  1578. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1579. uniform sampler2D clearcoatRoughnessMap;
  1580. #endif`,$be=`#ifdef USE_IRIDESCENCEMAP
  1581. uniform sampler2D iridescenceMap;
  1582. #endif
  1583. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1584. uniform sampler2D iridescenceThicknessMap;
  1585. #endif`,Hbe=`#ifdef OPAQUE
  1586. diffuseColor.a = 1.0;
  1587. #endif
  1588. #ifdef USE_TRANSMISSION
  1589. diffuseColor.a *= material.transmissionAlpha;
  1590. #endif
  1591. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Vbe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1592. return normalize( normal ) * 0.5 + 0.5;
  1593. }
  1594. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1595. return 2.0 * rgb.xyz - 1.0;
  1596. }
  1597. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1598. const float Inv255 = 1. / 255.;
  1599. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1600. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1601. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1602. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1603. vec4 packDepthToRGBA( const in float v ) {
  1604. if( v <= 0.0 )
  1605. return vec4( 0., 0., 0., 0. );
  1606. if( v >= 1.0 )
  1607. return vec4( 1., 1., 1., 1. );
  1608. float vuf;
  1609. float af = modf( v * PackFactors.a, vuf );
  1610. float bf = modf( vuf * ShiftRight8, vuf );
  1611. float gf = modf( vuf * ShiftRight8, vuf );
  1612. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1613. }
  1614. vec3 packDepthToRGB( const in float v ) {
  1615. if( v <= 0.0 )
  1616. return vec3( 0., 0., 0. );
  1617. if( v >= 1.0 )
  1618. return vec3( 1., 1., 1. );
  1619. float vuf;
  1620. float bf = modf( v * PackFactors.b, vuf );
  1621. float gf = modf( vuf * ShiftRight8, vuf );
  1622. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1623. }
  1624. vec2 packDepthToRG( const in float v ) {
  1625. if( v <= 0.0 )
  1626. return vec2( 0., 0. );
  1627. if( v >= 1.0 )
  1628. return vec2( 1., 1. );
  1629. float vuf;
  1630. float gf = modf( v * 256., vuf );
  1631. return vec2( vuf * Inv255, gf );
  1632. }
  1633. float unpackRGBAToDepth( const in vec4 v ) {
  1634. return dot( v, UnpackFactors4 );
  1635. }
  1636. float unpackRGBToDepth( const in vec3 v ) {
  1637. return dot( v, UnpackFactors3 );
  1638. }
  1639. float unpackRGToDepth( const in vec2 v ) {
  1640. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1641. }
  1642. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1643. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1644. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1645. }
  1646. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1647. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1648. }
  1649. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1650. return ( viewZ + near ) / ( near - far );
  1651. }
  1652. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1653. return depth * ( near - far ) - near;
  1654. }
  1655. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1656. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1657. }
  1658. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1659. return ( near * far ) / ( ( far - near ) * depth - far );
  1660. }`,Gbe=`#ifdef PREMULTIPLIED_ALPHA
  1661. gl_FragColor.rgb *= gl_FragColor.a;
  1662. #endif`,qbe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1663. #ifdef USE_BATCHING
  1664. mvPosition = batchingMatrix * mvPosition;
  1665. #endif
  1666. #ifdef USE_INSTANCING
  1667. mvPosition = instanceMatrix * mvPosition;
  1668. #endif
  1669. mvPosition = modelViewMatrix * mvPosition;
  1670. gl_Position = projectionMatrix * mvPosition;`,Wbe=`#ifdef DITHERING
  1671. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1672. #endif`,Kbe=`#ifdef DITHERING
  1673. vec3 dithering( vec3 color ) {
  1674. float grid_position = rand( gl_FragCoord.xy );
  1675. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1676. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1677. return color + dither_shift_RGB;
  1678. }
  1679. #endif`,Xbe=`float roughnessFactor = roughness;
  1680. #ifdef USE_ROUGHNESSMAP
  1681. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1682. roughnessFactor *= texelRoughness.g;
  1683. #endif`,Ybe=`#ifdef USE_ROUGHNESSMAP
  1684. uniform sampler2D roughnessMap;
  1685. #endif`,Qbe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1686. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1687. #endif
  1688. #if NUM_SPOT_LIGHT_MAPS > 0
  1689. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1690. #endif
  1691. #ifdef USE_SHADOWMAP
  1692. #if NUM_DIR_LIGHT_SHADOWS > 0
  1693. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1694. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1695. struct DirectionalLightShadow {
  1696. float shadowIntensity;
  1697. float shadowBias;
  1698. float shadowNormalBias;
  1699. float shadowRadius;
  1700. vec2 shadowMapSize;
  1701. };
  1702. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1703. #endif
  1704. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1705. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1706. struct SpotLightShadow {
  1707. float shadowIntensity;
  1708. float shadowBias;
  1709. float shadowNormalBias;
  1710. float shadowRadius;
  1711. vec2 shadowMapSize;
  1712. };
  1713. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1714. #endif
  1715. #if NUM_POINT_LIGHT_SHADOWS > 0
  1716. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1717. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1718. struct PointLightShadow {
  1719. float shadowIntensity;
  1720. float shadowBias;
  1721. float shadowNormalBias;
  1722. float shadowRadius;
  1723. vec2 shadowMapSize;
  1724. float shadowCameraNear;
  1725. float shadowCameraFar;
  1726. };
  1727. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1728. #endif
  1729. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1730. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1731. #ifdef USE_REVERSED_DEPTH_BUFFER
  1732. return step( depth, compare );
  1733. #else
  1734. return step( compare, depth );
  1735. #endif
  1736. }
  1737. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1738. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1739. }
  1740. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1741. float occlusion = 1.0;
  1742. vec2 distribution = texture2DDistribution( shadow, uv );
  1743. #ifdef USE_REVERSED_DEPTH_BUFFER
  1744. float hard_shadow = step( distribution.x, compare );
  1745. #else
  1746. float hard_shadow = step( compare, distribution.x );
  1747. #endif
  1748. if ( hard_shadow != 1.0 ) {
  1749. float distance = compare - distribution.x;
  1750. float variance = max( 0.00000, distribution.y * distribution.y );
  1751. 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 );
  1752. }
  1753. return occlusion;
  1754. }
  1755. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1756. float shadow = 1.0;
  1757. shadowCoord.xyz /= shadowCoord.w;
  1758. shadowCoord.z += shadowBias;
  1759. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1760. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1761. if ( frustumTest ) {
  1762. #if defined( SHADOWMAP_TYPE_PCF )
  1763. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1764. float dx0 = - texelSize.x * shadowRadius;
  1765. float dy0 = - texelSize.y * shadowRadius;
  1766. float dx1 = + texelSize.x * shadowRadius;
  1767. float dy1 = + texelSize.y * shadowRadius;
  1768. float dx2 = dx0 / 2.0;
  1769. float dy2 = dy0 / 2.0;
  1770. float dx3 = dx1 / 2.0;
  1771. float dy3 = dy1 / 2.0;
  1772. shadow = (
  1773. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1774. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1775. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1776. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1777. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1778. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1779. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1780. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1781. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1782. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1783. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1784. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1785. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1786. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1787. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1788. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1789. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1790. ) * ( 1.0 / 17.0 );
  1791. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1792. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1793. float dx = texelSize.x;
  1794. float dy = texelSize.y;
  1795. vec2 uv = shadowCoord.xy;
  1796. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1797. uv -= f * texelSize;
  1798. shadow = (
  1799. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1800. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1801. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1802. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1803. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1804. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1805. f.x ) +
  1806. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1807. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1808. f.x ) +
  1809. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1810. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1811. f.y ) +
  1812. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1813. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1814. f.y ) +
  1815. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1816. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1817. f.x ),
  1818. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1819. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1820. f.x ),
  1821. f.y )
  1822. ) * ( 1.0 / 9.0 );
  1823. #elif defined( SHADOWMAP_TYPE_VSM )
  1824. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1825. #else
  1826. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1827. #endif
  1828. }
  1829. return mix( 1.0, shadow, shadowIntensity );
  1830. }
  1831. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1832. vec3 absV = abs( v );
  1833. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1834. absV *= scaleToCube;
  1835. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1836. vec2 planar = v.xy;
  1837. float almostATexel = 1.5 * texelSizeY;
  1838. float almostOne = 1.0 - almostATexel;
  1839. if ( absV.z >= almostOne ) {
  1840. if ( v.z > 0.0 )
  1841. planar.x = 4.0 - v.x;
  1842. } else if ( absV.x >= almostOne ) {
  1843. float signX = sign( v.x );
  1844. planar.x = v.z * signX + 2.0 * signX;
  1845. } else if ( absV.y >= almostOne ) {
  1846. float signY = sign( v.y );
  1847. planar.x = v.x + 2.0 * signY + 2.0;
  1848. planar.y = v.z * signY - 2.0;
  1849. }
  1850. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1851. }
  1852. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1853. float shadow = 1.0;
  1854. vec3 lightToPosition = shadowCoord.xyz;
  1855. float lightToPositionLength = length( lightToPosition );
  1856. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1857. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1858. vec3 bd3D = normalize( lightToPosition );
  1859. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1860. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1861. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1862. shadow = (
  1863. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1864. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1865. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1866. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1867. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1868. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1869. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1870. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1871. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1872. ) * ( 1.0 / 9.0 );
  1873. #else
  1874. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1875. #endif
  1876. }
  1877. return mix( 1.0, shadow, shadowIntensity );
  1878. }
  1879. #endif`,Zbe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1880. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1881. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1882. #endif
  1883. #ifdef USE_SHADOWMAP
  1884. #if NUM_DIR_LIGHT_SHADOWS > 0
  1885. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1886. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1887. struct DirectionalLightShadow {
  1888. float shadowIntensity;
  1889. float shadowBias;
  1890. float shadowNormalBias;
  1891. float shadowRadius;
  1892. vec2 shadowMapSize;
  1893. };
  1894. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1895. #endif
  1896. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1897. struct SpotLightShadow {
  1898. float shadowIntensity;
  1899. float shadowBias;
  1900. float shadowNormalBias;
  1901. float shadowRadius;
  1902. vec2 shadowMapSize;
  1903. };
  1904. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1905. #endif
  1906. #if NUM_POINT_LIGHT_SHADOWS > 0
  1907. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1908. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1909. struct PointLightShadow {
  1910. float shadowIntensity;
  1911. float shadowBias;
  1912. float shadowNormalBias;
  1913. float shadowRadius;
  1914. vec2 shadowMapSize;
  1915. float shadowCameraNear;
  1916. float shadowCameraFar;
  1917. };
  1918. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1919. #endif
  1920. #endif`,Jbe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1921. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1922. vec4 shadowWorldPosition;
  1923. #endif
  1924. #if defined( USE_SHADOWMAP )
  1925. #if NUM_DIR_LIGHT_SHADOWS > 0
  1926. #pragma unroll_loop_start
  1927. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1928. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1929. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1930. }
  1931. #pragma unroll_loop_end
  1932. #endif
  1933. #if NUM_POINT_LIGHT_SHADOWS > 0
  1934. #pragma unroll_loop_start
  1935. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1936. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1937. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1938. }
  1939. #pragma unroll_loop_end
  1940. #endif
  1941. #endif
  1942. #if NUM_SPOT_LIGHT_COORDS > 0
  1943. #pragma unroll_loop_start
  1944. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1945. shadowWorldPosition = worldPosition;
  1946. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1947. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1948. #endif
  1949. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1950. }
  1951. #pragma unroll_loop_end
  1952. #endif`,exe=`float getShadowMask() {
  1953. float shadow = 1.0;
  1954. #ifdef USE_SHADOWMAP
  1955. #if NUM_DIR_LIGHT_SHADOWS > 0
  1956. DirectionalLightShadow directionalLight;
  1957. #pragma unroll_loop_start
  1958. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1959. directionalLight = directionalLightShadows[ i ];
  1960. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1961. }
  1962. #pragma unroll_loop_end
  1963. #endif
  1964. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1965. SpotLightShadow spotLight;
  1966. #pragma unroll_loop_start
  1967. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1968. spotLight = spotLightShadows[ i ];
  1969. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1970. }
  1971. #pragma unroll_loop_end
  1972. #endif
  1973. #if NUM_POINT_LIGHT_SHADOWS > 0
  1974. PointLightShadow pointLight;
  1975. #pragma unroll_loop_start
  1976. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1977. pointLight = pointLightShadows[ i ];
  1978. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1979. }
  1980. #pragma unroll_loop_end
  1981. #endif
  1982. #endif
  1983. return shadow;
  1984. }`,txe=`#ifdef USE_SKINNING
  1985. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1986. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1987. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1988. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1989. #endif`,nxe=`#ifdef USE_SKINNING
  1990. uniform mat4 bindMatrix;
  1991. uniform mat4 bindMatrixInverse;
  1992. uniform highp sampler2D boneTexture;
  1993. mat4 getBoneMatrix( const in float i ) {
  1994. int size = textureSize( boneTexture, 0 ).x;
  1995. int j = int( i ) * 4;
  1996. int x = j % size;
  1997. int y = j / size;
  1998. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1999. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2000. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2001. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2002. return mat4( v1, v2, v3, v4 );
  2003. }
  2004. #endif`,rxe=`#ifdef USE_SKINNING
  2005. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2006. vec4 skinned = vec4( 0.0 );
  2007. skinned += boneMatX * skinVertex * skinWeight.x;
  2008. skinned += boneMatY * skinVertex * skinWeight.y;
  2009. skinned += boneMatZ * skinVertex * skinWeight.z;
  2010. skinned += boneMatW * skinVertex * skinWeight.w;
  2011. transformed = ( bindMatrixInverse * skinned ).xyz;
  2012. #endif`,ixe=`#ifdef USE_SKINNING
  2013. mat4 skinMatrix = mat4( 0.0 );
  2014. skinMatrix += skinWeight.x * boneMatX;
  2015. skinMatrix += skinWeight.y * boneMatY;
  2016. skinMatrix += skinWeight.z * boneMatZ;
  2017. skinMatrix += skinWeight.w * boneMatW;
  2018. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2019. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2020. #ifdef USE_TANGENT
  2021. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2022. #endif
  2023. #endif`,axe=`float specularStrength;
  2024. #ifdef USE_SPECULARMAP
  2025. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2026. specularStrength = texelSpecular.r;
  2027. #else
  2028. specularStrength = 1.0;
  2029. #endif`,sxe=`#ifdef USE_SPECULARMAP
  2030. uniform sampler2D specularMap;
  2031. #endif`,oxe=`#if defined( TONE_MAPPING )
  2032. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2033. #endif`,lxe=`#ifndef saturate
  2034. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2035. #endif
  2036. uniform float toneMappingExposure;
  2037. vec3 LinearToneMapping( vec3 color ) {
  2038. return saturate( toneMappingExposure * color );
  2039. }
  2040. vec3 ReinhardToneMapping( vec3 color ) {
  2041. color *= toneMappingExposure;
  2042. return saturate( color / ( vec3( 1.0 ) + color ) );
  2043. }
  2044. vec3 CineonToneMapping( vec3 color ) {
  2045. color *= toneMappingExposure;
  2046. color = max( vec3( 0.0 ), color - 0.004 );
  2047. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2048. }
  2049. vec3 RRTAndODTFit( vec3 v ) {
  2050. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2051. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2052. return a / b;
  2053. }
  2054. vec3 ACESFilmicToneMapping( vec3 color ) {
  2055. const mat3 ACESInputMat = mat3(
  2056. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2057. vec3( 0.04823, 0.01566, 0.83777 )
  2058. );
  2059. const mat3 ACESOutputMat = mat3(
  2060. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2061. vec3( -0.07367, -0.00605, 1.07602 )
  2062. );
  2063. color *= toneMappingExposure / 0.6;
  2064. color = ACESInputMat * color;
  2065. color = RRTAndODTFit( color );
  2066. color = ACESOutputMat * color;
  2067. return saturate( color );
  2068. }
  2069. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2070. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2071. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2072. vec3( - 0.0728, - 0.0083, 1.1187 )
  2073. );
  2074. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2075. vec3( 0.6274, 0.0691, 0.0164 ),
  2076. vec3( 0.3293, 0.9195, 0.0880 ),
  2077. vec3( 0.0433, 0.0113, 0.8956 )
  2078. );
  2079. vec3 agxDefaultContrastApprox( vec3 x ) {
  2080. vec3 x2 = x * x;
  2081. vec3 x4 = x2 * x2;
  2082. return + 15.5 * x4 * x2
  2083. - 40.14 * x4 * x
  2084. + 31.96 * x4
  2085. - 6.868 * x2 * x
  2086. + 0.4298 * x2
  2087. + 0.1191 * x
  2088. - 0.00232;
  2089. }
  2090. vec3 AgXToneMapping( vec3 color ) {
  2091. const mat3 AgXInsetMatrix = mat3(
  2092. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2093. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2094. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2095. );
  2096. const mat3 AgXOutsetMatrix = mat3(
  2097. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2098. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2099. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2100. );
  2101. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2102. color *= toneMappingExposure;
  2103. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2104. color = AgXInsetMatrix * color;
  2105. color = max( color, 1e-10 ); color = log2( color );
  2106. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2107. color = clamp( color, 0.0, 1.0 );
  2108. color = agxDefaultContrastApprox( color );
  2109. color = AgXOutsetMatrix * color;
  2110. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2111. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2112. color = clamp( color, 0.0, 1.0 );
  2113. return color;
  2114. }
  2115. vec3 NeutralToneMapping( vec3 color ) {
  2116. const float StartCompression = 0.8 - 0.04;
  2117. const float Desaturation = 0.15;
  2118. color *= toneMappingExposure;
  2119. float x = min( color.r, min( color.g, color.b ) );
  2120. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2121. color -= offset;
  2122. float peak = max( color.r, max( color.g, color.b ) );
  2123. if ( peak < StartCompression ) return color;
  2124. float d = 1. - StartCompression;
  2125. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2126. color *= newPeak / peak;
  2127. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2128. return mix( color, vec3( newPeak ), g );
  2129. }
  2130. vec3 CustomToneMapping( vec3 color ) { return color; }`,cxe=`#ifdef USE_TRANSMISSION
  2131. material.transmission = transmission;
  2132. material.transmissionAlpha = 1.0;
  2133. material.thickness = thickness;
  2134. material.attenuationDistance = attenuationDistance;
  2135. material.attenuationColor = attenuationColor;
  2136. #ifdef USE_TRANSMISSIONMAP
  2137. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2138. #endif
  2139. #ifdef USE_THICKNESSMAP
  2140. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2141. #endif
  2142. vec3 pos = vWorldPosition;
  2143. vec3 v = normalize( cameraPosition - pos );
  2144. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2145. vec4 transmitted = getIBLVolumeRefraction(
  2146. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2147. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2148. material.attenuationColor, material.attenuationDistance );
  2149. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2150. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2151. #endif`,uxe=`#ifdef USE_TRANSMISSION
  2152. uniform float transmission;
  2153. uniform float thickness;
  2154. uniform float attenuationDistance;
  2155. uniform vec3 attenuationColor;
  2156. #ifdef USE_TRANSMISSIONMAP
  2157. uniform sampler2D transmissionMap;
  2158. #endif
  2159. #ifdef USE_THICKNESSMAP
  2160. uniform sampler2D thicknessMap;
  2161. #endif
  2162. uniform vec2 transmissionSamplerSize;
  2163. uniform sampler2D transmissionSamplerMap;
  2164. uniform mat4 modelMatrix;
  2165. uniform mat4 projectionMatrix;
  2166. varying vec3 vWorldPosition;
  2167. float w0( float a ) {
  2168. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2169. }
  2170. float w1( float a ) {
  2171. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2172. }
  2173. float w2( float a ){
  2174. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2175. }
  2176. float w3( float a ) {
  2177. return ( 1.0 / 6.0 ) * ( a * a * a );
  2178. }
  2179. float g0( float a ) {
  2180. return w0( a ) + w1( a );
  2181. }
  2182. float g1( float a ) {
  2183. return w2( a ) + w3( a );
  2184. }
  2185. float h0( float a ) {
  2186. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2187. }
  2188. float h1( float a ) {
  2189. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2190. }
  2191. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2192. uv = uv * texelSize.zw + 0.5;
  2193. vec2 iuv = floor( uv );
  2194. vec2 fuv = fract( uv );
  2195. float g0x = g0( fuv.x );
  2196. float g1x = g1( fuv.x );
  2197. float h0x = h0( fuv.x );
  2198. float h1x = h1( fuv.x );
  2199. float h0y = h0( fuv.y );
  2200. float h1y = h1( fuv.y );
  2201. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2202. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2203. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2204. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2205. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2206. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2207. }
  2208. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2209. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2210. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2211. vec2 fLodSizeInv = 1.0 / fLodSize;
  2212. vec2 cLodSizeInv = 1.0 / cLodSize;
  2213. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2214. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2215. return mix( fSample, cSample, fract( lod ) );
  2216. }
  2217. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2218. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2219. vec3 modelScale;
  2220. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2221. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2222. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2223. return normalize( refractionVector ) * thickness * modelScale;
  2224. }
  2225. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2226. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2227. }
  2228. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2229. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2230. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2231. }
  2232. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2233. if ( isinf( attenuationDistance ) ) {
  2234. return vec3( 1.0 );
  2235. } else {
  2236. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2237. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2238. }
  2239. }
  2240. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2241. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2242. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2243. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2244. vec4 transmittedLight;
  2245. vec3 transmittance;
  2246. #ifdef USE_DISPERSION
  2247. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2248. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2249. for ( int i = 0; i < 3; i ++ ) {
  2250. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2251. vec3 refractedRayExit = position + transmissionRay;
  2252. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2253. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2254. refractionCoords += 1.0;
  2255. refractionCoords /= 2.0;
  2256. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2257. transmittedLight[ i ] = transmissionSample[ i ];
  2258. transmittedLight.a += transmissionSample.a;
  2259. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2260. }
  2261. transmittedLight.a /= 3.0;
  2262. #else
  2263. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2264. vec3 refractedRayExit = position + transmissionRay;
  2265. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2266. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2267. refractionCoords += 1.0;
  2268. refractionCoords /= 2.0;
  2269. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2270. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2271. #endif
  2272. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2273. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2274. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2275. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2276. }
  2277. #endif`,dxe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2278. varying vec2 vUv;
  2279. #endif
  2280. #ifdef USE_MAP
  2281. varying vec2 vMapUv;
  2282. #endif
  2283. #ifdef USE_ALPHAMAP
  2284. varying vec2 vAlphaMapUv;
  2285. #endif
  2286. #ifdef USE_LIGHTMAP
  2287. varying vec2 vLightMapUv;
  2288. #endif
  2289. #ifdef USE_AOMAP
  2290. varying vec2 vAoMapUv;
  2291. #endif
  2292. #ifdef USE_BUMPMAP
  2293. varying vec2 vBumpMapUv;
  2294. #endif
  2295. #ifdef USE_NORMALMAP
  2296. varying vec2 vNormalMapUv;
  2297. #endif
  2298. #ifdef USE_EMISSIVEMAP
  2299. varying vec2 vEmissiveMapUv;
  2300. #endif
  2301. #ifdef USE_METALNESSMAP
  2302. varying vec2 vMetalnessMapUv;
  2303. #endif
  2304. #ifdef USE_ROUGHNESSMAP
  2305. varying vec2 vRoughnessMapUv;
  2306. #endif
  2307. #ifdef USE_ANISOTROPYMAP
  2308. varying vec2 vAnisotropyMapUv;
  2309. #endif
  2310. #ifdef USE_CLEARCOATMAP
  2311. varying vec2 vClearcoatMapUv;
  2312. #endif
  2313. #ifdef USE_CLEARCOAT_NORMALMAP
  2314. varying vec2 vClearcoatNormalMapUv;
  2315. #endif
  2316. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2317. varying vec2 vClearcoatRoughnessMapUv;
  2318. #endif
  2319. #ifdef USE_IRIDESCENCEMAP
  2320. varying vec2 vIridescenceMapUv;
  2321. #endif
  2322. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2323. varying vec2 vIridescenceThicknessMapUv;
  2324. #endif
  2325. #ifdef USE_SHEEN_COLORMAP
  2326. varying vec2 vSheenColorMapUv;
  2327. #endif
  2328. #ifdef USE_SHEEN_ROUGHNESSMAP
  2329. varying vec2 vSheenRoughnessMapUv;
  2330. #endif
  2331. #ifdef USE_SPECULARMAP
  2332. varying vec2 vSpecularMapUv;
  2333. #endif
  2334. #ifdef USE_SPECULAR_COLORMAP
  2335. varying vec2 vSpecularColorMapUv;
  2336. #endif
  2337. #ifdef USE_SPECULAR_INTENSITYMAP
  2338. varying vec2 vSpecularIntensityMapUv;
  2339. #endif
  2340. #ifdef USE_TRANSMISSIONMAP
  2341. uniform mat3 transmissionMapTransform;
  2342. varying vec2 vTransmissionMapUv;
  2343. #endif
  2344. #ifdef USE_THICKNESSMAP
  2345. uniform mat3 thicknessMapTransform;
  2346. varying vec2 vThicknessMapUv;
  2347. #endif`,hxe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2348. varying vec2 vUv;
  2349. #endif
  2350. #ifdef USE_MAP
  2351. uniform mat3 mapTransform;
  2352. varying vec2 vMapUv;
  2353. #endif
  2354. #ifdef USE_ALPHAMAP
  2355. uniform mat3 alphaMapTransform;
  2356. varying vec2 vAlphaMapUv;
  2357. #endif
  2358. #ifdef USE_LIGHTMAP
  2359. uniform mat3 lightMapTransform;
  2360. varying vec2 vLightMapUv;
  2361. #endif
  2362. #ifdef USE_AOMAP
  2363. uniform mat3 aoMapTransform;
  2364. varying vec2 vAoMapUv;
  2365. #endif
  2366. #ifdef USE_BUMPMAP
  2367. uniform mat3 bumpMapTransform;
  2368. varying vec2 vBumpMapUv;
  2369. #endif
  2370. #ifdef USE_NORMALMAP
  2371. uniform mat3 normalMapTransform;
  2372. varying vec2 vNormalMapUv;
  2373. #endif
  2374. #ifdef USE_DISPLACEMENTMAP
  2375. uniform mat3 displacementMapTransform;
  2376. varying vec2 vDisplacementMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. uniform mat3 emissiveMapTransform;
  2380. varying vec2 vEmissiveMapUv;
  2381. #endif
  2382. #ifdef USE_METALNESSMAP
  2383. uniform mat3 metalnessMapTransform;
  2384. varying vec2 vMetalnessMapUv;
  2385. #endif
  2386. #ifdef USE_ROUGHNESSMAP
  2387. uniform mat3 roughnessMapTransform;
  2388. varying vec2 vRoughnessMapUv;
  2389. #endif
  2390. #ifdef USE_ANISOTROPYMAP
  2391. uniform mat3 anisotropyMapTransform;
  2392. varying vec2 vAnisotropyMapUv;
  2393. #endif
  2394. #ifdef USE_CLEARCOATMAP
  2395. uniform mat3 clearcoatMapTransform;
  2396. varying vec2 vClearcoatMapUv;
  2397. #endif
  2398. #ifdef USE_CLEARCOAT_NORMALMAP
  2399. uniform mat3 clearcoatNormalMapTransform;
  2400. varying vec2 vClearcoatNormalMapUv;
  2401. #endif
  2402. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2403. uniform mat3 clearcoatRoughnessMapTransform;
  2404. varying vec2 vClearcoatRoughnessMapUv;
  2405. #endif
  2406. #ifdef USE_SHEEN_COLORMAP
  2407. uniform mat3 sheenColorMapTransform;
  2408. varying vec2 vSheenColorMapUv;
  2409. #endif
  2410. #ifdef USE_SHEEN_ROUGHNESSMAP
  2411. uniform mat3 sheenRoughnessMapTransform;
  2412. varying vec2 vSheenRoughnessMapUv;
  2413. #endif
  2414. #ifdef USE_IRIDESCENCEMAP
  2415. uniform mat3 iridescenceMapTransform;
  2416. varying vec2 vIridescenceMapUv;
  2417. #endif
  2418. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2419. uniform mat3 iridescenceThicknessMapTransform;
  2420. varying vec2 vIridescenceThicknessMapUv;
  2421. #endif
  2422. #ifdef USE_SPECULARMAP
  2423. uniform mat3 specularMapTransform;
  2424. varying vec2 vSpecularMapUv;
  2425. #endif
  2426. #ifdef USE_SPECULAR_COLORMAP
  2427. uniform mat3 specularColorMapTransform;
  2428. varying vec2 vSpecularColorMapUv;
  2429. #endif
  2430. #ifdef USE_SPECULAR_INTENSITYMAP
  2431. uniform mat3 specularIntensityMapTransform;
  2432. varying vec2 vSpecularIntensityMapUv;
  2433. #endif
  2434. #ifdef USE_TRANSMISSIONMAP
  2435. uniform mat3 transmissionMapTransform;
  2436. varying vec2 vTransmissionMapUv;
  2437. #endif
  2438. #ifdef USE_THICKNESSMAP
  2439. uniform mat3 thicknessMapTransform;
  2440. varying vec2 vThicknessMapUv;
  2441. #endif`,fxe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2442. vUv = vec3( uv, 1 ).xy;
  2443. #endif
  2444. #ifdef USE_MAP
  2445. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_ALPHAMAP
  2448. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_LIGHTMAP
  2451. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_AOMAP
  2454. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_BUMPMAP
  2457. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_NORMALMAP
  2460. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_DISPLACEMENTMAP
  2463. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_EMISSIVEMAP
  2466. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2467. #endif
  2468. #ifdef USE_METALNESSMAP
  2469. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2470. #endif
  2471. #ifdef USE_ROUGHNESSMAP
  2472. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2473. #endif
  2474. #ifdef USE_ANISOTROPYMAP
  2475. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2476. #endif
  2477. #ifdef USE_CLEARCOATMAP
  2478. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2479. #endif
  2480. #ifdef USE_CLEARCOAT_NORMALMAP
  2481. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2482. #endif
  2483. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2484. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2485. #endif
  2486. #ifdef USE_IRIDESCENCEMAP
  2487. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2488. #endif
  2489. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2490. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2491. #endif
  2492. #ifdef USE_SHEEN_COLORMAP
  2493. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2494. #endif
  2495. #ifdef USE_SHEEN_ROUGHNESSMAP
  2496. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2497. #endif
  2498. #ifdef USE_SPECULARMAP
  2499. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2500. #endif
  2501. #ifdef USE_SPECULAR_COLORMAP
  2502. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2503. #endif
  2504. #ifdef USE_SPECULAR_INTENSITYMAP
  2505. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2506. #endif
  2507. #ifdef USE_TRANSMISSIONMAP
  2508. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2509. #endif
  2510. #ifdef USE_THICKNESSMAP
  2511. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2512. #endif`,mxe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2513. vec4 worldPosition = vec4( transformed, 1.0 );
  2514. #ifdef USE_BATCHING
  2515. worldPosition = batchingMatrix * worldPosition;
  2516. #endif
  2517. #ifdef USE_INSTANCING
  2518. worldPosition = instanceMatrix * worldPosition;
  2519. #endif
  2520. worldPosition = modelMatrix * worldPosition;
  2521. #endif`;const pxe=`varying vec2 vUv;
  2522. uniform mat3 uvTransform;
  2523. void main() {
  2524. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2525. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2526. }`,gxe=`uniform sampler2D t2D;
  2527. uniform float backgroundIntensity;
  2528. varying vec2 vUv;
  2529. void main() {
  2530. vec4 texColor = texture2D( t2D, vUv );
  2531. #ifdef DECODE_VIDEO_TEXTURE
  2532. 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 );
  2533. #endif
  2534. texColor.rgb *= backgroundIntensity;
  2535. gl_FragColor = texColor;
  2536. #include <tonemapping_fragment>
  2537. #include <colorspace_fragment>
  2538. }`,bxe=`varying vec3 vWorldDirection;
  2539. #include <common>
  2540. void main() {
  2541. vWorldDirection = transformDirection( position, modelMatrix );
  2542. #include <begin_vertex>
  2543. #include <project_vertex>
  2544. gl_Position.z = gl_Position.w;
  2545. }`,xxe=`#ifdef ENVMAP_TYPE_CUBE
  2546. uniform samplerCube envMap;
  2547. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2548. uniform sampler2D envMap;
  2549. #endif
  2550. uniform float flipEnvMap;
  2551. uniform float backgroundBlurriness;
  2552. uniform float backgroundIntensity;
  2553. uniform mat3 backgroundRotation;
  2554. varying vec3 vWorldDirection;
  2555. #include <cube_uv_reflection_fragment>
  2556. void main() {
  2557. #ifdef ENVMAP_TYPE_CUBE
  2558. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2559. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2560. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2561. #else
  2562. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2563. #endif
  2564. texColor.rgb *= backgroundIntensity;
  2565. gl_FragColor = texColor;
  2566. #include <tonemapping_fragment>
  2567. #include <colorspace_fragment>
  2568. }`,yxe=`varying vec3 vWorldDirection;
  2569. #include <common>
  2570. void main() {
  2571. vWorldDirection = transformDirection( position, modelMatrix );
  2572. #include <begin_vertex>
  2573. #include <project_vertex>
  2574. gl_Position.z = gl_Position.w;
  2575. }`,vxe=`uniform samplerCube tCube;
  2576. uniform float tFlip;
  2577. uniform float opacity;
  2578. varying vec3 vWorldDirection;
  2579. void main() {
  2580. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2581. gl_FragColor = texColor;
  2582. gl_FragColor.a *= opacity;
  2583. #include <tonemapping_fragment>
  2584. #include <colorspace_fragment>
  2585. }`,wxe=`#include <common>
  2586. #include <batching_pars_vertex>
  2587. #include <uv_pars_vertex>
  2588. #include <displacementmap_pars_vertex>
  2589. #include <morphtarget_pars_vertex>
  2590. #include <skinning_pars_vertex>
  2591. #include <logdepthbuf_pars_vertex>
  2592. #include <clipping_planes_pars_vertex>
  2593. varying vec2 vHighPrecisionZW;
  2594. void main() {
  2595. #include <uv_vertex>
  2596. #include <batching_vertex>
  2597. #include <skinbase_vertex>
  2598. #include <morphinstance_vertex>
  2599. #ifdef USE_DISPLACEMENTMAP
  2600. #include <beginnormal_vertex>
  2601. #include <morphnormal_vertex>
  2602. #include <skinnormal_vertex>
  2603. #endif
  2604. #include <begin_vertex>
  2605. #include <morphtarget_vertex>
  2606. #include <skinning_vertex>
  2607. #include <displacementmap_vertex>
  2608. #include <project_vertex>
  2609. #include <logdepthbuf_vertex>
  2610. #include <clipping_planes_vertex>
  2611. vHighPrecisionZW = gl_Position.zw;
  2612. }`,_xe=`#if DEPTH_PACKING == 3200
  2613. uniform float opacity;
  2614. #endif
  2615. #include <common>
  2616. #include <packing>
  2617. #include <uv_pars_fragment>
  2618. #include <map_pars_fragment>
  2619. #include <alphamap_pars_fragment>
  2620. #include <alphatest_pars_fragment>
  2621. #include <alphahash_pars_fragment>
  2622. #include <logdepthbuf_pars_fragment>
  2623. #include <clipping_planes_pars_fragment>
  2624. varying vec2 vHighPrecisionZW;
  2625. void main() {
  2626. vec4 diffuseColor = vec4( 1.0 );
  2627. #include <clipping_planes_fragment>
  2628. #if DEPTH_PACKING == 3200
  2629. diffuseColor.a = opacity;
  2630. #endif
  2631. #include <map_fragment>
  2632. #include <alphamap_fragment>
  2633. #include <alphatest_fragment>
  2634. #include <alphahash_fragment>
  2635. #include <logdepthbuf_fragment>
  2636. #ifdef USE_REVERSED_DEPTH_BUFFER
  2637. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2638. #else
  2639. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2640. #endif
  2641. #if DEPTH_PACKING == 3200
  2642. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2643. #elif DEPTH_PACKING == 3201
  2644. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2645. #elif DEPTH_PACKING == 3202
  2646. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2647. #elif DEPTH_PACKING == 3203
  2648. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2649. #endif
  2650. }`,Sxe=`#define DISTANCE
  2651. varying vec3 vWorldPosition;
  2652. #include <common>
  2653. #include <batching_pars_vertex>
  2654. #include <uv_pars_vertex>
  2655. #include <displacementmap_pars_vertex>
  2656. #include <morphtarget_pars_vertex>
  2657. #include <skinning_pars_vertex>
  2658. #include <clipping_planes_pars_vertex>
  2659. void main() {
  2660. #include <uv_vertex>
  2661. #include <batching_vertex>
  2662. #include <skinbase_vertex>
  2663. #include <morphinstance_vertex>
  2664. #ifdef USE_DISPLACEMENTMAP
  2665. #include <beginnormal_vertex>
  2666. #include <morphnormal_vertex>
  2667. #include <skinnormal_vertex>
  2668. #endif
  2669. #include <begin_vertex>
  2670. #include <morphtarget_vertex>
  2671. #include <skinning_vertex>
  2672. #include <displacementmap_vertex>
  2673. #include <project_vertex>
  2674. #include <worldpos_vertex>
  2675. #include <clipping_planes_vertex>
  2676. vWorldPosition = worldPosition.xyz;
  2677. }`,Nxe=`#define DISTANCE
  2678. uniform vec3 referencePosition;
  2679. uniform float nearDistance;
  2680. uniform float farDistance;
  2681. varying vec3 vWorldPosition;
  2682. #include <common>
  2683. #include <packing>
  2684. #include <uv_pars_fragment>
  2685. #include <map_pars_fragment>
  2686. #include <alphamap_pars_fragment>
  2687. #include <alphatest_pars_fragment>
  2688. #include <alphahash_pars_fragment>
  2689. #include <clipping_planes_pars_fragment>
  2690. void main () {
  2691. vec4 diffuseColor = vec4( 1.0 );
  2692. #include <clipping_planes_fragment>
  2693. #include <map_fragment>
  2694. #include <alphamap_fragment>
  2695. #include <alphatest_fragment>
  2696. #include <alphahash_fragment>
  2697. float dist = length( vWorldPosition - referencePosition );
  2698. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2699. dist = saturate( dist );
  2700. gl_FragColor = packDepthToRGBA( dist );
  2701. }`,kxe=`varying vec3 vWorldDirection;
  2702. #include <common>
  2703. void main() {
  2704. vWorldDirection = transformDirection( position, modelMatrix );
  2705. #include <begin_vertex>
  2706. #include <project_vertex>
  2707. }`,Mxe=`uniform sampler2D tEquirect;
  2708. varying vec3 vWorldDirection;
  2709. #include <common>
  2710. void main() {
  2711. vec3 direction = normalize( vWorldDirection );
  2712. vec2 sampleUV = equirectUv( direction );
  2713. gl_FragColor = texture2D( tEquirect, sampleUV );
  2714. #include <tonemapping_fragment>
  2715. #include <colorspace_fragment>
  2716. }`,Cxe=`uniform float scale;
  2717. attribute float lineDistance;
  2718. varying float vLineDistance;
  2719. #include <common>
  2720. #include <uv_pars_vertex>
  2721. #include <color_pars_vertex>
  2722. #include <fog_pars_vertex>
  2723. #include <morphtarget_pars_vertex>
  2724. #include <logdepthbuf_pars_vertex>
  2725. #include <clipping_planes_pars_vertex>
  2726. void main() {
  2727. vLineDistance = scale * lineDistance;
  2728. #include <uv_vertex>
  2729. #include <color_vertex>
  2730. #include <morphinstance_vertex>
  2731. #include <morphcolor_vertex>
  2732. #include <begin_vertex>
  2733. #include <morphtarget_vertex>
  2734. #include <project_vertex>
  2735. #include <logdepthbuf_vertex>
  2736. #include <clipping_planes_vertex>
  2737. #include <fog_vertex>
  2738. }`,Exe=`uniform vec3 diffuse;
  2739. uniform float opacity;
  2740. uniform float dashSize;
  2741. uniform float totalSize;
  2742. varying float vLineDistance;
  2743. #include <common>
  2744. #include <color_pars_fragment>
  2745. #include <uv_pars_fragment>
  2746. #include <map_pars_fragment>
  2747. #include <fog_pars_fragment>
  2748. #include <logdepthbuf_pars_fragment>
  2749. #include <clipping_planes_pars_fragment>
  2750. void main() {
  2751. vec4 diffuseColor = vec4( diffuse, opacity );
  2752. #include <clipping_planes_fragment>
  2753. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2754. discard;
  2755. }
  2756. vec3 outgoingLight = vec3( 0.0 );
  2757. #include <logdepthbuf_fragment>
  2758. #include <map_fragment>
  2759. #include <color_fragment>
  2760. outgoingLight = diffuseColor.rgb;
  2761. #include <opaque_fragment>
  2762. #include <tonemapping_fragment>
  2763. #include <colorspace_fragment>
  2764. #include <fog_fragment>
  2765. #include <premultiplied_alpha_fragment>
  2766. }`,Axe=`#include <common>
  2767. #include <batching_pars_vertex>
  2768. #include <uv_pars_vertex>
  2769. #include <envmap_pars_vertex>
  2770. #include <color_pars_vertex>
  2771. #include <fog_pars_vertex>
  2772. #include <morphtarget_pars_vertex>
  2773. #include <skinning_pars_vertex>
  2774. #include <logdepthbuf_pars_vertex>
  2775. #include <clipping_planes_pars_vertex>
  2776. void main() {
  2777. #include <uv_vertex>
  2778. #include <color_vertex>
  2779. #include <morphinstance_vertex>
  2780. #include <morphcolor_vertex>
  2781. #include <batching_vertex>
  2782. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2783. #include <beginnormal_vertex>
  2784. #include <morphnormal_vertex>
  2785. #include <skinbase_vertex>
  2786. #include <skinnormal_vertex>
  2787. #include <defaultnormal_vertex>
  2788. #endif
  2789. #include <begin_vertex>
  2790. #include <morphtarget_vertex>
  2791. #include <skinning_vertex>
  2792. #include <project_vertex>
  2793. #include <logdepthbuf_vertex>
  2794. #include <clipping_planes_vertex>
  2795. #include <worldpos_vertex>
  2796. #include <envmap_vertex>
  2797. #include <fog_vertex>
  2798. }`,Txe=`uniform vec3 diffuse;
  2799. uniform float opacity;
  2800. #ifndef FLAT_SHADED
  2801. varying vec3 vNormal;
  2802. #endif
  2803. #include <common>
  2804. #include <dithering_pars_fragment>
  2805. #include <color_pars_fragment>
  2806. #include <uv_pars_fragment>
  2807. #include <map_pars_fragment>
  2808. #include <alphamap_pars_fragment>
  2809. #include <alphatest_pars_fragment>
  2810. #include <alphahash_pars_fragment>
  2811. #include <aomap_pars_fragment>
  2812. #include <lightmap_pars_fragment>
  2813. #include <envmap_common_pars_fragment>
  2814. #include <envmap_pars_fragment>
  2815. #include <fog_pars_fragment>
  2816. #include <specularmap_pars_fragment>
  2817. #include <logdepthbuf_pars_fragment>
  2818. #include <clipping_planes_pars_fragment>
  2819. void main() {
  2820. vec4 diffuseColor = vec4( diffuse, opacity );
  2821. #include <clipping_planes_fragment>
  2822. #include <logdepthbuf_fragment>
  2823. #include <map_fragment>
  2824. #include <color_fragment>
  2825. #include <alphamap_fragment>
  2826. #include <alphatest_fragment>
  2827. #include <alphahash_fragment>
  2828. #include <specularmap_fragment>
  2829. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2830. #ifdef USE_LIGHTMAP
  2831. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2832. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2833. #else
  2834. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2835. #endif
  2836. #include <aomap_fragment>
  2837. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2838. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2839. #include <envmap_fragment>
  2840. #include <opaque_fragment>
  2841. #include <tonemapping_fragment>
  2842. #include <colorspace_fragment>
  2843. #include <fog_fragment>
  2844. #include <premultiplied_alpha_fragment>
  2845. #include <dithering_fragment>
  2846. }`,jxe=`#define LAMBERT
  2847. varying vec3 vViewPosition;
  2848. #include <common>
  2849. #include <batching_pars_vertex>
  2850. #include <uv_pars_vertex>
  2851. #include <displacementmap_pars_vertex>
  2852. #include <envmap_pars_vertex>
  2853. #include <color_pars_vertex>
  2854. #include <fog_pars_vertex>
  2855. #include <normal_pars_vertex>
  2856. #include <morphtarget_pars_vertex>
  2857. #include <skinning_pars_vertex>
  2858. #include <shadowmap_pars_vertex>
  2859. #include <logdepthbuf_pars_vertex>
  2860. #include <clipping_planes_pars_vertex>
  2861. void main() {
  2862. #include <uv_vertex>
  2863. #include <color_vertex>
  2864. #include <morphinstance_vertex>
  2865. #include <morphcolor_vertex>
  2866. #include <batching_vertex>
  2867. #include <beginnormal_vertex>
  2868. #include <morphnormal_vertex>
  2869. #include <skinbase_vertex>
  2870. #include <skinnormal_vertex>
  2871. #include <defaultnormal_vertex>
  2872. #include <normal_vertex>
  2873. #include <begin_vertex>
  2874. #include <morphtarget_vertex>
  2875. #include <skinning_vertex>
  2876. #include <displacementmap_vertex>
  2877. #include <project_vertex>
  2878. #include <logdepthbuf_vertex>
  2879. #include <clipping_planes_vertex>
  2880. vViewPosition = - mvPosition.xyz;
  2881. #include <worldpos_vertex>
  2882. #include <envmap_vertex>
  2883. #include <shadowmap_vertex>
  2884. #include <fog_vertex>
  2885. }`,Pxe=`#define LAMBERT
  2886. uniform vec3 diffuse;
  2887. uniform vec3 emissive;
  2888. uniform float opacity;
  2889. #include <common>
  2890. #include <packing>
  2891. #include <dithering_pars_fragment>
  2892. #include <color_pars_fragment>
  2893. #include <uv_pars_fragment>
  2894. #include <map_pars_fragment>
  2895. #include <alphamap_pars_fragment>
  2896. #include <alphatest_pars_fragment>
  2897. #include <alphahash_pars_fragment>
  2898. #include <aomap_pars_fragment>
  2899. #include <lightmap_pars_fragment>
  2900. #include <emissivemap_pars_fragment>
  2901. #include <envmap_common_pars_fragment>
  2902. #include <envmap_pars_fragment>
  2903. #include <fog_pars_fragment>
  2904. #include <bsdfs>
  2905. #include <lights_pars_begin>
  2906. #include <normal_pars_fragment>
  2907. #include <lights_lambert_pars_fragment>
  2908. #include <shadowmap_pars_fragment>
  2909. #include <bumpmap_pars_fragment>
  2910. #include <normalmap_pars_fragment>
  2911. #include <specularmap_pars_fragment>
  2912. #include <logdepthbuf_pars_fragment>
  2913. #include <clipping_planes_pars_fragment>
  2914. void main() {
  2915. vec4 diffuseColor = vec4( diffuse, opacity );
  2916. #include <clipping_planes_fragment>
  2917. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2918. vec3 totalEmissiveRadiance = emissive;
  2919. #include <logdepthbuf_fragment>
  2920. #include <map_fragment>
  2921. #include <color_fragment>
  2922. #include <alphamap_fragment>
  2923. #include <alphatest_fragment>
  2924. #include <alphahash_fragment>
  2925. #include <specularmap_fragment>
  2926. #include <normal_fragment_begin>
  2927. #include <normal_fragment_maps>
  2928. #include <emissivemap_fragment>
  2929. #include <lights_lambert_fragment>
  2930. #include <lights_fragment_begin>
  2931. #include <lights_fragment_maps>
  2932. #include <lights_fragment_end>
  2933. #include <aomap_fragment>
  2934. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2935. #include <envmap_fragment>
  2936. #include <opaque_fragment>
  2937. #include <tonemapping_fragment>
  2938. #include <colorspace_fragment>
  2939. #include <fog_fragment>
  2940. #include <premultiplied_alpha_fragment>
  2941. #include <dithering_fragment>
  2942. }`,Dxe=`#define MATCAP
  2943. varying vec3 vViewPosition;
  2944. #include <common>
  2945. #include <batching_pars_vertex>
  2946. #include <uv_pars_vertex>
  2947. #include <color_pars_vertex>
  2948. #include <displacementmap_pars_vertex>
  2949. #include <fog_pars_vertex>
  2950. #include <normal_pars_vertex>
  2951. #include <morphtarget_pars_vertex>
  2952. #include <skinning_pars_vertex>
  2953. #include <logdepthbuf_pars_vertex>
  2954. #include <clipping_planes_pars_vertex>
  2955. void main() {
  2956. #include <uv_vertex>
  2957. #include <color_vertex>
  2958. #include <morphinstance_vertex>
  2959. #include <morphcolor_vertex>
  2960. #include <batching_vertex>
  2961. #include <beginnormal_vertex>
  2962. #include <morphnormal_vertex>
  2963. #include <skinbase_vertex>
  2964. #include <skinnormal_vertex>
  2965. #include <defaultnormal_vertex>
  2966. #include <normal_vertex>
  2967. #include <begin_vertex>
  2968. #include <morphtarget_vertex>
  2969. #include <skinning_vertex>
  2970. #include <displacementmap_vertex>
  2971. #include <project_vertex>
  2972. #include <logdepthbuf_vertex>
  2973. #include <clipping_planes_vertex>
  2974. #include <fog_vertex>
  2975. vViewPosition = - mvPosition.xyz;
  2976. }`,Rxe=`#define MATCAP
  2977. uniform vec3 diffuse;
  2978. uniform float opacity;
  2979. uniform sampler2D matcap;
  2980. varying vec3 vViewPosition;
  2981. #include <common>
  2982. #include <dithering_pars_fragment>
  2983. #include <color_pars_fragment>
  2984. #include <uv_pars_fragment>
  2985. #include <map_pars_fragment>
  2986. #include <alphamap_pars_fragment>
  2987. #include <alphatest_pars_fragment>
  2988. #include <alphahash_pars_fragment>
  2989. #include <fog_pars_fragment>
  2990. #include <normal_pars_fragment>
  2991. #include <bumpmap_pars_fragment>
  2992. #include <normalmap_pars_fragment>
  2993. #include <logdepthbuf_pars_fragment>
  2994. #include <clipping_planes_pars_fragment>
  2995. void main() {
  2996. vec4 diffuseColor = vec4( diffuse, opacity );
  2997. #include <clipping_planes_fragment>
  2998. #include <logdepthbuf_fragment>
  2999. #include <map_fragment>
  3000. #include <color_fragment>
  3001. #include <alphamap_fragment>
  3002. #include <alphatest_fragment>
  3003. #include <alphahash_fragment>
  3004. #include <normal_fragment_begin>
  3005. #include <normal_fragment_maps>
  3006. vec3 viewDir = normalize( vViewPosition );
  3007. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3008. vec3 y = cross( viewDir, x );
  3009. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3010. #ifdef USE_MATCAP
  3011. vec4 matcapColor = texture2D( matcap, uv );
  3012. #else
  3013. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3014. #endif
  3015. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3016. #include <opaque_fragment>
  3017. #include <tonemapping_fragment>
  3018. #include <colorspace_fragment>
  3019. #include <fog_fragment>
  3020. #include <premultiplied_alpha_fragment>
  3021. #include <dithering_fragment>
  3022. }`,Lxe=`#define NORMAL
  3023. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3024. varying vec3 vViewPosition;
  3025. #endif
  3026. #include <common>
  3027. #include <batching_pars_vertex>
  3028. #include <uv_pars_vertex>
  3029. #include <displacementmap_pars_vertex>
  3030. #include <normal_pars_vertex>
  3031. #include <morphtarget_pars_vertex>
  3032. #include <skinning_pars_vertex>
  3033. #include <logdepthbuf_pars_vertex>
  3034. #include <clipping_planes_pars_vertex>
  3035. void main() {
  3036. #include <uv_vertex>
  3037. #include <batching_vertex>
  3038. #include <beginnormal_vertex>
  3039. #include <morphinstance_vertex>
  3040. #include <morphnormal_vertex>
  3041. #include <skinbase_vertex>
  3042. #include <skinnormal_vertex>
  3043. #include <defaultnormal_vertex>
  3044. #include <normal_vertex>
  3045. #include <begin_vertex>
  3046. #include <morphtarget_vertex>
  3047. #include <skinning_vertex>
  3048. #include <displacementmap_vertex>
  3049. #include <project_vertex>
  3050. #include <logdepthbuf_vertex>
  3051. #include <clipping_planes_vertex>
  3052. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3053. vViewPosition = - mvPosition.xyz;
  3054. #endif
  3055. }`,Oxe=`#define NORMAL
  3056. uniform float opacity;
  3057. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3058. varying vec3 vViewPosition;
  3059. #endif
  3060. #include <packing>
  3061. #include <uv_pars_fragment>
  3062. #include <normal_pars_fragment>
  3063. #include <bumpmap_pars_fragment>
  3064. #include <normalmap_pars_fragment>
  3065. #include <logdepthbuf_pars_fragment>
  3066. #include <clipping_planes_pars_fragment>
  3067. void main() {
  3068. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3069. #include <clipping_planes_fragment>
  3070. #include <logdepthbuf_fragment>
  3071. #include <normal_fragment_begin>
  3072. #include <normal_fragment_maps>
  3073. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3074. #ifdef OPAQUE
  3075. gl_FragColor.a = 1.0;
  3076. #endif
  3077. }`,Fxe=`#define PHONG
  3078. varying vec3 vViewPosition;
  3079. #include <common>
  3080. #include <batching_pars_vertex>
  3081. #include <uv_pars_vertex>
  3082. #include <displacementmap_pars_vertex>
  3083. #include <envmap_pars_vertex>
  3084. #include <color_pars_vertex>
  3085. #include <fog_pars_vertex>
  3086. #include <normal_pars_vertex>
  3087. #include <morphtarget_pars_vertex>
  3088. #include <skinning_pars_vertex>
  3089. #include <shadowmap_pars_vertex>
  3090. #include <logdepthbuf_pars_vertex>
  3091. #include <clipping_planes_pars_vertex>
  3092. void main() {
  3093. #include <uv_vertex>
  3094. #include <color_vertex>
  3095. #include <morphcolor_vertex>
  3096. #include <batching_vertex>
  3097. #include <beginnormal_vertex>
  3098. #include <morphinstance_vertex>
  3099. #include <morphnormal_vertex>
  3100. #include <skinbase_vertex>
  3101. #include <skinnormal_vertex>
  3102. #include <defaultnormal_vertex>
  3103. #include <normal_vertex>
  3104. #include <begin_vertex>
  3105. #include <morphtarget_vertex>
  3106. #include <skinning_vertex>
  3107. #include <displacementmap_vertex>
  3108. #include <project_vertex>
  3109. #include <logdepthbuf_vertex>
  3110. #include <clipping_planes_vertex>
  3111. vViewPosition = - mvPosition.xyz;
  3112. #include <worldpos_vertex>
  3113. #include <envmap_vertex>
  3114. #include <shadowmap_vertex>
  3115. #include <fog_vertex>
  3116. }`,Ixe=`#define PHONG
  3117. uniform vec3 diffuse;
  3118. uniform vec3 emissive;
  3119. uniform vec3 specular;
  3120. uniform float shininess;
  3121. uniform float opacity;
  3122. #include <common>
  3123. #include <packing>
  3124. #include <dithering_pars_fragment>
  3125. #include <color_pars_fragment>
  3126. #include <uv_pars_fragment>
  3127. #include <map_pars_fragment>
  3128. #include <alphamap_pars_fragment>
  3129. #include <alphatest_pars_fragment>
  3130. #include <alphahash_pars_fragment>
  3131. #include <aomap_pars_fragment>
  3132. #include <lightmap_pars_fragment>
  3133. #include <emissivemap_pars_fragment>
  3134. #include <envmap_common_pars_fragment>
  3135. #include <envmap_pars_fragment>
  3136. #include <fog_pars_fragment>
  3137. #include <bsdfs>
  3138. #include <lights_pars_begin>
  3139. #include <normal_pars_fragment>
  3140. #include <lights_phong_pars_fragment>
  3141. #include <shadowmap_pars_fragment>
  3142. #include <bumpmap_pars_fragment>
  3143. #include <normalmap_pars_fragment>
  3144. #include <specularmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( diffuse, opacity );
  3149. #include <clipping_planes_fragment>
  3150. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3151. vec3 totalEmissiveRadiance = emissive;
  3152. #include <logdepthbuf_fragment>
  3153. #include <map_fragment>
  3154. #include <color_fragment>
  3155. #include <alphamap_fragment>
  3156. #include <alphatest_fragment>
  3157. #include <alphahash_fragment>
  3158. #include <specularmap_fragment>
  3159. #include <normal_fragment_begin>
  3160. #include <normal_fragment_maps>
  3161. #include <emissivemap_fragment>
  3162. #include <lights_phong_fragment>
  3163. #include <lights_fragment_begin>
  3164. #include <lights_fragment_maps>
  3165. #include <lights_fragment_end>
  3166. #include <aomap_fragment>
  3167. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3168. #include <envmap_fragment>
  3169. #include <opaque_fragment>
  3170. #include <tonemapping_fragment>
  3171. #include <colorspace_fragment>
  3172. #include <fog_fragment>
  3173. #include <premultiplied_alpha_fragment>
  3174. #include <dithering_fragment>
  3175. }`,zxe=`#define STANDARD
  3176. varying vec3 vViewPosition;
  3177. #ifdef USE_TRANSMISSION
  3178. varying vec3 vWorldPosition;
  3179. #endif
  3180. #include <common>
  3181. #include <batching_pars_vertex>
  3182. #include <uv_pars_vertex>
  3183. #include <displacementmap_pars_vertex>
  3184. #include <color_pars_vertex>
  3185. #include <fog_pars_vertex>
  3186. #include <normal_pars_vertex>
  3187. #include <morphtarget_pars_vertex>
  3188. #include <skinning_pars_vertex>
  3189. #include <shadowmap_pars_vertex>
  3190. #include <logdepthbuf_pars_vertex>
  3191. #include <clipping_planes_pars_vertex>
  3192. void main() {
  3193. #include <uv_vertex>
  3194. #include <color_vertex>
  3195. #include <morphinstance_vertex>
  3196. #include <morphcolor_vertex>
  3197. #include <batching_vertex>
  3198. #include <beginnormal_vertex>
  3199. #include <morphnormal_vertex>
  3200. #include <skinbase_vertex>
  3201. #include <skinnormal_vertex>
  3202. #include <defaultnormal_vertex>
  3203. #include <normal_vertex>
  3204. #include <begin_vertex>
  3205. #include <morphtarget_vertex>
  3206. #include <skinning_vertex>
  3207. #include <displacementmap_vertex>
  3208. #include <project_vertex>
  3209. #include <logdepthbuf_vertex>
  3210. #include <clipping_planes_vertex>
  3211. vViewPosition = - mvPosition.xyz;
  3212. #include <worldpos_vertex>
  3213. #include <shadowmap_vertex>
  3214. #include <fog_vertex>
  3215. #ifdef USE_TRANSMISSION
  3216. vWorldPosition = worldPosition.xyz;
  3217. #endif
  3218. }`,Uxe=`#define STANDARD
  3219. #ifdef PHYSICAL
  3220. #define IOR
  3221. #define USE_SPECULAR
  3222. #endif
  3223. uniform vec3 diffuse;
  3224. uniform vec3 emissive;
  3225. uniform float roughness;
  3226. uniform float metalness;
  3227. uniform float opacity;
  3228. #ifdef IOR
  3229. uniform float ior;
  3230. #endif
  3231. #ifdef USE_SPECULAR
  3232. uniform float specularIntensity;
  3233. uniform vec3 specularColor;
  3234. #ifdef USE_SPECULAR_COLORMAP
  3235. uniform sampler2D specularColorMap;
  3236. #endif
  3237. #ifdef USE_SPECULAR_INTENSITYMAP
  3238. uniform sampler2D specularIntensityMap;
  3239. #endif
  3240. #endif
  3241. #ifdef USE_CLEARCOAT
  3242. uniform float clearcoat;
  3243. uniform float clearcoatRoughness;
  3244. #endif
  3245. #ifdef USE_DISPERSION
  3246. uniform float dispersion;
  3247. #endif
  3248. #ifdef USE_IRIDESCENCE
  3249. uniform float iridescence;
  3250. uniform float iridescenceIOR;
  3251. uniform float iridescenceThicknessMinimum;
  3252. uniform float iridescenceThicknessMaximum;
  3253. #endif
  3254. #ifdef USE_SHEEN
  3255. uniform vec3 sheenColor;
  3256. uniform float sheenRoughness;
  3257. #ifdef USE_SHEEN_COLORMAP
  3258. uniform sampler2D sheenColorMap;
  3259. #endif
  3260. #ifdef USE_SHEEN_ROUGHNESSMAP
  3261. uniform sampler2D sheenRoughnessMap;
  3262. #endif
  3263. #endif
  3264. #ifdef USE_ANISOTROPY
  3265. uniform vec2 anisotropyVector;
  3266. #ifdef USE_ANISOTROPYMAP
  3267. uniform sampler2D anisotropyMap;
  3268. #endif
  3269. #endif
  3270. varying vec3 vViewPosition;
  3271. #include <common>
  3272. #include <packing>
  3273. #include <dithering_pars_fragment>
  3274. #include <color_pars_fragment>
  3275. #include <uv_pars_fragment>
  3276. #include <map_pars_fragment>
  3277. #include <alphamap_pars_fragment>
  3278. #include <alphatest_pars_fragment>
  3279. #include <alphahash_pars_fragment>
  3280. #include <aomap_pars_fragment>
  3281. #include <lightmap_pars_fragment>
  3282. #include <emissivemap_pars_fragment>
  3283. #include <iridescence_fragment>
  3284. #include <cube_uv_reflection_fragment>
  3285. #include <envmap_common_pars_fragment>
  3286. #include <envmap_physical_pars_fragment>
  3287. #include <fog_pars_fragment>
  3288. #include <lights_pars_begin>
  3289. #include <normal_pars_fragment>
  3290. #include <lights_physical_pars_fragment>
  3291. #include <transmission_pars_fragment>
  3292. #include <shadowmap_pars_fragment>
  3293. #include <bumpmap_pars_fragment>
  3294. #include <normalmap_pars_fragment>
  3295. #include <clearcoat_pars_fragment>
  3296. #include <iridescence_pars_fragment>
  3297. #include <roughnessmap_pars_fragment>
  3298. #include <metalnessmap_pars_fragment>
  3299. #include <logdepthbuf_pars_fragment>
  3300. #include <clipping_planes_pars_fragment>
  3301. void main() {
  3302. vec4 diffuseColor = vec4( diffuse, opacity );
  3303. #include <clipping_planes_fragment>
  3304. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3305. vec3 totalEmissiveRadiance = emissive;
  3306. #include <logdepthbuf_fragment>
  3307. #include <map_fragment>
  3308. #include <color_fragment>
  3309. #include <alphamap_fragment>
  3310. #include <alphatest_fragment>
  3311. #include <alphahash_fragment>
  3312. #include <roughnessmap_fragment>
  3313. #include <metalnessmap_fragment>
  3314. #include <normal_fragment_begin>
  3315. #include <normal_fragment_maps>
  3316. #include <clearcoat_normal_fragment_begin>
  3317. #include <clearcoat_normal_fragment_maps>
  3318. #include <emissivemap_fragment>
  3319. #include <lights_physical_fragment>
  3320. #include <lights_fragment_begin>
  3321. #include <lights_fragment_maps>
  3322. #include <lights_fragment_end>
  3323. #include <aomap_fragment>
  3324. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3325. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3326. #include <transmission_fragment>
  3327. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3328. #ifdef USE_SHEEN
  3329. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3330. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3331. #endif
  3332. #ifdef USE_CLEARCOAT
  3333. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3334. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3335. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3336. #endif
  3337. #include <opaque_fragment>
  3338. #include <tonemapping_fragment>
  3339. #include <colorspace_fragment>
  3340. #include <fog_fragment>
  3341. #include <premultiplied_alpha_fragment>
  3342. #include <dithering_fragment>
  3343. }`,Bxe=`#define TOON
  3344. varying vec3 vViewPosition;
  3345. #include <common>
  3346. #include <batching_pars_vertex>
  3347. #include <uv_pars_vertex>
  3348. #include <displacementmap_pars_vertex>
  3349. #include <color_pars_vertex>
  3350. #include <fog_pars_vertex>
  3351. #include <normal_pars_vertex>
  3352. #include <morphtarget_pars_vertex>
  3353. #include <skinning_pars_vertex>
  3354. #include <shadowmap_pars_vertex>
  3355. #include <logdepthbuf_pars_vertex>
  3356. #include <clipping_planes_pars_vertex>
  3357. void main() {
  3358. #include <uv_vertex>
  3359. #include <color_vertex>
  3360. #include <morphinstance_vertex>
  3361. #include <morphcolor_vertex>
  3362. #include <batching_vertex>
  3363. #include <beginnormal_vertex>
  3364. #include <morphnormal_vertex>
  3365. #include <skinbase_vertex>
  3366. #include <skinnormal_vertex>
  3367. #include <defaultnormal_vertex>
  3368. #include <normal_vertex>
  3369. #include <begin_vertex>
  3370. #include <morphtarget_vertex>
  3371. #include <skinning_vertex>
  3372. #include <displacementmap_vertex>
  3373. #include <project_vertex>
  3374. #include <logdepthbuf_vertex>
  3375. #include <clipping_planes_vertex>
  3376. vViewPosition = - mvPosition.xyz;
  3377. #include <worldpos_vertex>
  3378. #include <shadowmap_vertex>
  3379. #include <fog_vertex>
  3380. }`,$xe=`#define TOON
  3381. uniform vec3 diffuse;
  3382. uniform vec3 emissive;
  3383. uniform float opacity;
  3384. #include <common>
  3385. #include <packing>
  3386. #include <dithering_pars_fragment>
  3387. #include <color_pars_fragment>
  3388. #include <uv_pars_fragment>
  3389. #include <map_pars_fragment>
  3390. #include <alphamap_pars_fragment>
  3391. #include <alphatest_pars_fragment>
  3392. #include <alphahash_pars_fragment>
  3393. #include <aomap_pars_fragment>
  3394. #include <lightmap_pars_fragment>
  3395. #include <emissivemap_pars_fragment>
  3396. #include <gradientmap_pars_fragment>
  3397. #include <fog_pars_fragment>
  3398. #include <bsdfs>
  3399. #include <lights_pars_begin>
  3400. #include <normal_pars_fragment>
  3401. #include <lights_toon_pars_fragment>
  3402. #include <shadowmap_pars_fragment>
  3403. #include <bumpmap_pars_fragment>
  3404. #include <normalmap_pars_fragment>
  3405. #include <logdepthbuf_pars_fragment>
  3406. #include <clipping_planes_pars_fragment>
  3407. void main() {
  3408. vec4 diffuseColor = vec4( diffuse, opacity );
  3409. #include <clipping_planes_fragment>
  3410. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3411. vec3 totalEmissiveRadiance = emissive;
  3412. #include <logdepthbuf_fragment>
  3413. #include <map_fragment>
  3414. #include <color_fragment>
  3415. #include <alphamap_fragment>
  3416. #include <alphatest_fragment>
  3417. #include <alphahash_fragment>
  3418. #include <normal_fragment_begin>
  3419. #include <normal_fragment_maps>
  3420. #include <emissivemap_fragment>
  3421. #include <lights_toon_fragment>
  3422. #include <lights_fragment_begin>
  3423. #include <lights_fragment_maps>
  3424. #include <lights_fragment_end>
  3425. #include <aomap_fragment>
  3426. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3427. #include <opaque_fragment>
  3428. #include <tonemapping_fragment>
  3429. #include <colorspace_fragment>
  3430. #include <fog_fragment>
  3431. #include <premultiplied_alpha_fragment>
  3432. #include <dithering_fragment>
  3433. }`,Hxe=`uniform float size;
  3434. uniform float scale;
  3435. #include <common>
  3436. #include <color_pars_vertex>
  3437. #include <fog_pars_vertex>
  3438. #include <morphtarget_pars_vertex>
  3439. #include <logdepthbuf_pars_vertex>
  3440. #include <clipping_planes_pars_vertex>
  3441. #ifdef USE_POINTS_UV
  3442. varying vec2 vUv;
  3443. uniform mat3 uvTransform;
  3444. #endif
  3445. void main() {
  3446. #ifdef USE_POINTS_UV
  3447. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3448. #endif
  3449. #include <color_vertex>
  3450. #include <morphinstance_vertex>
  3451. #include <morphcolor_vertex>
  3452. #include <begin_vertex>
  3453. #include <morphtarget_vertex>
  3454. #include <project_vertex>
  3455. gl_PointSize = size;
  3456. #ifdef USE_SIZEATTENUATION
  3457. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3458. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3459. #endif
  3460. #include <logdepthbuf_vertex>
  3461. #include <clipping_planes_vertex>
  3462. #include <worldpos_vertex>
  3463. #include <fog_vertex>
  3464. }`,Vxe=`uniform vec3 diffuse;
  3465. uniform float opacity;
  3466. #include <common>
  3467. #include <color_pars_fragment>
  3468. #include <map_particle_pars_fragment>
  3469. #include <alphatest_pars_fragment>
  3470. #include <alphahash_pars_fragment>
  3471. #include <fog_pars_fragment>
  3472. #include <logdepthbuf_pars_fragment>
  3473. #include <clipping_planes_pars_fragment>
  3474. void main() {
  3475. vec4 diffuseColor = vec4( diffuse, opacity );
  3476. #include <clipping_planes_fragment>
  3477. vec3 outgoingLight = vec3( 0.0 );
  3478. #include <logdepthbuf_fragment>
  3479. #include <map_particle_fragment>
  3480. #include <color_fragment>
  3481. #include <alphatest_fragment>
  3482. #include <alphahash_fragment>
  3483. outgoingLight = diffuseColor.rgb;
  3484. #include <opaque_fragment>
  3485. #include <tonemapping_fragment>
  3486. #include <colorspace_fragment>
  3487. #include <fog_fragment>
  3488. #include <premultiplied_alpha_fragment>
  3489. }`,Gxe=`#include <common>
  3490. #include <batching_pars_vertex>
  3491. #include <fog_pars_vertex>
  3492. #include <morphtarget_pars_vertex>
  3493. #include <skinning_pars_vertex>
  3494. #include <logdepthbuf_pars_vertex>
  3495. #include <shadowmap_pars_vertex>
  3496. void main() {
  3497. #include <batching_vertex>
  3498. #include <beginnormal_vertex>
  3499. #include <morphinstance_vertex>
  3500. #include <morphnormal_vertex>
  3501. #include <skinbase_vertex>
  3502. #include <skinnormal_vertex>
  3503. #include <defaultnormal_vertex>
  3504. #include <begin_vertex>
  3505. #include <morphtarget_vertex>
  3506. #include <skinning_vertex>
  3507. #include <project_vertex>
  3508. #include <logdepthbuf_vertex>
  3509. #include <worldpos_vertex>
  3510. #include <shadowmap_vertex>
  3511. #include <fog_vertex>
  3512. }`,qxe=`uniform vec3 color;
  3513. uniform float opacity;
  3514. #include <common>
  3515. #include <packing>
  3516. #include <fog_pars_fragment>
  3517. #include <bsdfs>
  3518. #include <lights_pars_begin>
  3519. #include <logdepthbuf_pars_fragment>
  3520. #include <shadowmap_pars_fragment>
  3521. #include <shadowmask_pars_fragment>
  3522. void main() {
  3523. #include <logdepthbuf_fragment>
  3524. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3525. #include <tonemapping_fragment>
  3526. #include <colorspace_fragment>
  3527. #include <fog_fragment>
  3528. }`,Wxe=`uniform float rotation;
  3529. uniform vec2 center;
  3530. #include <common>
  3531. #include <uv_pars_vertex>
  3532. #include <fog_pars_vertex>
  3533. #include <logdepthbuf_pars_vertex>
  3534. #include <clipping_planes_pars_vertex>
  3535. void main() {
  3536. #include <uv_vertex>
  3537. vec4 mvPosition = modelViewMatrix[ 3 ];
  3538. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3539. #ifndef USE_SIZEATTENUATION
  3540. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3541. if ( isPerspective ) scale *= - mvPosition.z;
  3542. #endif
  3543. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3544. vec2 rotatedPosition;
  3545. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3546. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3547. mvPosition.xy += rotatedPosition;
  3548. gl_Position = projectionMatrix * mvPosition;
  3549. #include <logdepthbuf_vertex>
  3550. #include <clipping_planes_vertex>
  3551. #include <fog_vertex>
  3552. }`,Kxe=`uniform vec3 diffuse;
  3553. uniform float opacity;
  3554. #include <common>
  3555. #include <uv_pars_fragment>
  3556. #include <map_pars_fragment>
  3557. #include <alphamap_pars_fragment>
  3558. #include <alphatest_pars_fragment>
  3559. #include <alphahash_pars_fragment>
  3560. #include <fog_pars_fragment>
  3561. #include <logdepthbuf_pars_fragment>
  3562. #include <clipping_planes_pars_fragment>
  3563. void main() {
  3564. vec4 diffuseColor = vec4( diffuse, opacity );
  3565. #include <clipping_planes_fragment>
  3566. vec3 outgoingLight = vec3( 0.0 );
  3567. #include <logdepthbuf_fragment>
  3568. #include <map_fragment>
  3569. #include <alphamap_fragment>
  3570. #include <alphatest_fragment>
  3571. #include <alphahash_fragment>
  3572. outgoingLight = diffuseColor.rgb;
  3573. #include <opaque_fragment>
  3574. #include <tonemapping_fragment>
  3575. #include <colorspace_fragment>
  3576. #include <fog_fragment>
  3577. }`,Pn={alphahash_fragment:gge,alphahash_pars_fragment:bge,alphamap_fragment:xge,alphamap_pars_fragment:yge,alphatest_fragment:vge,alphatest_pars_fragment:wge,aomap_fragment:_ge,aomap_pars_fragment:Sge,batching_pars_vertex:Nge,batching_vertex:kge,begin_vertex:Mge,beginnormal_vertex:Cge,bsdfs:Ege,iridescence_fragment:Age,bumpmap_pars_fragment:Tge,clipping_planes_fragment:jge,clipping_planes_pars_fragment:Pge,clipping_planes_pars_vertex:Dge,clipping_planes_vertex:Rge,color_fragment:Lge,color_pars_fragment:Oge,color_pars_vertex:Fge,color_vertex:Ige,common:zge,cube_uv_reflection_fragment:Uge,defaultnormal_vertex:Bge,displacementmap_pars_vertex:$ge,displacementmap_vertex:Hge,emissivemap_fragment:Vge,emissivemap_pars_fragment:Gge,colorspace_fragment:qge,colorspace_pars_fragment:Wge,envmap_fragment:Kge,envmap_common_pars_fragment:Xge,envmap_pars_fragment:Yge,envmap_pars_vertex:Qge,envmap_physical_pars_fragment:lbe,envmap_vertex:Zge,fog_vertex:Jge,fog_pars_vertex:ebe,fog_fragment:tbe,fog_pars_fragment:nbe,gradientmap_pars_fragment:rbe,lightmap_pars_fragment:ibe,lights_lambert_fragment:abe,lights_lambert_pars_fragment:sbe,lights_pars_begin:obe,lights_toon_fragment:cbe,lights_toon_pars_fragment:ube,lights_phong_fragment:dbe,lights_phong_pars_fragment:hbe,lights_physical_fragment:fbe,lights_physical_pars_fragment:mbe,lights_fragment_begin:pbe,lights_fragment_maps:gbe,lights_fragment_end:bbe,logdepthbuf_fragment:xbe,logdepthbuf_pars_fragment:ybe,logdepthbuf_pars_vertex:vbe,logdepthbuf_vertex:wbe,map_fragment:_be,map_pars_fragment:Sbe,map_particle_fragment:Nbe,map_particle_pars_fragment:kbe,metalnessmap_fragment:Mbe,metalnessmap_pars_fragment:Cbe,morphinstance_vertex:Ebe,morphcolor_vertex:Abe,morphnormal_vertex:Tbe,morphtarget_pars_vertex:jbe,morphtarget_vertex:Pbe,normal_fragment_begin:Dbe,normal_fragment_maps:Rbe,normal_pars_fragment:Lbe,normal_pars_vertex:Obe,normal_vertex:Fbe,normalmap_pars_fragment:Ibe,clearcoat_normal_fragment_begin:zbe,clearcoat_normal_fragment_maps:Ube,clearcoat_pars_fragment:Bbe,iridescence_pars_fragment:$be,opaque_fragment:Hbe,packing:Vbe,premultiplied_alpha_fragment:Gbe,project_vertex:qbe,dithering_fragment:Wbe,dithering_pars_fragment:Kbe,roughnessmap_fragment:Xbe,roughnessmap_pars_fragment:Ybe,shadowmap_pars_fragment:Qbe,shadowmap_pars_vertex:Zbe,shadowmap_vertex:Jbe,shadowmask_pars_fragment:exe,skinbase_vertex:txe,skinning_pars_vertex:nxe,skinning_vertex:rxe,skinnormal_vertex:ixe,specularmap_fragment:axe,specularmap_pars_fragment:sxe,tonemapping_fragment:oxe,tonemapping_pars_fragment:lxe,transmission_fragment:cxe,transmission_pars_fragment:uxe,uv_pars_fragment:dxe,uv_pars_vertex:hxe,uv_vertex:fxe,worldpos_vertex:mxe,background_vert:pxe,background_frag:gxe,backgroundCube_vert:bxe,backgroundCube_frag:xxe,cube_vert:yxe,cube_frag:vxe,depth_vert:wxe,depth_frag:_xe,distanceRGBA_vert:Sxe,distanceRGBA_frag:Nxe,equirect_vert:kxe,equirect_frag:Mxe,linedashed_vert:Cxe,linedashed_frag:Exe,meshbasic_vert:Axe,meshbasic_frag:Txe,meshlambert_vert:jxe,meshlambert_frag:Pxe,meshmatcap_vert:Dxe,meshmatcap_frag:Rxe,meshnormal_vert:Lxe,meshnormal_frag:Oxe,meshphong_vert:Fxe,meshphong_frag:Ixe,meshphysical_vert:zxe,meshphysical_frag:Uxe,meshtoon_vert:Bxe,meshtoon_frag:$xe,points_vert:Hxe,points_frag:Vxe,shadow_vert:Gxe,shadow_frag:qxe,sprite_vert:Wxe,sprite_frag:Kxe},It={common:{diffuse:{value:new In(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Fn},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Fn}},envmap:{envMap:{value:null},envMapRotation:{value:new Fn},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 Fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Fn},normalScale:{value:new Rn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new In(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 In(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0},uvTransform:{value:new Fn}},sprite:{diffuse:{value:new In(16777215)},opacity:{value:1},center:{value:new Rn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Fn},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0}}},gc={basic:{uniforms:Ss([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.fog]),vertexShader:Pn.meshbasic_vert,fragmentShader:Pn.meshbasic_frag},lambert:{uniforms:Ss([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new In(0)}}]),vertexShader:Pn.meshlambert_vert,fragmentShader:Pn.meshlambert_frag},phong:{uniforms:Ss([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new In(0)},specular:{value:new In(1118481)},shininess:{value:30}}]),vertexShader:Pn.meshphong_vert,fragmentShader:Pn.meshphong_frag},standard:{uniforms:Ss([It.common,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.roughnessmap,It.metalnessmap,It.fog,It.lights,{emissive:{value:new In(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Pn.meshphysical_vert,fragmentShader:Pn.meshphysical_frag},toon:{uniforms:Ss([It.common,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.gradientmap,It.fog,It.lights,{emissive:{value:new In(0)}}]),vertexShader:Pn.meshtoon_vert,fragmentShader:Pn.meshtoon_frag},matcap:{uniforms:Ss([It.common,It.bumpmap,It.normalmap,It.displacementmap,It.fog,{matcap:{value:null}}]),vertexShader:Pn.meshmatcap_vert,fragmentShader:Pn.meshmatcap_frag},points:{uniforms:Ss([It.points,It.fog]),vertexShader:Pn.points_vert,fragmentShader:Pn.points_frag},dashed:{uniforms:Ss([It.common,It.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Pn.linedashed_vert,fragmentShader:Pn.linedashed_frag},depth:{uniforms:Ss([It.common,It.displacementmap]),vertexShader:Pn.depth_vert,fragmentShader:Pn.depth_frag},normal:{uniforms:Ss([It.common,It.bumpmap,It.normalmap,It.displacementmap,{opacity:{value:1}}]),vertexShader:Pn.meshnormal_vert,fragmentShader:Pn.meshnormal_frag},sprite:{uniforms:Ss([It.sprite,It.fog]),vertexShader:Pn.sprite_vert,fragmentShader:Pn.sprite_frag},background:{uniforms:{uvTransform:{value:new Fn},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 Fn}},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:Ss([It.common,It.displacementmap,{referencePosition:{value:new mt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Pn.distanceRGBA_vert,fragmentShader:Pn.distanceRGBA_frag},shadow:{uniforms:Ss([It.lights,It.fog,{color:{value:new In(0)},opacity:{value:1}}]),vertexShader:Pn.shadow_vert,fragmentShader:Pn.shadow_frag}};gc.physical={uniforms:Ss([gc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Fn},clearcoatNormalScale:{value:new Rn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Fn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Fn},sheen:{value:0},sheenColor:{value:new In(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Fn},transmissionSamplerSize:{value:new Rn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Fn},attenuationDistance:{value:0},attenuationColor:{value:new In(0)},specularColor:{value:new In(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Fn},anisotropyVector:{value:new Rn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Fn}}]),vertexShader:Pn.meshphysical_vert,fragmentShader:Pn.meshphysical_frag};const b_={r:0,b:0,g:0},Cf=new Uh,Xxe=new na;function Yxe(t,e,n,r,i,s,o){const l=new In(0);let c=s===!0?0:1,u,d,h=null,p=0,m=null;function x(k){let E=k.isScene===!0?k.background:null;return E&&E.isTexture&&(E=(k.backgroundBlurriness>0?n:e).get(E)),E}function y(k){let E=!1;const N=x(k);N===null?v(l,c):N&&N.isColor&&(v(N,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)&&(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(k,E){const N=x(E);N&&(N.isCubeTexture||N.mapping===Uk)?(d===void 0&&(d=new bl(new C4(1,1,1),new ed({name:"BackgroundCubeMaterial",uniforms:sb(gc.backgroundCube.uniforms),vertexShader:gc.backgroundCube.vertexShader,fragmentShader:gc.backgroundCube.fragmentShader,side:Qs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(A,M,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Cf.copy(E.backgroundRotation),Cf.x*=-1,Cf.y*=-1,Cf.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(Cf.y*=-1,Cf.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=E.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(Xxe.makeRotationFromEuler(Cf)),d.material.toneMapped=cr.getTransfer(N.colorSpace)!==Ar,(h!==N||p!==N.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,h=N,p=N.version,m=t.toneMapping),d.layers.enableAll(),k.unshift(d,d.geometry,d.material,0,0,null)):N&&N.isTexture&&(u===void 0&&(u=new bl(new A4(2,2),new ed({name:"BackgroundMaterial",uniforms:sb(gc.background.uniforms),vertexShader:gc.background.vertexShader,fragmentShader:gc.background.fragmentShader,side:zh,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=E.backgroundIntensity,u.material.toneMapped=cr.getTransfer(N.colorSpace)!==Ar,N.matrixAutoUpdate===!0&&N.updateMatrix(),u.material.uniforms.uvTransform.value.copy(N.matrix),(h!==N||p!==N.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=N,p=N.version,m=t.toneMapping),u.layers.enableAll(),k.unshift(u,u.geometry,u.material,0,0,null))}function v(k,E){k.getRGB(b_,zK(t)),r.buffers.color.setClear(b_.r,b_.g,b_.b,E,o)}function S(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return l},setClearColor:function(k,E=1){l.set(k),c=E,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(k){c=k,v(l,c)},render:y,addToRenderList:b,dispose:S}}function Qxe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=p(null);let s=i,o=!1;function l(j,z,F,$,D){let H=!1;const q=h($,F,z);s!==q&&(s=q,u(s.object)),H=m(j,$,F,D),H&&x(j,$,F,D),D!==null&&e.update(D,t.ELEMENT_ARRAY_BUFFER),(H||o)&&(o=!1,E(j,z,F,$),D!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function c(){return t.createVertexArray()}function u(j){return t.bindVertexArray(j)}function d(j){return t.deleteVertexArray(j)}function h(j,z,F){const $=F.wireframe===!0;let D=r[j.id];D===void 0&&(D={},r[j.id]=D);let H=D[z.id];H===void 0&&(H={},D[z.id]=H);let q=H[$];return q===void 0&&(q=p(c()),H[$]=q),q}function p(j){const z=[],F=[],$=[];for(let D=0;D<n;D++)z[D]=0,F[D]=0,$[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:F,attributeDivisors:$,object:j,attributes:{},index:null}}function m(j,z,F,$){const D=s.attributes,H=z.attributes;let q=0;const I=F.getAttributes();for(const K in I)if(I[K].location>=0){const se=D[K];let V=H[K];if(V===void 0&&(K==="instanceMatrix"&&j.instanceMatrix&&(V=j.instanceMatrix),K==="instanceColor"&&j.instanceColor&&(V=j.instanceColor)),se===void 0||se.attribute!==V||V&&se.data!==V.data)return!0;q++}return s.attributesNum!==q||s.index!==$}function x(j,z,F,$){const D={},H=z.attributes;let q=0;const I=F.getAttributes();for(const K in I)if(I[K].location>=0){let se=H[K];se===void 0&&(K==="instanceMatrix"&&j.instanceMatrix&&(se=j.instanceMatrix),K==="instanceColor"&&j.instanceColor&&(se=j.instanceColor));const V={};V.attribute=se,se&&se.data&&(V.data=se.data),D[K]=V,q++}s.attributes=D,s.attributesNum=q,s.index=$}function y(){const j=s.newAttributes;for(let z=0,F=j.length;z<F;z++)j[z]=0}function b(j){v(j,0)}function v(j,z){const F=s.newAttributes,$=s.enabledAttributes,D=s.attributeDivisors;F[j]=1,$[j]===0&&(t.enableVertexAttribArray(j),$[j]=1),D[j]!==z&&(t.vertexAttribDivisor(j,z),D[j]=z)}function S(){const j=s.newAttributes,z=s.enabledAttributes;for(let F=0,$=z.length;F<$;F++)z[F]!==j[F]&&(t.disableVertexAttribArray(F),z[F]=0)}function k(j,z,F,$,D,H,q){q===!0?t.vertexAttribIPointer(j,z,F,D,H):t.vertexAttribPointer(j,z,F,$,D,H)}function E(j,z,F,$){y();const D=$.attributes,H=F.getAttributes(),q=z.defaultAttributeValues;for(const I in H){const K=H[I];if(K.location>=0){let Z=D[I];if(Z===void 0&&(I==="instanceMatrix"&&j.instanceMatrix&&(Z=j.instanceMatrix),I==="instanceColor"&&j.instanceColor&&(Z=j.instanceColor)),Z!==void 0){const se=Z.normalized,V=Z.itemSize,W=e.get(Z);if(W===void 0)continue;const ie=W.buffer,J=W.type,pe=W.bytesPerElement,fe=J===t.INT||J===t.UNSIGNED_INT||Z.gpuType===b4;if(Z.isInterleavedBufferAttribute){const ve=Z.data,Le=ve.stride,de=Z.offset;if(ve.isInstancedInterleavedBuffer){for(let ce=0;ce<K.locationSize;ce++)v(K.location+ce,ve.meshPerAttribute);j.isInstancedMesh!==!0&&$._maxInstanceCount===void 0&&($._maxInstanceCount=ve.meshPerAttribute*ve.count)}else for(let ce=0;ce<K.locationSize;ce++)b(K.location+ce);t.bindBuffer(t.ARRAY_BUFFER,ie);for(let ce=0;ce<K.locationSize;ce++)k(K.location+ce,V/K.locationSize,J,se,Le*pe,(de+V/K.locationSize*ce)*pe,fe)}else{if(Z.isInstancedBufferAttribute){for(let ve=0;ve<K.locationSize;ve++)v(K.location+ve,Z.meshPerAttribute);j.isInstancedMesh!==!0&&$._maxInstanceCount===void 0&&($._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ve=0;ve<K.locationSize;ve++)b(K.location+ve);t.bindBuffer(t.ARRAY_BUFFER,ie);for(let ve=0;ve<K.locationSize;ve++)k(K.location+ve,V/K.locationSize,J,se,V*pe,V/K.locationSize*ve*pe,fe)}}else if(q!==void 0){const se=q[I];if(se!==void 0)switch(se.length){case 2:t.vertexAttrib2fv(K.location,se);break;case 3:t.vertexAttrib3fv(K.location,se);break;case 4:t.vertexAttrib4fv(K.location,se);break;default:t.vertexAttrib1fv(K.location,se)}}}}S()}function N(){P();for(const j in r){const z=r[j];for(const F in z){const $=z[F];for(const D in $)d($[D].object),delete $[D];delete z[F]}delete r[j]}}function A(j){if(r[j.id]===void 0)return;const z=r[j.id];for(const F in z){const $=z[F];for(const D in $)d($[D].object),delete $[D];delete z[F]}delete r[j.id]}function M(j){for(const z in r){const F=r[z];if(F[j.id]===void 0)continue;const $=F[j.id];for(const D in $)d($[D].object),delete $[D];delete F[j.id]}}function P(){T(),o=!0,s!==i&&(s=i,u(s.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:P,resetDefaultState:T,dispose:N,releaseStatesOfGeometry:A,releaseStatesOfProgram:M,initAttributes:y,enableAttribute:b,disableUnusedAttributes:S}}function Zxe(t,e,n){let r;function i(u){r=u}function s(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function o(u,d,h){h!==0&&(t.drawArraysInstanced(r,u,d,h),n.update(d,r,h))}function l(u,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,h);let m=0;for(let x=0;x<h;x++)m+=d[x];n.update(m,r,1)}function c(u,d,h,p){if(h===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<u.length;x++)o(u[x],d[x],p[x]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,p,0,h);let x=0;for(let y=0;y<h;y++)x+=d[y]*p[y];n.update(x,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function Jxe(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const M=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(M){return!(M!==Vl&&r.convert(M)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(M){const P=M===Rb&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(M!==jc&&r.convert(M)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&M!==Lu&&!P)}function c(M){if(M==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="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&&(vn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const h=n.logarithmicDepthBuffer===!0,p=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=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),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),k=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),N=x>0,A=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:h,reversedDepthBuffer:p,maxTextures:m,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:b,maxAttributes:v,maxVertexUniforms:S,maxVaryings:k,maxFragmentUniforms:E,vertexTextures:N,maxSamples:A}}function eye(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new nh,l=new Fn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const m=h.length!==0||p||r!==0||i;return i=p,r=h.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){n=d(h,p,0)},this.setState=function(h,p,m){const x=h.clippingPlanes,y=h.clipIntersection,b=h.clipShadows,v=t.get(h);if(!i||x===null||x.length===0||s&&!b)s?d(null):u();else{const S=s?0:r,k=S*4;let E=v.clippingState||null;c.value=E,E=d(x,p,k,m);for(let N=0;N!==k;++N)E[N]=n[N];v.clippingState=E,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(h,p,m,x){const y=h!==null?h.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=m+y*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(b===null||b.length<v)&&(b=new Float32Array(v));for(let k=0,E=m;k!==y;++k,E+=4)o.copy(h[k]).applyMatrix4(S,l),o.normal.toArray(b,E),b[E+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function tye(t){let e=new WeakMap;function n(o,l){return l===n3?o.mapping=rb:l===r3&&(o.mapping=ib),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===n3||l===r3)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 Wpe(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 s(){e=new WeakMap}return{get:r,dispose:s}}const ph=4,t8=[.125,.215,.35,.446,.526,.582],Hf=20,nye=256,Yx=new KK,n8=new In;let ZE=null,JE=0,eA=0,tA=!1;const rye=new mt;let r8=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,s={}){const{size:o=256,position:l=rye}=s;ZE=this._renderer.getRenderTarget(),JE=this._renderer.getActiveCubeFace(),eA=this._renderer.getActiveMipmapLevel(),tA=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=s8(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=a8(),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(ZE,JE,eA),this._renderer.xr.enabled=tA,e.scissorTest=!1,Hp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===rb||e.mapping===ib?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ZE=this._renderer.getRenderTarget(),JE=this._renderer.getActiveCubeFace(),eA=this._renderer.getActiveMipmapLevel(),tA=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:cl,minFilter:cl,generateMipmaps:!1,type:Rb,format:Vl,colorSpace:ab,depthBuffer:!1},i=i8(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=i8(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=iye(s)),this._blurMaterial=sye(s,e,n),this._ggxMaterial=aye(s,e,n)}return i}_compileMaterial(e){const n=new bl(new gl,e);this._renderer.compile(n,Yx)}_sceneToCubeUV(e,n,r,i,s){const c=new il(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,p=h.autoClear,m=h.toneMapping;h.getClearColor(n8),h.toneMapping=Ch,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new bl(new C4,new M4({name:"PMREM.Background",side:Qs,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,b=y.material;let v=!1;const S=e.background;S?S.isColor&&(b.color.copy(S),e.background=null,v=!0):(b.color.copy(n8),v=!0);for(let k=0;k<6;k++){const E=k%3;E===0?(c.up.set(0,u[k],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+d[k],s.y,s.z)):E===1?(c.up.set(0,0,u[k]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+d[k],s.z)):(c.up.set(0,u[k],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+d[k]));const N=this._cubeSize;Hp(i,E*N,k>2?N:0,N,N),h.setRenderTarget(i),v&&h.render(y,c),h.render(e,c)}h.toneMapping=m,h.autoClear=p,e.background=S}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===rb||e.mapping===ib;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=s8()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=a8());const s=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;const l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;Hp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Yx)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,s=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),h=Math.sqrt(u*u-d*d),p=.05+u*.95,m=h*p,{_lodMax:x}=this,y=this._sizeLods[r],b=3*y*(r>x-ph?r-x+ph:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=x-n,Hp(s,b,v,3*y,2*y),i.setRenderTarget(s),i.render(l,Yx),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-r,Hp(e,b,v,3*y,2*y),i.setRenderTarget(e),i.render(l,Yx)}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&zi("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=u;const p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Hf-1),y=s/x,b=isFinite(s)?1+Math.floor(d*y):Hf;b>Hf&&vn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Hf}`);const v=[];let S=0;for(let M=0;M<Hf;++M){const P=M/y,T=Math.exp(-P*P/2);v.push(T),M===0?S+=T:M<b&&(S+=2*T)}for(let M=0;M<v.length;M++)v[M]=v[M]/S;p.envMap.value=e.texture,p.samples.value=b,p.weights.value=v,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:k}=this;p.dTheta.value=x,p.mipInt.value=k-r;const E=this._sizeLods[i],N=3*E*(i>k-ph?i-k+ph:0),A=4*(this._cubeSize-E);Hp(n,N,A,3*E,2*E),c.setRenderTarget(n),c.render(h,Yx)}};function iye(t){const e=[],n=[],r=[];let i=t;const s=t-ph+1+t8.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-ph?c=t8[o-t+ph-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,h=1+u,p=[d,d,h,d,h,h,d,d,h,h,d,h],m=6,x=6,y=3,b=2,v=1,S=new Float32Array(y*x*m),k=new Float32Array(b*x*m),E=new Float32Array(v*x*m);for(let A=0;A<m;A++){const M=A%3*2/3-1,P=A>2?0:-1,T=[M,P,0,M+2/3,P,0,M+2/3,P+1,0,M,P,0,M+2/3,P+1,0,M,P+1,0];S.set(T,y*x*A),k.set(p,b*x*A);const j=[A,A,A,A,A,A];E.set(j,v*x*A)}const N=new gl;N.setAttribute("position",new Ts(S,y)),N.setAttribute("uv",new Ts(k,b)),N.setAttribute("faceIndex",new Ts(E,v)),r.push(new bl(N,null)),i>ph&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function i8(t,e,n){const r=new Am(t,e,n);return r.texture.mapping=Uk,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Hp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function aye(t,e,n){return new ed({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:nye,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:$k(),fragmentShader:`
  3578. precision highp float;
  3579. precision highp int;
  3580. varying vec3 vOutputDirection;
  3581. uniform sampler2D envMap;
  3582. uniform float roughness;
  3583. uniform float mipInt;
  3584. #define ENVMAP_TYPE_CUBE_UV
  3585. #include <cube_uv_reflection_fragment>
  3586. #define PI 3.14159265359
  3587. // Van der Corput radical inverse
  3588. float radicalInverse_VdC(uint bits) {
  3589. bits = (bits << 16u) | (bits >> 16u);
  3590. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3591. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3592. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3593. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3594. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3595. }
  3596. // Hammersley sequence
  3597. vec2 hammersley(uint i, uint N) {
  3598. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3599. }
  3600. // GGX VNDF importance sampling (Eric Heitz 2018)
  3601. // "Sampling the GGX Distribution of Visible Normals"
  3602. // https://jcgt.org/published/0007/04/01/
  3603. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3604. float alpha = roughness * roughness;
  3605. // Section 3.2: Transform view direction to hemisphere configuration
  3606. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3607. // Section 4.1: Orthonormal basis
  3608. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3609. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3610. vec3 T2 = cross(Vh, T1);
  3611. // Section 4.2: Parameterization of projected area
  3612. float r = sqrt(Xi.x);
  3613. float phi = 2.0 * PI * Xi.y;
  3614. float t1 = r * cos(phi);
  3615. float t2 = r * sin(phi);
  3616. float s = 0.5 * (1.0 + Vh.z);
  3617. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3618. // Section 4.3: Reprojection onto hemisphere
  3619. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3620. // Section 3.4: Transform back to ellipsoid configuration
  3621. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3622. }
  3623. void main() {
  3624. vec3 N = normalize(vOutputDirection);
  3625. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3626. vec3 prefilteredColor = vec3(0.0);
  3627. float totalWeight = 0.0;
  3628. // For very low roughness, just sample the environment directly
  3629. if (roughness < 0.001) {
  3630. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3631. return;
  3632. }
  3633. // Tangent space basis for VNDF sampling
  3634. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3635. vec3 tangent = normalize(cross(up, N));
  3636. vec3 bitangent = cross(N, tangent);
  3637. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3638. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3639. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3640. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3641. // Transform H back to world space
  3642. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3643. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3644. float NdotL = max(dot(N, L), 0.0);
  3645. if(NdotL > 0.0) {
  3646. // Sample environment at fixed mip level
  3647. // VNDF importance sampling handles the distribution filtering
  3648. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3649. // Weight by NdotL for the split-sum approximation
  3650. // VNDF PDF naturally accounts for the visible microfacet distribution
  3651. prefilteredColor += sampleColor * NdotL;
  3652. totalWeight += NdotL;
  3653. }
  3654. }
  3655. if (totalWeight > 0.0) {
  3656. prefilteredColor = prefilteredColor / totalWeight;
  3657. }
  3658. gl_FragColor = vec4(prefilteredColor, 1.0);
  3659. }
  3660. `,blending:Bu,depthTest:!1,depthWrite:!1})}function sye(t,e,n){const r=new Float32Array(Hf),i=new mt(0,1,0);return new ed({name:"SphericalGaussianBlur",defines:{n:Hf,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:$k(),fragmentShader:`
  3661. precision mediump float;
  3662. precision mediump int;
  3663. varying vec3 vOutputDirection;
  3664. uniform sampler2D envMap;
  3665. uniform int samples;
  3666. uniform float weights[ n ];
  3667. uniform bool latitudinal;
  3668. uniform float dTheta;
  3669. uniform float mipInt;
  3670. uniform vec3 poleAxis;
  3671. #define ENVMAP_TYPE_CUBE_UV
  3672. #include <cube_uv_reflection_fragment>
  3673. vec3 getSample( float theta, vec3 axis ) {
  3674. float cosTheta = cos( theta );
  3675. // Rodrigues' axis-angle rotation
  3676. vec3 sampleDirection = vOutputDirection * cosTheta
  3677. + cross( axis, vOutputDirection ) * sin( theta )
  3678. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3679. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3680. }
  3681. void main() {
  3682. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3683. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3684. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3685. }
  3686. axis = normalize( axis );
  3687. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3688. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3689. for ( int i = 1; i < n; i++ ) {
  3690. if ( i >= samples ) {
  3691. break;
  3692. }
  3693. float theta = dTheta * float( i );
  3694. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3695. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3696. }
  3697. }
  3698. `,blending:Bu,depthTest:!1,depthWrite:!1})}function a8(){return new ed({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:$k(),fragmentShader:`
  3699. precision mediump float;
  3700. precision mediump int;
  3701. varying vec3 vOutputDirection;
  3702. uniform sampler2D envMap;
  3703. #include <common>
  3704. void main() {
  3705. vec3 outputDirection = normalize( vOutputDirection );
  3706. vec2 uv = equirectUv( outputDirection );
  3707. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3708. }
  3709. `,blending:Bu,depthTest:!1,depthWrite:!1})}function s8(){return new ed({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:$k(),fragmentShader:`
  3710. precision mediump float;
  3711. precision mediump int;
  3712. uniform float flipEnvMap;
  3713. varying vec3 vOutputDirection;
  3714. uniform samplerCube envMap;
  3715. void main() {
  3716. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3717. }
  3718. `,blending:Bu,depthTest:!1,depthWrite:!1})}function $k(){return`
  3719. precision mediump float;
  3720. precision mediump int;
  3721. attribute float faceIndex;
  3722. varying vec3 vOutputDirection;
  3723. // RH coordinate system; PMREM face-indexing convention
  3724. vec3 getDirection( vec2 uv, float face ) {
  3725. uv = 2.0 * uv - 1.0;
  3726. vec3 direction = vec3( uv, 1.0 );
  3727. if ( face == 0.0 ) {
  3728. direction = direction.zyx; // ( 1, v, u ) pos x
  3729. } else if ( face == 1.0 ) {
  3730. direction = direction.xzy;
  3731. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3732. } else if ( face == 2.0 ) {
  3733. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3734. } else if ( face == 3.0 ) {
  3735. direction = direction.zyx;
  3736. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3737. } else if ( face == 4.0 ) {
  3738. direction = direction.xzy;
  3739. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3740. } else if ( face == 5.0 ) {
  3741. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3742. }
  3743. return direction;
  3744. }
  3745. void main() {
  3746. vOutputDirection = getDirection( uv, faceIndex );
  3747. gl_Position = vec4( position, 1.0 );
  3748. }
  3749. `}function oye(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===n3||c===r3,d=c===rb||c===ib;if(u||d){let h=e.get(l);const p=h!==void 0?h.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==p)return n===null&&(n=new r8(t)),h=u?n.fromEquirectangular(l,h):n.fromCubemap(l,h),h.texture.pmremVersion=l.pmremVersion,e.set(l,h),h.texture;if(h!==void 0)return h.texture;{const m=l.image;return u&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new r8(t)),h=u?n.fromEquirectangular(l):n.fromCubemap(l),h.texture.pmremVersion=l.pmremVersion,e.set(l,h),l.addEventListener("dispose",s),h.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 s(l){const c=l.target;c.removeEventListener("dispose",s);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 lye(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&&c0("WebGLRenderer: "+r+" extension not supported."),i}}}function cye(t,e,n,r){const i={},s=new WeakMap;function o(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const x in p.attributes)e.remove(p.attributes[x]);p.removeEventListener("dispose",o),delete i[p.id];const m=s.get(p);m&&(e.remove(m),s.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(h,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(h){const p=h.attributes;for(const m in p)e.update(p[m],t.ARRAY_BUFFER)}function u(h){const p=[],m=h.index,x=h.attributes.position;let y=0;if(m!==null){const S=m.array;y=m.version;for(let k=0,E=S.length;k<E;k+=3){const N=S[k+0],A=S[k+1],M=S[k+2];p.push(N,A,A,M,M,N)}}else if(x!==void 0){const S=x.array;y=x.version;for(let k=0,E=S.length/3-1;k<E;k+=3){const N=k+0,A=k+1,M=k+2;p.push(N,A,A,M,M,N)}}else return;const b=new(MK(p)?OK:LK)(p,1);b.version=y;const v=s.get(h);v&&e.remove(v),s.set(h,b)}function d(h){const p=s.get(h);if(p){const m=h.index;m!==null&&p.version<m.version&&u(h)}else u(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:d}}function uye(t,e,n){let r;function i(p){r=p}let s,o;function l(p){s=p.type,o=p.bytesPerElement}function c(p,m){t.drawElements(r,m,s,p*o),n.update(m,r,1)}function u(p,m,x){x!==0&&(t.drawElementsInstanced(r,m,s,p*o,x),n.update(m,r,x))}function d(p,m,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,s,p,0,x);let b=0;for(let v=0;v<x;v++)b+=m[v];n.update(b,r,1)}function h(p,m,x,y){if(x===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<p.length;v++)u(p[v]/o,m[v],y[v]);else{b.multiDrawElementsInstancedWEBGL(r,m,0,s,p,0,y,0,x);let v=0;for(let S=0;S<x;S++)v+=m[S]*y[S];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=h}function dye(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(s/3);break;case t.LINES:n.lines+=l*(s/2);break;case t.LINE_STRIP:n.lines+=l*(s-1);break;case t.LINE_LOOP:n.lines+=l*s;break;case t.POINTS:n.points+=l*s;break;default:zi("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 hye(t,e,n){const r=new WeakMap,i=new Zi;function s(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,h=d!==void 0?d.length:0;let p=r.get(l);if(p===void 0||p.count!==h){let j=function(){P.dispose(),r.delete(l),l.removeEventListener("dispose",j)};var m=j;p!==void 0&&p.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||[],S=l.morphAttributes.normal||[],k=l.morphAttributes.color||[];let E=0;x===!0&&(E=1),y===!0&&(E=2),b===!0&&(E=3);let N=l.attributes.position.count*E,A=1;N>e.maxTextureSize&&(A=Math.ceil(N/e.maxTextureSize),N=e.maxTextureSize);const M=new Float32Array(N*A*4*h),P=new jK(M,N,A,h);P.type=Lu,P.needsUpdate=!0;const T=E*4;for(let z=0;z<h;z++){const F=v[z],$=S[z],D=k[z],H=N*A*4*z;for(let q=0;q<F.count;q++){const I=q*T;x===!0&&(i.fromBufferAttribute(F,q),M[H+I+0]=i.x,M[H+I+1]=i.y,M[H+I+2]=i.z,M[H+I+3]=0),y===!0&&(i.fromBufferAttribute($,q),M[H+I+4]=i.x,M[H+I+5]=i.y,M[H+I+6]=i.z,M[H+I+7]=0),b===!0&&(i.fromBufferAttribute(D,q),M[H+I+8]=i.x,M[H+I+9]=i.y,M[H+I+10]=i.z,M[H+I+11]=D.itemSize===4?i.w:1)}}p={count:h,texture:P,size:new Rn(N,A)},r.set(l,p),l.addEventListener("dispose",j)}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",p.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}return{update:s}}function fye(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,h=e.get(c,d);if(i.get(h)!==u&&(e.update(h),i.set(h,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 p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return h}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:s,dispose:o}}const YK=new ec,o8=new HK(1,1),QK=new jK,ZK=new Tpe,JK=new BK,l8=[],c8=[],u8=new Float32Array(16),d8=new Float32Array(9),h8=new Float32Array(4);function Ob(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=l8[i];if(s===void 0&&(s=new Float32Array(i),l8[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function da(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 ha(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function Hk(t,e){let n=c8[e];n===void 0&&(n=new Int32Array(e),c8[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function mye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function pye(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(da(n,e))return;t.uniform2fv(this.addr,e),ha(n,e)}}function gye(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(da(n,e))return;t.uniform3fv(this.addr,e),ha(n,e)}}function bye(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(da(n,e))return;t.uniform4fv(this.addr,e),ha(n,e)}}function xye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(da(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ha(n,e)}else{if(da(n,r))return;h8.set(r),t.uniformMatrix2fv(this.addr,!1,h8),ha(n,r)}}function yye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(da(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ha(n,e)}else{if(da(n,r))return;d8.set(r),t.uniformMatrix3fv(this.addr,!1,d8),ha(n,r)}}function vye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(da(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ha(n,e)}else{if(da(n,r))return;u8.set(r),t.uniformMatrix4fv(this.addr,!1,u8),ha(n,r)}}function wye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function _ye(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(da(n,e))return;t.uniform2iv(this.addr,e),ha(n,e)}}function Sye(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(da(n,e))return;t.uniform3iv(this.addr,e),ha(n,e)}}function Nye(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(da(n,e))return;t.uniform4iv(this.addr,e),ha(n,e)}}function kye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Mye(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(da(n,e))return;t.uniform2uiv(this.addr,e),ha(n,e)}}function Cye(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(da(n,e))return;t.uniform3uiv(this.addr,e),ha(n,e)}}function Eye(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(da(n,e))return;t.uniform4uiv(this.addr,e),ha(n,e)}}function Aye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let s;this.type===t.SAMPLER_2D_SHADOW?(o8.compareFunction=kK,s=o8):s=YK,n.setTexture2D(e||s,i)}function Tye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||ZK,i)}function jye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||JK,i)}function Pye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||QK,i)}function Dye(t){switch(t){case 5126:return mye;case 35664:return pye;case 35665:return gye;case 35666:return bye;case 35674:return xye;case 35675:return yye;case 35676:return vye;case 5124:case 35670:return wye;case 35667:case 35671:return _ye;case 35668:case 35672:return Sye;case 35669:case 35673:return Nye;case 5125:return kye;case 36294:return Mye;case 36295:return Cye;case 36296:return Eye;case 35678:case 36198:case 36298:case 36306:case 35682:return Aye;case 35679:case 36299:case 36307:return Tye;case 35680:case 36300:case 36308:case 36293:return jye;case 36289:case 36303:case 36311:case 36292:return Pye}}function Rye(t,e){t.uniform1fv(this.addr,e)}function Lye(t,e){const n=Ob(e,this.size,2);t.uniform2fv(this.addr,n)}function Oye(t,e){const n=Ob(e,this.size,3);t.uniform3fv(this.addr,n)}function Fye(t,e){const n=Ob(e,this.size,4);t.uniform4fv(this.addr,n)}function Iye(t,e){const n=Ob(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function zye(t,e){const n=Ob(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Uye(t,e){const n=Ob(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Bye(t,e){t.uniform1iv(this.addr,e)}function $ye(t,e){t.uniform2iv(this.addr,e)}function Hye(t,e){t.uniform3iv(this.addr,e)}function Vye(t,e){t.uniform4iv(this.addr,e)}function Gye(t,e){t.uniform1uiv(this.addr,e)}function qye(t,e){t.uniform2uiv(this.addr,e)}function Wye(t,e){t.uniform3uiv(this.addr,e)}function Kye(t,e){t.uniform4uiv(this.addr,e)}function Xye(t,e,n){const r=this.cache,i=e.length,s=Hk(n,i);da(r,s)||(t.uniform1iv(this.addr,s),ha(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||YK,s[o])}function Yye(t,e,n){const r=this.cache,i=e.length,s=Hk(n,i);da(r,s)||(t.uniform1iv(this.addr,s),ha(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||ZK,s[o])}function Qye(t,e,n){const r=this.cache,i=e.length,s=Hk(n,i);da(r,s)||(t.uniform1iv(this.addr,s),ha(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||JK,s[o])}function Zye(t,e,n){const r=this.cache,i=e.length,s=Hk(n,i);da(r,s)||(t.uniform1iv(this.addr,s),ha(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||QK,s[o])}function Jye(t){switch(t){case 5126:return Rye;case 35664:return Lye;case 35665:return Oye;case 35666:return Fye;case 35674:return Iye;case 35675:return zye;case 35676:return Uye;case 5124:case 35670:return Bye;case 35667:case 35671:return $ye;case 35668:case 35672:return Hye;case 35669:case 35673:return Vye;case 5125:return Gye;case 36294:return qye;case 36295:return Wye;case 36296:return Kye;case 35678:case 36198:case 36298:case 36306:case 35682:return Xye;case 35679:case 36299:case 36307:return Yye;case 35680:case 36300:case 36308:case 36293:return Qye;case 36289:case 36303:case 36311:case 36292:return Zye}}let e0e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Dye(n.type)}},t0e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Jye(n.type)}},n0e=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const l=i[s];l.setValue(e,n[l.id],r)}}};const nA=/(\w+)(\])?(\[|\.)?/g;function f8(t,e){t.seq.push(e),t.map[e.id]=e}function r0e(t,e,n){const r=t.name,i=r.length;for(nA.lastIndex=0;;){const s=nA.exec(r),o=nA.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){f8(n,u===void 0?new e0e(l,t,e):new t0e(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new n0e(l),f8(n,h)),n=h}}}let $S=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),o=e.getUniformLocation(n,s.name);r0e(s,o,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.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 s=0,o=n.length;s!==o;++s){const l=n[s],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function m8(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const i0e=37297;let a0e=0;function s0e(t,e){const n=t.split(`
  3750. `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  3751. `)}const p8=new Fn;function o0e(t){cr._getMatrix(p8,cr.workingColorSpace,t);const e=`mat3( ${p8.elements.map(n=>n.toFixed(4))} )`;switch(cr.getTransfer(t)){case m1:return[e,"LinearTransferOETF"];case Ar:return[e,"sRGBTransferOETF"];default:return vn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function g8(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
  3752. `+s+`
  3753. `+s0e(t.getShaderSource(e),l)}else return s}function l0e(t,e){const n=o0e(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3754. `)}function c0e(t,e){let n;switch(e){case rpe:n="Linear";break;case ipe:n="Reinhard";break;case ape:n="Cineon";break;case spe:n="ACESFilmic";break;case lpe:n="AgX";break;case cpe:n="Neutral";break;case ope:n="Custom";break;default:vn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const x_=new mt;function u0e(){cr.getLuminanceCoefficients(x_);const t=x_.x.toFixed(4),e=x_.y.toFixed(4),n=x_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3755. `)}function d0e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(gy).join(`
  3756. `)}function h0e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3757. `)}function f0e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let l=1;s.type===t.FLOAT_MAT2&&(l=2),s.type===t.FLOAT_MAT3&&(l=3),s.type===t.FLOAT_MAT4&&(l=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function gy(t){return t!==""}function b8(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 x8(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const m0e=/^[ \t]*#include +<([\w\d./]+)>/gm;function O3(t){return t.replace(m0e,g0e)}const p0e=new Map;function g0e(t,e){let n=Pn[e];if(n===void 0){const r=p0e.get(e);if(r!==void 0)n=Pn[r],vn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return O3(n)}const b0e=/#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 y8(t){return t.replace(b0e,x0e)}function x0e(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function v8(t){let e=`precision ${t.precision} float;
  3758. precision ${t.precision} int;
  3759. precision ${t.precision} sampler2D;
  3760. precision ${t.precision} samplerCube;
  3761. precision ${t.precision} sampler3D;
  3762. precision ${t.precision} sampler2DArray;
  3763. precision ${t.precision} sampler2DShadow;
  3764. precision ${t.precision} samplerCubeShadow;
  3765. precision ${t.precision} sampler2DArrayShadow;
  3766. precision ${t.precision} isampler2D;
  3767. precision ${t.precision} isampler3D;
  3768. precision ${t.precision} isamplerCube;
  3769. precision ${t.precision} isampler2DArray;
  3770. precision ${t.precision} usampler2D;
  3771. precision ${t.precision} usampler3D;
  3772. precision ${t.precision} usamplerCube;
  3773. precision ${t.precision} usampler2DArray;
  3774. `;return t.precision==="highp"?e+=`
  3775. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3776. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3777. #define LOW_PRECISION`),e}function y0e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===pK?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Ome?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===_u&&(e="SHADOWMAP_TYPE_VSM"),e}function v0e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case rb:case ib:e="ENVMAP_TYPE_CUBE";break;case Uk:e="ENVMAP_TYPE_CUBE_UV";break}return e}function w0e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case ib:e="ENVMAP_MODE_REFRACTION";break}return e}function _0e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case g4:e="ENVMAP_BLENDING_MULTIPLY";break;case tpe:e="ENVMAP_BLENDING_MIX";break;case npe:e="ENVMAP_BLENDING_ADD";break}return e}function S0e(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 N0e(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=y0e(n),u=v0e(n),d=w0e(n),h=_0e(n),p=S0e(n),m=d0e(n),x=h0e(s),y=i.createProgram();let b,v,S=n.glslVersion?"#version "+n.glslVersion+`
  3778. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(gy).join(`
  3779. `),b.length>0&&(b+=`
  3780. `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(gy).join(`
  3781. `),v.length>0&&(v+=`
  3782. `)):(b=[v8(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",`
  3783. `].filter(gy).join(`
  3784. `),v=[v8(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 "+h:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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!==Ch?"#define TONE_MAPPING":"",n.toneMapping!==Ch?Pn.tonemapping_pars_fragment:"",n.toneMapping!==Ch?c0e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Pn.colorspace_pars_fragment,l0e("linearToOutputTexel",n.outputColorSpace),u0e(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3785. `].filter(gy).join(`
  3786. `)),o=O3(o),o=b8(o,n),o=x8(o,n),l=O3(l),l=b8(l,n),l=x8(l,n),o=y8(o),l=y8(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  3787. `,b=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3788. `)+`
  3789. `+b,v=["#define varying in",n.glslVersion===MB?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===MB?"":"#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(`
  3790. `)+`
  3791. `+v);const k=S+b+o,E=S+v+l,N=m8(i,i.VERTEX_SHADER,k),A=m8(i,i.FRAGMENT_SHADER,E);i.attachShader(y,N),i.attachShader(y,A),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function M(z){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(y)||"",$=i.getShaderInfoLog(N)||"",D=i.getShaderInfoLog(A)||"",H=F.trim(),q=$.trim(),I=D.trim();let K=!0,Z=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(K=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,N,A);else{const se=g8(i,N,"vertex"),V=g8(i,A,"fragment");zi("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  3792. Material Name: `+z.name+`
  3793. Material Type: `+z.type+`
  3794. Program Info Log: `+H+`
  3795. `+se+`
  3796. `+V)}else H!==""?vn("WebGLProgram: Program Info Log:",H):(q===""||I==="")&&(Z=!1);Z&&(z.diagnostics={runnable:K,programLog:H,vertexShader:{log:q,prefix:b},fragmentShader:{log:I,prefix:v}})}i.deleteShader(N),i.deleteShader(A),P=new $S(i,y),T=f0e(i,y)}let P;this.getUniforms=function(){return P===void 0&&M(this),P};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let j=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return j===!1&&(j=i.getProgramParameter(y,i0e)),j},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=a0e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=N,this.fragmentShader=A,this}let k0e=0,M0e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.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 C0e(e),n.set(e,r)),r}},C0e=class{constructor(e){this.id=k0e++,this.code=e,this.usedTimes=0}};function E0e(t,e,n,r,i,s,o){const l=new DK,c=new M0e,u=new Set,d=[],h=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=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(T){return u.add(T),T===0?"uv":`uv${T}`}function b(T,j,z,F,$){const D=F.fog,H=$.geometry,q=T.isMeshStandardMaterial?F.environment:null,I=(T.isMeshStandardMaterial?n:e).get(T.envMap||q),K=I&&I.mapping===Uk?I.image.height:null,Z=x[T.type];T.precision!==null&&(m=i.getMaxPrecision(T.precision),m!==T.precision&&vn("WebGLProgram.getParameters:",T.precision,"not supported, using",m,"instead."));const se=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,V=se!==void 0?se.length:0;let W=0;H.morphAttributes.position!==void 0&&(W=1),H.morphAttributes.normal!==void 0&&(W=2),H.morphAttributes.color!==void 0&&(W=3);let ie,J,pe,fe;if(Z){const Et=gc[Z];ie=Et.vertexShader,J=Et.fragmentShader}else ie=T.vertexShader,J=T.fragmentShader,c.update(T),pe=c.getVertexShaderID(T),fe=c.getFragmentShaderID(T);const ve=t.getRenderTarget(),Le=t.state.buffers.depth.getReversed(),de=$.isInstancedMesh===!0,ce=$.isBatchedMesh===!0,Ae=!!T.map,re=!!T.matcap,Ie=!!I,G=!!T.aoMap,Y=!!T.lightMap,ue=!!T.bumpMap,B=!!T.normalMap,ee=!!T.displacementMap,Q=!!T.emissiveMap,le=!!T.metalnessMap,he=!!T.roughnessMap,te=T.anisotropy>0,U=T.clearcoat>0,L=T.dispersion>0,X=T.iridescence>0,ge=T.sheen>0,_e=T.transmission>0,Ee=te&&!!T.anisotropyMap,$e=U&&!!T.clearcoatMap,Ce=U&&!!T.clearcoatNormalMap,He=U&&!!T.clearcoatRoughnessMap,Qe=X&&!!T.iridescenceMap,xe=X&&!!T.iridescenceThicknessMap,ye=ge&&!!T.sheenColorMap,we=ge&&!!T.sheenRoughnessMap,Ue=!!T.specularMap,Pe=!!T.specularColorMap,Ve=!!T.specularIntensityMap,ke=_e&&!!T.transmissionMap,Ze=_e&&!!T.thicknessMap,je=!!T.gradientMap,Xe=!!T.alphaMap,Re=T.alphaTest>0,Oe=!!T.alphaHash,Ne=!!T.extensions;let Je=Ch;T.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(Je=t.toneMapping);const yt={shaderID:Z,shaderType:T.type,shaderName:T.name,vertexShader:ie,fragmentShader:J,defines:T.defines,customVertexShaderID:pe,customFragmentShaderID:fe,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:m,batching:ce,batchingColor:ce&&$._colorsTexture!==null,instancing:de,instancingColor:de&&$.instanceColor!==null,instancingMorph:de&&$.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:ve===null?t.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:ab,alphaToCoverage:!!T.alphaToCoverage,map:Ae,matcap:re,envMap:Ie,envMapMode:Ie&&I.mapping,envMapCubeUVHeight:K,aoMap:G,lightMap:Y,bumpMap:ue,normalMap:B,displacementMap:p&&ee,emissiveMap:Q,normalMapObjectSpace:B&&T.normalMapType===fpe,normalMapTangentSpace:B&&T.normalMapType===NK,metalnessMap:le,roughnessMap:he,anisotropy:te,anisotropyMap:Ee,clearcoat:U,clearcoatMap:$e,clearcoatNormalMap:Ce,clearcoatRoughnessMap:He,dispersion:L,iridescence:X,iridescenceMap:Qe,iridescenceThicknessMap:xe,sheen:ge,sheenColorMap:ye,sheenRoughnessMap:we,specularMap:Ue,specularColorMap:Pe,specularIntensityMap:Ve,transmission:_e,transmissionMap:ke,thicknessMap:Ze,gradientMap:je,opaque:T.transparent===!1&&T.blending===Ig&&T.alphaToCoverage===!1,alphaMap:Xe,alphaTest:Re,alphaHash:Oe,combine:T.combine,mapUv:Ae&&y(T.map.channel),aoMapUv:G&&y(T.aoMap.channel),lightMapUv:Y&&y(T.lightMap.channel),bumpMapUv:ue&&y(T.bumpMap.channel),normalMapUv:B&&y(T.normalMap.channel),displacementMapUv:ee&&y(T.displacementMap.channel),emissiveMapUv:Q&&y(T.emissiveMap.channel),metalnessMapUv:le&&y(T.metalnessMap.channel),roughnessMapUv:he&&y(T.roughnessMap.channel),anisotropyMapUv:Ee&&y(T.anisotropyMap.channel),clearcoatMapUv:$e&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:Ce&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:He&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Qe&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:xe&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:ye&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:we&&y(T.sheenRoughnessMap.channel),specularMapUv:Ue&&y(T.specularMap.channel),specularColorMapUv:Pe&&y(T.specularColorMap.channel),specularIntensityMapUv:Ve&&y(T.specularIntensityMap.channel),transmissionMapUv:ke&&y(T.transmissionMap.channel),thicknessMapUv:Ze&&y(T.thicknessMap.channel),alphaMapUv:Xe&&y(T.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(B||te),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!H.attributes.uv&&(Ae||Xe),fog:!!D,useFog:T.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:T.flatShading===!0&&T.wireframe===!1,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Le,skinning:$.isSkinnedMesh===!0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:V,morphTextureStride:W,numDirLights:j.directional.length,numPointLights:j.point.length,numSpotLights:j.spot.length,numSpotLightMaps:j.spotLightMap.length,numRectAreaLights:j.rectArea.length,numHemiLights:j.hemi.length,numDirLightShadows:j.directionalShadowMap.length,numPointLightShadows:j.pointShadowMap.length,numSpotLightShadows:j.spotShadowMap.length,numSpotLightShadowsWithMaps:j.numSpotLightShadowsWithMaps,numLightProbes:j.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:Je,decodeVideoTexture:Ae&&T.map.isVideoTexture===!0&&cr.getTransfer(T.map.colorSpace)===Ar,decodeVideoTextureEmissive:Q&&T.emissiveMap.isVideoTexture===!0&&cr.getTransfer(T.emissiveMap.colorSpace)===Ar,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===xc,flipSided:T.side===Qs,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:Ne&&T.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ne&&T.extensions.multiDraw===!0||ce)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return yt.vertexUv1s=u.has(1),yt.vertexUv2s=u.has(2),yt.vertexUv3s=u.has(3),u.clear(),yt}function v(T){const j=[];if(T.shaderID?j.push(T.shaderID):(j.push(T.customVertexShaderID),j.push(T.customFragmentShaderID)),T.defines!==void 0)for(const z in T.defines)j.push(z),j.push(T.defines[z]);return T.isRawShaderMaterial===!1&&(S(j,T),k(j,T),j.push(t.outputColorSpace)),j.push(T.customProgramCacheKey),j.join()}function S(T,j){T.push(j.precision),T.push(j.outputColorSpace),T.push(j.envMapMode),T.push(j.envMapCubeUVHeight),T.push(j.mapUv),T.push(j.alphaMapUv),T.push(j.lightMapUv),T.push(j.aoMapUv),T.push(j.bumpMapUv),T.push(j.normalMapUv),T.push(j.displacementMapUv),T.push(j.emissiveMapUv),T.push(j.metalnessMapUv),T.push(j.roughnessMapUv),T.push(j.anisotropyMapUv),T.push(j.clearcoatMapUv),T.push(j.clearcoatNormalMapUv),T.push(j.clearcoatRoughnessMapUv),T.push(j.iridescenceMapUv),T.push(j.iridescenceThicknessMapUv),T.push(j.sheenColorMapUv),T.push(j.sheenRoughnessMapUv),T.push(j.specularMapUv),T.push(j.specularColorMapUv),T.push(j.specularIntensityMapUv),T.push(j.transmissionMapUv),T.push(j.thicknessMapUv),T.push(j.combine),T.push(j.fogExp2),T.push(j.sizeAttenuation),T.push(j.morphTargetsCount),T.push(j.morphAttributeCount),T.push(j.numDirLights),T.push(j.numPointLights),T.push(j.numSpotLights),T.push(j.numSpotLightMaps),T.push(j.numHemiLights),T.push(j.numRectAreaLights),T.push(j.numDirLightShadows),T.push(j.numPointLightShadows),T.push(j.numSpotLightShadows),T.push(j.numSpotLightShadowsWithMaps),T.push(j.numLightProbes),T.push(j.shadowMapType),T.push(j.toneMapping),T.push(j.numClippingPlanes),T.push(j.numClipIntersection),T.push(j.depthPacking)}function k(T,j){l.disableAll(),j.supportsVertexTextures&&l.enable(0),j.instancing&&l.enable(1),j.instancingColor&&l.enable(2),j.instancingMorph&&l.enable(3),j.matcap&&l.enable(4),j.envMap&&l.enable(5),j.normalMapObjectSpace&&l.enable(6),j.normalMapTangentSpace&&l.enable(7),j.clearcoat&&l.enable(8),j.iridescence&&l.enable(9),j.alphaTest&&l.enable(10),j.vertexColors&&l.enable(11),j.vertexAlphas&&l.enable(12),j.vertexUv1s&&l.enable(13),j.vertexUv2s&&l.enable(14),j.vertexUv3s&&l.enable(15),j.vertexTangents&&l.enable(16),j.anisotropy&&l.enable(17),j.alphaHash&&l.enable(18),j.batching&&l.enable(19),j.dispersion&&l.enable(20),j.batchingColor&&l.enable(21),j.gradientMap&&l.enable(22),T.push(l.mask),l.disableAll(),j.fog&&l.enable(0),j.useFog&&l.enable(1),j.flatShading&&l.enable(2),j.logarithmicDepthBuffer&&l.enable(3),j.reversedDepthBuffer&&l.enable(4),j.skinning&&l.enable(5),j.morphTargets&&l.enable(6),j.morphNormals&&l.enable(7),j.morphColors&&l.enable(8),j.premultipliedAlpha&&l.enable(9),j.shadowMapEnabled&&l.enable(10),j.doubleSided&&l.enable(11),j.flipSided&&l.enable(12),j.useDepthPacking&&l.enable(13),j.dithering&&l.enable(14),j.transmission&&l.enable(15),j.sheen&&l.enable(16),j.opaque&&l.enable(17),j.pointsUvs&&l.enable(18),j.decodeVideoTexture&&l.enable(19),j.decodeVideoTextureEmissive&&l.enable(20),j.alphaToCoverage&&l.enable(21),T.push(l.mask)}function E(T){const j=x[T.type];let z;if(j){const F=gc[j];z=Hpe.clone(F.uniforms)}else z=T.uniforms;return z}function N(T,j){let z;for(let F=0,$=d.length;F<$;F++){const D=d[F];if(D.cacheKey===j){z=D,++z.usedTimes;break}}return z===void 0&&(z=new N0e(t,j,T,s),d.push(z)),z}function A(T){if(--T.usedTimes===0){const j=d.indexOf(T);d[j]=d[d.length-1],d.pop(),T.destroy()}}function M(T){c.remove(T)}function P(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:E,acquireProgram:N,releaseProgram:A,releaseShaderCache:M,programs:d,dispose:P}}function A0e(){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 s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function T0e(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 w8(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 _8(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(h,p,m,x,y,b){let v=t[e];return v===void 0?(v={id:h.id,object:h,geometry:p,material:m,groupOrder:x,renderOrder:h.renderOrder,z:y,group:b},t[e]=v):(v.id=h.id,v.object=h,v.geometry=p,v.material=m,v.groupOrder=x,v.renderOrder=h.renderOrder,v.z=y,v.group=b),e++,v}function l(h,p,m,x,y,b){const v=o(h,p,m,x,y,b);m.transmission>0?r.push(v):m.transparent===!0?i.push(v):n.push(v)}function c(h,p,m,x,y,b){const v=o(h,p,m,x,y,b);m.transmission>0?r.unshift(v):m.transparent===!0?i.unshift(v):n.unshift(v)}function u(h,p){n.length>1&&n.sort(h||T0e),r.length>1&&r.sort(p||w8),i.length>1&&i.sort(p||w8)}function d(){for(let h=e,p=t.length;h<p;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function j0e(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new _8,t.set(r,[o])):i>=s.length?(o=new _8,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function P0e(){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 mt,color:new In};break;case"SpotLight":n={position:new mt,direction:new mt,color:new In,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new mt,color:new In,distance:0,decay:0};break;case"HemisphereLight":n={direction:new mt,skyColor:new In,groundColor:new In};break;case"RectAreaLight":n={color:new In,position:new mt,halfWidth:new mt,halfHeight:new mt};break}return t[e.id]=n,n}}}function D0e(){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 Rn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Rn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Rn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let R0e=0;function L0e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function O0e(t){const e=new P0e,n=D0e(),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 mt);const i=new mt,s=new na,o=new na;function l(u){let d=0,h=0,p=0;for(let T=0;T<9;T++)r.probe[T].set(0,0,0);let m=0,x=0,y=0,b=0,v=0,S=0,k=0,E=0,N=0,A=0,M=0;u.sort(L0e);for(let T=0,j=u.length;T<j;T++){const z=u[T],F=z.color,$=z.intensity,D=z.distance,H=z.shadow&&z.shadow.map?z.shadow.map.texture:null;if(z.isAmbientLight)d+=F.r*$,h+=F.g*$,p+=F.b*$;else if(z.isLightProbe){for(let q=0;q<9;q++)r.probe[q].addScaledVector(z.sh.coefficients[q],$);M++}else if(z.isDirectionalLight){const q=e.get(z);if(q.color.copy(z.color).multiplyScalar(z.intensity),z.castShadow){const I=z.shadow,K=n.get(z);K.shadowIntensity=I.intensity,K.shadowBias=I.bias,K.shadowNormalBias=I.normalBias,K.shadowRadius=I.radius,K.shadowMapSize=I.mapSize,r.directionalShadow[m]=K,r.directionalShadowMap[m]=H,r.directionalShadowMatrix[m]=z.shadow.matrix,S++}r.directional[m]=q,m++}else if(z.isSpotLight){const q=e.get(z);q.position.setFromMatrixPosition(z.matrixWorld),q.color.copy(F).multiplyScalar($),q.distance=D,q.coneCos=Math.cos(z.angle),q.penumbraCos=Math.cos(z.angle*(1-z.penumbra)),q.decay=z.decay,r.spot[y]=q;const I=z.shadow;if(z.map&&(r.spotLightMap[N]=z.map,N++,I.updateMatrices(z),z.castShadow&&A++),r.spotLightMatrix[y]=I.matrix,z.castShadow){const K=n.get(z);K.shadowIntensity=I.intensity,K.shadowBias=I.bias,K.shadowNormalBias=I.normalBias,K.shadowRadius=I.radius,K.shadowMapSize=I.mapSize,r.spotShadow[y]=K,r.spotShadowMap[y]=H,E++}y++}else if(z.isRectAreaLight){const q=e.get(z);q.color.copy(F).multiplyScalar($),q.halfWidth.set(z.width*.5,0,0),q.halfHeight.set(0,z.height*.5,0),r.rectArea[b]=q,b++}else if(z.isPointLight){const q=e.get(z);if(q.color.copy(z.color).multiplyScalar(z.intensity),q.distance=z.distance,q.decay=z.decay,z.castShadow){const I=z.shadow,K=n.get(z);K.shadowIntensity=I.intensity,K.shadowBias=I.bias,K.shadowNormalBias=I.normalBias,K.shadowRadius=I.radius,K.shadowMapSize=I.mapSize,K.shadowCameraNear=I.camera.near,K.shadowCameraFar=I.camera.far,r.pointShadow[x]=K,r.pointShadowMap[x]=H,r.pointShadowMatrix[x]=z.shadow.matrix,k++}r.point[x]=q,x++}else if(z.isHemisphereLight){const q=e.get(z);q.skyColor.copy(z.color).multiplyScalar($),q.groundColor.copy(z.groundColor).multiplyScalar($),r.hemi[v]=q,v++}}b>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=It.LTC_FLOAT_1,r.rectAreaLTC2=It.LTC_FLOAT_2):(r.rectAreaLTC1=It.LTC_HALF_1,r.rectAreaLTC2=It.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=h,r.ambient[2]=p;const P=r.hash;(P.directionalLength!==m||P.pointLength!==x||P.spotLength!==y||P.rectAreaLength!==b||P.hemiLength!==v||P.numDirectionalShadows!==S||P.numPointShadows!==k||P.numSpotShadows!==E||P.numSpotMaps!==N||P.numLightProbes!==M)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=b,r.point.length=x,r.hemi.length=v,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=k,r.pointShadowMap.length=k,r.spotShadow.length=E,r.spotShadowMap.length=E,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=k,r.spotLightMatrix.length=E+N-A,r.spotLightMap.length=N,r.numSpotLightShadowsWithMaps=A,r.numLightProbes=M,P.directionalLength=m,P.pointLength=x,P.spotLength=y,P.rectAreaLength=b,P.hemiLength=v,P.numDirectionalShadows=S,P.numPointShadows=k,P.numSpotShadows=E,P.numSpotMaps=N,P.numLightProbes=M,r.version=R0e++)}function c(u,d){let h=0,p=0,m=0,x=0,y=0;const b=d.matrixWorldInverse;for(let v=0,S=u.length;v<S;v++){const k=u[v];if(k.isDirectionalLight){const E=r.directional[h];E.direction.setFromMatrixPosition(k.matrixWorld),i.setFromMatrixPosition(k.target.matrixWorld),E.direction.sub(i),E.direction.transformDirection(b),h++}else if(k.isSpotLight){const E=r.spot[m];E.position.setFromMatrixPosition(k.matrixWorld),E.position.applyMatrix4(b),E.direction.setFromMatrixPosition(k.matrixWorld),i.setFromMatrixPosition(k.target.matrixWorld),E.direction.sub(i),E.direction.transformDirection(b),m++}else if(k.isRectAreaLight){const E=r.rectArea[x];E.position.setFromMatrixPosition(k.matrixWorld),E.position.applyMatrix4(b),o.identity(),s.copy(k.matrixWorld),s.premultiply(b),o.extractRotation(s),E.halfWidth.set(k.width*.5,0,0),E.halfHeight.set(0,k.height*.5,0),E.halfWidth.applyMatrix4(o),E.halfHeight.applyMatrix4(o),x++}else if(k.isPointLight){const E=r.point[p];E.position.setFromMatrixPosition(k.matrixWorld),E.position.applyMatrix4(b),p++}else if(k.isHemisphereLight){const E=r.hemi[y];E.direction.setFromMatrixPosition(k.matrixWorld),E.direction.transformDirection(b),y++}}}return{setup:l,setupView:c,state:r}}function S8(t){const e=new O0e(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function s(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:s,pushShadow:o}}function F0e(t){let e=new WeakMap;function n(i,s=0){const o=e.get(i);let l;return o===void 0?(l=new S8(t),e.set(i,[l])):s>=o.length?(l=new S8(t),o.push(l)):l=o[s],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const I0e=`void main() {
  3797. gl_Position = vec4( position, 1.0 );
  3798. }`,z0e=`uniform sampler2D shadow_pass;
  3799. uniform vec2 resolution;
  3800. uniform float radius;
  3801. #include <packing>
  3802. void main() {
  3803. const float samples = float( VSM_SAMPLES );
  3804. float mean = 0.0;
  3805. float squared_mean = 0.0;
  3806. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3807. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3808. for ( float i = 0.0; i < samples; i ++ ) {
  3809. float uvOffset = uvStart + i * uvStride;
  3810. #ifdef HORIZONTAL_PASS
  3811. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3812. mean += distribution.x;
  3813. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3814. #else
  3815. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3816. mean += depth;
  3817. squared_mean += depth * depth;
  3818. #endif
  3819. }
  3820. mean = mean / samples;
  3821. squared_mean = squared_mean / samples;
  3822. float std_dev = sqrt( squared_mean - mean * mean );
  3823. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3824. }`;function U0e(t,e,n){let r=new E4;const i=new Rn,s=new Rn,o=new Zi,l=new nge({depthPacking:hpe}),c=new rge,u={},d=n.maxTextureSize,h={[zh]:Qs,[Qs]:zh,[xc]:xc},p=new ed({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Rn},radius:{value:4}},vertexShader:I0e,fragmentShader:z0e}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new gl;x.setAttribute("position",new Ts(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new bl(x,p),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=pK;let v=this.type;this.render=function(A,M,P){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||A.length===0)return;const T=t.getRenderTarget(),j=t.getActiveCubeFace(),z=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Bu),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const $=v!==_u&&this.type===_u,D=v===_u&&this.type!==_u;for(let H=0,q=A.length;H<q;H++){const I=A[H],K=I.shadow;if(K===void 0){vn("WebGLShadowMap:",I,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;i.copy(K.mapSize);const Z=K.getFrameExtents();if(i.multiply(Z),s.copy(K.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Z.x),i.x=s.x*Z.x,K.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Z.y),i.y=s.y*Z.y,K.mapSize.y=s.y)),K.map===null||$===!0||D===!0){const V=this.type!==_u?{minFilter:ko,magFilter:ko}:{};K.map!==null&&K.map.dispose(),K.map=new Am(i.x,i.y,V),K.map.texture.name=I.name+".shadowMap",K.camera.updateProjectionMatrix()}t.setRenderTarget(K.map),t.clear();const se=K.getViewportCount();for(let V=0;V<se;V++){const W=K.getViewport(V);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),F.viewport(o),K.updateMatrices(I,V),r=K.getFrustum(),E(M,P,K.camera,I,this.type)}K.isPointLightShadow!==!0&&this.type===_u&&S(K,P),K.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(T,j,z)};function S(A,M){const P=e.update(y);p.defines.VSM_SAMPLES!==A.blurSamples&&(p.defines.VSM_SAMPLES=A.blurSamples,m.defines.VSM_SAMPLES=A.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new Am(i.x,i.y)),p.uniforms.shadow_pass.value=A.map.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(M,null,P,p,y,null),m.uniforms.shadow_pass.value=A.mapPass.texture,m.uniforms.resolution.value=A.mapSize,m.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(M,null,P,m,y,null)}function k(A,M,P,T){let j=null;const z=P.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(z!==void 0)j=z;else if(j=P.isPointLight===!0?c:l,t.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const F=j.uuid,$=M.uuid;let D=u[F];D===void 0&&(D={},u[F]=D);let H=D[$];H===void 0&&(H=j.clone(),D[$]=H,M.addEventListener("dispose",N)),j=H}if(j.visible=M.visible,j.wireframe=M.wireframe,T===_u?j.side=M.shadowSide!==null?M.shadowSide:M.side:j.side=M.shadowSide!==null?M.shadowSide:h[M.side],j.alphaMap=M.alphaMap,j.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,j.map=M.map,j.clipShadows=M.clipShadows,j.clippingPlanes=M.clippingPlanes,j.clipIntersection=M.clipIntersection,j.displacementMap=M.displacementMap,j.displacementScale=M.displacementScale,j.displacementBias=M.displacementBias,j.wireframeLinewidth=M.wireframeLinewidth,j.linewidth=M.linewidth,P.isPointLight===!0&&j.isMeshDistanceMaterial===!0){const F=t.properties.get(j);F.light=P}return j}function E(A,M,P,T,j){if(A.visible===!1)return;if(A.layers.test(M.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&j===_u)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,A.matrixWorld);const $=e.update(A),D=A.material;if(Array.isArray(D)){const H=$.groups;for(let q=0,I=H.length;q<I;q++){const K=H[q],Z=D[K.materialIndex];if(Z&&Z.visible){const se=k(A,Z,T,j);A.onBeforeShadow(t,A,M,P,$,se,K),t.renderBufferDirect(P,null,$,se,A,K),A.onAfterShadow(t,A,M,P,$,se,K)}}}else if(D.visible){const H=k(A,D,T,j);A.onBeforeShadow(t,A,M,P,$,H,null),t.renderBufferDirect(P,null,$,H,A,null),A.onAfterShadow(t,A,M,P,$,H,null)}}const F=A.children;for(let $=0,D=F.length;$<D;$++)E(F[$],M,P,T,j)}function N(A){A.target.removeEventListener("dispose",N);for(const P in u){const T=u[P],j=A.target.uuid;j in T&&(T[j].dispose(),delete T[j])}}}const B0e={[XP]:YP,[QP]:e3,[ZP]:t3,[nb]:JP,[YP]:XP,[e3]:QP,[t3]:ZP,[JP]:nb};function $0e(t,e){function n(){let ke=!1;const Ze=new Zi;let je=null;const Xe=new Zi(0,0,0,0);return{setMask:function(Re){je!==Re&&!ke&&(t.colorMask(Re,Re,Re,Re),je=Re)},setLocked:function(Re){ke=Re},setClear:function(Re,Oe,Ne,Je,yt){yt===!0&&(Re*=Je,Oe*=Je,Ne*=Je),Ze.set(Re,Oe,Ne,Je),Xe.equals(Ze)===!1&&(t.clearColor(Re,Oe,Ne,Je),Xe.copy(Ze))},reset:function(){ke=!1,je=null,Xe.set(-1,0,0,0)}}}function r(){let ke=!1,Ze=!1,je=null,Xe=null,Re=null;return{setReversed:function(Oe){if(Ze!==Oe){const Ne=e.get("EXT_clip_control");Oe?Ne.clipControlEXT(Ne.LOWER_LEFT_EXT,Ne.ZERO_TO_ONE_EXT):Ne.clipControlEXT(Ne.LOWER_LEFT_EXT,Ne.NEGATIVE_ONE_TO_ONE_EXT),Ze=Oe;const Je=Re;Re=null,this.setClear(Je)}},getReversed:function(){return Ze},setTest:function(Oe){Oe?ve(t.DEPTH_TEST):Le(t.DEPTH_TEST)},setMask:function(Oe){je!==Oe&&!ke&&(t.depthMask(Oe),je=Oe)},setFunc:function(Oe){if(Ze&&(Oe=B0e[Oe]),Xe!==Oe){switch(Oe){case XP:t.depthFunc(t.NEVER);break;case YP:t.depthFunc(t.ALWAYS);break;case QP:t.depthFunc(t.LESS);break;case nb:t.depthFunc(t.LEQUAL);break;case ZP:t.depthFunc(t.EQUAL);break;case JP:t.depthFunc(t.GEQUAL);break;case e3:t.depthFunc(t.GREATER);break;case t3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Xe=Oe}},setLocked:function(Oe){ke=Oe},setClear:function(Oe){Re!==Oe&&(Ze&&(Oe=1-Oe),t.clearDepth(Oe),Re=Oe)},reset:function(){ke=!1,je=null,Xe=null,Re=null,Ze=!1}}}function i(){let ke=!1,Ze=null,je=null,Xe=null,Re=null,Oe=null,Ne=null,Je=null,yt=null;return{setTest:function(Et){ke||(Et?ve(t.STENCIL_TEST):Le(t.STENCIL_TEST))},setMask:function(Et){Ze!==Et&&!ke&&(t.stencilMask(Et),Ze=Et)},setFunc:function(Et,an,jt){(je!==Et||Xe!==an||Re!==jt)&&(t.stencilFunc(Et,an,jt),je=Et,Xe=an,Re=jt)},setOp:function(Et,an,jt){(Oe!==Et||Ne!==an||Je!==jt)&&(t.stencilOp(Et,an,jt),Oe=Et,Ne=an,Je=jt)},setLocked:function(Et){ke=Et},setClear:function(Et){yt!==Et&&(t.clearStencil(Et),yt=Et)},reset:function(){ke=!1,Ze=null,je=null,Xe=null,Re=null,Oe=null,Ne=null,Je=null,yt=null}}}const s=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},h={},p=new WeakMap,m=[],x=null,y=!1,b=null,v=null,S=null,k=null,E=null,N=null,A=null,M=new In(0,0,0),P=0,T=!1,j=null,z=null,F=null,$=null,D=null;const H=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,I=0;const K=t.getParameter(t.VERSION);K.indexOf("WebGL")!==-1?(I=parseFloat(/^WebGL (\d)/.exec(K)[1]),q=I>=1):K.indexOf("OpenGL ES")!==-1&&(I=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),q=I>=2);let Z=null,se={};const V=t.getParameter(t.SCISSOR_BOX),W=t.getParameter(t.VIEWPORT),ie=new Zi().fromArray(V),J=new Zi().fromArray(W);function pe(ke,Ze,je,Xe){const Re=new Uint8Array(4),Oe=t.createTexture();t.bindTexture(ke,Oe),t.texParameteri(ke,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ke,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ne=0;Ne<je;Ne++)ke===t.TEXTURE_3D||ke===t.TEXTURE_2D_ARRAY?t.texImage3D(Ze,0,t.RGBA,1,1,Xe,0,t.RGBA,t.UNSIGNED_BYTE,Re):t.texImage2D(Ze+Ne,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Re);return Oe}const fe={};fe[t.TEXTURE_2D]=pe(t.TEXTURE_2D,t.TEXTURE_2D,1),fe[t.TEXTURE_CUBE_MAP]=pe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[t.TEXTURE_2D_ARRAY]=pe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),fe[t.TEXTURE_3D]=pe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),l.setClear(0),ve(t.DEPTH_TEST),o.setFunc(nb),ue(!1),B(vB),ve(t.CULL_FACE),G(Bu);function ve(ke){d[ke]!==!0&&(t.enable(ke),d[ke]=!0)}function Le(ke){d[ke]!==!1&&(t.disable(ke),d[ke]=!1)}function de(ke,Ze){return h[ke]!==Ze?(t.bindFramebuffer(ke,Ze),h[ke]=Ze,ke===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=Ze),ke===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=Ze),!0):!1}function ce(ke,Ze){let je=m,Xe=!1;if(ke){je=p.get(Ze),je===void 0&&(je=[],p.set(Ze,je));const Re=ke.textures;if(je.length!==Re.length||je[0]!==t.COLOR_ATTACHMENT0){for(let Oe=0,Ne=Re.length;Oe<Ne;Oe++)je[Oe]=t.COLOR_ATTACHMENT0+Oe;je.length=Re.length,Xe=!0}}else je[0]!==t.BACK&&(je[0]=t.BACK,Xe=!0);Xe&&t.drawBuffers(je)}function Ae(ke){return x!==ke?(t.useProgram(ke),x=ke,!0):!1}const re={[$f]:t.FUNC_ADD,[Ime]:t.FUNC_SUBTRACT,[zme]:t.FUNC_REVERSE_SUBTRACT};re[Ume]=t.MIN,re[Bme]=t.MAX;const Ie={[$me]:t.ZERO,[Hme]:t.ONE,[Vme]:t.SRC_COLOR,[WP]:t.SRC_ALPHA,[Yme]:t.SRC_ALPHA_SATURATE,[Kme]:t.DST_COLOR,[qme]:t.DST_ALPHA,[Gme]:t.ONE_MINUS_SRC_COLOR,[KP]:t.ONE_MINUS_SRC_ALPHA,[Xme]:t.ONE_MINUS_DST_COLOR,[Wme]:t.ONE_MINUS_DST_ALPHA,[Qme]:t.CONSTANT_COLOR,[Zme]:t.ONE_MINUS_CONSTANT_COLOR,[Jme]:t.CONSTANT_ALPHA,[epe]:t.ONE_MINUS_CONSTANT_ALPHA};function G(ke,Ze,je,Xe,Re,Oe,Ne,Je,yt,Et){if(ke===Bu){y===!0&&(Le(t.BLEND),y=!1);return}if(y===!1&&(ve(t.BLEND),y=!0),ke!==Fme){if(ke!==b||Et!==T){if((v!==$f||E!==$f)&&(t.blendEquation(t.FUNC_ADD),v=$f,E=$f),Et)switch(ke){case Ig:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case wB:t.blendFunc(t.ONE,t.ONE);break;case _B:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case SB:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:zi("WebGLState: Invalid blending: ",ke);break}else switch(ke){case Ig:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case wB:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case _B:zi("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case SB:zi("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:zi("WebGLState: Invalid blending: ",ke);break}S=null,k=null,N=null,A=null,M.set(0,0,0),P=0,b=ke,T=Et}return}Re=Re||Ze,Oe=Oe||je,Ne=Ne||Xe,(Ze!==v||Re!==E)&&(t.blendEquationSeparate(re[Ze],re[Re]),v=Ze,E=Re),(je!==S||Xe!==k||Oe!==N||Ne!==A)&&(t.blendFuncSeparate(Ie[je],Ie[Xe],Ie[Oe],Ie[Ne]),S=je,k=Xe,N=Oe,A=Ne),(Je.equals(M)===!1||yt!==P)&&(t.blendColor(Je.r,Je.g,Je.b,yt),M.copy(Je),P=yt),b=ke,T=!1}function Y(ke,Ze){ke.side===xc?Le(t.CULL_FACE):ve(t.CULL_FACE);let je=ke.side===Qs;Ze&&(je=!je),ue(je),ke.blending===Ig&&ke.transparent===!1?G(Bu):G(ke.blending,ke.blendEquation,ke.blendSrc,ke.blendDst,ke.blendEquationAlpha,ke.blendSrcAlpha,ke.blendDstAlpha,ke.blendColor,ke.blendAlpha,ke.premultipliedAlpha),o.setFunc(ke.depthFunc),o.setTest(ke.depthTest),o.setMask(ke.depthWrite),s.setMask(ke.colorWrite);const Xe=ke.stencilWrite;l.setTest(Xe),Xe&&(l.setMask(ke.stencilWriteMask),l.setFunc(ke.stencilFunc,ke.stencilRef,ke.stencilFuncMask),l.setOp(ke.stencilFail,ke.stencilZFail,ke.stencilZPass)),Q(ke.polygonOffset,ke.polygonOffsetFactor,ke.polygonOffsetUnits),ke.alphaToCoverage===!0?ve(t.SAMPLE_ALPHA_TO_COVERAGE):Le(t.SAMPLE_ALPHA_TO_COVERAGE)}function ue(ke){j!==ke&&(ke?t.frontFace(t.CW):t.frontFace(t.CCW),j=ke)}function B(ke){ke!==Rme?(ve(t.CULL_FACE),ke!==z&&(ke===vB?t.cullFace(t.BACK):ke===Lme?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Le(t.CULL_FACE),z=ke}function ee(ke){ke!==F&&(q&&t.lineWidth(ke),F=ke)}function Q(ke,Ze,je){ke?(ve(t.POLYGON_OFFSET_FILL),($!==Ze||D!==je)&&(t.polygonOffset(Ze,je),$=Ze,D=je)):Le(t.POLYGON_OFFSET_FILL)}function le(ke){ke?ve(t.SCISSOR_TEST):Le(t.SCISSOR_TEST)}function he(ke){ke===void 0&&(ke=t.TEXTURE0+H-1),Z!==ke&&(t.activeTexture(ke),Z=ke)}function te(ke,Ze,je){je===void 0&&(Z===null?je=t.TEXTURE0+H-1:je=Z);let Xe=se[je];Xe===void 0&&(Xe={type:void 0,texture:void 0},se[je]=Xe),(Xe.type!==ke||Xe.texture!==Ze)&&(Z!==je&&(t.activeTexture(je),Z=je),t.bindTexture(ke,Ze||fe[ke]),Xe.type=ke,Xe.texture=Ze)}function U(){const ke=se[Z];ke!==void 0&&ke.type!==void 0&&(t.bindTexture(ke.type,null),ke.type=void 0,ke.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function X(){try{t.compressedTexImage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function ge(){try{t.texSubImage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function _e(){try{t.texSubImage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function Ee(){try{t.compressedTexSubImage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function $e(){try{t.compressedTexSubImage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function Ce(){try{t.texStorage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function He(){try{t.texStorage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function Qe(){try{t.texImage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function xe(){try{t.texImage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function ye(ke){ie.equals(ke)===!1&&(t.scissor(ke.x,ke.y,ke.z,ke.w),ie.copy(ke))}function we(ke){J.equals(ke)===!1&&(t.viewport(ke.x,ke.y,ke.z,ke.w),J.copy(ke))}function Ue(ke,Ze){let je=u.get(Ze);je===void 0&&(je=new WeakMap,u.set(Ze,je));let Xe=je.get(ke);Xe===void 0&&(Xe=t.getUniformBlockIndex(Ze,ke.name),je.set(ke,Xe))}function Pe(ke,Ze){const Xe=u.get(Ze).get(ke);c.get(Ze)!==Xe&&(t.uniformBlockBinding(Ze,Xe,ke.__bindingPointIndex),c.set(Ze,Xe))}function Ve(){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={},Z=null,se={},h={},p=new WeakMap,m=[],x=null,y=!1,b=null,v=null,S=null,k=null,E=null,N=null,A=null,M=new In(0,0,0),P=0,T=!1,j=null,z=null,F=null,$=null,D=null,ie.set(0,0,t.canvas.width,t.canvas.height),J.set(0,0,t.canvas.width,t.canvas.height),s.reset(),o.reset(),l.reset()}return{buffers:{color:s,depth:o,stencil:l},enable:ve,disable:Le,bindFramebuffer:de,drawBuffers:ce,useProgram:Ae,setBlending:G,setMaterial:Y,setFlipSided:ue,setCullFace:B,setLineWidth:ee,setPolygonOffset:Q,setScissorTest:le,activeTexture:he,bindTexture:te,unbindTexture:U,compressedTexImage2D:L,compressedTexImage3D:X,texImage2D:Qe,texImage3D:xe,updateUBOMapping:Ue,uniformBlockBinding:Pe,texStorage2D:Ce,texStorage3D:He,texSubImage2D:ge,texSubImage3D:_e,compressedTexSubImage2D:Ee,compressedTexSubImage3D:$e,scissor:ye,viewport:we,reset:Ve}}function H0e(t,e,n,r,i,s,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 Rn,d=new WeakMap;let h;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(U,L){return m?new OffscreenCanvas(U,L):g1("canvas")}function y(U,L,X){let ge=1;const _e=te(U);if((_e.width>X||_e.height>X)&&(ge=X/Math.max(_e.width,_e.height)),ge<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 Ee=Math.floor(ge*_e.width),$e=Math.floor(ge*_e.height);h===void 0&&(h=x(Ee,$e));const Ce=L?x(Ee,$e):h;return Ce.width=Ee,Ce.height=$e,Ce.getContext("2d").drawImage(U,0,0,Ee,$e),vn("WebGLRenderer: Texture has been resized from ("+_e.width+"x"+_e.height+") to ("+Ee+"x"+$e+")."),Ce}else return"data"in U&&vn("WebGLRenderer: Image in DataTexture is too big ("+_e.width+"x"+_e.height+")."),U;return U}function b(U){return U.generateMipmaps}function v(U){t.generateMipmap(U)}function S(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 k(U,L,X,ge,_e=!1){if(U!==null){if(t[U]!==void 0)return t[U];vn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let Ee=L;if(L===t.RED&&(X===t.FLOAT&&(Ee=t.R32F),X===t.HALF_FLOAT&&(Ee=t.R16F),X===t.UNSIGNED_BYTE&&(Ee=t.R8)),L===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(Ee=t.R8UI),X===t.UNSIGNED_SHORT&&(Ee=t.R16UI),X===t.UNSIGNED_INT&&(Ee=t.R32UI),X===t.BYTE&&(Ee=t.R8I),X===t.SHORT&&(Ee=t.R16I),X===t.INT&&(Ee=t.R32I)),L===t.RG&&(X===t.FLOAT&&(Ee=t.RG32F),X===t.HALF_FLOAT&&(Ee=t.RG16F),X===t.UNSIGNED_BYTE&&(Ee=t.RG8)),L===t.RG_INTEGER&&(X===t.UNSIGNED_BYTE&&(Ee=t.RG8UI),X===t.UNSIGNED_SHORT&&(Ee=t.RG16UI),X===t.UNSIGNED_INT&&(Ee=t.RG32UI),X===t.BYTE&&(Ee=t.RG8I),X===t.SHORT&&(Ee=t.RG16I),X===t.INT&&(Ee=t.RG32I)),L===t.RGB_INTEGER&&(X===t.UNSIGNED_BYTE&&(Ee=t.RGB8UI),X===t.UNSIGNED_SHORT&&(Ee=t.RGB16UI),X===t.UNSIGNED_INT&&(Ee=t.RGB32UI),X===t.BYTE&&(Ee=t.RGB8I),X===t.SHORT&&(Ee=t.RGB16I),X===t.INT&&(Ee=t.RGB32I)),L===t.RGBA_INTEGER&&(X===t.UNSIGNED_BYTE&&(Ee=t.RGBA8UI),X===t.UNSIGNED_SHORT&&(Ee=t.RGBA16UI),X===t.UNSIGNED_INT&&(Ee=t.RGBA32UI),X===t.BYTE&&(Ee=t.RGBA8I),X===t.SHORT&&(Ee=t.RGBA16I),X===t.INT&&(Ee=t.RGBA32I)),L===t.RGB&&(X===t.UNSIGNED_INT_5_9_9_9_REV&&(Ee=t.RGB9_E5),X===t.UNSIGNED_INT_10F_11F_11F_REV&&(Ee=t.R11F_G11F_B10F)),L===t.RGBA){const $e=_e?m1:cr.getTransfer(ge);X===t.FLOAT&&(Ee=t.RGBA32F),X===t.HALF_FLOAT&&(Ee=t.RGBA16F),X===t.UNSIGNED_BYTE&&(Ee=$e===Ar?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(Ee=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(Ee=t.RGB5_A1)}return(Ee===t.R16F||Ee===t.R32F||Ee===t.RG16F||Ee===t.RG32F||Ee===t.RGBA16F||Ee===t.RGBA32F)&&e.get("EXT_color_buffer_float"),Ee}function E(U,L){let X;return U?L===null||L===Cm||L===s0?X=t.DEPTH24_STENCIL8:L===Lu?X=t.DEPTH32F_STENCIL8:L===a0&&(X=t.DEPTH24_STENCIL8,vn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Cm||L===s0?X=t.DEPTH_COMPONENT24:L===Lu?X=t.DEPTH_COMPONENT32F:L===a0&&(X=t.DEPTH_COMPONENT16),X}function N(U,L){return b(U)===!0||U.isFramebufferTexture&&U.minFilter!==ko&&U.minFilter!==cl?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function A(U){const L=U.target;L.removeEventListener("dispose",A),P(L),L.isVideoTexture&&d.delete(L)}function M(U){const L=U.target;L.removeEventListener("dispose",M),j(L)}function P(U){const L=r.get(U);if(L.__webglInit===void 0)return;const X=U.source,ge=p.get(X);if(ge){const _e=ge[L.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&T(U),Object.keys(ge).length===0&&p.delete(X)}r.remove(U)}function T(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const X=U.source,ge=p.get(X);delete ge[L.__cacheKey],o.memory.textures--}function j(U){const L=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++){if(Array.isArray(L.__webglFramebuffer[ge]))for(let _e=0;_e<L.__webglFramebuffer[ge].length;_e++)t.deleteFramebuffer(L.__webglFramebuffer[ge][_e]);else t.deleteFramebuffer(L.__webglFramebuffer[ge]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ge])}else{if(Array.isArray(L.__webglFramebuffer))for(let ge=0;ge<L.__webglFramebuffer.length;ge++)t.deleteFramebuffer(L.__webglFramebuffer[ge]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ge=0;ge<L.__webglColorRenderbuffer.length;ge++)L.__webglColorRenderbuffer[ge]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ge]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const X=U.textures;for(let ge=0,_e=X.length;ge<_e;ge++){const Ee=r.get(X[ge]);Ee.__webglTexture&&(t.deleteTexture(Ee.__webglTexture),o.memory.textures--),r.remove(X[ge])}r.remove(U)}let z=0;function F(){z=0}function $(){const U=z;return U>=i.maxTextures&&vn("WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),z+=1,U}function D(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function H(U,L){const X=r.get(U);if(U.isVideoTexture&&le(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&X.__version!==U.version){const ge=U.image;if(ge===null)vn("WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)vn("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(X,U,L);return}}else U.isExternalTexture&&(X.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+L)}function q(U,L){const X=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&X.__version!==U.version){fe(X,U,L);return}else U.isExternalTexture&&(X.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+L)}function I(U,L){const X=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&X.__version!==U.version){fe(X,U,L);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+L)}function K(U,L){const X=r.get(U);if(U.version>0&&X.__version!==U.version){ve(X,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+L)}const Z={[i3]:t.REPEAT,[Ru]:t.CLAMP_TO_EDGE,[a3]:t.MIRRORED_REPEAT},se={[ko]:t.NEAREST,[upe]:t.NEAREST_MIPMAP_NEAREST,[Qw]:t.NEAREST_MIPMAP_LINEAR,[cl]:t.LINEAR,[ME]:t.LINEAR_MIPMAP_NEAREST,[Qf]:t.LINEAR_MIPMAP_LINEAR},V={[mpe]:t.NEVER,[vpe]:t.ALWAYS,[ppe]:t.LESS,[kK]:t.LEQUAL,[gpe]:t.EQUAL,[ype]:t.GEQUAL,[bpe]:t.GREATER,[xpe]:t.NOTEQUAL};function W(U,L){if(L.type===Lu&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===cl||L.magFilter===ME||L.magFilter===Qw||L.magFilter===Qf||L.minFilter===cl||L.minFilter===ME||L.minFilter===Qw||L.minFilter===Qf)&&vn("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,Z[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,Z[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,Z[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,se[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,se[L.minFilter]),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,V[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ko||L.minFilter!==Qw&&L.minFilter!==Qf||L.type===Lu&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");t.texParameterf(U,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ie(U,L){let X=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",A));const ge=L.source;let _e=p.get(ge);_e===void 0&&(_e={},p.set(ge,_e));const Ee=D(L);if(Ee!==U.__cacheKey){_e[Ee]===void 0&&(_e[Ee]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,X=!0),_e[Ee].usedTimes++;const $e=_e[U.__cacheKey];$e!==void 0&&(_e[U.__cacheKey].usedTimes--,$e.usedTimes===0&&T(L)),U.__cacheKey=Ee,U.__webglTexture=_e[Ee].texture}return X}function J(U,L,X){return Math.floor(Math.floor(U/X)/L)}function pe(U,L,X,ge){const Ee=U.updateRanges;if(Ee.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,X,ge,L.data);else{Ee.sort((xe,ye)=>xe.start-ye.start);let $e=0;for(let xe=1;xe<Ee.length;xe++){const ye=Ee[$e],we=Ee[xe],Ue=ye.start+ye.count,Pe=J(we.start,L.width,4),Ve=J(ye.start,L.width,4);we.start<=Ue+1&&Pe===Ve&&J(we.start+we.count-1,L.width,4)===Pe?ye.count=Math.max(ye.count,we.start+we.count-ye.start):(++$e,Ee[$e]=we)}Ee.length=$e+1;const Ce=t.getParameter(t.UNPACK_ROW_LENGTH),He=t.getParameter(t.UNPACK_SKIP_PIXELS),Qe=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let xe=0,ye=Ee.length;xe<ye;xe++){const we=Ee[xe],Ue=Math.floor(we.start/4),Pe=Math.ceil(we.count/4),Ve=Ue%L.width,ke=Math.floor(Ue/L.width),Ze=Pe,je=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ve),t.pixelStorei(t.UNPACK_SKIP_ROWS,ke),n.texSubImage2D(t.TEXTURE_2D,0,Ve,ke,Ze,je,X,ge,L.data)}U.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ce),t.pixelStorei(t.UNPACK_SKIP_PIXELS,He),t.pixelStorei(t.UNPACK_SKIP_ROWS,Qe)}}function fe(U,L,X){let ge=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ge=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ge=t.TEXTURE_3D);const _e=ie(U,L),Ee=L.source;n.bindTexture(ge,U.__webglTexture,t.TEXTURE0+X);const $e=r.get(Ee);if(Ee.version!==$e.__version||_e===!0){n.activeTexture(t.TEXTURE0+X);const Ce=cr.getPrimaries(cr.workingColorSpace),He=L.colorSpace===dh?null:cr.getPrimaries(L.colorSpace),Qe=L.colorSpace===dh||Ce===He?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Qe);let xe=y(L.image,!1,i.maxTextureSize);xe=he(L,xe);const ye=s.convert(L.format,L.colorSpace),we=s.convert(L.type);let Ue=k(L.internalFormat,ye,we,L.colorSpace,L.isVideoTexture);W(ge,L);let Pe;const Ve=L.mipmaps,ke=L.isVideoTexture!==!0,Ze=$e.__version===void 0||_e===!0,je=Ee.dataReady,Xe=N(L,xe);if(L.isDepthTexture)Ue=E(L.format===l0,L.type),Ze&&(ke?n.texStorage2D(t.TEXTURE_2D,1,Ue,xe.width,xe.height):n.texImage2D(t.TEXTURE_2D,0,Ue,xe.width,xe.height,0,ye,we,null));else if(L.isDataTexture)if(Ve.length>0){ke&&Ze&&n.texStorage2D(t.TEXTURE_2D,Xe,Ue,Ve[0].width,Ve[0].height);for(let Re=0,Oe=Ve.length;Re<Oe;Re++)Pe=Ve[Re],ke?je&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,Pe.width,Pe.height,ye,we,Pe.data):n.texImage2D(t.TEXTURE_2D,Re,Ue,Pe.width,Pe.height,0,ye,we,Pe.data);L.generateMipmaps=!1}else ke?(Ze&&n.texStorage2D(t.TEXTURE_2D,Xe,Ue,xe.width,xe.height),je&&pe(L,xe,ye,we)):n.texImage2D(t.TEXTURE_2D,0,Ue,xe.width,xe.height,0,ye,we,xe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ke&&Ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Xe,Ue,Ve[0].width,Ve[0].height,xe.depth);for(let Re=0,Oe=Ve.length;Re<Oe;Re++)if(Pe=Ve[Re],L.format!==Vl)if(ye!==null)if(ke){if(je)if(L.layerUpdates.size>0){const Ne=e8(Pe.width,Pe.height,L.format,L.type);for(const Je of L.layerUpdates){const yt=Pe.data.subarray(Je*Ne/Pe.data.BYTES_PER_ELEMENT,(Je+1)*Ne/Pe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,Je,Pe.width,Pe.height,1,ye,yt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,0,Pe.width,Pe.height,xe.depth,ye,Pe.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Re,Ue,Pe.width,Pe.height,xe.depth,0,Pe.data,0,0);else vn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ke?je&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,0,Pe.width,Pe.height,xe.depth,ye,we,Pe.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Re,Ue,Pe.width,Pe.height,xe.depth,0,ye,we,Pe.data)}else{ke&&Ze&&n.texStorage2D(t.TEXTURE_2D,Xe,Ue,Ve[0].width,Ve[0].height);for(let Re=0,Oe=Ve.length;Re<Oe;Re++)Pe=Ve[Re],L.format!==Vl?ye!==null?ke?je&&n.compressedTexSubImage2D(t.TEXTURE_2D,Re,0,0,Pe.width,Pe.height,ye,Pe.data):n.compressedTexImage2D(t.TEXTURE_2D,Re,Ue,Pe.width,Pe.height,0,Pe.data):vn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ke?je&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,Pe.width,Pe.height,ye,we,Pe.data):n.texImage2D(t.TEXTURE_2D,Re,Ue,Pe.width,Pe.height,0,ye,we,Pe.data)}else if(L.isDataArrayTexture)if(ke){if(Ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Xe,Ue,xe.width,xe.height,xe.depth),je)if(L.layerUpdates.size>0){const Re=e8(xe.width,xe.height,L.format,L.type);for(const Oe of L.layerUpdates){const Ne=xe.data.subarray(Oe*Re/xe.data.BYTES_PER_ELEMENT,(Oe+1)*Re/xe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Oe,xe.width,xe.height,1,ye,we,Ne)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,xe.width,xe.height,xe.depth,ye,we,xe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ue,xe.width,xe.height,xe.depth,0,ye,we,xe.data);else if(L.isData3DTexture)ke?(Ze&&n.texStorage3D(t.TEXTURE_3D,Xe,Ue,xe.width,xe.height,xe.depth),je&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,xe.width,xe.height,xe.depth,ye,we,xe.data)):n.texImage3D(t.TEXTURE_3D,0,Ue,xe.width,xe.height,xe.depth,0,ye,we,xe.data);else if(L.isFramebufferTexture){if(Ze)if(ke)n.texStorage2D(t.TEXTURE_2D,Xe,Ue,xe.width,xe.height);else{let Re=xe.width,Oe=xe.height;for(let Ne=0;Ne<Xe;Ne++)n.texImage2D(t.TEXTURE_2D,Ne,Ue,Re,Oe,0,ye,we,null),Re>>=1,Oe>>=1}}else if(Ve.length>0){if(ke&&Ze){const Re=te(Ve[0]);n.texStorage2D(t.TEXTURE_2D,Xe,Ue,Re.width,Re.height)}for(let Re=0,Oe=Ve.length;Re<Oe;Re++)Pe=Ve[Re],ke?je&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,ye,we,Pe):n.texImage2D(t.TEXTURE_2D,Re,Ue,ye,we,Pe);L.generateMipmaps=!1}else if(ke){if(Ze){const Re=te(xe);n.texStorage2D(t.TEXTURE_2D,Xe,Ue,Re.width,Re.height)}je&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ye,we,xe)}else n.texImage2D(t.TEXTURE_2D,0,Ue,ye,we,xe);b(L)&&v(ge),$e.__version=Ee.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function ve(U,L,X){if(L.image.length!==6)return;const ge=ie(U,L),_e=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+X);const Ee=r.get(_e);if(_e.version!==Ee.__version||ge===!0){n.activeTexture(t.TEXTURE0+X);const $e=cr.getPrimaries(cr.workingColorSpace),Ce=L.colorSpace===dh?null:cr.getPrimaries(L.colorSpace),He=L.colorSpace===dh||$e===Ce?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);const Qe=L.isCompressedTexture||L.image[0].isCompressedTexture,xe=L.image[0]&&L.image[0].isDataTexture,ye=[];for(let Oe=0;Oe<6;Oe++)!Qe&&!xe?ye[Oe]=y(L.image[Oe],!0,i.maxCubemapSize):ye[Oe]=xe?L.image[Oe].image:L.image[Oe],ye[Oe]=he(L,ye[Oe]);const we=ye[0],Ue=s.convert(L.format,L.colorSpace),Pe=s.convert(L.type),Ve=k(L.internalFormat,Ue,Pe,L.colorSpace),ke=L.isVideoTexture!==!0,Ze=Ee.__version===void 0||ge===!0,je=_e.dataReady;let Xe=N(L,we);W(t.TEXTURE_CUBE_MAP,L);let Re;if(Qe){ke&&Ze&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Xe,Ve,we.width,we.height);for(let Oe=0;Oe<6;Oe++){Re=ye[Oe].mipmaps;for(let Ne=0;Ne<Re.length;Ne++){const Je=Re[Ne];L.format!==Vl?Ue!==null?ke?je&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne,0,0,Je.width,Je.height,Ue,Je.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne,Ve,Je.width,Je.height,0,Je.data):vn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ke?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne,0,0,Je.width,Je.height,Ue,Pe,Je.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne,Ve,Je.width,Je.height,0,Ue,Pe,Je.data)}}}else{if(Re=L.mipmaps,ke&&Ze){Re.length>0&&Xe++;const Oe=te(ye[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Xe,Ve,Oe.width,Oe.height)}for(let Oe=0;Oe<6;Oe++)if(xe){ke?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0,0,0,ye[Oe].width,ye[Oe].height,Ue,Pe,ye[Oe].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0,Ve,ye[Oe].width,ye[Oe].height,0,Ue,Pe,ye[Oe].data);for(let Ne=0;Ne<Re.length;Ne++){const yt=Re[Ne].image[Oe].image;ke?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne+1,0,0,yt.width,yt.height,Ue,Pe,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne+1,Ve,yt.width,yt.height,0,Ue,Pe,yt.data)}}else{ke?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0,0,0,Ue,Pe,ye[Oe]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0,Ve,Ue,Pe,ye[Oe]);for(let Ne=0;Ne<Re.length;Ne++){const Je=Re[Ne];ke?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne+1,0,0,Ue,Pe,Je.image[Oe]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne+1,Ve,Ue,Pe,Je.image[Oe])}}}b(L)&&v(t.TEXTURE_CUBE_MAP),Ee.__version=_e.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Le(U,L,X,ge,_e,Ee){const $e=s.convert(X.format,X.colorSpace),Ce=s.convert(X.type),He=k(X.internalFormat,$e,Ce,X.colorSpace),Qe=r.get(L),xe=r.get(X);if(xe.__renderTarget=L,!Qe.__hasExternalTextures){const ye=Math.max(1,L.width>>Ee),we=Math.max(1,L.height>>Ee);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,Ee,He,ye,we,L.depth,0,$e,Ce,null):n.texImage2D(_e,Ee,He,ye,we,0,$e,Ce,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),Q(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ge,_e,xe.__webglTexture,0,ee(L)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ge,_e,xe.__webglTexture,Ee),n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(U,L,X){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer){const ge=L.depthTexture,_e=ge&&ge.isDepthTexture?ge.type:null,Ee=E(L.stencilBuffer,_e),$e=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ce=ee(L);Q(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ce,Ee,L.width,L.height):X?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ce,Ee,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Ee,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,$e,t.RENDERBUFFER,U)}else{const ge=L.textures;for(let _e=0;_e<ge.length;_e++){const Ee=ge[_e],$e=s.convert(Ee.format,Ee.colorSpace),Ce=s.convert(Ee.type),He=k(Ee.internalFormat,$e,Ce,Ee.colorSpace),Qe=ee(L);X&&Q(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Qe,He,L.width,L.height):Q(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Qe,He,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,He,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ce(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ge=r.get(L.depthTexture);ge.__renderTarget=L,(!ge.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),H(L.depthTexture,0);const _e=ge.__webglTexture,Ee=ee(L);if(L.depthTexture.format===o0)Q(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0,Ee):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0);else if(L.depthTexture.format===l0)Q(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0,Ee):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0);else throw new Error("Unknown depthTexture format")}function Ae(U){const L=r.get(U),X=U.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==U.depthTexture){const ge=U.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ge){const _e=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ge.removeEventListener("dispose",_e)};ge.addEventListener("dispose",_e),L.__depthDisposeCallback=_e}L.__boundDepthTexture=ge}if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");const ge=U.texture.mipmaps;ge&&ge.length>0?ce(L.__webglFramebuffer[0],U):ce(L.__webglFramebuffer,U)}else if(X){L.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ge]),L.__webglDepthbuffer[ge]===void 0)L.__webglDepthbuffer[ge]=t.createRenderbuffer(),de(L.__webglDepthbuffer[ge],U,!1);else{const _e=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ee=L.__webglDepthbuffer[ge];t.bindRenderbuffer(t.RENDERBUFFER,Ee),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,Ee)}}else{const ge=U.texture.mipmaps;if(ge&&ge.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),de(L.__webglDepthbuffer,U,!1);else{const _e=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ee=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,Ee),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,Ee)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function re(U,L,X){const ge=r.get(U);L!==void 0&&Le(ge.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&Ae(U)}function Ie(U){const L=U.texture,X=r.get(U),ge=r.get(L);U.addEventListener("dispose",M);const _e=U.textures,Ee=U.isWebGLCubeRenderTarget===!0,$e=_e.length>1;if($e||(ge.__webglTexture===void 0&&(ge.__webglTexture=t.createTexture()),ge.__version=L.version,o.memory.textures++),Ee){X.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)if(L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer[Ce]=[];for(let He=0;He<L.mipmaps.length;He++)X.__webglFramebuffer[Ce][He]=t.createFramebuffer()}else X.__webglFramebuffer[Ce]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer=[];for(let Ce=0;Ce<L.mipmaps.length;Ce++)X.__webglFramebuffer[Ce]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if($e)for(let Ce=0,He=_e.length;Ce<He;Ce++){const Qe=r.get(_e[Ce]);Qe.__webglTexture===void 0&&(Qe.__webglTexture=t.createTexture(),o.memory.textures++)}if(U.samples>0&&Q(U)===!1){X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let Ce=0;Ce<_e.length;Ce++){const He=_e[Ce];X.__webglColorRenderbuffer[Ce]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[Ce]);const Qe=s.convert(He.format,He.colorSpace),xe=s.convert(He.type),ye=k(He.internalFormat,Qe,xe,He.colorSpace,U.isXRRenderTarget===!0),we=ee(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,we,ye,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ce,t.RENDERBUFFER,X.__webglColorRenderbuffer[Ce])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),de(X.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Ee){n.bindTexture(t.TEXTURE_CUBE_MAP,ge.__webglTexture),W(t.TEXTURE_CUBE_MAP,L);for(let Ce=0;Ce<6;Ce++)if(L.mipmaps&&L.mipmaps.length>0)for(let He=0;He<L.mipmaps.length;He++)Le(X.__webglFramebuffer[Ce][He],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,He);else Le(X.__webglFramebuffer[Ce],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0);b(L)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if($e){for(let Ce=0,He=_e.length;Ce<He;Ce++){const Qe=_e[Ce],xe=r.get(Qe);let ye=t.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ye=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ye,xe.__webglTexture),W(ye,Qe),Le(X.__webglFramebuffer,U,Qe,t.COLOR_ATTACHMENT0+Ce,ye,0),b(Qe)&&v(ye)}n.unbindTexture()}else{let Ce=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ce=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ce,ge.__webglTexture),W(Ce,L),L.mipmaps&&L.mipmaps.length>0)for(let He=0;He<L.mipmaps.length;He++)Le(X.__webglFramebuffer[He],U,L,t.COLOR_ATTACHMENT0,Ce,He);else Le(X.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Ce,0);b(L)&&v(Ce),n.unbindTexture()}U.depthBuffer&&Ae(U)}function G(U){const L=U.textures;for(let X=0,ge=L.length;X<ge;X++){const _e=L[X];if(b(_e)){const Ee=S(U),$e=r.get(_e).__webglTexture;n.bindTexture(Ee,$e),v(Ee),n.unbindTexture()}}}const Y=[],ue=[];function B(U){if(U.samples>0){if(Q(U)===!1){const L=U.textures,X=U.width,ge=U.height;let _e=t.COLOR_BUFFER_BIT;const Ee=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,$e=r.get(U),Ce=L.length>1;if(Ce)for(let Qe=0;Qe<L.length;Qe++)n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,$e.__webglMultisampledFramebuffer);const He=U.texture.mipmaps;He&&He.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglFramebuffer);for(let Qe=0;Qe<L.length;Qe++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Ce){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,$e.__webglColorRenderbuffer[Qe]);const xe=r.get(L[Qe]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,xe,0)}t.blitFramebuffer(0,0,X,ge,0,0,X,ge,_e,t.NEAREST),c===!0&&(Y.length=0,ue.length=0,Y.push(t.COLOR_ATTACHMENT0+Qe),U.depthBuffer&&U.resolveDepthBuffer===!1&&(Y.push(Ee),ue.push(Ee),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ue)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,Y))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ce)for(let Qe=0;Qe<L.length;Qe++){n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.RENDERBUFFER,$e.__webglColorRenderbuffer[Qe]);const xe=r.get(L[Qe]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.TEXTURE_2D,xe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&c){const L=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function ee(U){return Math.min(i.maxSamples,U.samples)}function Q(U){const L=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function le(U){const L=o.render.frame;d.get(U)!==L&&(d.set(U,L),U.update())}function he(U,L){const X=U.colorSpace,ge=U.format,_e=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||X!==ab&&X!==dh&&(cr.getTransfer(X)===Ar?(ge!==Vl||_e!==jc)&&vn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zi("WebGLTextures: Unsupported texture color space:",X)),L}function te(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=$,this.resetTextureUnits=F,this.setTexture2D=H,this.setTexture2DArray=q,this.setTexture3D=I,this.setTextureCube=K,this.rebindTextures=re,this.setupRenderTarget=Ie,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=B,this.setupDepthRenderbuffer=Ae,this.setupFrameBufferTexture=Le,this.useMultisampledRTT=Q}function V0e(t,e){function n(r,i=dh){let s;const o=cr.getTransfer(i);if(r===jc)return t.UNSIGNED_BYTE;if(r===x4)return t.UNSIGNED_SHORT_4_4_4_4;if(r===y4)return t.UNSIGNED_SHORT_5_5_5_1;if(r===yK)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===vK)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===bK)return t.BYTE;if(r===xK)return t.SHORT;if(r===a0)return t.UNSIGNED_SHORT;if(r===b4)return t.INT;if(r===Cm)return t.UNSIGNED_INT;if(r===Lu)return t.FLOAT;if(r===Rb)return t.HALF_FLOAT;if(r===wK)return t.ALPHA;if(r===_K)return t.RGB;if(r===Vl)return t.RGBA;if(r===o0)return t.DEPTH_COMPONENT;if(r===l0)return t.DEPTH_STENCIL;if(r===SK)return t.RED;if(r===v4)return t.RED_INTEGER;if(r===w4)return t.RG;if(r===_4)return t.RG_INTEGER;if(r===S4)return t.RGBA_INTEGER;if(r===LS||r===OS||r===FS||r===IS)if(o===Ar)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===LS)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===OS)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===FS)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===IS)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===LS)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===OS)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===FS)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===IS)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===s3||r===o3||r===l3||r===c3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===s3)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===o3)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===l3)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===c3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===u3||r===d3||r===h3)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===u3||r===d3)return o===Ar?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===h3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===f3||r===m3||r===p3||r===g3||r===b3||r===x3||r===y3||r===v3||r===w3||r===_3||r===S3||r===N3||r===k3||r===M3)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===f3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===m3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===p3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===g3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===b3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===x3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===y3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===v3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===w3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===_3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===S3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===N3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===k3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===M3)return o===Ar?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===C3||r===E3||r===A3)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===C3)return o===Ar?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===E3)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===A3)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===T3||r===j3||r===P3||r===D3)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===T3)return s.COMPRESSED_RED_RGTC1_EXT;if(r===j3)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===P3)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===D3)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===s0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const G0e=`
  3825. void main() {
  3826. gl_Position = vec4( position, 1.0 );
  3827. }`,q0e=`
  3828. uniform sampler2DArray depthColor;
  3829. uniform float depthWidth;
  3830. uniform float depthHeight;
  3831. void main() {
  3832. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3833. if ( coord.x >= 1.0 ) {
  3834. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3835. } else {
  3836. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3837. }
  3838. }`;class W0e{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new VK(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 ed({vertexShader:G0e,fragmentShader:q0e,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new bl(new A4(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let K0e=class extends qm{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,h=null,p=null,m=null,x=null;const y=typeof XRWebGLBinding<"u",b=new W0e,v={},S=n.getContextAttributes();let k=null,E=null;const N=[],A=[],M=new Rn;let P=null;const T=new il;T.viewport=new Zi;const j=new il;j.viewport=new Zi;const z=[T,j],F=new dge;let $=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let ve=N[fe];return ve===void 0&&(ve=new KE,N[fe]=ve),ve.getTargetRaySpace()},this.getControllerGrip=function(fe){let ve=N[fe];return ve===void 0&&(ve=new KE,N[fe]=ve),ve.getGripSpace()},this.getHand=function(fe){let ve=N[fe];return ve===void 0&&(ve=new KE,N[fe]=ve),ve.getHandSpace()};function H(fe){const ve=A.indexOf(fe.inputSource);if(ve===-1)return;const Le=N[ve];Le!==void 0&&(Le.update(fe.inputSource,fe.frame,u||o),Le.dispatchEvent({type:fe.type,data:fe.inputSource}))}function q(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",I);for(let fe=0;fe<N.length;fe++){const ve=A[fe];ve!==null&&(A[fe]=null,N[fe].disconnect(ve))}$=null,D=null,b.reset();for(const fe in v)delete v[fe];e.setRenderTarget(k),m=null,p=null,h=null,i=null,E=null,pe.stop(),r.isPresenting=!1,e.setPixelRatio(P),e.setSize(M.width,M.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(fe){s=fe,r.isPresenting===!0&&vn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(fe){l=fe,r.isPresenting===!0&&vn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(fe){u=fe},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(i,n)),h},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(fe){if(i=fe,i!==null){if(k=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",q),i.addEventListener("inputsourceschange",I),S.xrCompatible!==!0&&await n.makeXRCompatible(),P=e.getPixelRatio(),e.getSize(M),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Le=null,de=null,ce=null;S.depth&&(ce=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Le=S.stencil?l0:o0,de=S.stencil?s0:Cm);const Ae={colorFormat:n.RGBA8,depthFormat:ce,scaleFactor:s};h=this.getBinding(),p=h.createProjectionLayer(Ae),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),E=new Am(p.textureWidth,p.textureHeight,{format:Vl,type:jc,depthTexture:new HK(p.textureWidth,p.textureHeight,de,void 0,void 0,void 0,void 0,void 0,void 0,Le),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Le={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,Le),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),E=new Am(m.framebufferWidth,m.framebufferHeight,{format:Vl,type:jc,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),pe.setContext(i),pe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function I(fe){for(let ve=0;ve<fe.removed.length;ve++){const Le=fe.removed[ve],de=A.indexOf(Le);de>=0&&(A[de]=null,N[de].disconnect(Le))}for(let ve=0;ve<fe.added.length;ve++){const Le=fe.added[ve];let de=A.indexOf(Le);if(de===-1){for(let Ae=0;Ae<N.length;Ae++)if(Ae>=A.length){A.push(Le),de=Ae;break}else if(A[Ae]===null){A[Ae]=Le,de=Ae;break}if(de===-1)break}const ce=N[de];ce&&ce.connect(Le)}}const K=new mt,Z=new mt;function se(fe,ve,Le){K.setFromMatrixPosition(ve.matrixWorld),Z.setFromMatrixPosition(Le.matrixWorld);const de=K.distanceTo(Z),ce=ve.projectionMatrix.elements,Ae=Le.projectionMatrix.elements,re=ce[14]/(ce[10]-1),Ie=ce[14]/(ce[10]+1),G=(ce[9]+1)/ce[5],Y=(ce[9]-1)/ce[5],ue=(ce[8]-1)/ce[0],B=(Ae[8]+1)/Ae[0],ee=re*ue,Q=re*B,le=de/(-ue+B),he=le*-ue;if(ve.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(he),fe.translateZ(le),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),ce[10]===-1)fe.projectionMatrix.copy(ve.projectionMatrix),fe.projectionMatrixInverse.copy(ve.projectionMatrixInverse);else{const te=re+le,U=Ie+le,L=ee-he,X=Q+(de-he),ge=G*Ie/U*te,_e=Y*Ie/U*te;fe.projectionMatrix.makePerspective(L,X,ge,_e,te,U),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function V(fe,ve){ve===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(ve.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(i===null)return;let ve=fe.near,Le=fe.far;b.texture!==null&&(b.depthNear>0&&(ve=b.depthNear),b.depthFar>0&&(Le=b.depthFar)),F.near=j.near=T.near=ve,F.far=j.far=T.far=Le,($!==F.near||D!==F.far)&&(i.updateRenderState({depthNear:F.near,depthFar:F.far}),$=F.near,D=F.far),F.layers.mask=fe.layers.mask|6,T.layers.mask=F.layers.mask&3,j.layers.mask=F.layers.mask&5;const de=fe.parent,ce=F.cameras;V(F,de);for(let Ae=0;Ae<ce.length;Ae++)V(ce[Ae],de);ce.length===2?se(F,T,j):F.projectionMatrix.copy(T.projectionMatrix),W(fe,F,de)};function W(fe,ve,Le){Le===null?fe.matrix.copy(ve.matrixWorld):(fe.matrix.copy(Le.matrixWorld),fe.matrix.invert(),fe.matrix.multiply(ve.matrixWorld)),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.updateMatrixWorld(!0),fe.projectionMatrix.copy(ve.projectionMatrix),fe.projectionMatrixInverse.copy(ve.projectionMatrixInverse),fe.isPerspectiveCamera&&(fe.fov=R3*2*Math.atan(1/fe.projectionMatrix.elements[5]),fe.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(fe){c=fe,p!==null&&(p.fixedFoveation=fe),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=fe)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(F)},this.getCameraTexture=function(fe){return v[fe]};let ie=null;function J(fe,ve){if(d=ve.getViewerPose(u||o),x=ve,d!==null){const Le=d.views;m!==null&&(e.setRenderTargetFramebuffer(E,m.framebuffer),e.setRenderTarget(E));let de=!1;Le.length!==F.cameras.length&&(F.cameras.length=0,de=!0);for(let Ie=0;Ie<Le.length;Ie++){const G=Le[Ie];let Y=null;if(m!==null)Y=m.getViewport(G);else{const B=h.getViewSubImage(p,G);Y=B.viewport,Ie===0&&(e.setRenderTargetTextures(E,B.colorTexture,B.depthStencilTexture),e.setRenderTarget(E))}let ue=z[Ie];ue===void 0&&(ue=new il,ue.layers.enable(Ie),ue.viewport=new Zi,z[Ie]=ue),ue.matrix.fromArray(G.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(G.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(Y.x,Y.y,Y.width,Y.height),Ie===0&&(F.matrix.copy(ue.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),de===!0&&F.cameras.push(ue)}const ce=i.enabledFeatures;if(ce&&ce.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){h=r.getBinding();const Ie=h.getDepthInformation(Le[0]);Ie&&Ie.isValid&&Ie.texture&&b.init(Ie,i.renderState)}if(ce&&ce.includes("camera-access")&&y){e.state.unbindTexture(),h=r.getBinding();for(let Ie=0;Ie<Le.length;Ie++){const G=Le[Ie].camera;if(G){let Y=v[G];Y||(Y=new VK,v[G]=Y);const ue=h.getCameraImage(G);Y.sourceTexture=ue}}}}for(let Le=0;Le<N.length;Le++){const de=A[Le],ce=N[Le];de!==null&&ce!==void 0&&ce.update(de,ve,u||o)}ie&&ie(fe,ve),ve.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ve}),x=null}const pe=new XK;pe.setAnimationLoop(J),this.setAnimationLoop=function(fe){ie=fe},this.dispose=function(){}}};const Ef=new Uh,X0e=new na;function Y0e(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,zK(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,S,k,E){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(b,v):v.isMeshToonMaterial?(s(b,v),h(b,v)):v.isMeshPhongMaterial?(s(b,v),d(b,v)):v.isMeshStandardMaterial?(s(b,v),p(b,v),v.isMeshPhysicalMaterial&&m(b,v,E)):v.isMeshMatcapMaterial?(s(b,v),x(b,v)):v.isMeshDepthMaterial?s(b,v):v.isMeshDistanceMaterial?(s(b,v),y(b,v)):v.isMeshNormalMaterial?s(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,S,k):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(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===Qs&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===Qs&&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 S=e.get(v),k=S.envMap,E=S.envMapRotation;k&&(b.envMap.value=k,Ef.copy(E),Ef.x*=-1,Ef.y*=-1,Ef.z*=-1,k.isCubeTexture&&k.isRenderTargetTexture===!1&&(Ef.y*=-1,Ef.z*=-1),b.envMapRotation.value.setFromMatrix4(X0e.makeRotationFromEuler(Ef)),b.flipEnvMap.value=k.isCubeTexture&&k.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,S,k){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*S,b.scale.value=k*.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 h(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function p(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 m(b,v,S){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===Qs&&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=S.texture,b.transmissionSamplerSize.value.set(S.width,S.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 S=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(S.matrixWorld),b.nearDistance.value=S.shadow.camera.near,b.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Q0e(t,e,n,r){let i={},s={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,k){const E=k.program;r.uniformBlockBinding(S,E)}function u(S,k){let E=i[S.id];E===void 0&&(x(S),E=d(S),i[S.id]=E,S.addEventListener("dispose",b));const N=k.program;r.updateUBOMapping(S,N);const A=e.render.frame;s[S.id]!==A&&(p(S),s[S.id]=A)}function d(S){const k=h();S.__bindingPointIndex=k;const E=t.createBuffer(),N=S.__size,A=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,E),t.bufferData(t.UNIFORM_BUFFER,N,A),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,k,E),E}function h(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return zi("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const k=i[S.id],E=S.uniforms,N=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,k);for(let A=0,M=E.length;A<M;A++){const P=Array.isArray(E[A])?E[A]:[E[A]];for(let T=0,j=P.length;T<j;T++){const z=P[T];if(m(z,A,T,N)===!0){const F=z.__offset,$=Array.isArray(z.value)?z.value:[z.value];let D=0;for(let H=0;H<$.length;H++){const q=$[H],I=y(q);typeof q=="number"||typeof q=="boolean"?(z.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,F+D,z.__data)):q.isMatrix3?(z.__data[0]=q.elements[0],z.__data[1]=q.elements[1],z.__data[2]=q.elements[2],z.__data[3]=0,z.__data[4]=q.elements[3],z.__data[5]=q.elements[4],z.__data[6]=q.elements[5],z.__data[7]=0,z.__data[8]=q.elements[6],z.__data[9]=q.elements[7],z.__data[10]=q.elements[8],z.__data[11]=0):(q.toArray(z.__data,D),D+=I.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,F,z.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,k,E,N){const A=S.value,M=k+"_"+E;if(N[M]===void 0)return typeof A=="number"||typeof A=="boolean"?N[M]=A:N[M]=A.clone(),!0;{const P=N[M];if(typeof A=="number"||typeof A=="boolean"){if(P!==A)return N[M]=A,!0}else if(P.equals(A)===!1)return P.copy(A),!0}return!1}function x(S){const k=S.uniforms;let E=0;const N=16;for(let M=0,P=k.length;M<P;M++){const T=Array.isArray(k[M])?k[M]:[k[M]];for(let j=0,z=T.length;j<z;j++){const F=T[j],$=Array.isArray(F.value)?F.value:[F.value];for(let D=0,H=$.length;D<H;D++){const q=$[D],I=y(q),K=E%N,Z=K%I.boundary,se=K+Z;E+=Z,se!==0&&N-se<I.storage&&(E+=N-se),F.__data=new Float32Array(I.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=E,E+=I.storage}}}const A=E%N;return A>0&&(E+=N-A),S.__size=E,S.__cache={},this}function y(S){const k={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(k.boundary=4,k.storage=4):S.isVector2?(k.boundary=8,k.storage=8):S.isVector3||S.isColor?(k.boundary=16,k.storage=12):S.isVector4?(k.boundary=16,k.storage=16):S.isMatrix3?(k.boundary=48,k.storage=48):S.isMatrix4?(k.boundary=64,k.storage=64):S.isTexture?vn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):vn("WebGLRenderer: Unsupported uniform value type.",S),k}function b(S){const k=S.target;k.removeEventListener("dispose",b);const E=o.indexOf(k.__bindingPointIndex);o.splice(E,1),t.deleteBuffer(i[k.id]),delete i[k.id],delete s[k.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},s={}}return{bind:c,update:u,dispose:v}}const Z0e=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 hu=null;function J0e(){return hu===null&&(hu=new Ype(Z0e,32,32,w4,Rb),hu.minFilter=cl,hu.magFilter=cl,hu.wrapS=Ru,hu.wrapT=Ru,hu.generateMipmaps=!1,hu.needsUpdate=!0),hu}let eve=class{constructor(e={}){const{canvas:n=wpe(),context:r=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=o;const x=new Set([S4,_4,v4]),y=new Set([jc,Cm,a0,s0,x4,y4]),b=new Uint32Array(4),v=new Int32Array(4);let S=null,k=null;const E=[],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=Ch,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const A=this;let M=!1;this._outputColorSpace=yo;let P=0,T=0,j=null,z=-1,F=null;const $=new Zi,D=new Zi;let H=null;const q=new In(0);let I=0,K=n.width,Z=n.height,se=1,V=null,W=null;const ie=new Zi(0,0,K,Z),J=new Zi(0,0,K,Z);let pe=!1;const fe=new E4;let ve=!1,Le=!1;const de=new na,ce=new mt,Ae=new Zi,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ie=!1;function G(){return j===null?se:1}let Y=r;function ue(me,ze){return n.getContext(me,ze)}try{const me={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${p4}`),n.addEventListener("webglcontextlost",Re,!1),n.addEventListener("webglcontextrestored",Oe,!1),n.addEventListener("webglcontextcreationerror",Ne,!1),Y===null){const ze="webgl2";if(Y=ue(ze,me),Y===null)throw ue(ze)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(me){throw me("WebGLRenderer: "+me.message),me}let B,ee,Q,le,he,te,U,L,X,ge,_e,Ee,$e,Ce,He,Qe,xe,ye,we,Ue,Pe,Ve,ke,Ze;function je(){B=new lye(Y),B.init(),Ve=new V0e(Y,B),ee=new Jxe(Y,B,e,Ve),Q=new $0e(Y,B),ee.reversedDepthBuffer&&p&&Q.buffers.depth.setReversed(!0),le=new dye(Y),he=new A0e,te=new H0e(Y,B,Q,he,ee,Ve,le),U=new tye(A),L=new oye(A),X=new pge(Y),ke=new Qxe(Y,X),ge=new cye(Y,X,le,ke),_e=new fye(Y,ge,X,le),we=new hye(Y,ee,te),Qe=new eye(he),Ee=new E0e(A,U,L,B,ee,ke,Qe),$e=new Y0e(A,he),Ce=new j0e,He=new F0e(B),ye=new Yxe(A,U,L,Q,_e,m,c),xe=new U0e(A,_e,ee),Ze=new Q0e(Y,le,ee,Q),Ue=new Zxe(Y,B,le),Pe=new uye(Y,B,le),le.programs=Ee.programs,A.capabilities=ee,A.extensions=B,A.properties=he,A.renderLists=Ce,A.shadowMap=xe,A.state=Q,A.info=le}je();const Xe=new K0e(A,Y);this.xr=Xe,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){const me=B.get("WEBGL_lose_context");me&&me.loseContext()},this.forceContextRestore=function(){const me=B.get("WEBGL_lose_context");me&&me.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(me){me!==void 0&&(se=me,this.setSize(K,Z,!1))},this.getSize=function(me){return me.set(K,Z)},this.setSize=function(me,ze,Ke=!0){if(Xe.isPresenting){vn("WebGLRenderer: Can't change size while VR device is presenting.");return}K=me,Z=ze,n.width=Math.floor(me*se),n.height=Math.floor(ze*se),Ke===!0&&(n.style.width=me+"px",n.style.height=ze+"px"),this.setViewport(0,0,me,ze)},this.getDrawingBufferSize=function(me){return me.set(K*se,Z*se).floor()},this.setDrawingBufferSize=function(me,ze,Ke){K=me,Z=ze,se=Ke,n.width=Math.floor(me*Ke),n.height=Math.floor(ze*Ke),this.setViewport(0,0,me,ze)},this.getCurrentViewport=function(me){return me.copy($)},this.getViewport=function(me){return me.copy(ie)},this.setViewport=function(me,ze,Ke,Ge){me.isVector4?ie.set(me.x,me.y,me.z,me.w):ie.set(me,ze,Ke,Ge),Q.viewport($.copy(ie).multiplyScalar(se).round())},this.getScissor=function(me){return me.copy(J)},this.setScissor=function(me,ze,Ke,Ge){me.isVector4?J.set(me.x,me.y,me.z,me.w):J.set(me,ze,Ke,Ge),Q.scissor(D.copy(J).multiplyScalar(se).round())},this.getScissorTest=function(){return pe},this.setScissorTest=function(me){Q.setScissorTest(pe=me)},this.setOpaqueSort=function(me){V=me},this.setTransparentSort=function(me){W=me},this.getClearColor=function(me){return me.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor(...arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha(...arguments)},this.clear=function(me=!0,ze=!0,Ke=!0){let Ge=0;if(me){let be=!1;if(j!==null){const at=j.texture.format;be=x.has(at)}if(be){const at=j.texture.type,ht=y.has(at),rt=ye.getClearColor(),Ct=ye.getClearAlpha(),Vt=rt.r,Dt=rt.g,Tt=rt.b;ht?(b[0]=Vt,b[1]=Dt,b[2]=Tt,b[3]=Ct,Y.clearBufferuiv(Y.COLOR,0,b)):(v[0]=Vt,v[1]=Dt,v[2]=Tt,v[3]=Ct,Y.clearBufferiv(Y.COLOR,0,v))}else Ge|=Y.COLOR_BUFFER_BIT}ze&&(Ge|=Y.DEPTH_BUFFER_BIT),Ke&&(Ge|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(Ge)},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",Re,!1),n.removeEventListener("webglcontextrestored",Oe,!1),n.removeEventListener("webglcontextcreationerror",Ne,!1),ye.dispose(),Ce.dispose(),He.dispose(),he.dispose(),U.dispose(),L.dispose(),_e.dispose(),ke.dispose(),Ze.dispose(),Ee.dispose(),Xe.dispose(),Xe.removeEventListener("sessionstart",gt),Xe.removeEventListener("sessionend",Qt),tn.stop()};function Re(me){me.preventDefault(),EB("WebGLRenderer: Context Lost."),M=!0}function Oe(){EB("WebGLRenderer: Context Restored."),M=!1;const me=le.autoReset,ze=xe.enabled,Ke=xe.autoUpdate,Ge=xe.needsUpdate,be=xe.type;je(),le.autoReset=me,xe.enabled=ze,xe.autoUpdate=Ke,xe.needsUpdate=Ge,xe.type=be}function Ne(me){zi("WebGLRenderer: A WebGL context could not be created. Reason: ",me.statusMessage)}function Je(me){const ze=me.target;ze.removeEventListener("dispose",Je),yt(ze)}function yt(me){Et(me),he.remove(me)}function Et(me){const ze=he.get(me).programs;ze!==void 0&&(ze.forEach(function(Ke){Ee.releaseProgram(Ke)}),me.isShaderMaterial&&Ee.releaseShaderCache(me))}this.renderBufferDirect=function(me,ze,Ke,Ge,be,at){ze===null&&(ze=re);const ht=be.isMesh&&be.matrixWorld.determinant()<0,rt=De(me,ze,Ke,Ge,be);Q.setMaterial(Ge,ht);let Ct=Ke.index,Vt=1;if(Ge.wireframe===!0){if(Ct=ge.getWireframeAttribute(Ke),Ct===void 0)return;Vt=2}const Dt=Ke.drawRange,Tt=Ke.attributes.position;let Jt=Dt.start*Vt,Kt=(Dt.start+Dt.count)*Vt;at!==null&&(Jt=Math.max(Jt,at.start*Vt),Kt=Math.min(Kt,(at.start+at.count)*Vt)),Ct!==null?(Jt=Math.max(Jt,0),Kt=Math.min(Kt,Ct.count)):Tt!=null&&(Jt=Math.max(Jt,0),Kt=Math.min(Kt,Tt.count));const fn=Kt-Jt;if(fn<0||fn===1/0)return;ke.setup(be,Ge,rt,Ke,Ct);let Cn,gn=Ue;if(Ct!==null&&(Cn=X.get(Ct),gn=Pe,gn.setIndex(Cn)),be.isMesh)Ge.wireframe===!0?(Q.setLineWidth(Ge.wireframeLinewidth*G()),gn.setMode(Y.LINES)):gn.setMode(Y.TRIANGLES);else if(be.isLine){let Gt=Ge.linewidth;Gt===void 0&&(Gt=1),Q.setLineWidth(Gt*G()),be.isLineSegments?gn.setMode(Y.LINES):be.isLineLoop?gn.setMode(Y.LINE_LOOP):gn.setMode(Y.LINE_STRIP)}else be.isPoints?gn.setMode(Y.POINTS):be.isSprite&&gn.setMode(Y.TRIANGLES);if(be.isBatchedMesh)if(be._multiDrawInstances!==null)c0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),gn.renderMultiDrawInstances(be._multiDrawStarts,be._multiDrawCounts,be._multiDrawCount,be._multiDrawInstances);else if(B.get("WEBGL_multi_draw"))gn.renderMultiDraw(be._multiDrawStarts,be._multiDrawCounts,be._multiDrawCount);else{const Gt=be._multiDrawStarts,mn=be._multiDrawCounts,pn=be._multiDrawCount,Hr=Ct?X.get(Ct).bytesPerElement:1,Vr=he.get(Ge).currentProgram.getUniforms();for(let Tn=0;Tn<pn;Tn++)Vr.setValue(Y,"_gl_DrawID",Tn),gn.render(Gt[Tn]/Hr,mn[Tn])}else if(be.isInstancedMesh)gn.renderInstances(Jt,fn,be.count);else if(Ke.isInstancedBufferGeometry){const Gt=Ke._maxInstanceCount!==void 0?Ke._maxInstanceCount:1/0,mn=Math.min(Ke.instanceCount,Gt);gn.renderInstances(Jt,fn,mn)}else gn.render(Jt,fn)};function an(me,ze,Ke){me.transparent===!0&&me.side===xc&&me.forceSinglePass===!1?(me.side=Qs,me.needsUpdate=!0,sr(me,ze,Ke),me.side=zh,me.needsUpdate=!0,sr(me,ze,Ke),me.side=xc):sr(me,ze,Ke)}this.compile=function(me,ze,Ke=null){Ke===null&&(Ke=me),k=He.get(Ke),k.init(ze),N.push(k),Ke.traverseVisible(function(be){be.isLight&&be.layers.test(ze.layers)&&(k.pushLight(be),be.castShadow&&k.pushShadow(be))}),me!==Ke&&me.traverseVisible(function(be){be.isLight&&be.layers.test(ze.layers)&&(k.pushLight(be),be.castShadow&&k.pushShadow(be))}),k.setupLights();const Ge=new Set;return me.traverse(function(be){if(!(be.isMesh||be.isPoints||be.isLine||be.isSprite))return;const at=be.material;if(at)if(Array.isArray(at))for(let ht=0;ht<at.length;ht++){const rt=at[ht];an(rt,Ke,be),Ge.add(rt)}else an(at,Ke,be),Ge.add(at)}),k=N.pop(),Ge},this.compileAsync=function(me,ze,Ke=null){const Ge=this.compile(me,ze,Ke);return new Promise(be=>{function at(){if(Ge.forEach(function(ht){he.get(ht).currentProgram.isReady()&&Ge.delete(ht)}),Ge.size===0){be(me);return}setTimeout(at,10)}B.get("KHR_parallel_shader_compile")!==null?at():setTimeout(at,10)})};let jt=null;function Fe(me){jt&&jt(me)}function gt(){tn.stop()}function Qt(){tn.start()}const tn=new XK;tn.setAnimationLoop(Fe),typeof self<"u"&&tn.setContext(self),this.setAnimationLoop=function(me){jt=me,Xe.setAnimationLoop(me),me===null?tn.stop():tn.start()},Xe.addEventListener("sessionstart",gt),Xe.addEventListener("sessionend",Qt),this.render=function(me,ze){if(ze!==void 0&&ze.isCamera!==!0){zi("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;if(me.matrixWorldAutoUpdate===!0&&me.updateMatrixWorld(),ze.parent===null&&ze.matrixWorldAutoUpdate===!0&&ze.updateMatrixWorld(),Xe.enabled===!0&&Xe.isPresenting===!0&&(Xe.cameraAutoUpdate===!0&&Xe.updateCamera(ze),ze=Xe.getCamera()),me.isScene===!0&&me.onBeforeRender(A,me,ze,j),k=He.get(me,N.length),k.init(ze),N.push(k),de.multiplyMatrices(ze.projectionMatrix,ze.matrixWorldInverse),fe.setFromProjectionMatrix(de,_c,ze.reversedDepth),Le=this.localClippingEnabled,ve=Qe.init(this.clippingPlanes,Le),S=Ce.get(me,E.length),S.init(),E.push(S),Xe.enabled===!0&&Xe.isPresenting===!0){const at=A.xr.getDepthSensingMesh();at!==null&&un(at,ze,-1/0,A.sortObjects)}un(me,ze,0,A.sortObjects),S.finish(),A.sortObjects===!0&&S.sort(V,W),Ie=Xe.enabled===!1||Xe.isPresenting===!1||Xe.hasDepthSensing()===!1,Ie&&ye.addToRenderList(S,me),this.info.render.frame++,ve===!0&&Qe.beginShadows();const Ke=k.state.shadowsArray;xe.render(Ke,me,ze),ve===!0&&Qe.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ge=S.opaque,be=S.transmissive;if(k.setupLights(),ze.isArrayCamera){const at=ze.cameras;if(be.length>0)for(let ht=0,rt=at.length;ht<rt;ht++){const Ct=at[ht];gr(Ge,be,me,Ct)}Ie&&ye.render(me);for(let ht=0,rt=at.length;ht<rt;ht++){const Ct=at[ht];dr(S,me,Ct,Ct.viewport)}}else be.length>0&&gr(Ge,be,me,ze),Ie&&ye.render(me),dr(S,me,ze);j!==null&&T===0&&(te.updateMultisampleRenderTarget(j),te.updateRenderTargetMipmap(j)),me.isScene===!0&&me.onAfterRender(A,me,ze),ke.resetDefaultState(),z=-1,F=null,N.pop(),N.length>0?(k=N[N.length-1],ve===!0&&Qe.setGlobalState(A.clippingPlanes,k.state.camera)):k=null,E.pop(),E.length>0?S=E[E.length-1]:S=null};function un(me,ze,Ke,Ge){if(me.visible===!1)return;if(me.layers.test(ze.layers)){if(me.isGroup)Ke=me.renderOrder;else if(me.isLOD)me.autoUpdate===!0&&me.update(ze);else if(me.isLight)k.pushLight(me),me.castShadow&&k.pushShadow(me);else if(me.isSprite){if(!me.frustumCulled||fe.intersectsSprite(me)){Ge&&Ae.setFromMatrixPosition(me.matrixWorld).applyMatrix4(de);const ht=_e.update(me),rt=me.material;rt.visible&&S.push(me,ht,rt,Ke,Ae.z,null)}}else if((me.isMesh||me.isLine||me.isPoints)&&(!me.frustumCulled||fe.intersectsObject(me))){const ht=_e.update(me),rt=me.material;if(Ge&&(me.boundingSphere!==void 0?(me.boundingSphere===null&&me.computeBoundingSphere(),Ae.copy(me.boundingSphere.center)):(ht.boundingSphere===null&&ht.computeBoundingSphere(),Ae.copy(ht.boundingSphere.center)),Ae.applyMatrix4(me.matrixWorld).applyMatrix4(de)),Array.isArray(rt)){const Ct=ht.groups;for(let Vt=0,Dt=Ct.length;Vt<Dt;Vt++){const Tt=Ct[Vt],Jt=rt[Tt.materialIndex];Jt&&Jt.visible&&S.push(me,ht,Jt,Ke,Ae.z,Tt)}}else rt.visible&&S.push(me,ht,rt,Ke,Ae.z,null)}}const at=me.children;for(let ht=0,rt=at.length;ht<rt;ht++)un(at[ht],ze,Ke,Ge)}function dr(me,ze,Ke,Ge){const{opaque:be,transmissive:at,transparent:ht}=me;k.setupLightsView(Ke),ve===!0&&Qe.setGlobalState(A.clippingPlanes,Ke),Ge&&Q.viewport($.copy(Ge)),be.length>0&&ar(be,ze,Ke),at.length>0&&ar(at,ze,Ke),ht.length>0&&ar(ht,ze,Ke),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function gr(me,ze,Ke,Ge){if((Ke.isScene===!0?Ke.overrideMaterial:null)!==null)return;k.state.transmissionRenderTarget[Ge.id]===void 0&&(k.state.transmissionRenderTarget[Ge.id]=new Am(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")||B.has("EXT_color_buffer_float")?Rb:jc,minFilter:Qf,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:cr.workingColorSpace}));const at=k.state.transmissionRenderTarget[Ge.id],ht=Ge.viewport||$;at.setSize(ht.z*A.transmissionResolutionScale,ht.w*A.transmissionResolutionScale);const rt=A.getRenderTarget(),Ct=A.getActiveCubeFace(),Vt=A.getActiveMipmapLevel();A.setRenderTarget(at),A.getClearColor(q),I=A.getClearAlpha(),I<1&&A.setClearColor(16777215,.5),A.clear(),Ie&&ye.render(Ke);const Dt=A.toneMapping;A.toneMapping=Ch;const Tt=Ge.viewport;if(Ge.viewport!==void 0&&(Ge.viewport=void 0),k.setupLightsView(Ge),ve===!0&&Qe.setGlobalState(A.clippingPlanes,Ge),ar(me,Ke,Ge),te.updateMultisampleRenderTarget(at),te.updateRenderTargetMipmap(at),B.has("WEBGL_multisampled_render_to_texture")===!1){let Jt=!1;for(let Kt=0,fn=ze.length;Kt<fn;Kt++){const Cn=ze[Kt],{object:gn,geometry:Gt,material:mn,group:pn}=Cn;if(mn.side===xc&&gn.layers.test(Ge.layers)){const Hr=mn.side;mn.side=Qs,mn.needsUpdate=!0,Xt(gn,Ke,Ge,Gt,mn,pn),mn.side=Hr,mn.needsUpdate=!0,Jt=!0}}Jt===!0&&(te.updateMultisampleRenderTarget(at),te.updateRenderTargetMipmap(at))}A.setRenderTarget(rt,Ct,Vt),A.setClearColor(q,I),Tt!==void 0&&(Ge.viewport=Tt),A.toneMapping=Dt}function ar(me,ze,Ke){const Ge=ze.isScene===!0?ze.overrideMaterial:null;for(let be=0,at=me.length;be<at;be++){const ht=me[be],{object:rt,geometry:Ct,group:Vt}=ht;let Dt=ht.material;Dt.allowOverride===!0&&Ge!==null&&(Dt=Ge),rt.layers.test(Ke.layers)&&Xt(rt,ze,Ke,Ct,Dt,Vt)}}function Xt(me,ze,Ke,Ge,be,at){me.onBeforeRender(A,ze,Ke,Ge,be,at),me.modelViewMatrix.multiplyMatrices(Ke.matrixWorldInverse,me.matrixWorld),me.normalMatrix.getNormalMatrix(me.modelViewMatrix),be.onBeforeRender(A,ze,Ke,Ge,me,at),be.transparent===!0&&be.side===xc&&be.forceSinglePass===!1?(be.side=Qs,be.needsUpdate=!0,A.renderBufferDirect(Ke,ze,Ge,be,me,at),be.side=zh,be.needsUpdate=!0,A.renderBufferDirect(Ke,ze,Ge,be,me,at),be.side=xc):A.renderBufferDirect(Ke,ze,Ge,be,me,at),me.onAfterRender(A,ze,Ke,Ge,be,at)}function sr(me,ze,Ke){ze.isScene!==!0&&(ze=re);const Ge=he.get(me),be=k.state.lights,at=k.state.shadowsArray,ht=be.state.version,rt=Ee.getParameters(me,be.state,at,ze,Ke),Ct=Ee.getProgramCacheKey(rt);let Vt=Ge.programs;Ge.environment=me.isMeshStandardMaterial?ze.environment:null,Ge.fog=ze.fog,Ge.envMap=(me.isMeshStandardMaterial?L:U).get(me.envMap||Ge.environment),Ge.envMapRotation=Ge.environment!==null&&me.envMap===null?ze.environmentRotation:me.envMapRotation,Vt===void 0&&(me.addEventListener("dispose",Je),Vt=new Map,Ge.programs=Vt);let Dt=Vt.get(Ct);if(Dt!==void 0){if(Ge.currentProgram===Dt&&Ge.lightsStateVersion===ht)return Fa(me,rt),Dt}else rt.uniforms=Ee.getUniforms(me),me.onBeforeCompile(rt,A),Dt=Ee.acquireProgram(rt,Ct),Vt.set(Ct,Dt),Ge.uniforms=rt.uniforms;const Tt=Ge.uniforms;return(!me.isShaderMaterial&&!me.isRawShaderMaterial||me.clipping===!0)&&(Tt.clippingPlanes=Qe.uniform),Fa(me,rt),Ge.needsLights=dt(me),Ge.lightsStateVersion=ht,Ge.needsLights&&(Tt.ambientLightColor.value=be.state.ambient,Tt.lightProbe.value=be.state.probe,Tt.directionalLights.value=be.state.directional,Tt.directionalLightShadows.value=be.state.directionalShadow,Tt.spotLights.value=be.state.spot,Tt.spotLightShadows.value=be.state.spotShadow,Tt.rectAreaLights.value=be.state.rectArea,Tt.ltc_1.value=be.state.rectAreaLTC1,Tt.ltc_2.value=be.state.rectAreaLTC2,Tt.pointLights.value=be.state.point,Tt.pointLightShadows.value=be.state.pointShadow,Tt.hemisphereLights.value=be.state.hemi,Tt.directionalShadowMap.value=be.state.directionalShadowMap,Tt.directionalShadowMatrix.value=be.state.directionalShadowMatrix,Tt.spotShadowMap.value=be.state.spotShadowMap,Tt.spotLightMatrix.value=be.state.spotLightMatrix,Tt.spotLightMap.value=be.state.spotLightMap,Tt.pointShadowMap.value=be.state.pointShadowMap,Tt.pointShadowMatrix.value=be.state.pointShadowMatrix),Ge.currentProgram=Dt,Ge.uniformsList=null,Dt}function vi(me){if(me.uniformsList===null){const ze=me.currentProgram.getUniforms();me.uniformsList=$S.seqWithValue(ze.seq,me.uniforms)}return me.uniformsList}function Fa(me,ze){const Ke=he.get(me);Ke.outputColorSpace=ze.outputColorSpace,Ke.batching=ze.batching,Ke.batchingColor=ze.batchingColor,Ke.instancing=ze.instancing,Ke.instancingColor=ze.instancingColor,Ke.instancingMorph=ze.instancingMorph,Ke.skinning=ze.skinning,Ke.morphTargets=ze.morphTargets,Ke.morphNormals=ze.morphNormals,Ke.morphColors=ze.morphColors,Ke.morphTargetsCount=ze.morphTargetsCount,Ke.numClippingPlanes=ze.numClippingPlanes,Ke.numIntersection=ze.numClipIntersection,Ke.vertexAlphas=ze.vertexAlphas,Ke.vertexTangents=ze.vertexTangents,Ke.toneMapping=ze.toneMapping}function De(me,ze,Ke,Ge,be){ze.isScene!==!0&&(ze=re),te.resetTextureUnits();const at=ze.fog,ht=Ge.isMeshStandardMaterial?ze.environment:null,rt=j===null?A.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:ab,Ct=(Ge.isMeshStandardMaterial?L:U).get(Ge.envMap||ht),Vt=Ge.vertexColors===!0&&!!Ke.attributes.color&&Ke.attributes.color.itemSize===4,Dt=!!Ke.attributes.tangent&&(!!Ge.normalMap||Ge.anisotropy>0),Tt=!!Ke.morphAttributes.position,Jt=!!Ke.morphAttributes.normal,Kt=!!Ke.morphAttributes.color;let fn=Ch;Ge.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(fn=A.toneMapping);const Cn=Ke.morphAttributes.position||Ke.morphAttributes.normal||Ke.morphAttributes.color,gn=Cn!==void 0?Cn.length:0,Gt=he.get(Ge),mn=k.state.lights;if(ve===!0&&(Le===!0||me!==F)){const wi=me===F&&Ge.id===z;Qe.setState(Ge,me,wi)}let pn=!1;Ge.version===Gt.__version?(Gt.needsLights&&Gt.lightsStateVersion!==mn.state.version||Gt.outputColorSpace!==rt||be.isBatchedMesh&&Gt.batching===!1||!be.isBatchedMesh&&Gt.batching===!0||be.isBatchedMesh&&Gt.batchingColor===!0&&be.colorTexture===null||be.isBatchedMesh&&Gt.batchingColor===!1&&be.colorTexture!==null||be.isInstancedMesh&&Gt.instancing===!1||!be.isInstancedMesh&&Gt.instancing===!0||be.isSkinnedMesh&&Gt.skinning===!1||!be.isSkinnedMesh&&Gt.skinning===!0||be.isInstancedMesh&&Gt.instancingColor===!0&&be.instanceColor===null||be.isInstancedMesh&&Gt.instancingColor===!1&&be.instanceColor!==null||be.isInstancedMesh&&Gt.instancingMorph===!0&&be.morphTexture===null||be.isInstancedMesh&&Gt.instancingMorph===!1&&be.morphTexture!==null||Gt.envMap!==Ct||Ge.fog===!0&&Gt.fog!==at||Gt.numClippingPlanes!==void 0&&(Gt.numClippingPlanes!==Qe.numPlanes||Gt.numIntersection!==Qe.numIntersection)||Gt.vertexAlphas!==Vt||Gt.vertexTangents!==Dt||Gt.morphTargets!==Tt||Gt.morphNormals!==Jt||Gt.morphColors!==Kt||Gt.toneMapping!==fn||Gt.morphTargetsCount!==gn)&&(pn=!0):(pn=!0,Gt.__version=Ge.version);let Hr=Gt.currentProgram;pn===!0&&(Hr=sr(Ge,ze,be));let Vr=!1,Tn=!1,_n=!1;const $n=Hr.getUniforms(),mi=Gt.uniforms;if(Q.useProgram(Hr.program)&&(Vr=!0,Tn=!0,_n=!0),Ge.id!==z&&(z=Ge.id,Tn=!0),Vr||F!==me){Q.buffers.depth.getReversed()&&me.reversedDepth!==!0&&(me._reversedDepth=!0,me.updateProjectionMatrix()),$n.setValue(Y,"projectionMatrix",me.projectionMatrix),$n.setValue(Y,"viewMatrix",me.matrixWorldInverse);const bt=$n.map.cameraPosition;bt!==void 0&&bt.setValue(Y,ce.setFromMatrixPosition(me.matrixWorld)),ee.logarithmicDepthBuffer&&$n.setValue(Y,"logDepthBufFC",2/(Math.log(me.far+1)/Math.LN2)),(Ge.isMeshPhongMaterial||Ge.isMeshToonMaterial||Ge.isMeshLambertMaterial||Ge.isMeshBasicMaterial||Ge.isMeshStandardMaterial||Ge.isShaderMaterial)&&$n.setValue(Y,"isOrthographic",me.isOrthographicCamera===!0),F!==me&&(F=me,Tn=!0,_n=!0)}if(be.isSkinnedMesh){$n.setOptional(Y,be,"bindMatrix"),$n.setOptional(Y,be,"bindMatrixInverse");const wi=be.skeleton;wi&&(wi.boneTexture===null&&wi.computeBoneTexture(),$n.setValue(Y,"boneTexture",wi.boneTexture,te))}be.isBatchedMesh&&($n.setOptional(Y,be,"batchingTexture"),$n.setValue(Y,"batchingTexture",be._matricesTexture,te),$n.setOptional(Y,be,"batchingIdTexture"),$n.setValue(Y,"batchingIdTexture",be._indirectTexture,te),$n.setOptional(Y,be,"batchingColorTexture"),be._colorsTexture!==null&&$n.setValue(Y,"batchingColorTexture",be._colorsTexture,te));const hr=Ke.morphAttributes;if((hr.position!==void 0||hr.normal!==void 0||hr.color!==void 0)&&we.update(be,Ke,Hr),(Tn||Gt.receiveShadow!==be.receiveShadow)&&(Gt.receiveShadow=be.receiveShadow,$n.setValue(Y,"receiveShadow",be.receiveShadow)),Ge.isMeshGouraudMaterial&&Ge.envMap!==null&&(mi.envMap.value=Ct,mi.flipEnvMap.value=Ct.isCubeTexture&&Ct.isRenderTargetTexture===!1?-1:1),Ge.isMeshStandardMaterial&&Ge.envMap===null&&ze.environment!==null&&(mi.envMapIntensity.value=ze.environmentIntensity),mi.dfgLUT!==void 0&&(mi.dfgLUT.value=J0e()),Tn&&($n.setValue(Y,"toneMappingExposure",A.toneMappingExposure),Gt.needsLights&&nt(mi,_n),at&&Ge.fog===!0&&$e.refreshFogUniforms(mi,at),$e.refreshMaterialUniforms(mi,Ge,se,Z,k.state.transmissionRenderTarget[me.id]),$S.upload(Y,vi(Gt),mi,te)),Ge.isShaderMaterial&&Ge.uniformsNeedUpdate===!0&&($S.upload(Y,vi(Gt),mi,te),Ge.uniformsNeedUpdate=!1),Ge.isSpriteMaterial&&$n.setValue(Y,"center",be.center),$n.setValue(Y,"modelViewMatrix",be.modelViewMatrix),$n.setValue(Y,"normalMatrix",be.normalMatrix),$n.setValue(Y,"modelMatrix",be.matrixWorld),Ge.isShaderMaterial||Ge.isRawShaderMaterial){const wi=Ge.uniformsGroups;for(let bt=0,Ft=wi.length;bt<Ft;bt++){const Kn=wi[bt];Ze.update(Kn,Hr),Ze.bind(Kn,Hr)}}return Hr}function nt(me,ze){me.ambientLightColor.needsUpdate=ze,me.lightProbe.needsUpdate=ze,me.directionalLights.needsUpdate=ze,me.directionalLightShadows.needsUpdate=ze,me.pointLights.needsUpdate=ze,me.pointLightShadows.needsUpdate=ze,me.spotLights.needsUpdate=ze,me.spotLightShadows.needsUpdate=ze,me.rectAreaLights.needsUpdate=ze,me.hemisphereLights.needsUpdate=ze}function dt(me){return me.isMeshLambertMaterial||me.isMeshToonMaterial||me.isMeshPhongMaterial||me.isMeshStandardMaterial||me.isShadowMaterial||me.isShaderMaterial&&me.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return j},this.setRenderTargetTextures=function(me,ze,Ke){const Ge=he.get(me);Ge.__autoAllocateDepthBuffer=me.resolveDepthBuffer===!1,Ge.__autoAllocateDepthBuffer===!1&&(Ge.__useRenderToTexture=!1),he.get(me.texture).__webglTexture=ze,he.get(me.depthTexture).__webglTexture=Ge.__autoAllocateDepthBuffer?void 0:Ke,Ge.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(me,ze){const Ke=he.get(me);Ke.__webglFramebuffer=ze,Ke.__useDefaultFramebuffer=ze===void 0};const pt=Y.createFramebuffer();this.setRenderTarget=function(me,ze=0,Ke=0){j=me,P=ze,T=Ke;let Ge=!0,be=null,at=!1,ht=!1;if(me){const Ct=he.get(me);if(Ct.__useDefaultFramebuffer!==void 0)Q.bindFramebuffer(Y.FRAMEBUFFER,null),Ge=!1;else if(Ct.__webglFramebuffer===void 0)te.setupRenderTarget(me);else if(Ct.__hasExternalTextures)te.rebindTextures(me,he.get(me.texture).__webglTexture,he.get(me.depthTexture).__webglTexture);else if(me.depthBuffer){const Tt=me.depthTexture;if(Ct.__boundDepthTexture!==Tt){if(Tt!==null&&he.has(Tt)&&(me.width!==Tt.image.width||me.height!==Tt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");te.setupDepthRenderbuffer(me)}}const Vt=me.texture;(Vt.isData3DTexture||Vt.isDataArrayTexture||Vt.isCompressedArrayTexture)&&(ht=!0);const Dt=he.get(me).__webglFramebuffer;me.isWebGLCubeRenderTarget?(Array.isArray(Dt[ze])?be=Dt[ze][Ke]:be=Dt[ze],at=!0):me.samples>0&&te.useMultisampledRTT(me)===!1?be=he.get(me).__webglMultisampledFramebuffer:Array.isArray(Dt)?be=Dt[Ke]:be=Dt,$.copy(me.viewport),D.copy(me.scissor),H=me.scissorTest}else $.copy(ie).multiplyScalar(se).floor(),D.copy(J).multiplyScalar(se).floor(),H=pe;if(Ke!==0&&(be=pt),Q.bindFramebuffer(Y.FRAMEBUFFER,be)&&Ge&&Q.drawBuffers(me,be),Q.viewport($),Q.scissor(D),Q.setScissorTest(H),at){const Ct=he.get(me.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ct.__webglTexture,Ke)}else if(ht){const Ct=ze;for(let Vt=0;Vt<me.textures.length;Vt++){const Dt=he.get(me.textures[Vt]);Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0+Vt,Dt.__webglTexture,Ke,Ct)}}else if(me!==null&&Ke!==0){const Ct=he.get(me.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,Ct.__webglTexture,Ke)}z=-1},this.readRenderTargetPixels=function(me,ze,Ke,Ge,be,at,ht,rt=0){if(!(me&&me.isWebGLRenderTarget)){zi("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ct=he.get(me).__webglFramebuffer;if(me.isWebGLCubeRenderTarget&&ht!==void 0&&(Ct=Ct[ht]),Ct){Q.bindFramebuffer(Y.FRAMEBUFFER,Ct);try{const Vt=me.textures[rt],Dt=Vt.format,Tt=Vt.type;if(!ee.textureFormatReadable(Dt)){zi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ee.textureTypeReadable(Tt)){zi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ze>=0&&ze<=me.width-Ge&&Ke>=0&&Ke<=me.height-be&&(me.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+rt),Y.readPixels(ze,Ke,Ge,be,Ve.convert(Dt),Ve.convert(Tt),at))}finally{const Vt=j!==null?he.get(j).__webglFramebuffer:null;Q.bindFramebuffer(Y.FRAMEBUFFER,Vt)}}},this.readRenderTargetPixelsAsync=async function(me,ze,Ke,Ge,be,at,ht,rt=0){if(!(me&&me.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ct=he.get(me).__webglFramebuffer;if(me.isWebGLCubeRenderTarget&&ht!==void 0&&(Ct=Ct[ht]),Ct)if(ze>=0&&ze<=me.width-Ge&&Ke>=0&&Ke<=me.height-be){Q.bindFramebuffer(Y.FRAMEBUFFER,Ct);const Vt=me.textures[rt],Dt=Vt.format,Tt=Vt.type;if(!ee.textureFormatReadable(Dt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ee.textureTypeReadable(Tt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Jt=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,Jt),Y.bufferData(Y.PIXEL_PACK_BUFFER,at.byteLength,Y.STREAM_READ),me.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+rt),Y.readPixels(ze,Ke,Ge,be,Ve.convert(Dt),Ve.convert(Tt),0);const Kt=j!==null?he.get(j).__webglFramebuffer:null;Q.bindFramebuffer(Y.FRAMEBUFFER,Kt);const fn=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await _pe(Y,fn,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,Jt),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,at),Y.deleteBuffer(Jt),Y.deleteSync(fn),at}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(me,ze=null,Ke=0){const Ge=Math.pow(2,-Ke),be=Math.floor(me.image.width*Ge),at=Math.floor(me.image.height*Ge),ht=ze!==null?ze.x:0,rt=ze!==null?ze.y:0;te.setTexture2D(me,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,Ke,0,0,ht,rt,be,at),Q.unbindTexture()};const ot=Y.createFramebuffer(),Lt=Y.createFramebuffer();this.copyTextureToTexture=function(me,ze,Ke=null,Ge=null,be=0,at=null){at===null&&(be!==0?(c0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),at=be,be=0):at=0);let ht,rt,Ct,Vt,Dt,Tt,Jt,Kt,fn;const Cn=me.isCompressedTexture?me.mipmaps[at]:me.image;if(Ke!==null)ht=Ke.max.x-Ke.min.x,rt=Ke.max.y-Ke.min.y,Ct=Ke.isBox3?Ke.max.z-Ke.min.z:1,Vt=Ke.min.x,Dt=Ke.min.y,Tt=Ke.isBox3?Ke.min.z:0;else{const hr=Math.pow(2,-be);ht=Math.floor(Cn.width*hr),rt=Math.floor(Cn.height*hr),me.isDataArrayTexture?Ct=Cn.depth:me.isData3DTexture?Ct=Math.floor(Cn.depth*hr):Ct=1,Vt=0,Dt=0,Tt=0}Ge!==null?(Jt=Ge.x,Kt=Ge.y,fn=Ge.z):(Jt=0,Kt=0,fn=0);const gn=Ve.convert(ze.format),Gt=Ve.convert(ze.type);let mn;ze.isData3DTexture?(te.setTexture3D(ze,0),mn=Y.TEXTURE_3D):ze.isDataArrayTexture||ze.isCompressedArrayTexture?(te.setTexture2DArray(ze,0),mn=Y.TEXTURE_2D_ARRAY):(te.setTexture2D(ze,0),mn=Y.TEXTURE_2D),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,ze.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ze.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,ze.unpackAlignment);const pn=Y.getParameter(Y.UNPACK_ROW_LENGTH),Hr=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),Vr=Y.getParameter(Y.UNPACK_SKIP_PIXELS),Tn=Y.getParameter(Y.UNPACK_SKIP_ROWS),_n=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Cn.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Cn.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,Vt),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Dt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Tt);const $n=me.isDataArrayTexture||me.isData3DTexture,mi=ze.isDataArrayTexture||ze.isData3DTexture;if(me.isDepthTexture){const hr=he.get(me),wi=he.get(ze),bt=he.get(hr.__renderTarget),Ft=he.get(wi.__renderTarget);Q.bindFramebuffer(Y.READ_FRAMEBUFFER,bt.__webglFramebuffer),Q.bindFramebuffer(Y.DRAW_FRAMEBUFFER,Ft.__webglFramebuffer);for(let Kn=0;Kn<Ct;Kn++)$n&&(Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,he.get(me).__webglTexture,be,Tt+Kn),Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,he.get(ze).__webglTexture,at,fn+Kn)),Y.blitFramebuffer(Vt,Dt,ht,rt,Jt,Kt,ht,rt,Y.DEPTH_BUFFER_BIT,Y.NEAREST);Q.bindFramebuffer(Y.READ_FRAMEBUFFER,null),Q.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else if(be!==0||me.isRenderTargetTexture||he.has(me)){const hr=he.get(me),wi=he.get(ze);Q.bindFramebuffer(Y.READ_FRAMEBUFFER,ot),Q.bindFramebuffer(Y.DRAW_FRAMEBUFFER,Lt);for(let bt=0;bt<Ct;bt++)$n?Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,hr.__webglTexture,be,Tt+bt):Y.framebufferTexture2D(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,hr.__webglTexture,be),mi?Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,wi.__webglTexture,at,fn+bt):Y.framebufferTexture2D(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,wi.__webglTexture,at),be!==0?Y.blitFramebuffer(Vt,Dt,ht,rt,Jt,Kt,ht,rt,Y.COLOR_BUFFER_BIT,Y.NEAREST):mi?Y.copyTexSubImage3D(mn,at,Jt,Kt,fn+bt,Vt,Dt,ht,rt):Y.copyTexSubImage2D(mn,at,Jt,Kt,Vt,Dt,ht,rt);Q.bindFramebuffer(Y.READ_FRAMEBUFFER,null),Q.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else mi?me.isDataTexture||me.isData3DTexture?Y.texSubImage3D(mn,at,Jt,Kt,fn,ht,rt,Ct,gn,Gt,Cn.data):ze.isCompressedArrayTexture?Y.compressedTexSubImage3D(mn,at,Jt,Kt,fn,ht,rt,Ct,gn,Cn.data):Y.texSubImage3D(mn,at,Jt,Kt,fn,ht,rt,Ct,gn,Gt,Cn):me.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,at,Jt,Kt,ht,rt,gn,Gt,Cn.data):me.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,at,Jt,Kt,Cn.width,Cn.height,gn,Cn.data):Y.texSubImage2D(Y.TEXTURE_2D,at,Jt,Kt,ht,rt,gn,Gt,Cn);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,pn),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Hr),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,Vr),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Tn),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,_n),at===0&&ze.generateMipmaps&&Y.generateMipmap(mn),Q.unbindTexture()},this.initRenderTarget=function(me){he.get(me).__webglFramebuffer===void 0&&te.setupRenderTarget(me)},this.initTexture=function(me){me.isCubeTexture?te.setTextureCube(me,0):me.isData3DTexture?te.setTexture3D(me,0):me.isDataArrayTexture||me.isCompressedArrayTexture?te.setTexture2DArray(me,0):te.setTexture2D(me,0),Q.unbindTexture()},this.resetState=function(){P=0,T=0,j=null,Q.reset(),ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return _c}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=cr._getDrawingBufferColorSpace(e),n.unpackColorSpace=cr._getUnpackColorSpace()}};const N8={type:"change"},j4={type:"start"},eX={type:"end"},y_=new k4,k8=new nh,tve=Math.cos(70*Npe.DEG2RAD),oa=new mt,Vs=2*Math.PI,Pr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},rA=1e-6;class nve extends fge{constructor(e,n=null){super(e,n),this.state=Pr.NONE,this.target=new mt,this.cursor=new mt,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:Fg.ROTATE,MIDDLE:Fg.DOLLY,RIGHT:Fg.PAN},this.touches={ONE:Mg.ROTATE,TWO:Mg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new mt,this._lastQuaternion=new Em,this._lastTargetPosition=new mt,this._quat=new Em().setFromUnitVectors(e.up,new mt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new JB,this._sphericalDelta=new JB,this._scale=1,this._panOffset=new mt,this._rotateStart=new Rn,this._rotateEnd=new Rn,this._rotateDelta=new Rn,this._panStart=new Rn,this._panEnd=new Rn,this._panDelta=new Rn,this._dollyStart=new Rn,this._dollyEnd=new Rn,this._dollyDelta=new Rn,this._dollyDirection=new mt,this._mouse=new Rn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ive.bind(this),this._onPointerDown=rve.bind(this),this._onPointerUp=ave.bind(this),this._onContextMenu=hve.bind(this),this._onMouseWheel=lve.bind(this),this._onKeyDown=cve.bind(this),this._onTouchStart=uve.bind(this),this._onTouchMove=dve.bind(this),this._onMouseDown=sve.bind(this),this._onMouseMove=ove.bind(this),this._interceptControlDown=fve.bind(this),this._interceptControlUp=mve.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(N8),this.update(),this.state=Pr.NONE}update(e=null){const n=this.object.position;oa.copy(n).sub(this.target),oa.applyQuaternion(this._quat),this._spherical.setFromVector3(oa),this.autoRotate&&this.state===Pr.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=Vs:r>Math.PI&&(r-=Vs),i<-Math.PI?i+=Vs:i>Math.PI&&(i-=Vs),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 s=!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),s=o!=this._spherical.radius}if(oa.setFromSpherical(this._spherical),oa.applyQuaternion(this._quatInverse),n.copy(this.target).add(oa),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=oa.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const l=new mt(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(),s=c!==this.object.zoom;const u=new mt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=oa.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):(y_.origin.copy(this.object.position),y_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(y_.direction))<tve?this.object.lookAt(this.target):(k8.setFromNormalAndCoplanarPoint(this.object.up,this.target),y_.intersectPlane(k8,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(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>rA||8*(1-this._lastQuaternion.dot(this.object.quaternion))>rA||this._lastTargetPosition.distanceToSquared(this.target)>rA?(this.dispatchEvent(N8),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Vs/60*this.autoRotateSpeed*e:Vs/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){oa.setFromMatrixColumn(n,0),oa.multiplyScalar(-e),this._panOffset.add(oa)}_panUp(e,n){this.screenSpacePanning===!0?oa.setFromMatrixColumn(n,1):(oa.setFromMatrixColumn(n,0),oa.crossVectors(this.object.up,oa)),oa.multiplyScalar(e),this._panOffset.add(oa)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;oa.copy(i).sub(this.target);let s=oa.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*n*s/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,s=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/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(Vs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Vs*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(Vs*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(-Vs*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(Vs*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(-Vs*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,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_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),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Vs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Vs*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,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),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 Rn,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 rve(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 ive(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function ave(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(eX),this.state=Pr.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function sve(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 Fg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Pr.DOLLY;break;case Fg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Pr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Pr.ROTATE}break;case Fg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Pr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Pr.PAN}break;default:this.state=Pr.NONE}this.state!==Pr.NONE&&this.dispatchEvent(j4)}function ove(t){switch(this.state){case Pr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Pr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Pr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function lve(t){this.enabled===!1||this.enableZoom===!1||this.state!==Pr.NONE||(t.preventDefault(),this.dispatchEvent(j4),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(eX))}function cve(t){this.enabled!==!1&&this._handleKeyDown(t)}function uve(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Mg.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Pr.TOUCH_ROTATE;break;case Mg.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Pr.TOUCH_PAN;break;default:this.state=Pr.NONE}break;case 2:switch(this.touches.TWO){case Mg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Pr.TOUCH_DOLLY_PAN;break;case Mg.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Pr.TOUCH_DOLLY_ROTATE;break;default:this.state=Pr.NONE}break;default:this.state=Pr.NONE}this.state!==Pr.NONE&&this.dispatchEvent(j4)}function dve(t){switch(this._trackPointer(t),this.state){case Pr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Pr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Pr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Pr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Pr.NONE}}function hve(t){this.enabled!==!1&&t.preventDefault()}function fve(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function mve(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function pve(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)),s={},o={},l=t[0].morphTargetsRelative,c=new gl;let u=0;for(let d=0;d<t.length;++d){const h=t[d];let p=0;if(n!==(h.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 m in h.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(h.attributes[m]),p++}if(p!==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!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in h.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[m]===void 0&&(o[m]=[]),o[m].push(h.morphAttributes[m])}if(e){let m;if(n)m=h.index.count;else if(h.attributes.position!==void 0)m=h.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,m,d),u+=m}}if(n){let d=0;const h=[];for(let p=0;p<t.length;++p){const m=t[p].index;for(let x=0;x<m.count;++x)h.push(m.getX(x)+d);d+=t[p].attributes.position.count}c.setIndex(h)}for(const d in s){const h=M8(s[d]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,h)}for(const d in o){const h=o[d][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let p=0;p<h;++p){const m=[];for(let y=0;y<o[d].length;++y)m.push(o[d][y][p]);const x=M8(m);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 M8(t){let e,n,r,i=-1,s=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;s+=d.count*n}const o=new e(s),l=new Ts(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const h=c/n;for(let p=0,m=d.count;p<m;p++)for(let x=0;x<n;x++){const y=d.getComponent(p,x);l.setComponent(p+h,x,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}class gve extends T4{constructor(e){super(e)}load(e,n,r,i){const s=this,o=new oge(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{n(s.parse(l))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},r,i)}parse(e){function n(u){const d=new DataView(u),h=32/8*3+32/8*3*3+16/8,p=d.getUint32(80,!0);if(80+32/8+p*h===d.byteLength)return!0;const x=[115,111,108,105,100];for(let y=0;y<5;y++)if(r(x,d,y))return!1;return!0}function r(u,d,h){for(let p=0,m=u.length;p<m;p++)if(u[p]!==d.getUint8(h+p))return!1;return!0}function i(u){const d=new DataView(u),h=d.getUint32(80,!0);let p,m,x,y=!1,b,v,S,k,E;for(let z=0;z<70;z++)d.getUint32(z,!1)==1129270351&&d.getUint8(z+4)==82&&d.getUint8(z+5)==61&&(y=!0,b=new Float32Array(h*3*3),v=d.getUint8(z+6)/255,S=d.getUint8(z+7)/255,k=d.getUint8(z+8)/255,E=d.getUint8(z+9)/255);const N=84,A=50,M=new gl,P=new Float32Array(h*3*3),T=new Float32Array(h*3*3),j=new In;for(let z=0;z<h;z++){const F=N+z*A,$=d.getFloat32(F,!0),D=d.getFloat32(F+4,!0),H=d.getFloat32(F+8,!0);if(y){const q=d.getUint16(F+48,!0);(q&32768)===0?(p=(q&31)/31,m=(q>>5&31)/31,x=(q>>10&31)/31):(p=v,m=S,x=k)}for(let q=1;q<=3;q++){const I=F+q*12,K=z*3*3+(q-1)*3;P[K]=d.getFloat32(I,!0),P[K+1]=d.getFloat32(I+4,!0),P[K+2]=d.getFloat32(I+8,!0),T[K]=$,T[K+1]=D,T[K+2]=H,y&&(j.setRGB(p,m,x,yo),b[K]=j.r,b[K+1]=j.g,b[K+2]=j.b)}}return M.setAttribute("position",new Ts(P,3)),M.setAttribute("normal",new Ts(T,3)),y&&(M.setAttribute("color",new Ts(b,3)),M.hasColors=!0,M.alpha=E),M}function s(u){const d=new gl,h=/solid([\s\S]*?)endsolid/g,p=/facet([\s\S]*?)endfacet/g,m=/solid\s(.+)/;let x=0;const y=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,b=new RegExp("vertex"+y+y+y,"g"),v=new RegExp("normal"+y+y+y,"g"),S=[],k=[],E=[],N=new mt;let A,M=0,P=0,T=0;for(;(A=h.exec(u))!==null;){P=T;const j=A[0],z=(A=m.exec(j))!==null?A[1]:"";for(E.push(z);(A=p.exec(j))!==null;){let D=0,H=0;const q=A[0];for(;(A=v.exec(q))!==null;)N.x=parseFloat(A[1]),N.y=parseFloat(A[2]),N.z=parseFloat(A[3]),H++;for(;(A=b.exec(q))!==null;)S.push(parseFloat(A[1]),parseFloat(A[2]),parseFloat(A[3])),k.push(N.x,N.y,N.z),D++,T++;H!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+x),D!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+x),x++}const F=P,$=T-P;d.userData.groupNames=E,d.addGroup(F,$,M),M++}return d.setAttribute("position",new Mo(S,3)),d.setAttribute("normal",new Mo(k,3)),d}function o(u){return typeof u!="string"?new TextDecoder().decode(u):u}function l(u){if(typeof u=="string"){const d=new Uint8Array(u.length);for(let h=0;h<u.length;h++)d[h]=u.charCodeAt(h)&255;return d.buffer||d}else return u}const c=l(e);return n(c)?i(c):s(o(e))}}function v_(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 iA={exports:{}};var C8;function bve(){return C8||(C8=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function o(u,d){if(!i[u]){if(!r[u]){var h=typeof v_=="function"&&v_;if(!d&&h)return h(u,!0);if(l)return l(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(x){var y=r[u][1][x];return o(y||x)},m,m.exports,n,r,i,s)}return i[u].exports}for(var l=typeof v_=="function"&&v_,c=0;c<s.length;c++)o(s[c]);return o})({1:[function(n,r,i){var s=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,h,p,m,x,y,b=[],v=0,S=c.length,k=S,E=s.getTypeOf(c)!=="string";v<c.length;)k=S-v,h=E?(u=c[v++],d=v<S?c[v++]:0,v<S?c[v++]:0):(u=c.charCodeAt(v++),d=v<S?c.charCodeAt(v++):0,v<S?c.charCodeAt(v++):0),p=u>>2,m=(3&u)<<4|d>>4,x=1<k?(15&d)<<2|h>>6:64,y=2<k?63&h:64,b.push(l.charAt(p)+l.charAt(m)+l.charAt(x)+l.charAt(y));return b.join("")},i.decode=function(c){var u,d,h,p,m,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 S,k=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&k--,c.charAt(c.length-2)===l.charAt(64)&&k--,k%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|k):new Array(0|k);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(p=l.indexOf(c.charAt(y++)))>>4,d=(15&p)<<4|(m=l.indexOf(c.charAt(y++)))>>2,h=(3&m)<<6|(x=l.indexOf(c.charAt(y++))),S[b++]=u,m!==64&&(S[b++]=d),x!==64&&(S[b++]=h);return S}},{"./support":30,"./utils":32}],2:[function(n,r,i){var s=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,h,p,m,x){this.compressedSize=d,this.uncompressedSize=h,this.crc32=p,this.compression=m,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,h,p){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(h.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var s=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var s=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?s.getTypeOf(l)!=="string"?(function(u,d,h,p){var m=o,x=p+h;u^=-1;for(var y=p;y<x;y++)u=u>>>8^m[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,h,p){var m=o,x=p+h;u^=-1;for(var y=p;y<x;y++)u=u>>>8^m[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 s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=s?"uint8array":"array";function d(h,p){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=p,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,h.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 h=this;this._pako.onData=function(p){h.push({data:p,meta:h.meta})}},i.compressWorker=function(h){return new d("Deflate",h)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(m,x){var y,b="";for(y=0;y<x;y++)b+=String.fromCharCode(255&m),m>>>=8;return b}function o(m,x,y,b,v,S){var k,E,N=m.file,A=m.compression,M=S!==u.utf8encode,P=l.transformTo("string",S(N.name)),T=l.transformTo("string",u.utf8encode(N.name)),j=N.comment,z=l.transformTo("string",S(j)),F=l.transformTo("string",u.utf8encode(j)),$=T.length!==N.name.length,D=F.length!==j.length,H="",q="",I="",K=N.dir,Z=N.date,se={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(se.crc32=m.crc32,se.compressedSize=m.compressedSize,se.uncompressedSize=m.uncompressedSize);var V=0;x&&(V|=8),M||!$&&!D||(V|=2048);var W=0,ie=0;K&&(W|=16),v==="UNIX"?(ie=798,W|=(function(pe,fe){var ve=pe;return pe||(ve=fe?16893:33204),(65535&ve)<<16})(N.unixPermissions,K)):(ie=20,W|=(function(pe){return 63&(pe||0)})(N.dosPermissions)),k=Z.getUTCHours(),k<<=6,k|=Z.getUTCMinutes(),k<<=5,k|=Z.getUTCSeconds()/2,E=Z.getUTCFullYear()-1980,E<<=4,E|=Z.getUTCMonth()+1,E<<=5,E|=Z.getUTCDate(),$&&(q=s(1,1)+s(d(P),4)+T,H+="up"+s(q.length,2)+q),D&&(I=s(1,1)+s(d(z),4)+F,H+="uc"+s(I.length,2)+I);var J="";return J+=`
  3839. \0`,J+=s(V,2),J+=A.magic,J+=s(k,2),J+=s(E,2),J+=s(se.crc32,4),J+=s(se.compressedSize,4),J+=s(se.uncompressedSize,4),J+=s(P.length,2),J+=s(H.length,2),{fileRecord:h.LOCAL_FILE_HEADER+J+P+H,dirRecord:h.CENTRAL_FILE_HEADER+s(ie,2)+J+s(z.length,2)+"\0\0\0\0"+s(W,4)+s(b,4)+P+H+z}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),h=n("../signature");function p(m,x,y,b){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=b,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(p,c),p.prototype.push=function(m){var x=m.meta.percent||0,y=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:y?(x+100*(y-b-1))/y:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var x=this.streamFiles&&!m.file.dir;if(x){var y=o(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,y=o(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:(function(b){return h.DATA_DESCRIPTOR+s(b.crc32,4)+s(b.compressedSize,4)+s(b.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-m,b=(function(v,S,k,E,N){var A=l.transformTo("string",N(E));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(v,2)+s(v,2)+s(S,4)+s(k,4)+s(A.length,2)+A})(this.dirRecords.length,y,m,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(m){this._sources.push(m);var x=this;return m.on("data",function(y){x.processChunk(y)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(y){x.error(y)}),this},p.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))},p.prototype.error=function(m){var x=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var y=0;y<x.length;y++)try{x[y].error(m)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,x=0;x<m.length;x++)m[x].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var s=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{l.forEach(function(p,m){h++;var x=(function(S,k){var E=S||k,N=s[E];if(!N)throw new Error(E+" is not a valid compression method !");return N})(m.options.compression,c.compression),y=m.options.compressionOptions||c.compressionOptions||{},b=m.dir,v=m.date;m._compressWorker(x,y).withStreamInfo("file",{name:p,dir:b,date:v,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function s(){if(!(this instanceof s))return new s;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 s;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(o,l){return new s().loadAsync(o,l)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var s=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function h(p){return new o.Promise(function(m,x){var y=p.decompressed.getContentWorker().pipe(new u);y.on("error",function(b){x(b)}).on("end",function(){y.streamInfo.crc32!==p.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(p,m){var x=this;return m=s.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(p)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(y){var b=new c(m);return b.load(y),b}).then(function(y){var b=[o.Promise.resolve(y)],v=y.files;if(m.checkCRC32)for(var S=0;S<v.length;S++)b.push(h(v[S]));return o.Promise.all(b)}).then(function(y){for(var b=y.shift(),v=b.files,S=0;S<v.length;S++){var k=v[S],E=k.fileNameStr,N=s.resolve(k.fileNameStr);x.file(N,k.decompressed,{binary:!0,optimizedBinaryString:!0,date:k.date,dir:k.dir,comment:k.fileCommentStr.length?k.fileCommentStr:null,unixPermissions:k.unixPermissions,dosPermissions:k.dosPermissions,createFolders:m.createFolders}),k.dir||(x.file(N).unsafeOriginalName=E)}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 s=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)}s.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 s=n("readable-stream").Readable;function o(l,c,u){s.call(this,c),this._helper=l;var d=this;l.on("data",function(h,p){d.push(h)||d._helper.pause(),u&&u(p)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,s),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(s,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,o);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,o)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var o=new Buffer(s);return o.fill(0),o},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(N,A,M){var P,T=l.getTypeOf(A),j=l.extend(M||{},d);j.date=j.date||new Date,j.compression!==null&&(j.compression=j.compression.toUpperCase()),typeof j.unixPermissions=="string"&&(j.unixPermissions=parseInt(j.unixPermissions,8)),j.unixPermissions&&16384&j.unixPermissions&&(j.dir=!0),j.dosPermissions&&16&j.dosPermissions&&(j.dir=!0),j.dir&&(N=v(N)),j.createFolders&&(P=b(N))&&S.call(this,P,!0);var z=T==="string"&&j.binary===!1&&j.base64===!1;M&&M.binary!==void 0||(j.binary=!z),(A instanceof h&&A.uncompressedSize===0||j.dir||!A||A.length===0)&&(j.base64=!1,j.binary=!0,A="",j.compression="STORE",T="string");var F=null;F=A instanceof h||A instanceof c?A:x.isNode&&x.isStream(A)?new y(N,A):l.prepareContent(N,A,j.binary,j.optimizedBinaryString,j.base64);var $=new p(N,F,j);this.files[N]=$}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),h=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),b=function(N){N.slice(-1)==="/"&&(N=N.substring(0,N.length-1));var A=N.lastIndexOf("/");return 0<A?N.substring(0,A):""},v=function(N){return N.slice(-1)!=="/"&&(N+="/"),N},S=function(N,A){return A=A!==void 0?A:d.createFolders,N=v(N),this.files[N]||s.call(this,N,null,{dir:!0,createFolders:A}),this.files[N]};function k(N){return Object.prototype.toString.call(N)==="[object RegExp]"}var E={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(N){var A,M,P;for(A in this.files)P=this.files[A],(M=A.slice(this.root.length,A.length))&&A.slice(0,this.root.length)===this.root&&N(M,P)},filter:function(N){var A=[];return this.forEach(function(M,P){N(M,P)&&A.push(P)}),A},file:function(N,A,M){if(arguments.length!==1)return N=this.root+N,s.call(this,N,A,M),this;if(k(N)){var P=N;return this.filter(function(j,z){return!z.dir&&P.test(j)})}var T=this.files[this.root+N];return T&&!T.dir?T:null},folder:function(N){if(!N)return this;if(k(N))return this.filter(function(T,j){return j.dir&&N.test(T)});var A=this.root+N,M=S.call(this,A),P=this.clone();return P.root=M.name,P},remove:function(N){N=this.root+N;var A=this.files[N];if(A||(N.slice(-1)!=="/"&&(N+="/"),A=this.files[N]),A&&!A.dir)delete this.files[N];else for(var M=this.filter(function(T,j){return j.name.slice(0,N.length)===N}),P=0;P<M.length;P++)delete this.files[M[P].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 A,M={};try{if((M=l.extend(N||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=M.type.toLowerCase(),M.compression=M.compression.toUpperCase(),M.type==="binarystring"&&(M.type="string"),!M.type)throw new Error("No output type specified.");l.checkSupport(M.type),M.platform!=="darwin"&&M.platform!=="freebsd"&&M.platform!=="linux"&&M.platform!=="sunos"||(M.platform="UNIX"),M.platform==="win32"&&(M.platform="DOS");var P=M.comment||this.comment||"";A=m.generateWorker(this,M,P)}catch(T){(A=new c("error")).error(T)}return new u(A,M.type||"string",M.mimeType)},generateAsync:function(N,A){return this.generateInternalStream(N).accumulate(A)},generateNodeStream:function(N,A){return(N=N||{}).type||(N.type="nodebuffer"),this.generateInternalStream(N).toNodejsStream(A)}};r.exports=E},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var s=n("./DataReader");function o(l){s.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,s),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),h=l.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===h)return p-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&h===p[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 s=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 s.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 s=n("./Uint8ArrayReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),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 s=n("./DataReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),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 s=n("./ArrayReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),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 s=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(h){var p=s.getTypeOf(h);return s.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new u(h):o.uint8array?new d(s.transformTo("uint8array",h)):new l(s.transformTo("array",h)):new c(h)}},{"../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 s=n("./GenericWorker"),o=n("../utils");function l(c){s.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,s),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 s=n("./GenericWorker"),o=n("../crc32");function l(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,s),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 s=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.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 s=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=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.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,s.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.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 s(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}s.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=s},{}],29:[function(n,r,i){var s=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),h=null;if(u.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(x,y){return new d.Promise(function(b,v){var S=[],k=x._internalType,E=x._outputType,N=x._mimeType;x.on("data",function(A,M){S.push(A),y&&y(M)}).on("error",function(A){S=[],v(A)}).on("end",function(){try{var A=(function(M,P,T){switch(M){case"blob":return s.newBlob(s.transformTo("arraybuffer",P),T);case"base64":return c.encode(P);default:return s.transformTo(M,P)}})(E,(function(M,P){var T,j=0,z=null,F=0;for(T=0;T<P.length;T++)F+=P[T].length;switch(M){case"string":return P.join("");case"array":return Array.prototype.concat.apply([],P);case"uint8array":for(z=new Uint8Array(F),T=0;T<P.length;T++)z.set(P[T],j),j+=P[T].length;return z;case"nodebuffer":return Buffer.concat(P);default:throw new Error("concat : unsupported type '"+M+"'")}})(k,S),N);b(A)}catch(M){v(M)}S=[]}).resume()})}function m(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,s.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(S){this._worker=new l("error"),this._worker.error(S)}}m.prototype={accumulate:function(x){return p(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(){s.delay(y,arguments,b)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=m},{"../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 s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),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 s=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 h(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}i.utf8encode=function(m){return o.nodebuffer?l.newBufferFrom(m,"utf-8"):(function(x){var y,b,v,S,k,E=x.length,N=0;for(S=0;S<E;S++)(64512&(b=x.charCodeAt(S)))==55296&&S+1<E&&(64512&(v=x.charCodeAt(S+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),S++),N+=b<128?1:b<2048?2:b<65536?3:4;for(y=o.uint8array?new Uint8Array(N):new Array(N),S=k=0;k<N;S++)(64512&(b=x.charCodeAt(S)))==55296&&S+1<E&&(64512&(v=x.charCodeAt(S+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),S++),b<128?y[k++]=b:(b<2048?y[k++]=192|b>>>6:(b<65536?y[k++]=224|b>>>12:(y[k++]=240|b>>>18,y[k++]=128|b>>>12&63),y[k++]=128|b>>>6&63),y[k++]=128|63&b);return y})(m)},i.utf8decode=function(m){return o.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var y,b,v,S,k=x.length,E=new Array(2*k);for(y=b=0;y<k;)if((v=x[y++])<128)E[b++]=v;else if(4<(S=u[v]))E[b++]=65533,y+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&y<k;)v=v<<6|63&x[y++],S--;1<S?E[b++]=65533:v<65536?E[b++]=v:(v-=65536,E[b++]=55296|v>>10&1023,E[b++]=56320|1023&v)}return E.length!==b&&(E.subarray?E=E.subarray(0,b):E.length=b),s.applyFromCharCode(E)})(m=s.transformTo(o.uint8array?"uint8array":"array",m))},s.inherits(h,c),h.prototype.processChunk=function(m){var x=s.transformTo(o.uint8array?"uint8array":"array",m.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(S,k){var E;for((k=k||S.length)>S.length&&(k=S.length),E=k-1;0<=E&&(192&S[E])==128;)E--;return E<0||E===0?k:E+u[S[E]]>k?E:k})(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:m.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,s.inherits(p,c),p.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var s=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 h={stringifyByChunk:function(y,b,v){var S=[],k=0,E=y.length;if(E<=v)return String.fromCharCode.apply(null,y);for(;k<E;)b==="array"||b==="nodebuffer"?S.push(String.fromCharCode.apply(null,y.slice(k,Math.min(k+v,E)))):S.push(String.fromCharCode.apply(null,y.subarray(k,Math.min(k+v,E)))),k+=v;return S.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 s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function p(y){var b=65536,v=i.getTypeOf(y),S=!0;if(v==="uint8array"?S=h.applyCanBeUsed.uint8array:v==="nodebuffer"&&(S=h.applyCanBeUsed.nodebuffer),S)for(;1<b;)try{return h.stringifyByChunk(y,v,b)}catch{b=Math.floor(b/2)}return h.stringifyByChar(y)}function m(y,b){for(var v=0;v<y.length;v++)b[v]=y[v];return b}i.applyFromCharCode=p;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:p,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 p(new Uint8Array(y))},array:function(y){return m(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:p,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},x.nodebuffer={string:p,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(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=[],S=0;S<b.length;S++){var k=b[S];k==="."||k===""&&S!==0&&S!==b.length-1||(k===".."?v.pop():v.push(k))}return v.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":s.nodebuffer&&l.isBuffer(y)?"nodebuffer":s.uint8array&&y instanceof Uint8Array?"uint8array":s.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!s[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,S="";for(v=0;v<(y||"").length;v++)S+="\\x"+((b=y.charCodeAt(v))<16?"0":"")+b.toString(16).toUpperCase();return S},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,S,k){return c.Promise.resolve(b).then(function(E){return s.blob&&(E instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(E))!==-1)&&typeof FileReader<"u"?new c.Promise(function(N,A){var M=new FileReader;M.onload=function(P){N(P.target.result)},M.onerror=function(P){A(P.target.error)},M.readAsArrayBuffer(E)}):E}).then(function(E){var N=i.getTypeOf(E);return N?(N==="arraybuffer"?E=i.transformTo("uint8array",E):N==="string"&&(k?E=o.decode(E):v&&S!==!0&&(E=(function(A){return d(A,s.uint8array?new Uint8Array(A.length):new Array(A.length))})(E))),E):c.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var s=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(p)+", expected "+o.pretty(h)+")")}},isSignature:function(h,p){var m=this.reader.index;this.reader.setIndex(h);var x=this.reader.readString(4)===p;return this.reader.setIndex(m),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 h=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",m=o.transformTo(p,h);this.zipComment=this.loadOptions.decodeFileName(m)},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 h,p,m,x=this.zip64EndOfCentralSize-44;0<x;)h=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[h]={id:h,length:p,value:m}},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 h,p;for(h=0;h<this.files.length;h++)p=this.files[h],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);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 h=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(h<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(h);var p=h;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,(h=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(h),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 m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var x=p-m;if(0<x)this.isSignature(p,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(h){this.reader=s(h)},load:function(h){this.prepareReader(h),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 s=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),h=n("./support");function p(m,x){this.options=m,this.loadOptions=x}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var x,y;if(m.skip(22),this.fileNameLength=m.readInt(2),y=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.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,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var x=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(x),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var x,y,b,v=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<v;)x=m.readInt(2),y=m.readInt(2),b=m.readData(y),this.extraFields[x]={id:x,length:y,value:b};m.setIndex(v)},handleUTF8:function(){var m=h.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(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var v=o.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=s(m.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var x=s(m.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function s(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");s.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 S=!this._dataBinary;S&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!S&&v&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(k){(y=new d("error")).error(k)}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 h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<h.length;m++)s.prototype[h[m]]=p;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var o,l,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var u=0,d=new c(x),h=s.document.createTextNode("");d.observe(h,{characterData:!0}),o=function(){h.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)o="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var y=s.document.createElement("script");y.onreadystatechange=function(){x(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},s.document.documentElement.appendChild(y)}:function(){setTimeout(x,0)};else{var p=new s.MessageChannel;p.port1.onmessage=x,o=function(){p.port2.postMessage(0)}}var m=[];function x(){var y,b;l=!0;for(var v=m.length;v;){for(b=m,m=[],y=-1;++y<v;)b[y]();v=m.length}l=!1}r.exports=function(y){m.push(y)!==1||l||o()}}).call(this,typeof Gw<"u"?Gw:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(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 p(v,S,k){this.promise=v,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}function m(v,S,k){s(function(){var E;try{E=S(k)}catch(N){return l.reject(v,N)}E===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,E)})}function x(v){var S=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof S=="function")return function(){S.apply(v,arguments)}}function y(v,S){var k=!1;function E(M){k||(k=!0,l.reject(v,M))}function N(M){k||(k=!0,l.resolve(v,M))}var A=b(function(){S(N,E)});A.status==="error"&&E(A.value)}function b(v,S){var k={};try{k.value=v(S),k.status="success"}catch(E){k.status="error",k.value=E}return k}(r.exports=h).prototype.finally=function(v){if(typeof v!="function")return this;var S=this.constructor;return this.then(function(k){return S.resolve(v()).then(function(){return k})},function(k){return S.resolve(v()).then(function(){throw k})})},h.prototype.catch=function(v){return this.then(null,v)},h.prototype.then=function(v,S){if(typeof v!="function"&&this.state===u||typeof S!="function"&&this.state===c)return this;var k=new this.constructor(o);return this.state!==d?m(k,this.state===u?v:S,this.outcome):this.queue.push(new p(k,v,S)),k},p.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},p.prototype.otherCallFulfilled=function(v){m(this.promise,this.onFulfilled,v)},p.prototype.callRejected=function(v){l.reject(this.promise,v)},p.prototype.otherCallRejected=function(v){m(this.promise,this.onRejected,v)},l.resolve=function(v,S){var k=b(x,S);if(k.status==="error")return l.reject(v,k.value);var E=k.value;if(E)y(v,E);else{v.state=u,v.outcome=S;for(var N=-1,A=v.queue.length;++N<A;)v.queue[N].callFulfilled(S)}return v},l.reject=function(v,S){v.state=c,v.outcome=S;for(var k=-1,E=v.queue.length;++k<E;)v.queue[k].callRejected(S);return v},h.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},h.reject=function(v){var S=new this(o);return l.reject(S,v)},h.all=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=v.length,E=!1;if(!k)return this.resolve([]);for(var N=new Array(k),A=0,M=-1,P=new this(o);++M<k;)T(v[M],M);return P;function T(j,z){S.resolve(j).then(function(F){N[z]=F,++A!==k||E||(E=!0,l.resolve(P,N))},function(F){E||(E=!0,l.reject(P,F))})}},h.race=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=v.length,E=!1;if(!k)return this.resolve([]);for(var N=-1,A=new this(o);++N<k;)M=v[N],S.resolve(M).then(function(P){E||(E=!0,l.resolve(A,P))},function(P){E||(E=!0,l.reject(A,P))});var M;return A}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,h=0,p=-1,m=0,x=8;function y(v){if(!(this instanceof y))return new y(v);this.options=o.assign({level:p,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},v||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var k=s.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(k!==h)throw new Error(c[k]);if(S.header&&s.deflateSetHeader(this.strm,S.header),S.dictionary){var E;if(E=typeof S.dictionary=="string"?l.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(k=s.deflateSetDictionary(this.strm,E))!==h)throw new Error(c[k]);this._dict_set=!0}}function b(v,S){var k=new y(S);if(k.push(v,!0),k.err)throw k.msg||c[k.err];return k.result}y.prototype.push=function(v,S){var k,E,N=this.strm,A=this.options.chunkSize;if(this.ended)return!1;E=S===~~S?S:S===!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(A),N.next_out=0,N.avail_out=A),(k=s.deflate(N,E))!==1&&k!==h)return this.onEnd(k),!(this.ended=!0);N.avail_out!==0&&(N.avail_in!==0||E!==4&&E!==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)&&k!==1);return E===4?(k=s.deflateEnd(this.strm),this.onEnd(k),this.ended=!0,k===h):E!==2||(this.onEnd(h),!(N.avail_out=0))},y.prototype.onData=function(v){this.chunks.push(v)},y.prototype.onEnd=function(v){v===h&&(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,S){return(S=S||{}).raw=!0,b(v,S)},i.gzip=function(v,S){return(S=S||{}).gzip=!0,b(v,S)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var s=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),h=n("./zlib/gzheader"),p=Object.prototype.toString;function m(y){if(!(this instanceof m))return new m(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=s.inflateInit2(this.strm,b.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function x(y,b){var v=new m(b);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}m.prototype.push=function(y,b){var v,S,k,E,N,A,M=this.strm,P=this.options.chunkSize,T=this.options.dictionary,j=!1;if(this.ended)return!1;S=b===~~b?b:b===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?M.input=l.binstring2buf(y):p.call(y)==="[object ArrayBuffer]"?M.input=new Uint8Array(y):M.input=y,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new o.Buf8(P),M.next_out=0,M.avail_out=P),(v=s.inflate(M,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&T&&(A=typeof T=="string"?l.string2buf(T):p.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,v=s.inflateSetDictionary(this.strm,A)),v===c.Z_BUF_ERROR&&j===!0&&(v=c.Z_OK,j=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);M.next_out&&(M.avail_out!==0&&v!==c.Z_STREAM_END&&(M.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(k=l.utf8border(M.output,M.next_out),E=M.next_out-k,N=l.buf2string(M.output,k),M.next_out=E,M.avail_out=P-E,E&&o.arraySet(M.output,M.output,k,E,0),this.onData(N)):this.onData(o.shrinkBuf(M.output,M.next_out)))),M.avail_in===0&&M.avail_out===0&&(j=!0)}while((0<M.avail_in||M.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(v=s.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(M.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.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=m,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 s=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 h in d)d.hasOwnProperty(h)&&(c[h]=d[h])}}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,h,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),p);else for(var m=0;m<h;m++)c[p+m]=u[d+m]},flattenChunks:function(c){var u,d,h,p,m,x;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(x=new Uint8Array(h),u=p=0,d=c.length;u<d;u++)m=c[u],x.set(m,p),p+=m.length;return x}},l={arraySet:function(c,u,d,h,p){for(var m=0;m<h;m++)c[p+m]=u[d+m]},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(s)},{}],42:[function(n,r,i){var s=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 s.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(h,p){if(p<65537&&(h.subarray&&l||!h.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(h,p));for(var m="",x=0;x<p;x++)m+=String.fromCharCode(h[x]);return m}c[254]=c[254]=1,i.string2buf=function(h){var p,m,x,y,b,v=h.length,S=0;for(y=0;y<v;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),y++),S+=m<128?1:m<2048?2:m<65536?3:4;for(p=new s.Buf8(S),y=b=0;b<S;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),y++),m<128?p[b++]=m:(m<2048?p[b++]=192|m>>>6:(m<65536?p[b++]=224|m>>>12:(p[b++]=240|m>>>18,p[b++]=128|m>>>12&63),p[b++]=128|m>>>6&63),p[b++]=128|63&m);return p},i.buf2binstring=function(h){return d(h,h.length)},i.binstring2buf=function(h){for(var p=new s.Buf8(h.length),m=0,x=p.length;m<x;m++)p[m]=h.charCodeAt(m);return p},i.buf2string=function(h,p){var m,x,y,b,v=p||h.length,S=new Array(2*v);for(m=x=0;m<v;)if((y=h[m++])<128)S[x++]=y;else if(4<(b=c[y]))S[x++]=65533,m+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&m<v;)y=y<<6|63&h[m++],b--;1<b?S[x++]=65533:y<65536?S[x++]=y:(y-=65536,S[x++]=55296|y>>10&1023,S[x++]=56320|1023&y)}return d(S,x)},i.utf8border=function(h,p){var m;for((p=p||h.length)>h.length&&(p=h.length),m=p-1;0<=m&&(192&h[m])==128;)m--;return m<0||m===0?p:m+c[h[m]]>p?m:p}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,o,l,c){for(var u=65535&s|0,d=s>>>16&65535|0,h=0;l!==0;){for(l-=h=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--h;);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 s=(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=s,h=u+c;o^=-1;for(var p=u;p<h;p++)o=o>>>8^d[255&(o^l[p])];return-1^o}},{}],46:[function(n,r,i){var s,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),h=0,p=4,m=0,x=-2,y=-1,b=4,v=2,S=8,k=9,E=286,N=30,A=19,M=2*E+1,P=15,T=3,j=258,z=j+T+1,F=42,$=113,D=1,H=2,q=3,I=4;function K(G,Y){return G.msg=d[Y],Y}function Z(G){return(G<<1)-(4<G?9:0)}function se(G){for(var Y=G.length;0<=--Y;)G[Y]=0}function V(G){var Y=G.state,ue=Y.pending;ue>G.avail_out&&(ue=G.avail_out),ue!==0&&(o.arraySet(G.output,Y.pending_buf,Y.pending_out,ue,G.next_out),G.next_out+=ue,Y.pending_out+=ue,G.total_out+=ue,G.avail_out-=ue,Y.pending-=ue,Y.pending===0&&(Y.pending_out=0))}function W(G,Y){l._tr_flush_block(G,0<=G.block_start?G.block_start:-1,G.strstart-G.block_start,Y),G.block_start=G.strstart,V(G.strm)}function ie(G,Y){G.pending_buf[G.pending++]=Y}function J(G,Y){G.pending_buf[G.pending++]=Y>>>8&255,G.pending_buf[G.pending++]=255&Y}function pe(G,Y){var ue,B,ee=G.max_chain_length,Q=G.strstart,le=G.prev_length,he=G.nice_match,te=G.strstart>G.w_size-z?G.strstart-(G.w_size-z):0,U=G.window,L=G.w_mask,X=G.prev,ge=G.strstart+j,_e=U[Q+le-1],Ee=U[Q+le];G.prev_length>=G.good_match&&(ee>>=2),he>G.lookahead&&(he=G.lookahead);do if(U[(ue=Y)+le]===Ee&&U[ue+le-1]===_e&&U[ue]===U[Q]&&U[++ue]===U[Q+1]){Q+=2,ue++;do;while(U[++Q]===U[++ue]&&U[++Q]===U[++ue]&&U[++Q]===U[++ue]&&U[++Q]===U[++ue]&&U[++Q]===U[++ue]&&U[++Q]===U[++ue]&&U[++Q]===U[++ue]&&U[++Q]===U[++ue]&&Q<ge);if(B=j-(ge-Q),Q=ge-j,le<B){if(G.match_start=Y,he<=(le=B))break;_e=U[Q+le-1],Ee=U[Q+le]}}while((Y=X[Y&L])>te&&--ee!=0);return le<=G.lookahead?le:G.lookahead}function fe(G){var Y,ue,B,ee,Q,le,he,te,U,L,X=G.w_size;do{if(ee=G.window_size-G.lookahead-G.strstart,G.strstart>=X+(X-z)){for(o.arraySet(G.window,G.window,X,X,0),G.match_start-=X,G.strstart-=X,G.block_start-=X,Y=ue=G.hash_size;B=G.head[--Y],G.head[Y]=X<=B?B-X:0,--ue;);for(Y=ue=X;B=G.prev[--Y],G.prev[Y]=X<=B?B-X:0,--ue;);ee+=X}if(G.strm.avail_in===0)break;if(le=G.strm,he=G.window,te=G.strstart+G.lookahead,U=ee,L=void 0,L=le.avail_in,U<L&&(L=U),ue=L===0?0:(le.avail_in-=L,o.arraySet(he,le.input,le.next_in,L,te),le.state.wrap===1?le.adler=c(le.adler,he,L,te):le.state.wrap===2&&(le.adler=u(le.adler,he,L,te)),le.next_in+=L,le.total_in+=L,L),G.lookahead+=ue,G.lookahead+G.insert>=T)for(Q=G.strstart-G.insert,G.ins_h=G.window[Q],G.ins_h=(G.ins_h<<G.hash_shift^G.window[Q+1])&G.hash_mask;G.insert&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[Q+T-1])&G.hash_mask,G.prev[Q&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=Q,Q++,G.insert--,!(G.lookahead+G.insert<T)););}while(G.lookahead<z&&G.strm.avail_in!==0)}function ve(G,Y){for(var ue,B;;){if(G.lookahead<z){if(fe(G),G.lookahead<z&&Y===h)return D;if(G.lookahead===0)break}if(ue=0,G.lookahead>=T&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+T-1])&G.hash_mask,ue=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),ue!==0&&G.strstart-ue<=G.w_size-z&&(G.match_length=pe(G,ue)),G.match_length>=T)if(B=l._tr_tally(G,G.strstart-G.match_start,G.match_length-T),G.lookahead-=G.match_length,G.match_length<=G.max_lazy_match&&G.lookahead>=T){for(G.match_length--;G.strstart++,G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+T-1])&G.hash_mask,ue=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart,--G.match_length!=0;);G.strstart++}else G.strstart+=G.match_length,G.match_length=0,G.ins_h=G.window[G.strstart],G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+1])&G.hash_mask;else B=l._tr_tally(G,0,G.window[G.strstart]),G.lookahead--,G.strstart++;if(B&&(W(G,!1),G.strm.avail_out===0))return D}return G.insert=G.strstart<T-1?G.strstart:T-1,Y===p?(W(G,!0),G.strm.avail_out===0?q:I):G.last_lit&&(W(G,!1),G.strm.avail_out===0)?D:H}function Le(G,Y){for(var ue,B,ee;;){if(G.lookahead<z){if(fe(G),G.lookahead<z&&Y===h)return D;if(G.lookahead===0)break}if(ue=0,G.lookahead>=T&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+T-1])&G.hash_mask,ue=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),G.prev_length=G.match_length,G.prev_match=G.match_start,G.match_length=T-1,ue!==0&&G.prev_length<G.max_lazy_match&&G.strstart-ue<=G.w_size-z&&(G.match_length=pe(G,ue),G.match_length<=5&&(G.strategy===1||G.match_length===T&&4096<G.strstart-G.match_start)&&(G.match_length=T-1)),G.prev_length>=T&&G.match_length<=G.prev_length){for(ee=G.strstart+G.lookahead-T,B=l._tr_tally(G,G.strstart-1-G.prev_match,G.prev_length-T),G.lookahead-=G.prev_length-1,G.prev_length-=2;++G.strstart<=ee&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+T-1])&G.hash_mask,ue=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),--G.prev_length!=0;);if(G.match_available=0,G.match_length=T-1,G.strstart++,B&&(W(G,!1),G.strm.avail_out===0))return D}else if(G.match_available){if((B=l._tr_tally(G,0,G.window[G.strstart-1]))&&W(G,!1),G.strstart++,G.lookahead--,G.strm.avail_out===0)return D}else G.match_available=1,G.strstart++,G.lookahead--}return G.match_available&&(B=l._tr_tally(G,0,G.window[G.strstart-1]),G.match_available=0),G.insert=G.strstart<T-1?G.strstart:T-1,Y===p?(W(G,!0),G.strm.avail_out===0?q:I):G.last_lit&&(W(G,!1),G.strm.avail_out===0)?D:H}function de(G,Y,ue,B,ee){this.good_length=G,this.max_lazy=Y,this.nice_length=ue,this.max_chain=B,this.func=ee}function ce(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=S,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*M),this.dyn_dtree=new o.Buf16(2*(2*N+1)),this.bl_tree=new o.Buf16(2*(2*A+1)),se(this.dyn_ltree),se(this.dyn_dtree),se(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(P+1),this.heap=new o.Buf16(2*E+1),se(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*E+1),se(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 Ae(G){var Y;return G&&G.state?(G.total_in=G.total_out=0,G.data_type=v,(Y=G.state).pending=0,Y.pending_out=0,Y.wrap<0&&(Y.wrap=-Y.wrap),Y.status=Y.wrap?F:$,G.adler=Y.wrap===2?0:1,Y.last_flush=h,l._tr_init(Y),m):K(G,x)}function re(G){var Y=Ae(G);return Y===m&&(function(ue){ue.window_size=2*ue.w_size,se(ue.head),ue.max_lazy_match=s[ue.level].max_lazy,ue.good_match=s[ue.level].good_length,ue.nice_match=s[ue.level].nice_length,ue.max_chain_length=s[ue.level].max_chain,ue.strstart=0,ue.block_start=0,ue.lookahead=0,ue.insert=0,ue.match_length=ue.prev_length=T-1,ue.match_available=0,ue.ins_h=0})(G.state),Y}function Ie(G,Y,ue,B,ee,Q){if(!G)return x;var le=1;if(Y===y&&(Y=6),B<0?(le=0,B=-B):15<B&&(le=2,B-=16),ee<1||k<ee||ue!==S||B<8||15<B||Y<0||9<Y||Q<0||b<Q)return K(G,x);B===8&&(B=9);var he=new ce;return(G.state=he).strm=G,he.wrap=le,he.gzhead=null,he.w_bits=B,he.w_size=1<<he.w_bits,he.w_mask=he.w_size-1,he.hash_bits=ee+7,he.hash_size=1<<he.hash_bits,he.hash_mask=he.hash_size-1,he.hash_shift=~~((he.hash_bits+T-1)/T),he.window=new o.Buf8(2*he.w_size),he.head=new o.Buf16(he.hash_size),he.prev=new o.Buf16(he.w_size),he.lit_bufsize=1<<ee+6,he.pending_buf_size=4*he.lit_bufsize,he.pending_buf=new o.Buf8(he.pending_buf_size),he.d_buf=1*he.lit_bufsize,he.l_buf=3*he.lit_bufsize,he.level=Y,he.strategy=Q,he.method=ue,re(G)}s=[new de(0,0,0,0,function(G,Y){var ue=65535;for(ue>G.pending_buf_size-5&&(ue=G.pending_buf_size-5);;){if(G.lookahead<=1){if(fe(G),G.lookahead===0&&Y===h)return D;if(G.lookahead===0)break}G.strstart+=G.lookahead,G.lookahead=0;var B=G.block_start+ue;if((G.strstart===0||G.strstart>=B)&&(G.lookahead=G.strstart-B,G.strstart=B,W(G,!1),G.strm.avail_out===0)||G.strstart-G.block_start>=G.w_size-z&&(W(G,!1),G.strm.avail_out===0))return D}return G.insert=0,Y===p?(W(G,!0),G.strm.avail_out===0?q:I):(G.strstart>G.block_start&&(W(G,!1),G.strm.avail_out),D)}),new de(4,4,8,4,ve),new de(4,5,16,8,ve),new de(4,6,32,32,ve),new de(4,4,16,16,Le),new de(8,16,32,32,Le),new de(8,16,128,128,Le),new de(8,32,128,256,Le),new de(32,128,258,1024,Le),new de(32,258,258,4096,Le)],i.deflateInit=function(G,Y){return Ie(G,Y,S,15,8,0)},i.deflateInit2=Ie,i.deflateReset=re,i.deflateResetKeep=Ae,i.deflateSetHeader=function(G,Y){return G&&G.state?G.state.wrap!==2?x:(G.state.gzhead=Y,m):x},i.deflate=function(G,Y){var ue,B,ee,Q;if(!G||!G.state||5<Y||Y<0)return G?K(G,x):x;if(B=G.state,!G.output||!G.input&&G.avail_in!==0||B.status===666&&Y!==p)return K(G,G.avail_out===0?-5:x);if(B.strm=G,ue=B.last_flush,B.last_flush=Y,B.status===F)if(B.wrap===2)G.adler=0,ie(B,31),ie(B,139),ie(B,8),B.gzhead?(ie(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(B.gzhead.extra?4:0)+(B.gzhead.name?8:0)+(B.gzhead.comment?16:0)),ie(B,255&B.gzhead.time),ie(B,B.gzhead.time>>8&255),ie(B,B.gzhead.time>>16&255),ie(B,B.gzhead.time>>24&255),ie(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ie(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(ie(B,255&B.gzhead.extra.length),ie(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(G.adler=u(G.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(ie(B,0),ie(B,0),ie(B,0),ie(B,0),ie(B,0),ie(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ie(B,3),B.status=$);else{var le=S+(B.w_bits-8<<4)<<8;le|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(le|=32),le+=31-le%31,B.status=$,J(B,le),B.strstart!==0&&(J(B,G.adler>>>16),J(B,65535&G.adler)),G.adler=1}if(B.status===69)if(B.gzhead.extra){for(ee=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>ee&&(G.adler=u(G.adler,B.pending_buf,B.pending-ee,ee)),V(G),ee=B.pending,B.pending!==B.pending_buf_size));)ie(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>ee&&(G.adler=u(G.adler,B.pending_buf,B.pending-ee,ee)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){ee=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>ee&&(G.adler=u(G.adler,B.pending_buf,B.pending-ee,ee)),V(G),ee=B.pending,B.pending===B.pending_buf_size)){Q=1;break}Q=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,ie(B,Q)}while(Q!==0);B.gzhead.hcrc&&B.pending>ee&&(G.adler=u(G.adler,B.pending_buf,B.pending-ee,ee)),Q===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){ee=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>ee&&(G.adler=u(G.adler,B.pending_buf,B.pending-ee,ee)),V(G),ee=B.pending,B.pending===B.pending_buf_size)){Q=1;break}Q=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,ie(B,Q)}while(Q!==0);B.gzhead.hcrc&&B.pending>ee&&(G.adler=u(G.adler,B.pending_buf,B.pending-ee,ee)),Q===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&V(G),B.pending+2<=B.pending_buf_size&&(ie(B,255&G.adler),ie(B,G.adler>>8&255),G.adler=0,B.status=$)):B.status=$),B.pending!==0){if(V(G),G.avail_out===0)return B.last_flush=-1,m}else if(G.avail_in===0&&Z(Y)<=Z(ue)&&Y!==p)return K(G,-5);if(B.status===666&&G.avail_in!==0)return K(G,-5);if(G.avail_in!==0||B.lookahead!==0||Y!==h&&B.status!==666){var he=B.strategy===2?(function(te,U){for(var L;;){if(te.lookahead===0&&(fe(te),te.lookahead===0)){if(U===h)return D;break}if(te.match_length=0,L=l._tr_tally(te,0,te.window[te.strstart]),te.lookahead--,te.strstart++,L&&(W(te,!1),te.strm.avail_out===0))return D}return te.insert=0,U===p?(W(te,!0),te.strm.avail_out===0?q:I):te.last_lit&&(W(te,!1),te.strm.avail_out===0)?D:H})(B,Y):B.strategy===3?(function(te,U){for(var L,X,ge,_e,Ee=te.window;;){if(te.lookahead<=j){if(fe(te),te.lookahead<=j&&U===h)return D;if(te.lookahead===0)break}if(te.match_length=0,te.lookahead>=T&&0<te.strstart&&(X=Ee[ge=te.strstart-1])===Ee[++ge]&&X===Ee[++ge]&&X===Ee[++ge]){_e=te.strstart+j;do;while(X===Ee[++ge]&&X===Ee[++ge]&&X===Ee[++ge]&&X===Ee[++ge]&&X===Ee[++ge]&&X===Ee[++ge]&&X===Ee[++ge]&&X===Ee[++ge]&&ge<_e);te.match_length=j-(_e-ge),te.match_length>te.lookahead&&(te.match_length=te.lookahead)}if(te.match_length>=T?(L=l._tr_tally(te,1,te.match_length-T),te.lookahead-=te.match_length,te.strstart+=te.match_length,te.match_length=0):(L=l._tr_tally(te,0,te.window[te.strstart]),te.lookahead--,te.strstart++),L&&(W(te,!1),te.strm.avail_out===0))return D}return te.insert=0,U===p?(W(te,!0),te.strm.avail_out===0?q:I):te.last_lit&&(W(te,!1),te.strm.avail_out===0)?D:H})(B,Y):s[B.level].func(B,Y);if(he!==q&&he!==I||(B.status=666),he===D||he===q)return G.avail_out===0&&(B.last_flush=-1),m;if(he===H&&(Y===1?l._tr_align(B):Y!==5&&(l._tr_stored_block(B,0,0,!1),Y===3&&(se(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),V(G),G.avail_out===0))return B.last_flush=-1,m}return Y!==p?m:B.wrap<=0?1:(B.wrap===2?(ie(B,255&G.adler),ie(B,G.adler>>8&255),ie(B,G.adler>>16&255),ie(B,G.adler>>24&255),ie(B,255&G.total_in),ie(B,G.total_in>>8&255),ie(B,G.total_in>>16&255),ie(B,G.total_in>>24&255)):(J(B,G.adler>>>16),J(B,65535&G.adler)),V(G),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?m:1)},i.deflateEnd=function(G){var Y;return G&&G.state?(Y=G.state.status)!==F&&Y!==69&&Y!==73&&Y!==91&&Y!==103&&Y!==$&&Y!==666?K(G,x):(G.state=null,Y===$?K(G,-3):m):x},i.deflateSetDictionary=function(G,Y){var ue,B,ee,Q,le,he,te,U,L=Y.length;if(!G||!G.state||(Q=(ue=G.state).wrap)===2||Q===1&&ue.status!==F||ue.lookahead)return x;for(Q===1&&(G.adler=c(G.adler,Y,L,0)),ue.wrap=0,L>=ue.w_size&&(Q===0&&(se(ue.head),ue.strstart=0,ue.block_start=0,ue.insert=0),U=new o.Buf8(ue.w_size),o.arraySet(U,Y,L-ue.w_size,ue.w_size,0),Y=U,L=ue.w_size),le=G.avail_in,he=G.next_in,te=G.input,G.avail_in=L,G.next_in=0,G.input=Y,fe(ue);ue.lookahead>=T;){for(B=ue.strstart,ee=ue.lookahead-(T-1);ue.ins_h=(ue.ins_h<<ue.hash_shift^ue.window[B+T-1])&ue.hash_mask,ue.prev[B&ue.w_mask]=ue.head[ue.ins_h],ue.head[ue.ins_h]=B,B++,--ee;);ue.strstart=B,ue.lookahead=T-1,fe(ue)}return ue.strstart+=ue.lookahead,ue.block_start=ue.strstart,ue.insert=ue.lookahead,ue.lookahead=0,ue.match_length=ue.prev_length=T-1,ue.match_available=0,G.next_in=he,G.input=te,G.avail_in=le,ue.wrap=Q,m},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(s,o){var l,c,u,d,h,p,m,x,y,b,v,S,k,E,N,A,M,P,T,j,z,F,$,D,H;l=s.state,c=s.next_in,D=s.input,u=c+(s.avail_in-5),d=s.next_out,H=s.output,h=d-(o-s.avail_out),p=d+(s.avail_out-257),m=l.dmax,x=l.wsize,y=l.whave,b=l.wnext,v=l.window,S=l.hold,k=l.bits,E=l.lencode,N=l.distcode,A=(1<<l.lenbits)-1,M=(1<<l.distbits)-1;e:do{k<15&&(S+=D[c++]<<k,k+=8,S+=D[c++]<<k,k+=8),P=E[S&A];t:for(;;){if(S>>>=T=P>>>24,k-=T,(T=P>>>16&255)===0)H[d++]=65535&P;else{if(!(16&T)){if((64&T)==0){P=E[(65535&P)+(S&(1<<T)-1)];continue t}if(32&T){l.mode=12;break e}s.msg="invalid literal/length code",l.mode=30;break e}j=65535&P,(T&=15)&&(k<T&&(S+=D[c++]<<k,k+=8),j+=S&(1<<T)-1,S>>>=T,k-=T),k<15&&(S+=D[c++]<<k,k+=8,S+=D[c++]<<k,k+=8),P=N[S&M];n:for(;;){if(S>>>=T=P>>>24,k-=T,!(16&(T=P>>>16&255))){if((64&T)==0){P=N[(65535&P)+(S&(1<<T)-1)];continue n}s.msg="invalid distance code",l.mode=30;break e}if(z=65535&P,k<(T&=15)&&(S+=D[c++]<<k,(k+=8)<T&&(S+=D[c++]<<k,k+=8)),m<(z+=S&(1<<T)-1)){s.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=T,k-=T,(T=d-h)<z){if(y<(T=z-T)&&l.sane){s.msg="invalid distance too far back",l.mode=30;break e}if($=v,(F=0)===b){if(F+=x-T,T<j){for(j-=T;H[d++]=v[F++],--T;);F=d-z,$=H}}else if(b<T){if(F+=x+b-T,(T-=b)<j){for(j-=T;H[d++]=v[F++],--T;);if(F=0,b<j){for(j-=T=b;H[d++]=v[F++],--T;);F=d-z,$=H}}}else if(F+=b-T,T<j){for(j-=T;H[d++]=v[F++],--T;);F=d-z,$=H}for(;2<j;)H[d++]=$[F++],H[d++]=$[F++],H[d++]=$[F++],j-=3;j&&(H[d++]=$[F++],1<j&&(H[d++]=$[F++]))}else{for(F=d-z;H[d++]=H[F++],H[d++]=H[F++],H[d++]=H[F++],2<(j-=3););j&&(H[d++]=H[F++],1<j&&(H[d++]=H[F++]))}break}}break}}while(c<u&&d<p);c-=j=k>>3,S&=(1<<(k-=j<<3))-1,s.next_in=c,s.next_out=d,s.avail_in=c<u?u-c+5:5-(c-u),s.avail_out=d<p?p-d+257:257-(d-p),l.hold=S,l.bits=k}},{}],49:[function(n,r,i){var s=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,h=2,p=0,m=-2,x=1,y=852,b=592;function v(F){return(F>>>24&255)+(F>>>8&65280)+((65280&F)<<8)+((255&F)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function k(F){var $;return F&&F.state?($=F.state,F.total_in=F.total_out=$.total=0,F.msg="",$.wrap&&(F.adler=1&$.wrap),$.mode=x,$.last=0,$.havedict=0,$.dmax=32768,$.head=null,$.hold=0,$.bits=0,$.lencode=$.lendyn=new s.Buf32(y),$.distcode=$.distdyn=new s.Buf32(b),$.sane=1,$.back=-1,p):m}function E(F){var $;return F&&F.state?(($=F.state).wsize=0,$.whave=0,$.wnext=0,k(F)):m}function N(F,$){var D,H;return F&&F.state?(H=F.state,$<0?(D=0,$=-$):(D=1+($>>4),$<48&&($&=15)),$&&($<8||15<$)?m:(H.window!==null&&H.wbits!==$&&(H.window=null),H.wrap=D,H.wbits=$,E(F))):m}function A(F,$){var D,H;return F?(H=new S,(F.state=H).window=null,(D=N(F,$))!==p&&(F.state=null),D):m}var M,P,T=!0;function j(F){if(T){var $;for(M=new s.Buf32(512),P=new s.Buf32(32),$=0;$<144;)F.lens[$++]=8;for(;$<256;)F.lens[$++]=9;for(;$<280;)F.lens[$++]=7;for(;$<288;)F.lens[$++]=8;for(u(d,F.lens,0,288,M,0,F.work,{bits:9}),$=0;$<32;)F.lens[$++]=5;u(h,F.lens,0,32,P,0,F.work,{bits:5}),T=!1}F.lencode=M,F.lenbits=9,F.distcode=P,F.distbits=5}function z(F,$,D,H){var q,I=F.state;return I.window===null&&(I.wsize=1<<I.wbits,I.wnext=0,I.whave=0,I.window=new s.Buf8(I.wsize)),H>=I.wsize?(s.arraySet(I.window,$,D-I.wsize,I.wsize,0),I.wnext=0,I.whave=I.wsize):(H<(q=I.wsize-I.wnext)&&(q=H),s.arraySet(I.window,$,D-H,q,I.wnext),(H-=q)?(s.arraySet(I.window,$,D-H,H,0),I.wnext=H,I.whave=I.wsize):(I.wnext+=q,I.wnext===I.wsize&&(I.wnext=0),I.whave<I.wsize&&(I.whave+=q))),0}i.inflateReset=E,i.inflateReset2=N,i.inflateResetKeep=k,i.inflateInit=function(F){return A(F,15)},i.inflateInit2=A,i.inflate=function(F,$){var D,H,q,I,K,Z,se,V,W,ie,J,pe,fe,ve,Le,de,ce,Ae,re,Ie,G,Y,ue,B,ee=0,Q=new s.Buf8(4),le=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!F||!F.state||!F.output||!F.input&&F.avail_in!==0)return m;(D=F.state).mode===12&&(D.mode=13),K=F.next_out,q=F.output,se=F.avail_out,I=F.next_in,H=F.input,Z=F.avail_in,V=D.hold,W=D.bits,ie=Z,J=se,Y=p;e:for(;;)switch(D.mode){case x:if(D.wrap===0){D.mode=13;break}for(;W<16;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if(2&D.wrap&&V===35615){Q[D.check=0]=255&V,Q[1]=V>>>8&255,D.check=l(D.check,Q,2,0),W=V=0,D.mode=2;break}if(D.flags=0,D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&V)<<8)+(V>>8))%31){F.msg="incorrect header check",D.mode=30;break}if((15&V)!=8){F.msg="unknown compression method",D.mode=30;break}if(W-=4,G=8+(15&(V>>>=4)),D.wbits===0)D.wbits=G;else if(G>D.wbits){F.msg="invalid window size",D.mode=30;break}D.dmax=1<<G,F.adler=D.check=1,D.mode=512&V?10:12,W=V=0;break;case 2:for(;W<16;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if(D.flags=V,(255&D.flags)!=8){F.msg="unknown compression method",D.mode=30;break}if(57344&D.flags){F.msg="unknown header flags set",D.mode=30;break}D.head&&(D.head.text=V>>8&1),512&D.flags&&(Q[0]=255&V,Q[1]=V>>>8&255,D.check=l(D.check,Q,2,0)),W=V=0,D.mode=3;case 3:for(;W<32;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}D.head&&(D.head.time=V),512&D.flags&&(Q[0]=255&V,Q[1]=V>>>8&255,Q[2]=V>>>16&255,Q[3]=V>>>24&255,D.check=l(D.check,Q,4,0)),W=V=0,D.mode=4;case 4:for(;W<16;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}D.head&&(D.head.xflags=255&V,D.head.os=V>>8),512&D.flags&&(Q[0]=255&V,Q[1]=V>>>8&255,D.check=l(D.check,Q,2,0)),W=V=0,D.mode=5;case 5:if(1024&D.flags){for(;W<16;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}D.length=V,D.head&&(D.head.extra_len=V),512&D.flags&&(Q[0]=255&V,Q[1]=V>>>8&255,D.check=l(D.check,Q,2,0)),W=V=0}else D.head&&(D.head.extra=null);D.mode=6;case 6:if(1024&D.flags&&(Z<(pe=D.length)&&(pe=Z),pe&&(D.head&&(G=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Array(D.head.extra_len)),s.arraySet(D.head.extra,H,I,pe,G)),512&D.flags&&(D.check=l(D.check,H,pe,I)),Z-=pe,I+=pe,D.length-=pe),D.length))break e;D.length=0,D.mode=7;case 7:if(2048&D.flags){if(Z===0)break e;for(pe=0;G=H[I+pe++],D.head&&G&&D.length<65536&&(D.head.name+=String.fromCharCode(G)),G&&pe<Z;);if(512&D.flags&&(D.check=l(D.check,H,pe,I)),Z-=pe,I+=pe,G)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=8;case 8:if(4096&D.flags){if(Z===0)break e;for(pe=0;G=H[I+pe++],D.head&&G&&D.length<65536&&(D.head.comment+=String.fromCharCode(G)),G&&pe<Z;);if(512&D.flags&&(D.check=l(D.check,H,pe,I)),Z-=pe,I+=pe,G)break e}else D.head&&(D.head.comment=null);D.mode=9;case 9:if(512&D.flags){for(;W<16;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if(V!==(65535&D.check)){F.msg="header crc mismatch",D.mode=30;break}W=V=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),F.adler=D.check=0,D.mode=12;break;case 10:for(;W<32;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}F.adler=D.check=v(V),W=V=0,D.mode=11;case 11:if(D.havedict===0)return F.next_out=K,F.avail_out=se,F.next_in=I,F.avail_in=Z,D.hold=V,D.bits=W,2;F.adler=D.check=1,D.mode=12;case 12:if($===5||$===6)break e;case 13:if(D.last){V>>>=7&W,W-=7&W,D.mode=27;break}for(;W<3;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}switch(D.last=1&V,W-=1,3&(V>>>=1)){case 0:D.mode=14;break;case 1:if(j(D),D.mode=20,$!==6)break;V>>>=2,W-=2;break e;case 2:D.mode=17;break;case 3:F.msg="invalid block type",D.mode=30}V>>>=2,W-=2;break;case 14:for(V>>>=7&W,W-=7&W;W<32;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if((65535&V)!=(V>>>16^65535)){F.msg="invalid stored block lengths",D.mode=30;break}if(D.length=65535&V,W=V=0,D.mode=15,$===6)break e;case 15:D.mode=16;case 16:if(pe=D.length){if(Z<pe&&(pe=Z),se<pe&&(pe=se),pe===0)break e;s.arraySet(q,H,I,pe,K),Z-=pe,I+=pe,se-=pe,K+=pe,D.length-=pe;break}D.mode=12;break;case 17:for(;W<14;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if(D.nlen=257+(31&V),V>>>=5,W-=5,D.ndist=1+(31&V),V>>>=5,W-=5,D.ncode=4+(15&V),V>>>=4,W-=4,286<D.nlen||30<D.ndist){F.msg="too many length or distance symbols",D.mode=30;break}D.have=0,D.mode=18;case 18:for(;D.have<D.ncode;){for(;W<3;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}D.lens[le[D.have++]]=7&V,V>>>=3,W-=3}for(;D.have<19;)D.lens[le[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,ue={bits:D.lenbits},Y=u(0,D.lens,0,19,D.lencode,0,D.work,ue),D.lenbits=ue.bits,Y){F.msg="invalid code lengths set",D.mode=30;break}D.have=0,D.mode=19;case 19:for(;D.have<D.nlen+D.ndist;){for(;de=(ee=D.lencode[V&(1<<D.lenbits)-1])>>>16&255,ce=65535&ee,!((Le=ee>>>24)<=W);){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if(ce<16)V>>>=Le,W-=Le,D.lens[D.have++]=ce;else{if(ce===16){for(B=Le+2;W<B;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if(V>>>=Le,W-=Le,D.have===0){F.msg="invalid bit length repeat",D.mode=30;break}G=D.lens[D.have-1],pe=3+(3&V),V>>>=2,W-=2}else if(ce===17){for(B=Le+3;W<B;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}W-=Le,G=0,pe=3+(7&(V>>>=Le)),V>>>=3,W-=3}else{for(B=Le+7;W<B;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}W-=Le,G=0,pe=11+(127&(V>>>=Le)),V>>>=7,W-=7}if(D.have+pe>D.nlen+D.ndist){F.msg="invalid bit length repeat",D.mode=30;break}for(;pe--;)D.lens[D.have++]=G}}if(D.mode===30)break;if(D.lens[256]===0){F.msg="invalid code -- missing end-of-block",D.mode=30;break}if(D.lenbits=9,ue={bits:D.lenbits},Y=u(d,D.lens,0,D.nlen,D.lencode,0,D.work,ue),D.lenbits=ue.bits,Y){F.msg="invalid literal/lengths set",D.mode=30;break}if(D.distbits=6,D.distcode=D.distdyn,ue={bits:D.distbits},Y=u(h,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,ue),D.distbits=ue.bits,Y){F.msg="invalid distances set",D.mode=30;break}if(D.mode=20,$===6)break e;case 20:D.mode=21;case 21:if(6<=Z&&258<=se){F.next_out=K,F.avail_out=se,F.next_in=I,F.avail_in=Z,D.hold=V,D.bits=W,c(F,J),K=F.next_out,q=F.output,se=F.avail_out,I=F.next_in,H=F.input,Z=F.avail_in,V=D.hold,W=D.bits,D.mode===12&&(D.back=-1);break}for(D.back=0;de=(ee=D.lencode[V&(1<<D.lenbits)-1])>>>16&255,ce=65535&ee,!((Le=ee>>>24)<=W);){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if(de&&(240&de)==0){for(Ae=Le,re=de,Ie=ce;de=(ee=D.lencode[Ie+((V&(1<<Ae+re)-1)>>Ae)])>>>16&255,ce=65535&ee,!(Ae+(Le=ee>>>24)<=W);){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}V>>>=Ae,W-=Ae,D.back+=Ae}if(V>>>=Le,W-=Le,D.back+=Le,D.length=ce,de===0){D.mode=26;break}if(32&de){D.back=-1,D.mode=12;break}if(64&de){F.msg="invalid literal/length code",D.mode=30;break}D.extra=15&de,D.mode=22;case 22:if(D.extra){for(B=D.extra;W<B;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}D.length+=V&(1<<D.extra)-1,V>>>=D.extra,W-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=23;case 23:for(;de=(ee=D.distcode[V&(1<<D.distbits)-1])>>>16&255,ce=65535&ee,!((Le=ee>>>24)<=W);){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if((240&de)==0){for(Ae=Le,re=de,Ie=ce;de=(ee=D.distcode[Ie+((V&(1<<Ae+re)-1)>>Ae)])>>>16&255,ce=65535&ee,!(Ae+(Le=ee>>>24)<=W);){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}V>>>=Ae,W-=Ae,D.back+=Ae}if(V>>>=Le,W-=Le,D.back+=Le,64&de){F.msg="invalid distance code",D.mode=30;break}D.offset=ce,D.extra=15&de,D.mode=24;case 24:if(D.extra){for(B=D.extra;W<B;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}D.offset+=V&(1<<D.extra)-1,V>>>=D.extra,W-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){F.msg="invalid distance too far back",D.mode=30;break}D.mode=25;case 25:if(se===0)break e;if(pe=J-se,D.offset>pe){if((pe=D.offset-pe)>D.whave&&D.sane){F.msg="invalid distance too far back",D.mode=30;break}fe=pe>D.wnext?(pe-=D.wnext,D.wsize-pe):D.wnext-pe,pe>D.length&&(pe=D.length),ve=D.window}else ve=q,fe=K-D.offset,pe=D.length;for(se<pe&&(pe=se),se-=pe,D.length-=pe;q[K++]=ve[fe++],--pe;);D.length===0&&(D.mode=21);break;case 26:if(se===0)break e;q[K++]=D.length,se--,D.mode=21;break;case 27:if(D.wrap){for(;W<32;){if(Z===0)break e;Z--,V|=H[I++]<<W,W+=8}if(J-=se,F.total_out+=J,D.total+=J,J&&(F.adler=D.check=D.flags?l(D.check,q,J,K-J):o(D.check,q,J,K-J)),J=se,(D.flags?V:v(V))!==D.check){F.msg="incorrect data check",D.mode=30;break}W=V=0}D.mode=28;case 28:if(D.wrap&&D.flags){for(;W<32;){if(Z===0)break e;Z--,V+=H[I++]<<W,W+=8}if(V!==(4294967295&D.total)){F.msg="incorrect length check",D.mode=30;break}W=V=0}D.mode=29;case 29:Y=1;break e;case 30:Y=-3;break e;case 31:return-4;case 32:default:return m}return F.next_out=K,F.avail_out=se,F.next_in=I,F.avail_in=Z,D.hold=V,D.bits=W,(D.wsize||J!==F.avail_out&&D.mode<30&&(D.mode<27||$!==4))&&z(F,F.output,F.next_out,J-F.avail_out)?(D.mode=31,-4):(ie-=F.avail_in,J-=F.avail_out,F.total_in+=ie,F.total_out+=J,D.total+=J,D.wrap&&J&&(F.adler=D.check=D.flags?l(D.check,q,J,F.next_out-J):o(D.check,q,J,F.next_out-J)),F.data_type=D.bits+(D.last?64:0)+(D.mode===12?128:0)+(D.mode===20||D.mode===15?256:0),(ie==0&&J===0||$===4)&&Y===p&&(Y=-5),Y)},i.inflateEnd=function(F){if(!F||!F.state)return m;var $=F.state;return $.window&&($.window=null),F.state=null,p},i.inflateGetHeader=function(F,$){var D;return F&&F.state?(2&(D=F.state).wrap)==0?m:((D.head=$).done=!1,p):m},i.inflateSetDictionary=function(F,$){var D,H=$.length;return F&&F.state?(D=F.state).wrap!==0&&D.mode!==11?m:D.mode===11&&o(1,$,H,0)!==D.check?-3:z(F,$,H,H)?(D.mode=31,-4):(D.havedict=1,p):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var s=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,h,p,m,x,y,b,v){var S,k,E,N,A,M,P,T,j,z=v.bits,F=0,$=0,D=0,H=0,q=0,I=0,K=0,Z=0,se=0,V=0,W=null,ie=0,J=new s.Buf16(16),pe=new s.Buf16(16),fe=null,ve=0;for(F=0;F<=15;F++)J[F]=0;for($=0;$<m;$++)J[h[p+$]]++;for(q=z,H=15;1<=H&&J[H]===0;H--);if(H<q&&(q=H),H===0)return x[y++]=20971520,x[y++]=20971520,v.bits=1,0;for(D=1;D<H&&J[D]===0;D++);for(q<D&&(q=D),F=Z=1;F<=15;F++)if(Z<<=1,(Z-=J[F])<0)return-1;if(0<Z&&(d===0||H!==1))return-1;for(pe[1]=0,F=1;F<15;F++)pe[F+1]=pe[F]+J[F];for($=0;$<m;$++)h[p+$]!==0&&(b[pe[h[p+$]]++]=$);if(M=d===0?(W=fe=b,19):d===1?(W=o,ie-=257,fe=l,ve-=257,256):(W=c,fe=u,-1),F=D,A=y,K=$=V=0,E=-1,N=(se=1<<(I=q))-1,d===1&&852<se||d===2&&592<se)return 1;for(;;){for(P=F-K,j=b[$]<M?(T=0,b[$]):b[$]>M?(T=fe[ve+b[$]],W[ie+b[$]]):(T=96,0),S=1<<F-K,D=k=1<<I;x[A+(V>>K)+(k-=S)]=P<<24|T<<16|j|0,k!==0;);for(S=1<<F-1;V&S;)S>>=1;if(S!==0?(V&=S-1,V+=S):V=0,$++,--J[F]==0){if(F===H)break;F=h[p+b[$]]}if(q<F&&(V&N)!==E){for(K===0&&(K=q),A+=D,Z=1<<(I=F-K);I+K<H&&!((Z-=J[I+K])<=0);)I++,Z<<=1;if(se+=1<<I,d===1&&852<se||d===2&&592<se)return 1;x[E=V&N]=q<<24|I<<16|A-y|0}}return V!==0&&(x[A+V]=F-K<<24|64<<16|0),v.bits=q,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 s=n("../utils/common"),o=0,l=1;function c(ee){for(var Q=ee.length;0<=--Q;)ee[Q]=0}var u=0,d=29,h=256,p=h+1+d,m=30,x=19,y=2*p+1,b=15,v=16,S=7,k=256,E=16,N=17,A=18,M=[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],P=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(p+2));c(z);var F=new Array(2*m);c(F);var $=new Array(512);c($);var D=new Array(256);c(D);var H=new Array(d);c(H);var q,I,K,Z=new Array(m);function se(ee,Q,le,he,te){this.static_tree=ee,this.extra_bits=Q,this.extra_base=le,this.elems=he,this.max_length=te,this.has_stree=ee&&ee.length}function V(ee,Q){this.dyn_tree=ee,this.max_code=0,this.stat_desc=Q}function W(ee){return ee<256?$[ee]:$[256+(ee>>>7)]}function ie(ee,Q){ee.pending_buf[ee.pending++]=255&Q,ee.pending_buf[ee.pending++]=Q>>>8&255}function J(ee,Q,le){ee.bi_valid>v-le?(ee.bi_buf|=Q<<ee.bi_valid&65535,ie(ee,ee.bi_buf),ee.bi_buf=Q>>v-ee.bi_valid,ee.bi_valid+=le-v):(ee.bi_buf|=Q<<ee.bi_valid&65535,ee.bi_valid+=le)}function pe(ee,Q,le){J(ee,le[2*Q],le[2*Q+1])}function fe(ee,Q){for(var le=0;le|=1&ee,ee>>>=1,le<<=1,0<--Q;);return le>>>1}function ve(ee,Q,le){var he,te,U=new Array(b+1),L=0;for(he=1;he<=b;he++)U[he]=L=L+le[he-1]<<1;for(te=0;te<=Q;te++){var X=ee[2*te+1];X!==0&&(ee[2*te]=fe(U[X]++,X))}}function Le(ee){var Q;for(Q=0;Q<p;Q++)ee.dyn_ltree[2*Q]=0;for(Q=0;Q<m;Q++)ee.dyn_dtree[2*Q]=0;for(Q=0;Q<x;Q++)ee.bl_tree[2*Q]=0;ee.dyn_ltree[2*k]=1,ee.opt_len=ee.static_len=0,ee.last_lit=ee.matches=0}function de(ee){8<ee.bi_valid?ie(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 ce(ee,Q,le,he){var te=2*Q,U=2*le;return ee[te]<ee[U]||ee[te]===ee[U]&&he[Q]<=he[le]}function Ae(ee,Q,le){for(var he=ee.heap[le],te=le<<1;te<=ee.heap_len&&(te<ee.heap_len&&ce(Q,ee.heap[te+1],ee.heap[te],ee.depth)&&te++,!ce(Q,he,ee.heap[te],ee.depth));)ee.heap[le]=ee.heap[te],le=te,te<<=1;ee.heap[le]=he}function re(ee,Q,le){var he,te,U,L,X=0;if(ee.last_lit!==0)for(;he=ee.pending_buf[ee.d_buf+2*X]<<8|ee.pending_buf[ee.d_buf+2*X+1],te=ee.pending_buf[ee.l_buf+X],X++,he===0?pe(ee,te,Q):(pe(ee,(U=D[te])+h+1,Q),(L=M[U])!==0&&J(ee,te-=H[U],L),pe(ee,U=W(--he),le),(L=P[U])!==0&&J(ee,he-=Z[U],L)),X<ee.last_lit;);pe(ee,k,Q)}function Ie(ee,Q){var le,he,te,U=Q.dyn_tree,L=Q.stat_desc.static_tree,X=Q.stat_desc.has_stree,ge=Q.stat_desc.elems,_e=-1;for(ee.heap_len=0,ee.heap_max=y,le=0;le<ge;le++)U[2*le]!==0?(ee.heap[++ee.heap_len]=_e=le,ee.depth[le]=0):U[2*le+1]=0;for(;ee.heap_len<2;)U[2*(te=ee.heap[++ee.heap_len]=_e<2?++_e:0)]=1,ee.depth[te]=0,ee.opt_len--,X&&(ee.static_len-=L[2*te+1]);for(Q.max_code=_e,le=ee.heap_len>>1;1<=le;le--)Ae(ee,U,le);for(te=ge;le=ee.heap[1],ee.heap[1]=ee.heap[ee.heap_len--],Ae(ee,U,1),he=ee.heap[1],ee.heap[--ee.heap_max]=le,ee.heap[--ee.heap_max]=he,U[2*te]=U[2*le]+U[2*he],ee.depth[te]=(ee.depth[le]>=ee.depth[he]?ee.depth[le]:ee.depth[he])+1,U[2*le+1]=U[2*he+1]=te,ee.heap[1]=te++,Ae(ee,U,1),2<=ee.heap_len;);ee.heap[--ee.heap_max]=ee.heap[1],(function(Ee,$e){var Ce,He,Qe,xe,ye,we,Ue=$e.dyn_tree,Pe=$e.max_code,Ve=$e.stat_desc.static_tree,ke=$e.stat_desc.has_stree,Ze=$e.stat_desc.extra_bits,je=$e.stat_desc.extra_base,Xe=$e.stat_desc.max_length,Re=0;for(xe=0;xe<=b;xe++)Ee.bl_count[xe]=0;for(Ue[2*Ee.heap[Ee.heap_max]+1]=0,Ce=Ee.heap_max+1;Ce<y;Ce++)Xe<(xe=Ue[2*Ue[2*(He=Ee.heap[Ce])+1]+1]+1)&&(xe=Xe,Re++),Ue[2*He+1]=xe,Pe<He||(Ee.bl_count[xe]++,ye=0,je<=He&&(ye=Ze[He-je]),we=Ue[2*He],Ee.opt_len+=we*(xe+ye),ke&&(Ee.static_len+=we*(Ve[2*He+1]+ye)));if(Re!==0){do{for(xe=Xe-1;Ee.bl_count[xe]===0;)xe--;Ee.bl_count[xe]--,Ee.bl_count[xe+1]+=2,Ee.bl_count[Xe]--,Re-=2}while(0<Re);for(xe=Xe;xe!==0;xe--)for(He=Ee.bl_count[xe];He!==0;)Pe<(Qe=Ee.heap[--Ce])||(Ue[2*Qe+1]!==xe&&(Ee.opt_len+=(xe-Ue[2*Qe+1])*Ue[2*Qe],Ue[2*Qe+1]=xe),He--)}})(ee,Q),ve(U,_e,ee.bl_count)}function G(ee,Q,le){var he,te,U=-1,L=Q[1],X=0,ge=7,_e=4;for(L===0&&(ge=138,_e=3),Q[2*(le+1)+1]=65535,he=0;he<=le;he++)te=L,L=Q[2*(he+1)+1],++X<ge&&te===L||(X<_e?ee.bl_tree[2*te]+=X:te!==0?(te!==U&&ee.bl_tree[2*te]++,ee.bl_tree[2*E]++):X<=10?ee.bl_tree[2*N]++:ee.bl_tree[2*A]++,U=te,_e=(X=0)===L?(ge=138,3):te===L?(ge=6,3):(ge=7,4))}function Y(ee,Q,le){var he,te,U=-1,L=Q[1],X=0,ge=7,_e=4;for(L===0&&(ge=138,_e=3),he=0;he<=le;he++)if(te=L,L=Q[2*(he+1)+1],!(++X<ge&&te===L)){if(X<_e)for(;pe(ee,te,ee.bl_tree),--X!=0;);else te!==0?(te!==U&&(pe(ee,te,ee.bl_tree),X--),pe(ee,E,ee.bl_tree),J(ee,X-3,2)):X<=10?(pe(ee,N,ee.bl_tree),J(ee,X-3,3)):(pe(ee,A,ee.bl_tree),J(ee,X-11,7));U=te,_e=(X=0)===L?(ge=138,3):te===L?(ge=6,3):(ge=7,4)}}c(Z);var ue=!1;function B(ee,Q,le,he){J(ee,(u<<1)+(he?1:0),3),(function(te,U,L,X){de(te),ie(te,L),ie(te,~L),s.arraySet(te.pending_buf,te.window,U,L,te.pending),te.pending+=L})(ee,Q,le)}i._tr_init=function(ee){ue||((function(){var Q,le,he,te,U,L=new Array(b+1);for(te=he=0;te<d-1;te++)for(H[te]=he,Q=0;Q<1<<M[te];Q++)D[he++]=te;for(D[he-1]=te,te=U=0;te<16;te++)for(Z[te]=U,Q=0;Q<1<<P[te];Q++)$[U++]=te;for(U>>=7;te<m;te++)for(Z[te]=U<<7,Q=0;Q<1<<P[te]-7;Q++)$[256+U++]=te;for(le=0;le<=b;le++)L[le]=0;for(Q=0;Q<=143;)z[2*Q+1]=8,Q++,L[8]++;for(;Q<=255;)z[2*Q+1]=9,Q++,L[9]++;for(;Q<=279;)z[2*Q+1]=7,Q++,L[7]++;for(;Q<=287;)z[2*Q+1]=8,Q++,L[8]++;for(ve(z,p+1,L),Q=0;Q<m;Q++)F[2*Q+1]=5,F[2*Q]=fe(Q,5);q=new se(z,M,h+1,p,b),I=new se(F,P,0,m,b),K=new se(new Array(0),T,0,x,S)})(),ue=!0),ee.l_desc=new V(ee.dyn_ltree,q),ee.d_desc=new V(ee.dyn_dtree,I),ee.bl_desc=new V(ee.bl_tree,K),ee.bi_buf=0,ee.bi_valid=0,Le(ee)},i._tr_stored_block=B,i._tr_flush_block=function(ee,Q,le,he){var te,U,L=0;0<ee.level?(ee.strm.data_type===2&&(ee.strm.data_type=(function(X){var ge,_e=4093624447;for(ge=0;ge<=31;ge++,_e>>>=1)if(1&_e&&X.dyn_ltree[2*ge]!==0)return o;if(X.dyn_ltree[18]!==0||X.dyn_ltree[20]!==0||X.dyn_ltree[26]!==0)return l;for(ge=32;ge<h;ge++)if(X.dyn_ltree[2*ge]!==0)return l;return o})(ee)),Ie(ee,ee.l_desc),Ie(ee,ee.d_desc),L=(function(X){var ge;for(G(X,X.dyn_ltree,X.l_desc.max_code),G(X,X.dyn_dtree,X.d_desc.max_code),Ie(X,X.bl_desc),ge=x-1;3<=ge&&X.bl_tree[2*j[ge]+1]===0;ge--);return X.opt_len+=3*(ge+1)+5+5+4,ge})(ee),te=ee.opt_len+3+7>>>3,(U=ee.static_len+3+7>>>3)<=te&&(te=U)):te=U=le+5,le+4<=te&&Q!==-1?B(ee,Q,le,he):ee.strategy===4||U===te?(J(ee,2+(he?1:0),3),re(ee,z,F)):(J(ee,4+(he?1:0),3),(function(X,ge,_e,Ee){var $e;for(J(X,ge-257,5),J(X,_e-1,5),J(X,Ee-4,4),$e=0;$e<Ee;$e++)J(X,X.bl_tree[2*j[$e]+1],3);Y(X,X.dyn_ltree,ge-1),Y(X,X.dyn_dtree,_e-1)})(ee,ee.l_desc.max_code+1,ee.d_desc.max_code+1,L+1),re(ee,ee.dyn_ltree,ee.dyn_dtree)),Le(ee),he&&de(ee)},i._tr_tally=function(ee,Q,le){return ee.pending_buf[ee.d_buf+2*ee.last_lit]=Q>>>8&255,ee.pending_buf[ee.d_buf+2*ee.last_lit+1]=255&Q,ee.pending_buf[ee.l_buf+ee.last_lit]=255&le,ee.last_lit++,Q===0?ee.dyn_ltree[2*le]++:(ee.matches++,Q--,ee.dyn_ltree[2*(D[le]+h+1)]++,ee.dyn_dtree[2*W(Q)]++),ee.last_lit===ee.lit_bufsize-1},i._tr_align=function(ee){J(ee,2,3),pe(ee,k,z),(function(Q){Q.bi_valid===16?(ie(Q,Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0):8<=Q.bi_valid&&(Q.pending_buf[Q.pending++]=255&Q.bi_buf,Q.bi_buf>>=8,Q.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(s){(function(o,l){if(!o.setImmediate){var c,u,d,h,p=1,m={},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(E){process.nextTick(function(){S(E)})}:(function(){if(o.postMessage&&!o.importScripts){var E=!0,N=o.onmessage;return o.onmessage=function(){E=!1},o.postMessage("","*"),o.onmessage=N,E}})()?(h="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",k,!1):o.attachEvent("onmessage",k),function(E){o.postMessage(h+E,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(E){S(E.data)},function(E){d.port2.postMessage(E)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(E){var N=y.createElement("script");N.onreadystatechange=function(){S(E),N.onreadystatechange=null,u.removeChild(N),N=null},u.appendChild(N)}):function(E){setTimeout(S,0,E)},b.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var N=new Array(arguments.length-1),A=0;A<N.length;A++)N[A]=arguments[A+1];var M={callback:E,args:N};return m[p]=M,c(p),p++},b.clearImmediate=v}function v(E){delete m[E]}function S(E){if(x)setTimeout(S,0,E);else{var N=m[E];if(N){x=!0;try{(function(A){var M=A.callback,P=A.args;switch(P.length){case 0:M();break;case 1:M(P[0]);break;case 2:M(P[0],P[1]);break;case 3:M(P[0],P[1],P[2]);break;default:M.apply(l,P)}})(N)}finally{v(E),x=!1}}}}function k(E){E.source===o&&typeof E.data=="string"&&E.data.indexOf(h)===0&&S(+E.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Gw<"u"?Gw:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(iA)),iA.exports}var xve=bve();const yve=wl(xve);function vve(t){const e=new na;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 E8=vve;async function A8(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const s=r[i],o=[],l=[],c=s.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const h=c[d];o.push(parseFloat(h.getAttribute("x")||"0"),parseFloat(h.getAttribute("y")||"0"),parseFloat(h.getAttribute("z")||"0"))}const u=s.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const h=u[d];l.push(parseInt(h.getAttribute("v1")||"0"),parseInt(h.getAttribute("v2")||"0"),parseInt(h.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}function T8(t){const e=Array.from(t.attributes).find(r=>{const i=r.name.toLowerCase();return i==="plate_id"||i==="plater_id"||i==="plateid"||i==="platerid"||i.endsWith(":plate_id")||i.endsWith(":plater_id")});if(!e?.value)return null;const n=Number.parseInt(e.value,10);return Number.isFinite(n)?n:null}async function wve(t){let e;try{e=await yve.loadAsync(t)}catch{throw new Error("Unsupported file format")}const n=new Map,r=[],i=new Map,s=new Map,o=new DOMParser;async function l(k){const E=k.startsWith("/")?k.slice(1):k,N=e.files[E];if(!N)return null;const A=await N.async("string");return o.parseFromString(A,"application/xml")}const c=new Map,u=new Map,d=new Map,h=new Map,p=e.files["Metadata/model_settings.config"];if(p)try{const k=await p.async("string"),E=o.parseFromString(k,"application/xml"),N=E.getElementsByTagName("object");for(let M=0;M<N.length;M++){const P=N[M],T=P.getAttribute("id");if(!T)continue;const j=Array.from(P.children).filter(D=>D.tagName==="metadata"&&D.getAttribute("key")==="extruder");if(j.length>0){const D=j[0].getAttribute("value");D&&c.set(T,Math.max(0,parseInt(D,10)-1))}const F=Array.from(P.children).find(D=>D.tagName==="metadata"&&D.getAttribute("key")==="name")?.getAttribute("value");F&&d.set(T,F);const $=P.getElementsByTagName("part");for(let D=0;D<$.length;D++){const H=$[D],q=H.getAttribute("id");if(!q)continue;const I=Array.from(H.children).filter(K=>K.tagName==="metadata"&&K.getAttribute("key")==="extruder");if(I.length>0){const K=I[0].getAttribute("value");K&&u.set(`${T}:${q}`,Math.max(0,parseInt(K,10)-1))}}}const A=E.getElementsByTagName("plate");for(let M=0;M<A.length;M++){const P=A[M];let T=null;const j=P.getElementsByTagName("metadata");let z=0,F=0;for(let D=0;D<j.length;D++){const H=j[D],q=H.getAttribute("key");if(q==="plater_id"||q==="plate_id"){const I=H.getAttribute("value");if(I){const K=Number.parseInt(I,10);Number.isFinite(K)&&(T=K)}}else if(q==="pos_x"){const I=H.getAttribute("value"),K=I?Number.parseFloat(I):Number.NaN;Number.isFinite(K)&&(z=K)}else if(q==="pos_y"){const I=H.getAttribute("value"),K=I?Number.parseFloat(I):Number.NaN;Number.isFinite(K)&&(F=K)}}if(T==null)continue;(z!==0||F!==0)&&s.set(T,{offsetX:z,offsetY:F});const $=P.getElementsByTagName("model_instance");for(let D=0;D<$.length;D++){const q=$[D].getElementsByTagName("metadata");for(let I=0;I<q.length;I++){const K=q[I];if(K.getAttribute("key")==="object_id"){const Z=K.getAttribute("value");Z&&h.set(Z,T)}}}}}catch{}const m=new Map,x=Object.keys(e.files).filter(k=>k.startsWith("Metadata/plate_")&&k.endsWith(".json"));for(const k of x){const E=k.match(/^Metadata\/plate_(\d+)\.json$/);if(!E)continue;const N=Number.parseInt(E[1],10);if(Number.isFinite(N))try{const A=await e.files[k].async("string"),M=JSON.parse(A),P=M.bbox_objects??[];for(const T of P)T?.name&&m.set(T.name,N);if(Array.isArray(M.bbox_all)&&M.bbox_all.length>=4){const[T,j,z,F]=M.bbox_all;[T,j,z,F].every($=>Number.isFinite($))&&i.set(N,{minX:T,minY:j,maxX:z,maxY:F})}}catch{}}const y=Object.keys(e.files).find(k=>k==="3D/3dmodel.model"||k.endsWith("/3dmodel.model"));if(!y){const k=Object.keys(e.files).find(E=>E.endsWith(".model"));if(k){const E=await l(k);if(E){const N=await A8(E,0);N.length>0&&n.set("1",{id:"1",meshes:N,defaultExtruder:0})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s}}const b=await l(y);if(!b)return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s};const v=b.getElementsByTagName("object");for(let k=0;k<v.length;k++){const E=v[k],N=E.getAttribute("id");if(!N)continue;const A=T8(E)??h.get(N)??null;let M=c.get(N)??-1;if(M<0){const z=E.getAttribute("p:extruder")||E.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";M=Math.max(0,parseInt(z,10)-1)}const P=[],T=E.getElementsByTagName("mesh");for(let z=0;z<T.length;z++){const F=T[z],$=[],D=[],H=F.getElementsByTagName("vertex");for(let I=0;I<H.length;I++){const K=H[I];$.push(parseFloat(K.getAttribute("x")||"0"),parseFloat(K.getAttribute("y")||"0"),parseFloat(K.getAttribute("z")||"0"))}const q=F.getElementsByTagName("triangle");for(let I=0;I<q.length;I++){const K=q[I];D.push(parseInt(K.getAttribute("v1")||"0"),parseInt(K.getAttribute("v2")||"0"),parseInt(K.getAttribute("v3")||"0"))}$.length>0&&D.length>0&&P.push({vertices:$,triangles:D,extruder:M})}const j=E.getElementsByTagName("component");for(let z=0;z<j.length;z++){const F=j[z],$=F.getAttribute("p:path")||F.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),D=F.getAttribute("objectid");if($){const H=await l($);if(H){const q=D?`${N}:${D}`:null,I=q?u.get(q)??M:M,K=await A8(H,I),Z=F.getAttribute("transform"),se=E8(Z);for(const V of K)if(Z){const W=[];for(let ie=0;ie<V.vertices.length;ie+=3){const J=new mt(V.vertices[ie],V.vertices[ie+1],V.vertices[ie+2]);J.applyMatrix4(se),W.push(J.x,J.y,J.z)}P.push({vertices:W,triangles:V.triangles,extruder:V.extruder})}else P.push(V)}}}P.length>0&&n.set(N,{id:N,meshes:P,defaultExtruder:M,plateId:A})}const S=b.getElementsByTagName("build");if(S.length>0){const k=S[0].getElementsByTagName("item");for(let E=0;E<k.length;E++){const N=k[E],A=N.getAttribute("objectid");if(!A)continue;const M=E8(N.getAttribute("transform")),P=T8(N),T=n.get(A)?.plateId??null,j=d.get(A),z=j?m.get(j)??null:null;r.push({objectId:A,transform:M,plateId:P??T??z??null})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s}}function j8(t){const e=new gl,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 Ts(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function _ve(t){t.traverse(e=>{if(e instanceof bl)if(e.geometry.dispose(),Array.isArray(e.material))for(const n of e.material)n.dispose();else e.material.dispose()})}function Sve(t,e,n){const{objects:r,buildItems:i}=t,s=new Cg,o=h=>{const m=n?.[h]||"#00ae42",x=new In(m);return new qK({color:x,shininess:30,flatShading:!1})},l=new Map,c=i.some(h=>h.plateId!=null),u=e==null||!c?i:i.filter(h=>h.plateId===e),d=u.length>0?u:i;if(d.length>0)for(const h of d){const p=r.get(h.objectId);if(p)for(const m of p.meshes){const x=h.extruder??m.extruder,y=[];for(let v=0;v<m.vertices.length;v+=3){const S=new mt(m.vertices[v],m.vertices[v+1],m.vertices[v+2]);S.applyMatrix4(h.transform),y.push(S.x,S.y,S.z)}const b=j8({vertices:y,triangles:m.triangles});l.has(x)||l.set(x,[]),l.get(x).push(b)}}else for(const h of r.values())for(const p of h.meshes){const m=p.extruder,x=j8(p);l.has(m)||l.set(m,[]),l.get(m).push(x)}for(const[h,p]of l){if(p.length===0)continue;const m=p.length===1?p[0]:pve(p,!1);if(m){const x=o(h),y=new bl(m,x);s.add(y)}if(p.length>1)for(const x of p)x.dispose()}return s}function tX({url:t,fileType:e,buildVolume:n={x:256,y:256,z:256},filamentColors:r,selectedPlateId:i=null,className:s=""}){const{t:o}=Ut(),l=w.useRef(null),c=w.useRef(null),u=w.useRef(null),d=w.useRef(null),h=w.useRef(null),p=w.useRef(null),m=w.useRef(null),x=w.useRef(null),[y,b]=w.useState(!0),[v,S]=w.useState(null),[k,E]=w.useState(null),[N,A]=w.useState(null);w.useEffect(()=>{if(!l.current)return;const T=l.current,j=T.clientWidth,z=T.clientHeight,F=new Xpe;F.background=new In(1710618),u.current=F;const $=new il(45,j/z,.1,1e4);$.position.set(150,150,150),d.current=$;const D=new eve({antialias:!0});D.setSize(j,z),D.setPixelRatio(window.devicePixelRatio),T.appendChild(D.domElement),c.current=D;const H=new nve($,D.domElement);H.enableDamping=!0,H.dampingFactor=.05,h.current=H;const q=new uge(16777215,.6);F.add(q);const I=new ZB(16777215,.8);I.position.set(100,100,100),F.add(I);const K=new ZB(16777215,.4);K.position.set(-100,50,-100),F.add(K);const Z=Math.max(n.x,n.y),se=Math.ceil(Z/16),V=new hge(Z,se,4473924,3355443);F.add(V),x.current=V;const W=new A4(n.x,n.y),ie=new M4({color:44610,transparent:!0,opacity:.15,side:xc}),J=new bl(W,ie);J.rotation.x=-Math.PI/2,J.position.y=-.5,F.add(J),m.current=J;let pe;const fe=()=>{pe=requestAnimationFrame(fe),H.update(),D.render(F,$)};fe(),b(!0),S(null),E(null),A(null);const ve=(e||t.split("?")[0].split(".").pop()||"").toLowerCase(),Le={},de=Ju();de&&(Le.Authorization=`Bearer ${de}`),ve==="stl"?fetch(t,{headers:Le}).then(re=>{if(!re.ok)throw new Error(o("modelViewer.errors.failedToLoad"));return re.arrayBuffer()}).then(re=>{const G=new gve().parse(re);G.computeVertexNormals(),G.rotateX(-Math.PI/2),A(G)}).catch(re=>{S(re.message),b(!1)}):ve==="3mf"?fetch(t,{headers:Le}).then(re=>{if(!re.ok)throw new Error(o("modelViewer.errors.failedToLoad"));return re.arrayBuffer()}).then(wve).then(re=>{if(re.objects.size===0)throw new Error(o("modelViewer.errors.noMeshes"));E(re)}).catch(re=>{S(re.message),b(!1)}):(S(o("modelViewer.errors.unsupportedFormat")),b(!1));const ce=()=>{if(!T)return;const re=T.clientWidth,Ie=T.clientHeight;re===0||Ie===0||($.aspect=re/Ie,$.updateProjectionMatrix(),D.setSize(re,Ie))};window.addEventListener("resize",ce);const Ae=new ResizeObserver(()=>{ce()});return Ae.observe(T),()=>{window.removeEventListener("resize",ce),Ae.disconnect(),cancelAnimationFrame(pe),H.dispose(),D.dispose(),T.removeChild(D.domElement),p.current=null,m.current=null,x.current=null}},[t,n,e,o]),w.useEffect(()=>{if(!u.current||!d.current||!h.current||!k&&!N)return;p.current&&(u.current.remove(p.current),_ve(p.current));const T=!!N,j=T?(()=>{const ve=r?.[0]||"#00ae42",Le=new qK({color:new In(ve),shininess:30}),de=new bl(N,Le),ce=new Cg;return ce.add(de),ce})():Sve(k,i??null,r);p.current=j,u.current.add(j);const z=new Eh().setFromObject(j),F=z.getCenter(new mt);j.position.y=-z.min.y;const $=!T&&i!=null&&k.buildItems.length>0?k.plateBounds.get(i):void 0,D=!T&&i!=null?k.plateOffsets.get(i):void 0,H=T||k.buildItems.length===0||i!=null&&!$&&!D,q=H?-F.x:0,I=H?-F.z:0;let K=0,Z=0;if(!T&&i!=null&&k.buildItems.length>0&&$){const ve=new Eh().setFromObject(j);K=ve.min.x-$.minX,Z=ve.min.z-$.minY}const se=n.x/2,V=n.y/2;!T&&i!=null&&k.buildItems.length>0&&$?(j.position.x=q-K,j.position.z=I-Z):!T&&i!=null&&D?(j.position.x=q+(se-D.offsetX),j.position.z=I+(V-D.offsetY)):H?(j.position.x=q+se,j.position.z=I+V):(j.position.x=q,j.position.z=I),m.current&&(m.current.position.x=se,m.current.position.z=V),x.current&&(x.current.position.x=se,x.current.position.z=V);const W=new Eh().setFromObject(j),ie=W.getCenter(new mt),J=W.getSize(new mt),fe=Math.max(J.x,J.y,J.z)*1.8;d.current.position.set(ie.x+fe*.7,ie.y+fe*.5,ie.z+fe*.7),h.current.target.copy(ie),h.current.update(),b(!1)},[k,N,i,r,n]);const M=()=>{d.current&&h.current&&(d.current.position.set(150,150,150),h.current.target.set(0,50,0),h.current.update())},P=T=>{d.current&&d.current.position.multiplyScalar(T)};return a.jsxs("div",{className:`relative ${s}`,children:[a.jsx("div",{ref:l,className:"w-full h-full min-h-[400px]"}),y&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}),v&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("p",{className:"text-red-400",children:v})}),!y&&!v&&a.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>P(.8),children:a.jsx(h4,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>P(1.25),children:a.jsx(f4,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:M,children:a.jsx(Po,{className:"w-4 h-4"})})]})]})}const Vk="159",Vp={ROTATE:0,DOLLY:1,PAN:2},Gp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Nve=0,P8=1,kve=2,nX=1,Mve=2,Su=3,Bh=0,Zs=1,Eu=2,Ah=0,Ug=1,D8=2,R8=3,L8=4,Cve=5,Vf=100,Eve=101,Ave=102,O8=103,F8=104,Tve=200,jve=201,Pve=202,Dve=203,F3=204,I3=205,Rve=206,Lve=207,Ove=208,Fve=209,Ive=210,zve=211,Uve=212,Bve=213,$ve=214,Hve=0,Vve=1,Gve=2,y1=3,qve=4,Wve=5,Kve=6,Xve=7,P4=0,Yve=1,Qve=2,Th=0,Zve=1,Jve=2,ewe=3,twe=4,nwe=5,rX=300,ob=301,lb=302,z3=303,U3=304,Gk=306,B3=1e3,zl=1001,$3=1002,Ka=1003,I8=1004,aA=1005,al=1006,rwe=1007,u0=1008,jh=1009,iwe=1010,awe=1011,D4=1012,iX=1013,gh=1014,Ou=1015,d0=1016,aX=1017,sX=1018,sm=1020,swe=1021,sl=1023,owe=1024,lwe=1025,om=1026,cb=1027,cwe=1028,oX=1029,uwe=1030,lX=1031,cX=1033,sA=33776,oA=33777,lA=33778,cA=33779,z8=35840,U8=35841,B8=35842,$8=35843,uX=36196,H8=37492,V8=37496,G8=37808,q8=37809,W8=37810,K8=37811,X8=37812,Y8=37813,Q8=37814,Z8=37815,J8=37816,e6=37817,t6=37818,n6=37819,r6=37820,i6=37821,uA=36492,a6=36494,s6=36495,dwe=36283,o6=36284,l6=36285,c6=36286,dX=3e3,lm=3001,hwe=3200,fwe=3201,hX=0,mwe=1,ol="",Xa="srgb",td="srgb-linear",R4="display-p3",qk="display-p3-linear",v1="linear",ei="srgb",w1="rec709",_1="p3",qp=7680,u6=519,pwe=512,gwe=513,bwe=514,fX=515,xwe=516,ywe=517,vwe=518,wwe=519,H3=35044,d6="300 es",V3=1035,Sc=2e3,h0=2001;class Wm{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 s=i.indexOf(n);s!==-1&&i.splice(s,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 s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}}const as=["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 h6=1234567;const jy=Math.PI/180,f0=180/Math.PI;function Hu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(as[t&255]+as[t>>8&255]+as[t>>16&255]+as[t>>24&255]+"-"+as[e&255]+as[e>>8&255]+"-"+as[e>>16&15|64]+as[e>>24&255]+"-"+as[n&63|128]+as[n>>8&255]+"-"+as[n>>16&255]+as[n>>24&255]+as[r&255]+as[r>>8&255]+as[r>>16&255]+as[r>>24&255]).toLowerCase()}function Ya(t,e,n){return Math.max(e,Math.min(n,t))}function L4(t,e){return(t%e+e)%e}function _we(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function Swe(t,e,n){return t!==e?(n-t)/(e-t):0}function Py(t,e,n){return(1-n)*t+n*e}function Nwe(t,e,n,r){return Py(t,e,1-Math.exp(-n*r))}function kwe(t,e=1){return e-Math.abs(L4(t,e*2)-e)}function Mwe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function Cwe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function Ewe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function Awe(t,e){return t+Math.random()*(e-t)}function Twe(t){return t*(.5-Math.random())}function jwe(t){t!==void 0&&(h6=t);let e=h6+=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 Pwe(t){return t*jy}function Dwe(t){return t*f0}function G3(t){return(t&t-1)===0&&t!==0}function Rwe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function S1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Lwe(t,e,n,r,i){const s=Math.cos,o=Math.sin,l=s(n/2),c=o(n/2),u=s((e+r)/2),d=o((e+r)/2),h=s((e-r)/2),p=o((e-r)/2),m=s((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*h,c*p,l*u);break;case"YZY":t.set(c*p,l*d,c*h,l*u);break;case"ZXZ":t.set(c*h,c*p,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*m,l*u);break;case"YXY":t.set(c*m,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*m,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function yc(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 Tr(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 mX={DEG2RAD:jy,RAD2DEG:f0,generateUUID:Hu,clamp:Ya,euclideanModulo:L4,mapLinear:_we,inverseLerp:Swe,lerp:Py,damp:Nwe,pingpong:kwe,smoothstep:Mwe,smootherstep:Cwe,randInt:Ewe,randFloat:Awe,randFloatSpread:Twe,seededRandom:jwe,degToRad:Pwe,radToDeg:Dwe,isPowerOfTwo:G3,ceilPowerOfTwo:Rwe,floorPowerOfTwo:S1,setQuaternionFromProperEuler:Lwe,normalize:Tr,denormalize:yc};class Sn{constructor(e=0,n=0){Sn.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(Ya(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),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*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 Bn{constructor(e,n,r,i,s,o,l,c,u){Bn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u)}set(e,n,r,i,s,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=s,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,s=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],h=r[7],p=r[2],m=r[5],x=r[8],y=i[0],b=i[3],v=i[6],S=i[1],k=i[4],E=i[7],N=i[2],A=i[5],M=i[8];return s[0]=o*y+l*S+c*N,s[3]=o*b+l*k+c*A,s[6]=o*v+l*E+c*M,s[1]=u*y+d*S+h*N,s[4]=u*b+d*k+h*A,s[7]=u*v+d*E+h*M,s[2]=p*y+m*S+x*N,s[5]=p*b+m*k+x*A,s[8]=p*v+m*E+x*M,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],s=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*s*d+r*l*c+i*s*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=d*o-l*u,p=l*c-d*s,m=u*s-o*c,x=n*h+r*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=h*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=p*y,e[4]=(d*n-i*c)*y,e[5]=(i*s-l*n)*y,e[6]=m*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*s)*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,s,o,l){const c=Math.cos(s),u=Math.sin(s);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(dA.makeScale(e,n)),this}rotate(e){return this.premultiply(dA.makeRotation(-e)),this}translate(e,n){return this.premultiply(dA.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 dA=new Bn;function pX(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function N1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Owe(){const t=N1("canvas");return t.style.display="block",t}const f6={};function Dy(t){t in f6||(f6[t]=!0,console.warn(t))}const m6=new Bn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),p6=new Bn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),w_={[td]:{transfer:v1,primaries:w1,toReference:t=>t,fromReference:t=>t},[Xa]:{transfer:ei,primaries:w1,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[qk]:{transfer:v1,primaries:_1,toReference:t=>t.applyMatrix3(p6),fromReference:t=>t.applyMatrix3(m6)},[R4]:{transfer:ei,primaries:_1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(p6),fromReference:t=>t.applyMatrix3(m6).convertLinearToSRGB()}},Fwe=new Set([td,qk]),jr={enabled:!0,_workingColorSpace:td,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(!Fwe.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=w_[e].toReference,i=w_[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 w_[t].primaries},getTransfer:function(t){return t===ol?v1:w_[t].transfer}};function Bg(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function hA(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Wp;class gX{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Wp===void 0&&(Wp=N1("canvas")),Wp.width=e.width,Wp.height=e.height;const r=Wp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Wp}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=N1("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),s=i.data;for(let o=0;o<s.length;o++)s[o]=Bg(s[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(Bg(n[r]/255)*255):n[r]=Bg(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 Iwe=0;class bX{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Iwe++}),this.uuid=Hu(),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 s;if(Array.isArray(i)){s=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(fA(i[o].image)):s.push(fA(i[o]))}else s=fA(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function fA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?gX.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 zwe=0;class Js extends Wm{constructor(e=Js.DEFAULT_IMAGE,n=Js.DEFAULT_MAPPING,r=zl,i=zl,s=al,o=u0,l=sl,c=jh,u=Js.DEFAULT_ANISOTROPY,d=ol){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:zwe++}),this.uuid=Hu(),this.name="",this.source=new bX(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new Sn(0,0),this.repeat=new Sn(1,1),this.center=new Sn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Bn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Dy("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===lm?Xa:ol),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!==rX)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case B3:e.x=e.x-Math.floor(e.x);break;case zl:e.x=e.x<0?0:1;break;case $3:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case B3:e.y=e.y-Math.floor(e.y);break;case zl:e.y=e.y<0?0:1;break;case $3:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Dy("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Xa?lm:dX}set encoding(e){Dy("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===lm?Xa:ol}}Js.DEFAULT_IMAGE=null;Js.DEFAULT_MAPPING=rX;Js.DEFAULT_ANISOTROPY=1;class Dr{constructor(e=0,n=0,r=0,i=1){Dr.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,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,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,s;const c=e.elements,u=c[0],d=c[4],h=c[8],p=c[1],m=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-p)<.01&&Math.abs(h-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+m+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const k=(u+1)/2,E=(m+1)/2,N=(v+1)/2,A=(d+p)/4,M=(h+y)/4,P=(x+b)/4;return k>E&&k>N?k<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(k),i=A/r,s=M/r):E>N?E<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(E),r=A/i,s=P/i):N<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(N),r=M/s,i=P/s),this.set(r,i,s,n),this}let S=Math.sqrt((b-x)*(b-x)+(h-y)*(h-y)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(b-x)/S,this.y=(h-y)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+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 Uwe extends Wm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Dr(0,0,e,n),this.scissorTest=!1,this.viewport=new Dr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Dy("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===lm?Xa:ol),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:al,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Js(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 bX(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Tm extends Uwe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class xX extends Js{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=Ka,this.minFilter=Ka,this.wrapR=zl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Bwe extends Js{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=Ka,this.minFilter=Ka,this.wrapR=zl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class jm{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,s,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],h=r[i+3];const p=s[o+0],m=s[o+1],x=s[o+2],y=s[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h;return}if(l===1){e[n+0]=p,e[n+1]=m,e[n+2]=x,e[n+3]=y;return}if(h!==y||c!==p||u!==m||d!==x){let b=1-l;const v=c*p+u*m+d*x+h*y,S=v>=0?1:-1,k=1-v*v;if(k>Number.EPSILON){const N=Math.sqrt(k),A=Math.atan2(N,v*S);b=Math.sin(b*A)/N,l=Math.sin(l*A)/N}const E=l*S;if(c=c*b+p*E,u=u*b+m*E,d=d*b+x*E,h=h*b+y*E,b===1-l){const N=1/Math.sqrt(c*c+u*u+d*d+h*h);c*=N,u*=N,d*=N,h*=N}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],h=s[o],p=s[o+1],m=s[o+2],x=s[o+3];return e[n]=l*x+d*h+c*m-u*p,e[n+1]=c*x+d*p+u*h-l*m,e[n+2]=u*x+d*m+l*p-c*h,e[n+3]=d*x-l*h-c*p-u*m,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,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),h=l(s/2),p=c(r/2),m=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=p*d*h+u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h-p*m*x;break;case"YXZ":this._x=p*d*h+u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h+p*m*x;break;case"ZXY":this._x=p*d*h-u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h-p*m*x;break;case"ZYX":this._x=p*d*h-u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h+p*m*x;break;case"YZX":this._x=p*d*h+u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h-p*m*x;break;case"XZY":this._x=p*d*h-u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h+p*m*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],s=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],h=n[10],p=r+l+h;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(s-u)*m,this._z=(o-i)*m}else if(r>l&&r>h){const m=2*Math.sqrt(1+r-l-h);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(s+u)/m}else if(l>h){const m=2*Math.sqrt(1+l-r-h);this._w=(s-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+h-r-l);this._w=(o-i)/m,this._x=(s+u)/m,this._y=(c+d)/m,this._z=.25*m}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(Ya(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,s=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-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*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,s=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+s*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=s,this;const c=1-l*l;if(c<=Number.EPSILON){const m=1-n;return this._w=m*o+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),h=Math.sin((1-n)*d)/u,p=Math.sin(n*d)/u;return this._w=o*h+this._w*p,this._x=r*h+this._x*p,this._y=i*h+this._y*p,this._z=s*h+this._z*p,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(),s=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(s),r*Math.cos(s),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 We{constructor(e=0,n=0,r=0){We.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(g6.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(g6.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-s*i),h=2*(s*r-o*n);return this.x=n+c*u+o*h-l*d,this.y=r+c*d+l*u-s*h,this.z=i+c*h+s*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,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[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,s=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-s*l,this.y=s*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 mA.copy(this).projectOnVector(e),this.sub(mA)}reflect(e){return this.sub(mA.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(Ya(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 mA=new We,g6=new jm;class hl{constructor(e=new We(1/0,1/0,1/0),n=new We(-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(Ll.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ll.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=Ll.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 s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=s.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Ll):Ll.fromBufferAttribute(s,o),Ll.applyMatrix4(e.matrixWorld),this.expandByPoint(Ll);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),__.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),__.copy(r.boundingBox)),__.applyMatrix4(e.matrixWorld),this.union(__)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],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,Ll),Ll.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(Qx),S_.subVectors(this.max,Qx),Kp.subVectors(e.a,Qx),Xp.subVectors(e.b,Qx),Yp.subVectors(e.c,Qx),Gd.subVectors(Xp,Kp),qd.subVectors(Yp,Xp),Af.subVectors(Kp,Yp);let n=[0,-Gd.z,Gd.y,0,-qd.z,qd.y,0,-Af.z,Af.y,Gd.z,0,-Gd.x,qd.z,0,-qd.x,Af.z,0,-Af.x,-Gd.y,Gd.x,0,-qd.y,qd.x,0,-Af.y,Af.x,0];return!pA(n,Kp,Xp,Yp,S_)||(n=[1,0,0,0,1,0,0,0,1],!pA(n,Kp,Xp,Yp,S_))?!1:(N_.crossVectors(Gd,qd),n=[N_.x,N_.y,N_.z],pA(n,Kp,Xp,Yp,S_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ll).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ll).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:(fu[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fu[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fu[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fu[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fu[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fu[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fu[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fu[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fu),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 fu=[new We,new We,new We,new We,new We,new We,new We,new We],Ll=new We,__=new hl,Kp=new We,Xp=new We,Yp=new We,Gd=new We,qd=new We,Af=new We,Qx=new We,S_=new We,N_=new We,Tf=new We;function pA(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){Tf.fromArray(t,s);const l=i.x*Math.abs(Tf.x)+i.y*Math.abs(Tf.y)+i.z*Math.abs(Tf.z),c=e.dot(Tf),u=n.dot(Tf),d=r.dot(Tf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const $we=new hl,Zx=new We,gA=new We;class Mc{constructor(e=new We,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):$we.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));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;Zx.subVectors(e,this.center);const n=Zx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Zx,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):(gA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Zx.copy(e.center).add(gA)),this.expandByPoint(Zx.copy(e.center).sub(gA))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const mu=new We,bA=new We,k_=new We,Wd=new We,xA=new We,M_=new We,yA=new We;class O4{constructor(e=new We,n=new We(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,mu)),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=mu.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(mu.copy(this.origin).addScaledVector(this.direction,n),mu.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){bA.copy(e).add(n).multiplyScalar(.5),k_.copy(n).sub(e).normalize(),Wd.copy(this.origin).sub(bA);const s=e.distanceTo(n)*.5,o=-this.direction.dot(k_),l=Wd.dot(this.direction),c=-Wd.dot(k_),u=Wd.lengthSq(),d=Math.abs(1-o*o);let h,p,m,x;if(d>0)if(h=o*c-l,p=o*l-c,x=s*d,h>=0)if(p>=-x)if(p<=x){const y=1/d;h*=y,p*=y,m=h*(h+o*p+2*l)+p*(o*h+p+2*c)+u}else p=s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p=-s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p<=-x?(h=Math.max(0,-(-o*s+l)),p=h>0?-s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u):p<=x?(h=0,p=Math.min(Math.max(-s,-c),s),m=p*(p+2*c)+u):(h=Math.max(0,-(o*s+l)),p=h>0?s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u);else p=o>0?-s:s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(bA).addScaledVector(k_,p),m}intersectSphere(e,n){mu.subVectors(e.center,this.origin);const r=mu.dot(this.direction),i=mu.dot(mu)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-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,s,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(s=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(l=(e.min.z-p.z)*h,c=(e.max.z-p.z)*h):(l=(e.max.z-p.z)*h,c=(e.min.z-p.z)*h),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,mu)!==null}intersectTriangle(e,n,r,i,s){xA.subVectors(n,e),M_.subVectors(r,e),yA.crossVectors(xA,M_);let o=this.direction.dot(yA),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Wd.subVectors(this.origin,e);const c=l*this.direction.dot(M_.crossVectors(Wd,M_));if(c<0)return null;const u=l*this.direction.dot(xA.cross(Wd));if(u<0||c+u>o)return null;const d=-l*Wd.dot(yA);return d<0?null:this.at(d/o,s)}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 Xr{constructor(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,b){Xr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,b)}set(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,b){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=s,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=h,v[14]=p,v[3]=m,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 Xr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return 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/Qp.setFromMatrixColumn(e,0).length(),s=1/Qp.setFromMatrixColumn(e,1).length(),o=1/Qp.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]*s,n[5]=r[5]*s,n[6]=r[6]*s,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,s=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=o*d,m=o*h,x=l*d,y=l*h;n[0]=c*d,n[4]=-c*h,n[8]=u,n[1]=m+x*u,n[5]=p-y*u,n[9]=-l*c,n[2]=y-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*h,x=u*d,y=u*h;n[0]=p+y*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*h,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=y+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*h,x=u*d,y=u*h;n[0]=p-y*l,n[4]=-o*h,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=y-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*h,x=l*d,y=l*h;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+y,n[1]=c*h,n[5]=y*u+p,n[9]=m*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-p*h,n[8]=x*h+m,n[1]=h,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*h+x,n[10]=p-y*h}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-h,n[8]=u*d,n[1]=p*h+y,n[5]=o*d,n[9]=m*h-x,n[2]=x*h-m,n[6]=l*d,n[10]=y*h+p}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(Hwe,e,Vwe)}lookAt(e,n,r){const i=this.elements;return bo.subVectors(e,n),bo.lengthSq()===0&&(bo.z=1),bo.normalize(),Kd.crossVectors(r,bo),Kd.lengthSq()===0&&(Math.abs(r.z)===1?bo.x+=1e-4:bo.z+=1e-4,bo.normalize(),Kd.crossVectors(r,bo)),Kd.normalize(),C_.crossVectors(bo,Kd),i[0]=Kd.x,i[4]=C_.x,i[8]=bo.x,i[1]=Kd.y,i[5]=C_.y,i[9]=bo.y,i[2]=Kd.z,i[6]=C_.z,i[10]=bo.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,s=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],h=r[5],p=r[9],m=r[13],x=r[2],y=r[6],b=r[10],v=r[14],S=r[3],k=r[7],E=r[11],N=r[15],A=i[0],M=i[4],P=i[8],T=i[12],j=i[1],z=i[5],F=i[9],$=i[13],D=i[2],H=i[6],q=i[10],I=i[14],K=i[3],Z=i[7],se=i[11],V=i[15];return s[0]=o*A+l*j+c*D+u*K,s[4]=o*M+l*z+c*H+u*Z,s[8]=o*P+l*F+c*q+u*se,s[12]=o*T+l*$+c*I+u*V,s[1]=d*A+h*j+p*D+m*K,s[5]=d*M+h*z+p*H+m*Z,s[9]=d*P+h*F+p*q+m*se,s[13]=d*T+h*$+p*I+m*V,s[2]=x*A+y*j+b*D+v*K,s[6]=x*M+y*z+b*H+v*Z,s[10]=x*P+y*F+b*q+v*se,s[14]=x*T+y*$+b*I+v*V,s[3]=S*A+k*j+E*D+N*K,s[7]=S*M+k*z+E*H+N*Z,s[11]=S*P+k*F+E*q+N*se,s[15]=S*T+k*$+E*I+N*V,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],s=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],h=e[6],p=e[10],m=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+s*c*h-i*u*h-s*l*p+r*u*p+i*l*m-r*c*m)+y*(+n*c*m-n*u*p+s*o*p-i*o*m+i*u*d-s*c*d)+b*(+n*u*h-n*l*m-s*o*h+r*o*m+s*l*d-r*u*d)+v*(-i*l*d-n*c*h+n*l*p+i*o*h-r*o*p+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],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=e[9],p=e[10],m=e[11],x=e[12],y=e[13],b=e[14],v=e[15],S=h*b*u-y*p*u+y*c*m-l*b*m-h*c*v+l*p*v,k=x*p*u-d*b*u-x*c*m+o*b*m+d*c*v-o*p*v,E=d*y*u-x*h*u+x*l*m-o*y*m-d*l*v+o*h*v,N=x*h*c-d*y*c-x*l*p+o*y*p+d*l*b-o*h*b,A=n*S+r*k+i*E+s*N;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/A;return e[0]=S*M,e[1]=(y*p*s-h*b*s-y*i*m+r*b*m+h*i*v-r*p*v)*M,e[2]=(l*b*s-y*c*s+y*i*u-r*b*u-l*i*v+r*c*v)*M,e[3]=(h*c*s-l*p*s-h*i*u+r*p*u+l*i*m-r*c*m)*M,e[4]=k*M,e[5]=(d*b*s-x*p*s+x*i*m-n*b*m-d*i*v+n*p*v)*M,e[6]=(x*c*s-o*b*s-x*i*u+n*b*u+o*i*v-n*c*v)*M,e[7]=(o*p*s-d*c*s+d*i*u-n*p*u-o*i*m+n*c*m)*M,e[8]=E*M,e[9]=(x*h*s-d*y*s-x*r*m+n*y*m+d*r*v-n*h*v)*M,e[10]=(o*y*s-x*l*s+x*r*u-n*y*u-o*r*v+n*l*v)*M,e[11]=(d*l*s-o*h*s-d*r*u+n*h*u+o*r*m-n*l*m)*M,e[12]=N*M,e[13]=(d*y*i-x*h*i+x*r*p-n*y*p-d*r*b+n*h*b)*M,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*M,e[15]=(o*h*i-d*l*i+d*r*c-n*h*c-o*r*p+n*l*p)*M,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,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),s=1-r,o=e.x,l=e.y,c=e.z,u=s*o,d=s*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,s*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,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,l=n._z,c=n._w,u=s+s,d=o+o,h=l+l,p=s*u,m=s*d,x=s*h,y=o*d,b=o*h,v=l*h,S=c*u,k=c*d,E=c*h,N=r.x,A=r.y,M=r.z;return i[0]=(1-(y+v))*N,i[1]=(m+E)*N,i[2]=(x-k)*N,i[3]=0,i[4]=(m-E)*A,i[5]=(1-(p+v))*A,i[6]=(b+S)*A,i[7]=0,i[8]=(x+k)*M,i[9]=(b-S)*M,i[10]=(1-(p+y))*M,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 s=Qp.set(i[0],i[1],i[2]).length();const o=Qp.set(i[4],i[5],i[6]).length(),l=Qp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Ol.copy(this);const u=1/s,d=1/o,h=1/l;return Ol.elements[0]*=u,Ol.elements[1]*=u,Ol.elements[2]*=u,Ol.elements[4]*=d,Ol.elements[5]*=d,Ol.elements[6]*=d,Ol.elements[8]*=h,Ol.elements[9]*=h,Ol.elements[10]*=h,n.setFromRotationMatrix(Ol),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=Sc){const c=this.elements,u=2*s/(n-e),d=2*s/(r-i),h=(n+e)/(n-e),p=(r+i)/(r-i);let m,x;if(l===Sc)m=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(l===h0)m=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=Sc){const c=this.elements,u=1/(n-e),d=1/(r-i),h=1/(o-s),p=(n+e)*u,m=(r+i)*d;let x,y;if(l===Sc)x=(o+s)*h,y=-2*h;else if(l===h0)x=s*h,y=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,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 Qp=new We,Ol=new Xr,Hwe=new We(0,0,0),Vwe=new We(1,1,1),Kd=new We,C_=new We,bo=new We,b6=new Xr,x6=new jm;class Q0{constructor(e=0,n=0,r=0,i=Q0.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,s=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],h=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Ya(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Ya(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ya(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ya(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Ya(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Ya(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,m),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 b6.makeRotationFromQuaternion(e),this.setFromRotationMatrix(b6,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return x6.setFromEuler(this),this.setFromQuaternion(x6,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}}Q0.DEFAULT_ORDER="XYZ";class yX{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 Gwe=0;const y6=new We,Zp=new jm,pu=new Xr,E_=new We,Jx=new We,qwe=new We,Wwe=new jm,v6=new We(1,0,0),w6=new We(0,1,0),_6=new We(0,0,1),Kwe={type:"added"},Xwe={type:"removed"};class js extends Wm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gwe++}),this.uuid=Hu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=js.DEFAULT_UP.clone();const e=new We,n=new Q0,r=new jm,i=new We(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),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 Xr},normalMatrix:{value:new Bn}}),this.matrix=new Xr,this.matrixWorld=new Xr,this.matrixAutoUpdate=js.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=js.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yX,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 Zp.setFromAxisAngle(e,n),this.quaternion.multiply(Zp),this}rotateOnWorldAxis(e,n){return Zp.setFromAxisAngle(e,n),this.quaternion.premultiply(Zp),this}rotateX(e){return this.rotateOnAxis(v6,e)}rotateY(e){return this.rotateOnAxis(w6,e)}rotateZ(e){return this.rotateOnAxis(_6,e)}translateOnAxis(e,n){return y6.copy(e).applyQuaternion(this.quaternion),this.position.add(y6.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(v6,e)}translateY(e){return this.translateOnAxis(w6,e)}translateZ(e){return this.translateOnAxis(_6,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(pu.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?E_.copy(e):E_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Jx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?pu.lookAt(Jx,E_,this.up):pu.lookAt(E_,Jx,this.up),this.quaternion.setFromRotationMatrix(pu),i&&(pu.extractRotation(i.matrixWorld),Zp.setFromRotationMatrix(pu),this.quaternion.premultiply(Zp.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(Kwe)):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(Xwe)),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),pu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),pu.multiply(e.parent.matrixWorld)),e.applyMatrix4(pu),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 s=0,o=i.length;s<o;s++)i[s].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(Jx,e,qwe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Jx,Wwe,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 s=n[r];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.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 s=0,o=i.length;s<o;s++){const l=i[s];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 s(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=s(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 h=c[u];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(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(s(e.materials,this.material[c]));i.material=l}else i.material=s(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(s(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),h=o(e.shapes),p=o(e.skeletons),m=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),h.length>0&&(r.shapes=h),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),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}}js.DEFAULT_UP=new We(0,1,0);js.DEFAULT_MATRIX_AUTO_UPDATE=!0;js.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Fl=new We,gu=new We,vA=new We,bu=new We,Jp=new We,eg=new We,S6=new We,wA=new We,_A=new We,SA=new We;let A_=!1;class Il{constructor(e=new We,n=new We,r=new We){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Fl.subVectors(e,n),i.cross(Fl);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){Fl.subVectors(i,n),gu.subVectors(r,n),vA.subVectors(e,n);const o=Fl.dot(Fl),l=Fl.dot(gu),c=Fl.dot(vA),u=gu.dot(gu),d=gu.dot(vA),h=o*u-l*l;if(h===0)return s.set(-2,-1,-1);const p=1/h,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,bu),bu.x>=0&&bu.y>=0&&bu.x+bu.y<=1}static getUV(e,n,r,i,s,o,l,c){return A_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),A_=!0),this.getInterpolation(e,n,r,i,s,o,l,c)}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,bu),c.setScalar(0),c.addScaledVector(s,bu.x),c.addScaledVector(o,bu.y),c.addScaledVector(l,bu.z),c}static isFrontFacing(e,n,r,i){return Fl.subVectors(r,n),gu.subVectors(e,n),Fl.cross(gu).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 Fl.subVectors(this.c,this.b),gu.subVectors(this.a,this.b),Fl.cross(gu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Il.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Il.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return A_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),A_=!0),Il.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return Il.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Il.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Il.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let o,l;Jp.subVectors(i,r),eg.subVectors(s,r),wA.subVectors(e,r);const c=Jp.dot(wA),u=eg.dot(wA);if(c<=0&&u<=0)return n.copy(r);_A.subVectors(e,i);const d=Jp.dot(_A),h=eg.dot(_A);if(d>=0&&h<=d)return n.copy(i);const p=c*h-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Jp,o);SA.subVectors(e,s);const m=Jp.dot(SA),x=eg.dot(SA);if(x>=0&&m<=x)return n.copy(s);const y=m*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(eg,l);const b=d*x-m*h;if(b<=0&&h-d>=0&&m-x>=0)return S6.subVectors(s,i),l=(h-d)/(h-d+(m-x)),n.copy(i).addScaledVector(S6,l);const v=1/(b+y+p);return o=y*v,l=p*v,n.copy(r).addScaledVector(Jp,o).addScaledVector(eg,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const vX={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},Xd={h:0,s:0,l:0},T_={h:0,s:0,l:0};function NA(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 cn=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=Xa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=jr.workingColorSpace){return this.r=e,this.g=n,this.b=r,jr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=jr.workingColorSpace){if(e=L4(e,1),n=Ya(n,0,1),r=Ya(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=NA(o,s,e+1/3),this.g=NA(o,s,e),this.b=NA(o,s,e-1/3)}return jr.toWorkingColorSpace(this,i),this}setStyle(e,n=Xa){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,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=Xa){const r=vX[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=Bg(e.r),this.g=Bg(e.g),this.b=Bg(e.b),this}copyLinearToSRGB(e){return this.r=hA(e.r),this.g=hA(e.g),this.b=hA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Xa){return jr.fromWorkingColorSpace(ss.copy(this),e),Math.round(Ya(ss.r*255,0,255))*65536+Math.round(Ya(ss.g*255,0,255))*256+Math.round(Ya(ss.b*255,0,255))}getHexString(e=Xa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=jr.workingColorSpace){jr.fromWorkingColorSpace(ss.copy(this),n);const r=ss.r,i=ss.g,s=ss.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const h=o-l;switch(u=d<=.5?h/(o+l):h/(2-o-l),o){case r:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-r)/h+2;break;case s:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=jr.workingColorSpace){return jr.fromWorkingColorSpace(ss.copy(this),n),e.r=ss.r,e.g=ss.g,e.b=ss.b,e}getStyle(e=Xa){jr.fromWorkingColorSpace(ss.copy(this),e);const n=ss.r,r=ss.g,i=ss.b;return e!==Xa?`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(Xd),this.setHSL(Xd.h+e,Xd.s+n,Xd.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(Xd),e.getHSL(T_);const r=Py(Xd.h,T_.h,n),i=Py(Xd.s,T_.s,n),s=Py(Xd.l,T_.l,n);return this.setHSL(r,i,s),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,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[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 ss=new cn;cn.NAMES=vX;let Ywe=0;class Fb extends Wm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ywe++}),this.uuid=Hu(),this.name="",this.type="Material",this.blending=Ug,this.side=Bh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=F3,this.blendDst=I3,this.blendEquation=Vf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new cn(0,0,0),this.blendAlpha=0,this.depthFunc=y1,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=u6,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qp,this.stencilZFail=qp,this.stencilZPass=qp,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!==Ug&&(r.blending=this.blending),this.side!==Bh&&(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!==F3&&(r.blendSrc=this.blendSrc),this.blendDst!==I3&&(r.blendDst=this.blendDst),this.blendEquation!==Vf&&(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!==y1&&(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!==u6&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==qp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==qp&&(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(s){const o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),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 s=0;s!==i;++s)r[s]=n[s].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 wX extends Fb{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new cn(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=P4,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 Ki=new We,j_=new Sn;class Co{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=H3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ou,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,s=this.itemSize;i<s;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++)j_.fromBufferAttribute(this,n),j_.applyMatrix3(e),this.setXY(n,j_.x,j_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Ki.fromBufferAttribute(this,n),Ki.applyMatrix3(e),this.setXYZ(n,Ki.x,Ki.y,Ki.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Ki.fromBufferAttribute(this,n),Ki.applyMatrix4(e),this.setXYZ(n,Ki.x,Ki.y,Ki.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ki.fromBufferAttribute(this,n),Ki.applyNormalMatrix(e),this.setXYZ(n,Ki.x,Ki.y,Ki.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ki.fromBufferAttribute(this,n),Ki.transformDirection(e),this.setXYZ(n,Ki.x,Ki.y,Ki.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=yc(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Tr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=yc(n,this.array)),n}setX(e,n){return this.normalized&&(n=Tr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=yc(n,this.array)),n}setY(e,n){return this.normalized&&(n=Tr(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=yc(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Tr(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=yc(n,this.array)),n}setW(e,n){return this.normalized&&(n=Tr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Tr(n,this.array),r=Tr(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=Tr(n,this.array),r=Tr(r,this.array),i=Tr(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Tr(n,this.array),r=Tr(r,this.array),i=Tr(i,this.array),s=Tr(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,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!==H3&&(e.usage=this.usage),e}}class _X extends Co{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class SX extends Co{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Bi extends Co{constructor(e,n,r){super(new Float32Array(e),n,r)}}let Qwe=0;const Wo=new Xr,kA=new js,tg=new We,xo=new hl,ey=new hl,Ma=new We;class bs extends Wm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qwe++}),this.uuid=Hu(),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(pX(e)?SX:_X)(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 s=new Bn().getNormalMatrix(e);r.applyNormalMatrix(s),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 Wo.makeRotationFromQuaternion(e),this.applyMatrix4(Wo),this}rotateX(e){return Wo.makeRotationX(e),this.applyMatrix4(Wo),this}rotateY(e){return Wo.makeRotationY(e),this.applyMatrix4(Wo),this}rotateZ(e){return Wo.makeRotationZ(e),this.applyMatrix4(Wo),this}translate(e,n,r){return Wo.makeTranslation(e,n,r),this.applyMatrix4(Wo),this}scale(e,n,r){return Wo.makeScale(e,n,r),this.applyMatrix4(Wo),this}lookAt(e){return kA.lookAt(e),kA.updateMatrix(),this.applyMatrix4(kA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(tg).negate(),this.translate(tg.x,tg.y,tg.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Bi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new hl);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 We(-1/0,-1/0,-1/0),new We(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 s=n[r];xo.setFromBufferAttribute(s),this.morphTargetsRelative?(Ma.addVectors(this.boundingBox.min,xo.min),this.boundingBox.expandByPoint(Ma),Ma.addVectors(this.boundingBox.max,xo.max),this.boundingBox.expandByPoint(Ma)):(this.boundingBox.expandByPoint(xo.min),this.boundingBox.expandByPoint(xo.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 Mc);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 We,1/0);return}if(e){const r=this.boundingSphere.center;if(xo.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];ey.setFromBufferAttribute(l),this.morphTargetsRelative?(Ma.addVectors(xo.min,ey.min),xo.expandByPoint(Ma),Ma.addVectors(xo.max,ey.max),xo.expandByPoint(Ma)):(xo.expandByPoint(ey.min),xo.expandByPoint(ey.max))}xo.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)Ma.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ma));if(n)for(let s=0,o=n.length;s<o;s++){const l=n[s],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Ma.fromBufferAttribute(l,u),c&&(tg.fromBufferAttribute(e,u),Ma.add(tg)),i=Math.max(i,r.distanceToSquared(Ma))}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,s=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Co(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let j=0;j<l;j++)u[j]=new We,d[j]=new We;const h=new We,p=new We,m=new We,x=new Sn,y=new Sn,b=new Sn,v=new We,S=new We;function k(j,z,F){h.fromArray(i,j*3),p.fromArray(i,z*3),m.fromArray(i,F*3),x.fromArray(o,j*2),y.fromArray(o,z*2),b.fromArray(o,F*2),p.sub(h),m.sub(h),y.sub(x),b.sub(x);const $=1/(y.x*b.y-b.x*y.y);isFinite($)&&(v.copy(p).multiplyScalar(b.y).addScaledVector(m,-y.y).multiplyScalar($),S.copy(m).multiplyScalar(y.x).addScaledVector(p,-b.x).multiplyScalar($),u[j].add(v),u[z].add(v),u[F].add(v),d[j].add(S),d[z].add(S),d[F].add(S))}let E=this.groups;E.length===0&&(E=[{start:0,count:r.length}]);for(let j=0,z=E.length;j<z;++j){const F=E[j],$=F.start,D=F.count;for(let H=$,q=$+D;H<q;H+=3)k(r[H+0],r[H+1],r[H+2])}const N=new We,A=new We,M=new We,P=new We;function T(j){M.fromArray(s,j*3),P.copy(M);const z=u[j];N.copy(z),N.sub(M.multiplyScalar(M.dot(z))).normalize(),A.crossVectors(P,z);const $=A.dot(d[j])<0?-1:1;c[j*4]=N.x,c[j*4+1]=N.y,c[j*4+2]=N.z,c[j*4+3]=$}for(let j=0,z=E.length;j<z;++j){const F=E[j],$=F.start,D=F.count;for(let H=$,q=$+D;H<q;H+=3)T(r[H+0]),T(r[H+1]),T(r[H+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Co(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,m=r.count;p<m;p++)r.setXYZ(p,0,0,0);const i=new We,s=new We,o=new We,l=new We,c=new We,u=new We,d=new We,h=new We;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),y=e.getX(p+1),b=e.getX(p+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),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 p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),s.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+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++)Ma.fromBufferAttribute(e,n),Ma.normalize(),e.setXYZ(n,Ma.x,Ma.y,Ma.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,h=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?m=c[y]*l.data.stride+l.offset:m=c[y]*d;for(let v=0;v<d;v++)p[x++]=u[m++]}return new Co(p,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new bs,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 s=this.morphAttributes;for(const l in s){const c=[],u=s[l];for(let d=0,h=u.length;d<h;d++){const p=u[d],m=e(p,r);c.push(m)}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 s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let h=0,p=u.length;h<p;h++){const m=u[h];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(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 s=e.morphAttributes;for(const u in s){const d=[],h=s[u];for(let p=0,m=h.length;p<m;p++)d.push(h[p].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 h=o[u];this.addGroup(h.start,h.count,h.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 N6=new Xr,jf=new O4,P_=new Mc,k6=new We,ng=new We,rg=new We,ig=new We,MA=new We,D_=new We,R_=new Sn,L_=new Sn,O_=new Sn,M6=new We,C6=new We,E6=new We,F_=new We,I_=new We;class Gl extends js{constructor(e=new bs,n=new wX){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 s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(s&&l){D_.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],h=s[c];d!==0&&(MA.fromBufferAttribute(h,e),o?D_.addScaledVector(MA,d):D_.addScaledVector(MA.sub(n),d))}n.add(D_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),P_.copy(r.boundingSphere),P_.applyMatrix4(s),jf.copy(e.ray).recast(e.near),!(P_.containsPoint(jf.origin)===!1&&(jf.intersectSphere(P_,k6)===null||jf.origin.distanceToSquared(k6)>(e.far-e.near)**2))&&(N6.copy(s).invert(),jf.copy(e.ray).applyMatrix4(N6),!(r.boundingBox!==null&&jf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,jf)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,p=s.groups,m=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=p.length;x<y;x++){const b=p[x],v=o[b.materialIndex],S=Math.max(b.start,m.start),k=Math.min(l.count,Math.min(b.start+b.count,m.start+m.count));for(let E=S,N=k;E<N;E+=3){const A=l.getX(E),M=l.getX(E+1),P=l.getX(E+2);i=z_(this,v,e,r,u,d,h,A,M,P),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let b=x,v=y;b<v;b+=3){const S=l.getX(b),k=l.getX(b+1),E=l.getX(b+2);i=z_(this,o,e,r,u,d,h,S,k,E),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=p.length;x<y;x++){const b=p[x],v=o[b.materialIndex],S=Math.max(b.start,m.start),k=Math.min(c.count,Math.min(b.start+b.count,m.start+m.count));for(let E=S,N=k;E<N;E+=3){const A=E,M=E+1,P=E+2;i=z_(this,v,e,r,u,d,h,A,M,P),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let b=x,v=y;b<v;b+=3){const S=b,k=b+1,E=b+2;i=z_(this,o,e,r,u,d,h,S,k,E),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function Zwe(t,e,n,r,i,s,o,l){let c;if(e.side===Zs?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===Bh,l),c===null)return null;I_.copy(l),I_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(I_);return u<n.near||u>n.far?null:{distance:u,point:I_.clone(),object:t}}function z_(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,ng),t.getVertexPosition(c,rg),t.getVertexPosition(u,ig);const d=Zwe(t,e,n,r,ng,rg,ig,F_);if(d){i&&(R_.fromBufferAttribute(i,l),L_.fromBufferAttribute(i,c),O_.fromBufferAttribute(i,u),d.uv=Il.getInterpolation(F_,ng,rg,ig,R_,L_,O_,new Sn)),s&&(R_.fromBufferAttribute(s,l),L_.fromBufferAttribute(s,c),O_.fromBufferAttribute(s,u),d.uv1=Il.getInterpolation(F_,ng,rg,ig,R_,L_,O_,new Sn),d.uv2=d.uv1),o&&(M6.fromBufferAttribute(o,l),C6.fromBufferAttribute(o,c),E6.fromBufferAttribute(o,u),d.normal=Il.getInterpolation(F_,ng,rg,ig,M6,C6,E6,new We),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const h={a:l,b:c,c:u,normal:new We,materialIndex:0};Il.getNormal(ng,rg,ig,h.normal),d.face=h}return d}class Z0 extends bs{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const l=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],u=[],d=[],h=[];let p=0,m=0;x("z","y","x",-1,-1,r,n,e,o,s,0),x("z","y","x",1,-1,r,n,-e,o,s,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,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new Bi(u,3)),this.setAttribute("normal",new Bi(d,3)),this.setAttribute("uv",new Bi(h,2));function x(y,b,v,S,k,E,N,A,M,P,T){const j=E/M,z=N/P,F=E/2,$=N/2,D=A/2,H=M+1,q=P+1;let I=0,K=0;const Z=new We;for(let se=0;se<q;se++){const V=se*z-$;for(let W=0;W<H;W++){const ie=W*j-F;Z[y]=ie*S,Z[b]=V*k,Z[v]=D,u.push(Z.x,Z.y,Z.z),Z[y]=0,Z[b]=0,Z[v]=A>0?1:-1,d.push(Z.x,Z.y,Z.z),h.push(W/M),h.push(1-se/P),I+=1}}for(let se=0;se<P;se++)for(let V=0;V<M;V++){const W=p+V+H*se,ie=p+V+H*(se+1),J=p+(V+1)+H*(se+1),pe=p+(V+1)+H*se;c.push(W,ie,pe),c.push(ie,J,pe),K+=6}l.addGroup(m,K,T),m+=K,p+=I}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Z0(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ub(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 Ns(t){const e={};for(let n=0;n<t.length;n++){const r=ub(t[n]);for(const i in r)e[i]=r[i]}return e}function Jwe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function NX(t){return t.getRenderTarget()===null?t.outputColorSpace:jr.workingColorSpace}const F4={clone:ub,merge:Ns};var e_e=`void main() {
  3840. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3841. }`,t_e=`void main() {
  3842. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3843. }`;class $h extends Fb{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=e_e,this.fragmentShader=t_e,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=ub(e.uniforms),this.uniformsGroups=Jwe(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 kX extends js{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xr,this.projectionMatrix=new Xr,this.projectionMatrixInverse=new Xr,this.coordinateSystem=Sc}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 wo extends kX{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=f0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(jy*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return f0*2*Math.atan(Math.tan(jy*.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,s,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=s,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(jy*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+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 ag=-90,sg=1;class n_e extends js{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new wo(ag,sg,e,n);i.layers=this.layers,this.add(i);const s=new wo(ag,sg,e,n);s.layers=this.layers,this.add(s);const o=new wo(ag,sg,e,n);o.layers=this.layers,this.add(o);const l=new wo(ag,sg,e,n);l.layers=this.layers,this.add(l);const c=new wo(ag,sg,e,n);c.layers=this.layers,this.add(c);const u=new wo(ag,sg,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const u of n)this.remove(u);if(e===Sc)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.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===h0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.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[s,o,l,c,u,d]=this.children,h=e.getRenderTarget(),p=e.getActiveCubeFace(),m=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,s),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(h,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class MX extends Js{constructor(e,n,r,i,s,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:ob,super(e,n,r,i,s,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class r_e extends Tm{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(Dy("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===lm?Xa:ol),this.texture=new MX(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:al}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:`
  3844. varying vec3 vWorldDirection;
  3845. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3846. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3847. }
  3848. void main() {
  3849. vWorldDirection = transformDirection( position, modelMatrix );
  3850. #include <begin_vertex>
  3851. #include <project_vertex>
  3852. }
  3853. `,fragmentShader:`
  3854. uniform sampler2D tEquirect;
  3855. varying vec3 vWorldDirection;
  3856. #include <common>
  3857. void main() {
  3858. vec3 direction = normalize( vWorldDirection );
  3859. vec2 sampleUV = equirectUv( direction );
  3860. gl_FragColor = texture2D( tEquirect, sampleUV );
  3861. }
  3862. `},i=new Z0(5,5,5),s=new $h({name:"CubemapFromEquirect",uniforms:ub(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Zs,blending:Ah});s.uniforms.tEquirect.value=n;const o=new Gl(i,s),l=n.minFilter;return n.minFilter===u0&&(n.minFilter=al),new n_e(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}}const CA=new We,i_e=new We,a_e=new Bn;class rh{constructor(e=new We(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=CA.subVectors(r,n).cross(i_e.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(CA),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}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||a_e.getNormalMatrix(e),i=this.coplanarPoint(CA).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),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 Pf=new Mc,U_=new We;class Wk{constructor(e=new rh,n=new rh,r=new rh,i=new rh,s=new rh,o=new rh){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,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(s),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=Sc){const r=this.planes,i=e.elements,s=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],h=i[6],p=i[7],m=i[8],x=i[9],y=i[10],b=i[11],v=i[12],S=i[13],k=i[14],E=i[15];if(r[0].setComponents(c-s,p-u,b-m,E-v).normalize(),r[1].setComponents(c+s,p+u,b+m,E+v).normalize(),r[2].setComponents(c+o,p+d,b+x,E+S).normalize(),r[3].setComponents(c-o,p-d,b-x,E-S).normalize(),r[4].setComponents(c-l,p-h,b-y,E-k).normalize(),n===Sc)r[5].setComponents(c+l,p+h,b+y,E+k).normalize();else if(n===h0)r[5].setComponents(l,h,y,k).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(),Pf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Pf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Pf)}intersectsSprite(e){return Pf.center.set(0,0,0),Pf.radius=.7071067811865476,Pf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Pf)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].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(U_.x=i.normal.x>0?e.max.x:e.min.x,U_.y=i.normal.y>0?e.max.y:e.min.y,U_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(U_)<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 CX(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,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(s){n=s},setContext:function(s){t=s}}}function s_e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const h=u.array,p=u.usage,m=h.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,h,p),u.onUploadCallback();let y;if(h instanceof Float32Array)y=t.FLOAT;else if(h 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(h instanceof Int16Array)y=t.SHORT;else if(h instanceof Uint32Array)y=t.UNSIGNED_INT;else if(h instanceof Int32Array)y=t.INT;else if(h instanceof Int8Array)y=t.BYTE;else if(h instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:x,type:y,bytesPerElement:h.BYTES_PER_ELEMENT,version:u.version,size:m}}function s(u,d,h){const p=d.array,m=d._updateRange,x=d.updateRanges;if(t.bindBuffer(h,u),m.count===-1&&x.length===0&&t.bufferSubData(h,0,p),x.length!==0){for(let y=0,b=x.length;y<b;y++){const v=x[y];n?t.bufferSubData(h,v.start*p.BYTES_PER_ELEMENT,p,v.start,v.count):t.bufferSubData(h,v.start*p.BYTES_PER_ELEMENT,p.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.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 p=r.get(u);(!p||p.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 h=r.get(u);if(h===void 0)r.set(u,i(u,d));else if(h.version<u.version){if(h.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.");s(h.buffer,u,d),h.version=u.version}}return{get:o,remove:l,update:c}}class I4 extends bs{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,h=e/l,p=n/c,m=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const S=v*p-o;for(let k=0;k<u;k++){const E=k*h-s;x.push(E,-S,0),y.push(0,0,1),b.push(k/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const k=S+u*v,E=S+u*(v+1),N=S+1+u*(v+1),A=S+1+u*v;m.push(k,E,A),m.push(E,N,A)}this.setIndex(m),this.setAttribute("position",new Bi(x,3)),this.setAttribute("normal",new Bi(y,3)),this.setAttribute("uv",new Bi(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new I4(e.width,e.height,e.widthSegments,e.heightSegments)}}var o_e=`#ifdef USE_ALPHAHASH
  3863. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3864. #endif`,l_e=`#ifdef USE_ALPHAHASH
  3865. const float ALPHA_HASH_SCALE = 0.05;
  3866. float hash2D( vec2 value ) {
  3867. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3868. }
  3869. float hash3D( vec3 value ) {
  3870. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3871. }
  3872. float getAlphaHashThreshold( vec3 position ) {
  3873. float maxDeriv = max(
  3874. length( dFdx( position.xyz ) ),
  3875. length( dFdy( position.xyz ) )
  3876. );
  3877. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3878. vec2 pixScales = vec2(
  3879. exp2( floor( log2( pixScale ) ) ),
  3880. exp2( ceil( log2( pixScale ) ) )
  3881. );
  3882. vec2 alpha = vec2(
  3883. hash3D( floor( pixScales.x * position.xyz ) ),
  3884. hash3D( floor( pixScales.y * position.xyz ) )
  3885. );
  3886. float lerpFactor = fract( log2( pixScale ) );
  3887. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3888. float a = min( lerpFactor, 1.0 - lerpFactor );
  3889. vec3 cases = vec3(
  3890. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3891. ( x - 0.5 * a ) / ( 1.0 - a ),
  3892. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3893. );
  3894. float threshold = ( x < ( 1.0 - a ) )
  3895. ? ( ( x < a ) ? cases.x : cases.y )
  3896. : cases.z;
  3897. return clamp( threshold , 1.0e-6, 1.0 );
  3898. }
  3899. #endif`,c_e=`#ifdef USE_ALPHAMAP
  3900. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3901. #endif`,u_e=`#ifdef USE_ALPHAMAP
  3902. uniform sampler2D alphaMap;
  3903. #endif`,d_e=`#ifdef USE_ALPHATEST
  3904. if ( diffuseColor.a < alphaTest ) discard;
  3905. #endif`,h_e=`#ifdef USE_ALPHATEST
  3906. uniform float alphaTest;
  3907. #endif`,f_e=`#ifdef USE_AOMAP
  3908. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3909. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3910. #if defined( USE_CLEARCOAT )
  3911. clearcoatSpecularIndirect *= ambientOcclusion;
  3912. #endif
  3913. #if defined( USE_SHEEN )
  3914. sheenSpecularIndirect *= ambientOcclusion;
  3915. #endif
  3916. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3917. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3918. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3919. #endif
  3920. #endif`,m_e=`#ifdef USE_AOMAP
  3921. uniform sampler2D aoMap;
  3922. uniform float aoMapIntensity;
  3923. #endif`,p_e=`#ifdef USE_BATCHING
  3924. attribute float batchId;
  3925. uniform highp sampler2D batchingTexture;
  3926. mat4 getBatchingMatrix( const in float i ) {
  3927. int size = textureSize( batchingTexture, 0 ).x;
  3928. int j = int( i ) * 4;
  3929. int x = j % size;
  3930. int y = j / size;
  3931. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  3932. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  3933. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  3934. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  3935. return mat4( v1, v2, v3, v4 );
  3936. }
  3937. #endif`,g_e=`#ifdef USE_BATCHING
  3938. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3939. #endif`,b_e=`vec3 transformed = vec3( position );
  3940. #ifdef USE_ALPHAHASH
  3941. vPosition = vec3( position );
  3942. #endif`,x_e=`vec3 objectNormal = vec3( normal );
  3943. #ifdef USE_TANGENT
  3944. vec3 objectTangent = vec3( tangent.xyz );
  3945. #endif`,y_e=`float G_BlinnPhong_Implicit( ) {
  3946. return 0.25;
  3947. }
  3948. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  3949. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  3950. }
  3951. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  3952. vec3 halfDir = normalize( lightDir + viewDir );
  3953. float dotNH = saturate( dot( normal, halfDir ) );
  3954. float dotVH = saturate( dot( viewDir, halfDir ) );
  3955. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  3956. float G = G_BlinnPhong_Implicit( );
  3957. float D = D_BlinnPhong( shininess, dotNH );
  3958. return F * ( G * D );
  3959. } // validated`,v_e=`#ifdef USE_IRIDESCENCE
  3960. const mat3 XYZ_TO_REC709 = mat3(
  3961. 3.2404542, -0.9692660, 0.0556434,
  3962. -1.5371385, 1.8760108, -0.2040259,
  3963. -0.4985314, 0.0415560, 1.0572252
  3964. );
  3965. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  3966. vec3 sqrtF0 = sqrt( fresnel0 );
  3967. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  3968. }
  3969. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  3970. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  3971. }
  3972. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  3973. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  3974. }
  3975. vec3 evalSensitivity( float OPD, vec3 shift ) {
  3976. float phase = 2.0 * PI * OPD * 1.0e-9;
  3977. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  3978. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  3979. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  3980. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  3981. 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 ) );
  3982. xyz /= 1.0685e-7;
  3983. vec3 rgb = XYZ_TO_REC709 * xyz;
  3984. return rgb;
  3985. }
  3986. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  3987. vec3 I;
  3988. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  3989. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  3990. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  3991. if ( cosTheta2Sq < 0.0 ) {
  3992. return vec3( 1.0 );
  3993. }
  3994. float cosTheta2 = sqrt( cosTheta2Sq );
  3995. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  3996. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  3997. float T121 = 1.0 - R12;
  3998. float phi12 = 0.0;
  3999. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4000. float phi21 = PI - phi12;
  4001. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4002. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4003. vec3 phi23 = vec3( 0.0 );
  4004. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4005. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4006. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4007. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4008. vec3 phi = vec3( phi21 ) + phi23;
  4009. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4010. vec3 r123 = sqrt( R123 );
  4011. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4012. vec3 C0 = R12 + Rs;
  4013. I = C0;
  4014. vec3 Cm = Rs - T121;
  4015. for ( int m = 1; m <= 2; ++ m ) {
  4016. Cm *= r123;
  4017. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4018. I += Cm * Sm;
  4019. }
  4020. return max( I, vec3( 0.0 ) );
  4021. }
  4022. #endif`,w_e=`#ifdef USE_BUMPMAP
  4023. uniform sampler2D bumpMap;
  4024. uniform float bumpScale;
  4025. vec2 dHdxy_fwd() {
  4026. vec2 dSTdx = dFdx( vBumpMapUv );
  4027. vec2 dSTdy = dFdy( vBumpMapUv );
  4028. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4029. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4030. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4031. return vec2( dBx, dBy );
  4032. }
  4033. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4034. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4035. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4036. vec3 vN = surf_norm;
  4037. vec3 R1 = cross( vSigmaY, vN );
  4038. vec3 R2 = cross( vN, vSigmaX );
  4039. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4040. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4041. return normalize( abs( fDet ) * surf_norm - vGrad );
  4042. }
  4043. #endif`,__e=`#if NUM_CLIPPING_PLANES > 0
  4044. vec4 plane;
  4045. #pragma unroll_loop_start
  4046. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4047. plane = clippingPlanes[ i ];
  4048. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4049. }
  4050. #pragma unroll_loop_end
  4051. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4052. bool clipped = true;
  4053. #pragma unroll_loop_start
  4054. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4055. plane = clippingPlanes[ i ];
  4056. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4057. }
  4058. #pragma unroll_loop_end
  4059. if ( clipped ) discard;
  4060. #endif
  4061. #endif`,S_e=`#if NUM_CLIPPING_PLANES > 0
  4062. varying vec3 vClipPosition;
  4063. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4064. #endif`,N_e=`#if NUM_CLIPPING_PLANES > 0
  4065. varying vec3 vClipPosition;
  4066. #endif`,k_e=`#if NUM_CLIPPING_PLANES > 0
  4067. vClipPosition = - mvPosition.xyz;
  4068. #endif`,M_e=`#if defined( USE_COLOR_ALPHA )
  4069. diffuseColor *= vColor;
  4070. #elif defined( USE_COLOR )
  4071. diffuseColor.rgb *= vColor;
  4072. #endif`,C_e=`#if defined( USE_COLOR_ALPHA )
  4073. varying vec4 vColor;
  4074. #elif defined( USE_COLOR )
  4075. varying vec3 vColor;
  4076. #endif`,E_e=`#if defined( USE_COLOR_ALPHA )
  4077. varying vec4 vColor;
  4078. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4079. varying vec3 vColor;
  4080. #endif`,A_e=`#if defined( USE_COLOR_ALPHA )
  4081. vColor = vec4( 1.0 );
  4082. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4083. vColor = vec3( 1.0 );
  4084. #endif
  4085. #ifdef USE_COLOR
  4086. vColor *= color;
  4087. #endif
  4088. #ifdef USE_INSTANCING_COLOR
  4089. vColor.xyz *= instanceColor.xyz;
  4090. #endif`,T_e=`#define PI 3.141592653589793
  4091. #define PI2 6.283185307179586
  4092. #define PI_HALF 1.5707963267948966
  4093. #define RECIPROCAL_PI 0.3183098861837907
  4094. #define RECIPROCAL_PI2 0.15915494309189535
  4095. #define EPSILON 1e-6
  4096. #ifndef saturate
  4097. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4098. #endif
  4099. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4100. float pow2( const in float x ) { return x*x; }
  4101. vec3 pow2( const in vec3 x ) { return x*x; }
  4102. float pow3( const in float x ) { return x*x*x; }
  4103. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4104. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4105. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4106. highp float rand( const in vec2 uv ) {
  4107. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4108. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4109. return fract( sin( sn ) * c );
  4110. }
  4111. #ifdef HIGH_PRECISION
  4112. float precisionSafeLength( vec3 v ) { return length( v ); }
  4113. #else
  4114. float precisionSafeLength( vec3 v ) {
  4115. float maxComponent = max3( abs( v ) );
  4116. return length( v / maxComponent ) * maxComponent;
  4117. }
  4118. #endif
  4119. struct IncidentLight {
  4120. vec3 color;
  4121. vec3 direction;
  4122. bool visible;
  4123. };
  4124. struct ReflectedLight {
  4125. vec3 directDiffuse;
  4126. vec3 directSpecular;
  4127. vec3 indirectDiffuse;
  4128. vec3 indirectSpecular;
  4129. };
  4130. #ifdef USE_ALPHAHASH
  4131. varying vec3 vPosition;
  4132. #endif
  4133. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4134. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4135. }
  4136. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4137. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4138. }
  4139. mat3 transposeMat3( const in mat3 m ) {
  4140. mat3 tmp;
  4141. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4142. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4143. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4144. return tmp;
  4145. }
  4146. float luminance( const in vec3 rgb ) {
  4147. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4148. return dot( weights, rgb );
  4149. }
  4150. bool isPerspectiveMatrix( mat4 m ) {
  4151. return m[ 2 ][ 3 ] == - 1.0;
  4152. }
  4153. vec2 equirectUv( in vec3 dir ) {
  4154. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4155. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4156. return vec2( u, v );
  4157. }
  4158. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4159. return RECIPROCAL_PI * diffuseColor;
  4160. }
  4161. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4162. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4163. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4164. }
  4165. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4166. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4167. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4168. } // validated`,j_e=`#ifdef ENVMAP_TYPE_CUBE_UV
  4169. #define cubeUV_minMipLevel 4.0
  4170. #define cubeUV_minTileSize 16.0
  4171. float getFace( vec3 direction ) {
  4172. vec3 absDirection = abs( direction );
  4173. float face = - 1.0;
  4174. if ( absDirection.x > absDirection.z ) {
  4175. if ( absDirection.x > absDirection.y )
  4176. face = direction.x > 0.0 ? 0.0 : 3.0;
  4177. else
  4178. face = direction.y > 0.0 ? 1.0 : 4.0;
  4179. } else {
  4180. if ( absDirection.z > absDirection.y )
  4181. face = direction.z > 0.0 ? 2.0 : 5.0;
  4182. else
  4183. face = direction.y > 0.0 ? 1.0 : 4.0;
  4184. }
  4185. return face;
  4186. }
  4187. vec2 getUV( vec3 direction, float face ) {
  4188. vec2 uv;
  4189. if ( face == 0.0 ) {
  4190. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4191. } else if ( face == 1.0 ) {
  4192. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4193. } else if ( face == 2.0 ) {
  4194. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4195. } else if ( face == 3.0 ) {
  4196. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4197. } else if ( face == 4.0 ) {
  4198. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4199. } else {
  4200. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4201. }
  4202. return 0.5 * ( uv + 1.0 );
  4203. }
  4204. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4205. float face = getFace( direction );
  4206. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4207. mipInt = max( mipInt, cubeUV_minMipLevel );
  4208. float faceSize = exp2( mipInt );
  4209. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4210. if ( face > 2.0 ) {
  4211. uv.y += faceSize;
  4212. face -= 3.0;
  4213. }
  4214. uv.x += face * faceSize;
  4215. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4216. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4217. uv.x *= CUBEUV_TEXEL_WIDTH;
  4218. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4219. #ifdef texture2DGradEXT
  4220. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4221. #else
  4222. return texture2D( envMap, uv ).rgb;
  4223. #endif
  4224. }
  4225. #define cubeUV_r0 1.0
  4226. #define cubeUV_v0 0.339
  4227. #define cubeUV_m0 - 2.0
  4228. #define cubeUV_r1 0.8
  4229. #define cubeUV_v1 0.276
  4230. #define cubeUV_m1 - 1.0
  4231. #define cubeUV_r4 0.4
  4232. #define cubeUV_v4 0.046
  4233. #define cubeUV_m4 2.0
  4234. #define cubeUV_r5 0.305
  4235. #define cubeUV_v5 0.016
  4236. #define cubeUV_m5 3.0
  4237. #define cubeUV_r6 0.21
  4238. #define cubeUV_v6 0.0038
  4239. #define cubeUV_m6 4.0
  4240. float roughnessToMip( float roughness ) {
  4241. float mip = 0.0;
  4242. if ( roughness >= cubeUV_r1 ) {
  4243. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4244. } else if ( roughness >= cubeUV_r4 ) {
  4245. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4246. } else if ( roughness >= cubeUV_r5 ) {
  4247. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4248. } else if ( roughness >= cubeUV_r6 ) {
  4249. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4250. } else {
  4251. mip = - 2.0 * log2( 1.16 * roughness ); }
  4252. return mip;
  4253. }
  4254. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4255. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4256. float mipF = fract( mip );
  4257. float mipInt = floor( mip );
  4258. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4259. if ( mipF == 0.0 ) {
  4260. return vec4( color0, 1.0 );
  4261. } else {
  4262. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4263. return vec4( mix( color0, color1, mipF ), 1.0 );
  4264. }
  4265. }
  4266. #endif`,P_e=`vec3 transformedNormal = objectNormal;
  4267. #ifdef USE_TANGENT
  4268. vec3 transformedTangent = objectTangent;
  4269. #endif
  4270. #ifdef USE_BATCHING
  4271. mat3 bm = mat3( batchingMatrix );
  4272. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4273. transformedNormal = bm * transformedNormal;
  4274. #ifdef USE_TANGENT
  4275. transformedTangent = bm * transformedTangent;
  4276. #endif
  4277. #endif
  4278. #ifdef USE_INSTANCING
  4279. mat3 im = mat3( instanceMatrix );
  4280. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4281. transformedNormal = im * transformedNormal;
  4282. #ifdef USE_TANGENT
  4283. transformedTangent = im * transformedTangent;
  4284. #endif
  4285. #endif
  4286. transformedNormal = normalMatrix * transformedNormal;
  4287. #ifdef FLIP_SIDED
  4288. transformedNormal = - transformedNormal;
  4289. #endif
  4290. #ifdef USE_TANGENT
  4291. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4292. #ifdef FLIP_SIDED
  4293. transformedTangent = - transformedTangent;
  4294. #endif
  4295. #endif`,D_e=`#ifdef USE_DISPLACEMENTMAP
  4296. uniform sampler2D displacementMap;
  4297. uniform float displacementScale;
  4298. uniform float displacementBias;
  4299. #endif`,R_e=`#ifdef USE_DISPLACEMENTMAP
  4300. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4301. #endif`,L_e=`#ifdef USE_EMISSIVEMAP
  4302. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4303. totalEmissiveRadiance *= emissiveColor.rgb;
  4304. #endif`,O_e=`#ifdef USE_EMISSIVEMAP
  4305. uniform sampler2D emissiveMap;
  4306. #endif`,F_e="gl_FragColor = linearToOutputTexel( gl_FragColor );",I_e=`
  4307. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4308. vec3( 0.8224621, 0.177538, 0.0 ),
  4309. vec3( 0.0331941, 0.9668058, 0.0 ),
  4310. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4311. );
  4312. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4313. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4314. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4315. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4316. );
  4317. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4318. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4319. }
  4320. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4321. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4322. }
  4323. vec4 LinearTransferOETF( in vec4 value ) {
  4324. return value;
  4325. }
  4326. vec4 sRGBTransferOETF( in vec4 value ) {
  4327. 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 );
  4328. }
  4329. vec4 LinearToLinear( in vec4 value ) {
  4330. return value;
  4331. }
  4332. vec4 LinearTosRGB( in vec4 value ) {
  4333. return sRGBTransferOETF( value );
  4334. }`,z_e=`#ifdef USE_ENVMAP
  4335. #ifdef ENV_WORLDPOS
  4336. vec3 cameraToFrag;
  4337. if ( isOrthographic ) {
  4338. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4339. } else {
  4340. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4341. }
  4342. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4343. #ifdef ENVMAP_MODE_REFLECTION
  4344. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4345. #else
  4346. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4347. #endif
  4348. #else
  4349. vec3 reflectVec = vReflect;
  4350. #endif
  4351. #ifdef ENVMAP_TYPE_CUBE
  4352. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4353. #else
  4354. vec4 envColor = vec4( 0.0 );
  4355. #endif
  4356. #ifdef ENVMAP_BLENDING_MULTIPLY
  4357. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4358. #elif defined( ENVMAP_BLENDING_MIX )
  4359. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4360. #elif defined( ENVMAP_BLENDING_ADD )
  4361. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4362. #endif
  4363. #endif`,U_e=`#ifdef USE_ENVMAP
  4364. uniform float envMapIntensity;
  4365. uniform float flipEnvMap;
  4366. #ifdef ENVMAP_TYPE_CUBE
  4367. uniform samplerCube envMap;
  4368. #else
  4369. uniform sampler2D envMap;
  4370. #endif
  4371. #endif`,B_e=`#ifdef USE_ENVMAP
  4372. uniform float reflectivity;
  4373. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4374. #define ENV_WORLDPOS
  4375. #endif
  4376. #ifdef ENV_WORLDPOS
  4377. varying vec3 vWorldPosition;
  4378. uniform float refractionRatio;
  4379. #else
  4380. varying vec3 vReflect;
  4381. #endif
  4382. #endif`,$_e=`#ifdef USE_ENVMAP
  4383. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4384. #define ENV_WORLDPOS
  4385. #endif
  4386. #ifdef ENV_WORLDPOS
  4387. varying vec3 vWorldPosition;
  4388. #else
  4389. varying vec3 vReflect;
  4390. uniform float refractionRatio;
  4391. #endif
  4392. #endif`,H_e=`#ifdef USE_ENVMAP
  4393. #ifdef ENV_WORLDPOS
  4394. vWorldPosition = worldPosition.xyz;
  4395. #else
  4396. vec3 cameraToVertex;
  4397. if ( isOrthographic ) {
  4398. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4399. } else {
  4400. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4401. }
  4402. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4403. #ifdef ENVMAP_MODE_REFLECTION
  4404. vReflect = reflect( cameraToVertex, worldNormal );
  4405. #else
  4406. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4407. #endif
  4408. #endif
  4409. #endif`,V_e=`#ifdef USE_FOG
  4410. vFogDepth = - mvPosition.z;
  4411. #endif`,G_e=`#ifdef USE_FOG
  4412. varying float vFogDepth;
  4413. #endif`,q_e=`#ifdef USE_FOG
  4414. #ifdef FOG_EXP2
  4415. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4416. #else
  4417. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4418. #endif
  4419. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4420. #endif`,W_e=`#ifdef USE_FOG
  4421. uniform vec3 fogColor;
  4422. varying float vFogDepth;
  4423. #ifdef FOG_EXP2
  4424. uniform float fogDensity;
  4425. #else
  4426. uniform float fogNear;
  4427. uniform float fogFar;
  4428. #endif
  4429. #endif`,K_e=`#ifdef USE_GRADIENTMAP
  4430. uniform sampler2D gradientMap;
  4431. #endif
  4432. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4433. float dotNL = dot( normal, lightDirection );
  4434. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4435. #ifdef USE_GRADIENTMAP
  4436. return vec3( texture2D( gradientMap, coord ).r );
  4437. #else
  4438. vec2 fw = fwidth( coord ) * 0.5;
  4439. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4440. #endif
  4441. }`,X_e=`#ifdef USE_LIGHTMAP
  4442. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4443. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4444. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4445. #endif`,Y_e=`#ifdef USE_LIGHTMAP
  4446. uniform sampler2D lightMap;
  4447. uniform float lightMapIntensity;
  4448. #endif`,Q_e=`LambertMaterial material;
  4449. material.diffuseColor = diffuseColor.rgb;
  4450. material.specularStrength = specularStrength;`,Z_e=`varying vec3 vViewPosition;
  4451. struct LambertMaterial {
  4452. vec3 diffuseColor;
  4453. float specularStrength;
  4454. };
  4455. 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 ) {
  4456. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4457. vec3 irradiance = dotNL * directLight.color;
  4458. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4459. }
  4460. 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 ) {
  4461. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4462. }
  4463. #define RE_Direct RE_Direct_Lambert
  4464. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,J_e=`uniform bool receiveShadow;
  4465. uniform vec3 ambientLightColor;
  4466. #if defined( USE_LIGHT_PROBES )
  4467. uniform vec3 lightProbe[ 9 ];
  4468. #endif
  4469. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4470. float x = normal.x, y = normal.y, z = normal.z;
  4471. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4472. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4473. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4474. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4475. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4476. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4477. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4478. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4479. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4480. return result;
  4481. }
  4482. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4483. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4484. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4485. return irradiance;
  4486. }
  4487. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4488. vec3 irradiance = ambientLightColor;
  4489. return irradiance;
  4490. }
  4491. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4492. #if defined ( LEGACY_LIGHTS )
  4493. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4494. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4495. }
  4496. return 1.0;
  4497. #else
  4498. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4499. if ( cutoffDistance > 0.0 ) {
  4500. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4501. }
  4502. return distanceFalloff;
  4503. #endif
  4504. }
  4505. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4506. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4507. }
  4508. #if NUM_DIR_LIGHTS > 0
  4509. struct DirectionalLight {
  4510. vec3 direction;
  4511. vec3 color;
  4512. };
  4513. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4514. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4515. light.color = directionalLight.color;
  4516. light.direction = directionalLight.direction;
  4517. light.visible = true;
  4518. }
  4519. #endif
  4520. #if NUM_POINT_LIGHTS > 0
  4521. struct PointLight {
  4522. vec3 position;
  4523. vec3 color;
  4524. float distance;
  4525. float decay;
  4526. };
  4527. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4528. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4529. vec3 lVector = pointLight.position - geometryPosition;
  4530. light.direction = normalize( lVector );
  4531. float lightDistance = length( lVector );
  4532. light.color = pointLight.color;
  4533. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4534. light.visible = ( light.color != vec3( 0.0 ) );
  4535. }
  4536. #endif
  4537. #if NUM_SPOT_LIGHTS > 0
  4538. struct SpotLight {
  4539. vec3 position;
  4540. vec3 direction;
  4541. vec3 color;
  4542. float distance;
  4543. float decay;
  4544. float coneCos;
  4545. float penumbraCos;
  4546. };
  4547. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4548. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4549. vec3 lVector = spotLight.position - geometryPosition;
  4550. light.direction = normalize( lVector );
  4551. float angleCos = dot( light.direction, spotLight.direction );
  4552. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4553. if ( spotAttenuation > 0.0 ) {
  4554. float lightDistance = length( lVector );
  4555. light.color = spotLight.color * spotAttenuation;
  4556. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4557. light.visible = ( light.color != vec3( 0.0 ) );
  4558. } else {
  4559. light.color = vec3( 0.0 );
  4560. light.visible = false;
  4561. }
  4562. }
  4563. #endif
  4564. #if NUM_RECT_AREA_LIGHTS > 0
  4565. struct RectAreaLight {
  4566. vec3 color;
  4567. vec3 position;
  4568. vec3 halfWidth;
  4569. vec3 halfHeight;
  4570. };
  4571. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4572. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4573. #endif
  4574. #if NUM_HEMI_LIGHTS > 0
  4575. struct HemisphereLight {
  4576. vec3 direction;
  4577. vec3 skyColor;
  4578. vec3 groundColor;
  4579. };
  4580. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4581. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4582. float dotNL = dot( normal, hemiLight.direction );
  4583. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4584. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4585. return irradiance;
  4586. }
  4587. #endif`,eSe=`#ifdef USE_ENVMAP
  4588. vec3 getIBLIrradiance( const in vec3 normal ) {
  4589. #ifdef ENVMAP_TYPE_CUBE_UV
  4590. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4591. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4592. return PI * envMapColor.rgb * envMapIntensity;
  4593. #else
  4594. return vec3( 0.0 );
  4595. #endif
  4596. }
  4597. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4598. #ifdef ENVMAP_TYPE_CUBE_UV
  4599. vec3 reflectVec = reflect( - viewDir, normal );
  4600. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4601. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4602. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4603. return envMapColor.rgb * envMapIntensity;
  4604. #else
  4605. return vec3( 0.0 );
  4606. #endif
  4607. }
  4608. #ifdef USE_ANISOTROPY
  4609. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4610. #ifdef ENVMAP_TYPE_CUBE_UV
  4611. vec3 bentNormal = cross( bitangent, viewDir );
  4612. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4613. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4614. return getIBLRadiance( viewDir, bentNormal, roughness );
  4615. #else
  4616. return vec3( 0.0 );
  4617. #endif
  4618. }
  4619. #endif
  4620. #endif`,tSe=`ToonMaterial material;
  4621. material.diffuseColor = diffuseColor.rgb;`,nSe=`varying vec3 vViewPosition;
  4622. struct ToonMaterial {
  4623. vec3 diffuseColor;
  4624. };
  4625. 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 ) {
  4626. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4627. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4628. }
  4629. 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 ) {
  4630. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4631. }
  4632. #define RE_Direct RE_Direct_Toon
  4633. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,rSe=`BlinnPhongMaterial material;
  4634. material.diffuseColor = diffuseColor.rgb;
  4635. material.specularColor = specular;
  4636. material.specularShininess = shininess;
  4637. material.specularStrength = specularStrength;`,iSe=`varying vec3 vViewPosition;
  4638. struct BlinnPhongMaterial {
  4639. vec3 diffuseColor;
  4640. vec3 specularColor;
  4641. float specularShininess;
  4642. float specularStrength;
  4643. };
  4644. 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 ) {
  4645. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4646. vec3 irradiance = dotNL * directLight.color;
  4647. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4648. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4649. }
  4650. 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 ) {
  4651. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4652. }
  4653. #define RE_Direct RE_Direct_BlinnPhong
  4654. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,aSe=`PhysicalMaterial material;
  4655. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4656. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4657. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4658. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4659. material.roughness = min( material.roughness, 1.0 );
  4660. #ifdef IOR
  4661. material.ior = ior;
  4662. #ifdef USE_SPECULAR
  4663. float specularIntensityFactor = specularIntensity;
  4664. vec3 specularColorFactor = specularColor;
  4665. #ifdef USE_SPECULAR_COLORMAP
  4666. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4667. #endif
  4668. #ifdef USE_SPECULAR_INTENSITYMAP
  4669. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4670. #endif
  4671. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4672. #else
  4673. float specularIntensityFactor = 1.0;
  4674. vec3 specularColorFactor = vec3( 1.0 );
  4675. material.specularF90 = 1.0;
  4676. #endif
  4677. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4678. #else
  4679. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4680. material.specularF90 = 1.0;
  4681. #endif
  4682. #ifdef USE_CLEARCOAT
  4683. material.clearcoat = clearcoat;
  4684. material.clearcoatRoughness = clearcoatRoughness;
  4685. material.clearcoatF0 = vec3( 0.04 );
  4686. material.clearcoatF90 = 1.0;
  4687. #ifdef USE_CLEARCOATMAP
  4688. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4689. #endif
  4690. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4691. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4692. #endif
  4693. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4694. material.clearcoatRoughness += geometryRoughness;
  4695. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4696. #endif
  4697. #ifdef USE_IRIDESCENCE
  4698. material.iridescence = iridescence;
  4699. material.iridescenceIOR = iridescenceIOR;
  4700. #ifdef USE_IRIDESCENCEMAP
  4701. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4702. #endif
  4703. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4704. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4705. #else
  4706. material.iridescenceThickness = iridescenceThicknessMaximum;
  4707. #endif
  4708. #endif
  4709. #ifdef USE_SHEEN
  4710. material.sheenColor = sheenColor;
  4711. #ifdef USE_SHEEN_COLORMAP
  4712. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4713. #endif
  4714. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4715. #ifdef USE_SHEEN_ROUGHNESSMAP
  4716. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4717. #endif
  4718. #endif
  4719. #ifdef USE_ANISOTROPY
  4720. #ifdef USE_ANISOTROPYMAP
  4721. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4722. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4723. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4724. #else
  4725. vec2 anisotropyV = anisotropyVector;
  4726. #endif
  4727. material.anisotropy = length( anisotropyV );
  4728. if( material.anisotropy == 0.0 ) {
  4729. anisotropyV = vec2( 1.0, 0.0 );
  4730. } else {
  4731. anisotropyV /= material.anisotropy;
  4732. material.anisotropy = saturate( material.anisotropy );
  4733. }
  4734. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4735. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4736. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4737. #endif`,sSe=`struct PhysicalMaterial {
  4738. vec3 diffuseColor;
  4739. float roughness;
  4740. vec3 specularColor;
  4741. float specularF90;
  4742. #ifdef USE_CLEARCOAT
  4743. float clearcoat;
  4744. float clearcoatRoughness;
  4745. vec3 clearcoatF0;
  4746. float clearcoatF90;
  4747. #endif
  4748. #ifdef USE_IRIDESCENCE
  4749. float iridescence;
  4750. float iridescenceIOR;
  4751. float iridescenceThickness;
  4752. vec3 iridescenceFresnel;
  4753. vec3 iridescenceF0;
  4754. #endif
  4755. #ifdef USE_SHEEN
  4756. vec3 sheenColor;
  4757. float sheenRoughness;
  4758. #endif
  4759. #ifdef IOR
  4760. float ior;
  4761. #endif
  4762. #ifdef USE_TRANSMISSION
  4763. float transmission;
  4764. float transmissionAlpha;
  4765. float thickness;
  4766. float attenuationDistance;
  4767. vec3 attenuationColor;
  4768. #endif
  4769. #ifdef USE_ANISOTROPY
  4770. float anisotropy;
  4771. float alphaT;
  4772. vec3 anisotropyT;
  4773. vec3 anisotropyB;
  4774. #endif
  4775. };
  4776. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4777. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4778. vec3 sheenSpecularDirect = vec3( 0.0 );
  4779. vec3 sheenSpecularIndirect = vec3(0.0 );
  4780. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4781. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4782. float x2 = x * x;
  4783. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4784. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4785. }
  4786. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4787. float a2 = pow2( alpha );
  4788. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4789. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4790. return 0.5 / max( gv + gl, EPSILON );
  4791. }
  4792. float D_GGX( const in float alpha, const in float dotNH ) {
  4793. float a2 = pow2( alpha );
  4794. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4795. return RECIPROCAL_PI * a2 / pow2( denom );
  4796. }
  4797. #ifdef USE_ANISOTROPY
  4798. 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 ) {
  4799. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4800. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4801. float v = 0.5 / ( gv + gl );
  4802. return saturate(v);
  4803. }
  4804. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4805. float a2 = alphaT * alphaB;
  4806. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4807. highp float v2 = dot( v, v );
  4808. float w2 = a2 / v2;
  4809. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4810. }
  4811. #endif
  4812. #ifdef USE_CLEARCOAT
  4813. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4814. vec3 f0 = material.clearcoatF0;
  4815. float f90 = material.clearcoatF90;
  4816. float roughness = material.clearcoatRoughness;
  4817. float alpha = pow2( roughness );
  4818. vec3 halfDir = normalize( lightDir + viewDir );
  4819. float dotNL = saturate( dot( normal, lightDir ) );
  4820. float dotNV = saturate( dot( normal, viewDir ) );
  4821. float dotNH = saturate( dot( normal, halfDir ) );
  4822. float dotVH = saturate( dot( viewDir, halfDir ) );
  4823. vec3 F = F_Schlick( f0, f90, dotVH );
  4824. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4825. float D = D_GGX( alpha, dotNH );
  4826. return F * ( V * D );
  4827. }
  4828. #endif
  4829. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4830. vec3 f0 = material.specularColor;
  4831. float f90 = material.specularF90;
  4832. float roughness = material.roughness;
  4833. float alpha = pow2( roughness );
  4834. vec3 halfDir = normalize( lightDir + viewDir );
  4835. float dotNL = saturate( dot( normal, lightDir ) );
  4836. float dotNV = saturate( dot( normal, viewDir ) );
  4837. float dotNH = saturate( dot( normal, halfDir ) );
  4838. float dotVH = saturate( dot( viewDir, halfDir ) );
  4839. vec3 F = F_Schlick( f0, f90, dotVH );
  4840. #ifdef USE_IRIDESCENCE
  4841. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4842. #endif
  4843. #ifdef USE_ANISOTROPY
  4844. float dotTL = dot( material.anisotropyT, lightDir );
  4845. float dotTV = dot( material.anisotropyT, viewDir );
  4846. float dotTH = dot( material.anisotropyT, halfDir );
  4847. float dotBL = dot( material.anisotropyB, lightDir );
  4848. float dotBV = dot( material.anisotropyB, viewDir );
  4849. float dotBH = dot( material.anisotropyB, halfDir );
  4850. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4851. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4852. #else
  4853. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4854. float D = D_GGX( alpha, dotNH );
  4855. #endif
  4856. return F * ( V * D );
  4857. }
  4858. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4859. const float LUT_SIZE = 64.0;
  4860. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4861. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4862. float dotNV = saturate( dot( N, V ) );
  4863. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4864. uv = uv * LUT_SCALE + LUT_BIAS;
  4865. return uv;
  4866. }
  4867. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4868. float l = length( f );
  4869. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4870. }
  4871. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4872. float x = dot( v1, v2 );
  4873. float y = abs( x );
  4874. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4875. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4876. float v = a / b;
  4877. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4878. return cross( v1, v2 ) * theta_sintheta;
  4879. }
  4880. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4881. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4882. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4883. vec3 lightNormal = cross( v1, v2 );
  4884. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4885. vec3 T1, T2;
  4886. T1 = normalize( V - N * dot( V, N ) );
  4887. T2 = - cross( N, T1 );
  4888. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4889. vec3 coords[ 4 ];
  4890. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4891. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4892. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4893. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4894. coords[ 0 ] = normalize( coords[ 0 ] );
  4895. coords[ 1 ] = normalize( coords[ 1 ] );
  4896. coords[ 2 ] = normalize( coords[ 2 ] );
  4897. coords[ 3 ] = normalize( coords[ 3 ] );
  4898. vec3 vectorFormFactor = vec3( 0.0 );
  4899. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4900. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4901. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4902. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4903. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4904. return vec3( result );
  4905. }
  4906. #if defined( USE_SHEEN )
  4907. float D_Charlie( float roughness, float dotNH ) {
  4908. float alpha = pow2( roughness );
  4909. float invAlpha = 1.0 / alpha;
  4910. float cos2h = dotNH * dotNH;
  4911. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4912. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4913. }
  4914. float V_Neubelt( float dotNV, float dotNL ) {
  4915. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4916. }
  4917. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4918. vec3 halfDir = normalize( lightDir + viewDir );
  4919. float dotNL = saturate( dot( normal, lightDir ) );
  4920. float dotNV = saturate( dot( normal, viewDir ) );
  4921. float dotNH = saturate( dot( normal, halfDir ) );
  4922. float D = D_Charlie( sheenRoughness, dotNH );
  4923. float V = V_Neubelt( dotNV, dotNL );
  4924. return sheenColor * ( D * V );
  4925. }
  4926. #endif
  4927. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4928. float dotNV = saturate( dot( normal, viewDir ) );
  4929. float r2 = roughness * roughness;
  4930. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  4931. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  4932. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  4933. return saturate( DG * RECIPROCAL_PI );
  4934. }
  4935. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4936. float dotNV = saturate( dot( normal, viewDir ) );
  4937. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  4938. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  4939. vec4 r = roughness * c0 + c1;
  4940. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  4941. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  4942. return fab;
  4943. }
  4944. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  4945. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4946. return specularColor * fab.x + specularF90 * fab.y;
  4947. }
  4948. #ifdef USE_IRIDESCENCE
  4949. 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 ) {
  4950. #else
  4951. 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 ) {
  4952. #endif
  4953. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4954. #ifdef USE_IRIDESCENCE
  4955. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  4956. #else
  4957. vec3 Fr = specularColor;
  4958. #endif
  4959. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  4960. float Ess = fab.x + fab.y;
  4961. float Ems = 1.0 - Ess;
  4962. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  4963. singleScatter += FssEss;
  4964. multiScatter += Fms * Ems;
  4965. }
  4966. #if NUM_RECT_AREA_LIGHTS > 0
  4967. 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 ) {
  4968. vec3 normal = geometryNormal;
  4969. vec3 viewDir = geometryViewDir;
  4970. vec3 position = geometryPosition;
  4971. vec3 lightPos = rectAreaLight.position;
  4972. vec3 halfWidth = rectAreaLight.halfWidth;
  4973. vec3 halfHeight = rectAreaLight.halfHeight;
  4974. vec3 lightColor = rectAreaLight.color;
  4975. float roughness = material.roughness;
  4976. vec3 rectCoords[ 4 ];
  4977. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  4978. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  4979. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  4980. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  4981. vec4 t1 = texture2D( ltc_1, uv );
  4982. vec4 t2 = texture2D( ltc_2, uv );
  4983. mat3 mInv = mat3(
  4984. vec3( t1.x, 0, t1.y ),
  4985. vec3( 0, 1, 0 ),
  4986. vec3( t1.z, 0, t1.w )
  4987. );
  4988. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  4989. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  4990. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  4991. }
  4992. #endif
  4993. 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 ) {
  4994. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4995. vec3 irradiance = dotNL * directLight.color;
  4996. #ifdef USE_CLEARCOAT
  4997. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  4998. vec3 ccIrradiance = dotNLcc * directLight.color;
  4999. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5000. #endif
  5001. #ifdef USE_SHEEN
  5002. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5003. #endif
  5004. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5005. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5006. }
  5007. 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 ) {
  5008. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5009. }
  5010. 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) {
  5011. #ifdef USE_CLEARCOAT
  5012. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5013. #endif
  5014. #ifdef USE_SHEEN
  5015. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5016. #endif
  5017. vec3 singleScattering = vec3( 0.0 );
  5018. vec3 multiScattering = vec3( 0.0 );
  5019. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5020. #ifdef USE_IRIDESCENCE
  5021. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5022. #else
  5023. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5024. #endif
  5025. vec3 totalScattering = singleScattering + multiScattering;
  5026. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5027. reflectedLight.indirectSpecular += radiance * singleScattering;
  5028. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5029. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5030. }
  5031. #define RE_Direct RE_Direct_Physical
  5032. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5033. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5034. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5035. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5036. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5037. }`,oSe=`
  5038. vec3 geometryPosition = - vViewPosition;
  5039. vec3 geometryNormal = normal;
  5040. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5041. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5042. #ifdef USE_CLEARCOAT
  5043. geometryClearcoatNormal = clearcoatNormal;
  5044. #endif
  5045. #ifdef USE_IRIDESCENCE
  5046. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5047. if ( material.iridescenceThickness == 0.0 ) {
  5048. material.iridescence = 0.0;
  5049. } else {
  5050. material.iridescence = saturate( material.iridescence );
  5051. }
  5052. if ( material.iridescence > 0.0 ) {
  5053. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5054. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5055. }
  5056. #endif
  5057. IncidentLight directLight;
  5058. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5059. PointLight pointLight;
  5060. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5061. PointLightShadow pointLightShadow;
  5062. #endif
  5063. #pragma unroll_loop_start
  5064. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5065. pointLight = pointLights[ i ];
  5066. getPointLightInfo( pointLight, geometryPosition, directLight );
  5067. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5068. pointLightShadow = pointLightShadows[ i ];
  5069. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5070. #endif
  5071. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5072. }
  5073. #pragma unroll_loop_end
  5074. #endif
  5075. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5076. SpotLight spotLight;
  5077. vec4 spotColor;
  5078. vec3 spotLightCoord;
  5079. bool inSpotLightMap;
  5080. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5081. SpotLightShadow spotLightShadow;
  5082. #endif
  5083. #pragma unroll_loop_start
  5084. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5085. spotLight = spotLights[ i ];
  5086. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5087. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5088. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5089. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5090. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5091. #else
  5092. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5093. #endif
  5094. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5095. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5096. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5097. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5098. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5099. #endif
  5100. #undef SPOT_LIGHT_MAP_INDEX
  5101. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5102. spotLightShadow = spotLightShadows[ i ];
  5103. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5104. #endif
  5105. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5106. }
  5107. #pragma unroll_loop_end
  5108. #endif
  5109. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5110. DirectionalLight directionalLight;
  5111. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5112. DirectionalLightShadow directionalLightShadow;
  5113. #endif
  5114. #pragma unroll_loop_start
  5115. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5116. directionalLight = directionalLights[ i ];
  5117. getDirectionalLightInfo( directionalLight, directLight );
  5118. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5119. directionalLightShadow = directionalLightShadows[ i ];
  5120. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5121. #endif
  5122. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5123. }
  5124. #pragma unroll_loop_end
  5125. #endif
  5126. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5127. RectAreaLight rectAreaLight;
  5128. #pragma unroll_loop_start
  5129. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5130. rectAreaLight = rectAreaLights[ i ];
  5131. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5132. }
  5133. #pragma unroll_loop_end
  5134. #endif
  5135. #if defined( RE_IndirectDiffuse )
  5136. vec3 iblIrradiance = vec3( 0.0 );
  5137. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5138. #if defined( USE_LIGHT_PROBES )
  5139. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5140. #endif
  5141. #if ( NUM_HEMI_LIGHTS > 0 )
  5142. #pragma unroll_loop_start
  5143. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5144. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5145. }
  5146. #pragma unroll_loop_end
  5147. #endif
  5148. #endif
  5149. #if defined( RE_IndirectSpecular )
  5150. vec3 radiance = vec3( 0.0 );
  5151. vec3 clearcoatRadiance = vec3( 0.0 );
  5152. #endif`,lSe=`#if defined( RE_IndirectDiffuse )
  5153. #ifdef USE_LIGHTMAP
  5154. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5155. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5156. irradiance += lightMapIrradiance;
  5157. #endif
  5158. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5159. iblIrradiance += getIBLIrradiance( geometryNormal );
  5160. #endif
  5161. #endif
  5162. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5163. #ifdef USE_ANISOTROPY
  5164. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5165. #else
  5166. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5167. #endif
  5168. #ifdef USE_CLEARCOAT
  5169. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5170. #endif
  5171. #endif`,cSe=`#if defined( RE_IndirectDiffuse )
  5172. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5173. #endif
  5174. #if defined( RE_IndirectSpecular )
  5175. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5176. #endif`,uSe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5177. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5178. #endif`,dSe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5179. uniform float logDepthBufFC;
  5180. varying float vFragDepth;
  5181. varying float vIsPerspective;
  5182. #endif`,hSe=`#ifdef USE_LOGDEPTHBUF
  5183. #ifdef USE_LOGDEPTHBUF_EXT
  5184. varying float vFragDepth;
  5185. varying float vIsPerspective;
  5186. #else
  5187. uniform float logDepthBufFC;
  5188. #endif
  5189. #endif`,fSe=`#ifdef USE_LOGDEPTHBUF
  5190. #ifdef USE_LOGDEPTHBUF_EXT
  5191. vFragDepth = 1.0 + gl_Position.w;
  5192. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5193. #else
  5194. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5195. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5196. gl_Position.z *= gl_Position.w;
  5197. }
  5198. #endif
  5199. #endif`,mSe=`#ifdef USE_MAP
  5200. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5201. #ifdef DECODE_VIDEO_TEXTURE
  5202. 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 );
  5203. #endif
  5204. diffuseColor *= sampledDiffuseColor;
  5205. #endif`,pSe=`#ifdef USE_MAP
  5206. uniform sampler2D map;
  5207. #endif`,gSe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5208. #if defined( USE_POINTS_UV )
  5209. vec2 uv = vUv;
  5210. #else
  5211. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5212. #endif
  5213. #endif
  5214. #ifdef USE_MAP
  5215. diffuseColor *= texture2D( map, uv );
  5216. #endif
  5217. #ifdef USE_ALPHAMAP
  5218. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5219. #endif`,bSe=`#if defined( USE_POINTS_UV )
  5220. varying vec2 vUv;
  5221. #else
  5222. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5223. uniform mat3 uvTransform;
  5224. #endif
  5225. #endif
  5226. #ifdef USE_MAP
  5227. uniform sampler2D map;
  5228. #endif
  5229. #ifdef USE_ALPHAMAP
  5230. uniform sampler2D alphaMap;
  5231. #endif`,xSe=`float metalnessFactor = metalness;
  5232. #ifdef USE_METALNESSMAP
  5233. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5234. metalnessFactor *= texelMetalness.b;
  5235. #endif`,ySe=`#ifdef USE_METALNESSMAP
  5236. uniform sampler2D metalnessMap;
  5237. #endif`,vSe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5238. vColor *= morphTargetBaseInfluence;
  5239. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5240. #if defined( USE_COLOR_ALPHA )
  5241. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5242. #elif defined( USE_COLOR )
  5243. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5244. #endif
  5245. }
  5246. #endif`,wSe=`#ifdef USE_MORPHNORMALS
  5247. objectNormal *= morphTargetBaseInfluence;
  5248. #ifdef MORPHTARGETS_TEXTURE
  5249. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5250. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5251. }
  5252. #else
  5253. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5254. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5255. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5256. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5257. #endif
  5258. #endif`,_Se=`#ifdef USE_MORPHTARGETS
  5259. uniform float morphTargetBaseInfluence;
  5260. #ifdef MORPHTARGETS_TEXTURE
  5261. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5262. uniform sampler2DArray morphTargetsTexture;
  5263. uniform ivec2 morphTargetsTextureSize;
  5264. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5265. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5266. int y = texelIndex / morphTargetsTextureSize.x;
  5267. int x = texelIndex - y * morphTargetsTextureSize.x;
  5268. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5269. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5270. }
  5271. #else
  5272. #ifndef USE_MORPHNORMALS
  5273. uniform float morphTargetInfluences[ 8 ];
  5274. #else
  5275. uniform float morphTargetInfluences[ 4 ];
  5276. #endif
  5277. #endif
  5278. #endif`,SSe=`#ifdef USE_MORPHTARGETS
  5279. transformed *= morphTargetBaseInfluence;
  5280. #ifdef MORPHTARGETS_TEXTURE
  5281. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5282. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5283. }
  5284. #else
  5285. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5286. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5287. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5288. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5289. #ifndef USE_MORPHNORMALS
  5290. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5291. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5292. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5293. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5294. #endif
  5295. #endif
  5296. #endif`,NSe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5297. #ifdef FLAT_SHADED
  5298. vec3 fdx = dFdx( vViewPosition );
  5299. vec3 fdy = dFdy( vViewPosition );
  5300. vec3 normal = normalize( cross( fdx, fdy ) );
  5301. #else
  5302. vec3 normal = normalize( vNormal );
  5303. #ifdef DOUBLE_SIDED
  5304. normal *= faceDirection;
  5305. #endif
  5306. #endif
  5307. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5308. #ifdef USE_TANGENT
  5309. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5310. #else
  5311. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5312. #if defined( USE_NORMALMAP )
  5313. vNormalMapUv
  5314. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5315. vClearcoatNormalMapUv
  5316. #else
  5317. vUv
  5318. #endif
  5319. );
  5320. #endif
  5321. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5322. tbn[0] *= faceDirection;
  5323. tbn[1] *= faceDirection;
  5324. #endif
  5325. #endif
  5326. #ifdef USE_CLEARCOAT_NORMALMAP
  5327. #ifdef USE_TANGENT
  5328. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5329. #else
  5330. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5331. #endif
  5332. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5333. tbn2[0] *= faceDirection;
  5334. tbn2[1] *= faceDirection;
  5335. #endif
  5336. #endif
  5337. vec3 nonPerturbedNormal = normal;`,kSe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5338. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5339. #ifdef FLIP_SIDED
  5340. normal = - normal;
  5341. #endif
  5342. #ifdef DOUBLE_SIDED
  5343. normal = normal * faceDirection;
  5344. #endif
  5345. normal = normalize( normalMatrix * normal );
  5346. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5347. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5348. mapN.xy *= normalScale;
  5349. normal = normalize( tbn * mapN );
  5350. #elif defined( USE_BUMPMAP )
  5351. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5352. #endif`,MSe=`#ifndef FLAT_SHADED
  5353. varying vec3 vNormal;
  5354. #ifdef USE_TANGENT
  5355. varying vec3 vTangent;
  5356. varying vec3 vBitangent;
  5357. #endif
  5358. #endif`,CSe=`#ifndef FLAT_SHADED
  5359. varying vec3 vNormal;
  5360. #ifdef USE_TANGENT
  5361. varying vec3 vTangent;
  5362. varying vec3 vBitangent;
  5363. #endif
  5364. #endif`,ESe=`#ifndef FLAT_SHADED
  5365. vNormal = normalize( transformedNormal );
  5366. #ifdef USE_TANGENT
  5367. vTangent = normalize( transformedTangent );
  5368. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5369. #endif
  5370. #endif`,ASe=`#ifdef USE_NORMALMAP
  5371. uniform sampler2D normalMap;
  5372. uniform vec2 normalScale;
  5373. #endif
  5374. #ifdef USE_NORMALMAP_OBJECTSPACE
  5375. uniform mat3 normalMatrix;
  5376. #endif
  5377. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5378. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5379. vec3 q0 = dFdx( eye_pos.xyz );
  5380. vec3 q1 = dFdy( eye_pos.xyz );
  5381. vec2 st0 = dFdx( uv.st );
  5382. vec2 st1 = dFdy( uv.st );
  5383. vec3 N = surf_norm;
  5384. vec3 q1perp = cross( q1, N );
  5385. vec3 q0perp = cross( N, q0 );
  5386. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5387. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5388. float det = max( dot( T, T ), dot( B, B ) );
  5389. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5390. return mat3( T * scale, B * scale, N );
  5391. }
  5392. #endif`,TSe=`#ifdef USE_CLEARCOAT
  5393. vec3 clearcoatNormal = nonPerturbedNormal;
  5394. #endif`,jSe=`#ifdef USE_CLEARCOAT_NORMALMAP
  5395. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5396. clearcoatMapN.xy *= clearcoatNormalScale;
  5397. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5398. #endif`,PSe=`#ifdef USE_CLEARCOATMAP
  5399. uniform sampler2D clearcoatMap;
  5400. #endif
  5401. #ifdef USE_CLEARCOAT_NORMALMAP
  5402. uniform sampler2D clearcoatNormalMap;
  5403. uniform vec2 clearcoatNormalScale;
  5404. #endif
  5405. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5406. uniform sampler2D clearcoatRoughnessMap;
  5407. #endif`,DSe=`#ifdef USE_IRIDESCENCEMAP
  5408. uniform sampler2D iridescenceMap;
  5409. #endif
  5410. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5411. uniform sampler2D iridescenceThicknessMap;
  5412. #endif`,RSe=`#ifdef OPAQUE
  5413. diffuseColor.a = 1.0;
  5414. #endif
  5415. #ifdef USE_TRANSMISSION
  5416. diffuseColor.a *= material.transmissionAlpha;
  5417. #endif
  5418. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,LSe=`vec3 packNormalToRGB( const in vec3 normal ) {
  5419. return normalize( normal ) * 0.5 + 0.5;
  5420. }
  5421. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5422. return 2.0 * rgb.xyz - 1.0;
  5423. }
  5424. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5425. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5426. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5427. const float ShiftRight8 = 1. / 256.;
  5428. vec4 packDepthToRGBA( const in float v ) {
  5429. vec4 r = vec4( fract( v * PackFactors ), v );
  5430. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5431. }
  5432. float unpackRGBAToDepth( const in vec4 v ) {
  5433. return dot( v, UnpackFactors );
  5434. }
  5435. vec2 packDepthToRG( in highp float v ) {
  5436. return packDepthToRGBA( v ).yx;
  5437. }
  5438. float unpackRGToDepth( const in highp vec2 v ) {
  5439. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5440. }
  5441. vec4 pack2HalfToRGBA( vec2 v ) {
  5442. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5443. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5444. }
  5445. vec2 unpackRGBATo2Half( vec4 v ) {
  5446. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5447. }
  5448. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5449. return ( viewZ + near ) / ( near - far );
  5450. }
  5451. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5452. return depth * ( near - far ) - near;
  5453. }
  5454. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5455. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5456. }
  5457. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5458. return ( near * far ) / ( ( far - near ) * depth - far );
  5459. }`,OSe=`#ifdef PREMULTIPLIED_ALPHA
  5460. gl_FragColor.rgb *= gl_FragColor.a;
  5461. #endif`,FSe=`vec4 mvPosition = vec4( transformed, 1.0 );
  5462. #ifdef USE_BATCHING
  5463. mvPosition = batchingMatrix * mvPosition;
  5464. #endif
  5465. #ifdef USE_INSTANCING
  5466. mvPosition = instanceMatrix * mvPosition;
  5467. #endif
  5468. mvPosition = modelViewMatrix * mvPosition;
  5469. gl_Position = projectionMatrix * mvPosition;`,ISe=`#ifdef DITHERING
  5470. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5471. #endif`,zSe=`#ifdef DITHERING
  5472. vec3 dithering( vec3 color ) {
  5473. float grid_position = rand( gl_FragCoord.xy );
  5474. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5475. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5476. return color + dither_shift_RGB;
  5477. }
  5478. #endif`,USe=`float roughnessFactor = roughness;
  5479. #ifdef USE_ROUGHNESSMAP
  5480. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5481. roughnessFactor *= texelRoughness.g;
  5482. #endif`,BSe=`#ifdef USE_ROUGHNESSMAP
  5483. uniform sampler2D roughnessMap;
  5484. #endif`,$Se=`#if NUM_SPOT_LIGHT_COORDS > 0
  5485. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5486. #endif
  5487. #if NUM_SPOT_LIGHT_MAPS > 0
  5488. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5489. #endif
  5490. #ifdef USE_SHADOWMAP
  5491. #if NUM_DIR_LIGHT_SHADOWS > 0
  5492. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5493. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5494. struct DirectionalLightShadow {
  5495. float shadowBias;
  5496. float shadowNormalBias;
  5497. float shadowRadius;
  5498. vec2 shadowMapSize;
  5499. };
  5500. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5501. #endif
  5502. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5503. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5504. struct SpotLightShadow {
  5505. float shadowBias;
  5506. float shadowNormalBias;
  5507. float shadowRadius;
  5508. vec2 shadowMapSize;
  5509. };
  5510. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5511. #endif
  5512. #if NUM_POINT_LIGHT_SHADOWS > 0
  5513. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5514. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5515. struct PointLightShadow {
  5516. float shadowBias;
  5517. float shadowNormalBias;
  5518. float shadowRadius;
  5519. vec2 shadowMapSize;
  5520. float shadowCameraNear;
  5521. float shadowCameraFar;
  5522. };
  5523. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5524. #endif
  5525. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5526. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5527. }
  5528. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5529. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5530. }
  5531. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5532. float occlusion = 1.0;
  5533. vec2 distribution = texture2DDistribution( shadow, uv );
  5534. float hard_shadow = step( compare , distribution.x );
  5535. if (hard_shadow != 1.0 ) {
  5536. float distance = compare - distribution.x ;
  5537. float variance = max( 0.00000, distribution.y * distribution.y );
  5538. 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 );
  5539. }
  5540. return occlusion;
  5541. }
  5542. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5543. float shadow = 1.0;
  5544. shadowCoord.xyz /= shadowCoord.w;
  5545. shadowCoord.z += shadowBias;
  5546. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5547. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5548. if ( frustumTest ) {
  5549. #if defined( SHADOWMAP_TYPE_PCF )
  5550. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5551. float dx0 = - texelSize.x * shadowRadius;
  5552. float dy0 = - texelSize.y * shadowRadius;
  5553. float dx1 = + texelSize.x * shadowRadius;
  5554. float dy1 = + texelSize.y * shadowRadius;
  5555. float dx2 = dx0 / 2.0;
  5556. float dy2 = dy0 / 2.0;
  5557. float dx3 = dx1 / 2.0;
  5558. float dy3 = dy1 / 2.0;
  5559. shadow = (
  5560. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5561. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5562. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5563. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5564. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5565. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5566. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5567. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5568. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5569. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5570. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5571. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5572. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5573. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5574. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5575. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5576. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5577. ) * ( 1.0 / 17.0 );
  5578. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5579. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5580. float dx = texelSize.x;
  5581. float dy = texelSize.y;
  5582. vec2 uv = shadowCoord.xy;
  5583. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5584. uv -= f * texelSize;
  5585. shadow = (
  5586. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5587. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5588. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5589. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5590. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5591. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5592. f.x ) +
  5593. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5594. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5595. f.x ) +
  5596. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5597. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5598. f.y ) +
  5599. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5600. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5601. f.y ) +
  5602. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5603. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5604. f.x ),
  5605. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5606. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5607. f.x ),
  5608. f.y )
  5609. ) * ( 1.0 / 9.0 );
  5610. #elif defined( SHADOWMAP_TYPE_VSM )
  5611. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5612. #else
  5613. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5614. #endif
  5615. }
  5616. return shadow;
  5617. }
  5618. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5619. vec3 absV = abs( v );
  5620. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5621. absV *= scaleToCube;
  5622. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5623. vec2 planar = v.xy;
  5624. float almostATexel = 1.5 * texelSizeY;
  5625. float almostOne = 1.0 - almostATexel;
  5626. if ( absV.z >= almostOne ) {
  5627. if ( v.z > 0.0 )
  5628. planar.x = 4.0 - v.x;
  5629. } else if ( absV.x >= almostOne ) {
  5630. float signX = sign( v.x );
  5631. planar.x = v.z * signX + 2.0 * signX;
  5632. } else if ( absV.y >= almostOne ) {
  5633. float signY = sign( v.y );
  5634. planar.x = v.x + 2.0 * signY + 2.0;
  5635. planar.y = v.z * signY - 2.0;
  5636. }
  5637. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5638. }
  5639. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5640. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5641. vec3 lightToPosition = shadowCoord.xyz;
  5642. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5643. vec3 bd3D = normalize( lightToPosition );
  5644. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5645. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5646. return (
  5647. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5648. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5649. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5650. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5651. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5652. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5653. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5654. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5655. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5656. ) * ( 1.0 / 9.0 );
  5657. #else
  5658. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5659. #endif
  5660. }
  5661. #endif`,HSe=`#if NUM_SPOT_LIGHT_COORDS > 0
  5662. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5663. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5664. #endif
  5665. #ifdef USE_SHADOWMAP
  5666. #if NUM_DIR_LIGHT_SHADOWS > 0
  5667. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5668. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5669. struct DirectionalLightShadow {
  5670. float shadowBias;
  5671. float shadowNormalBias;
  5672. float shadowRadius;
  5673. vec2 shadowMapSize;
  5674. };
  5675. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5676. #endif
  5677. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5678. struct SpotLightShadow {
  5679. float shadowBias;
  5680. float shadowNormalBias;
  5681. float shadowRadius;
  5682. vec2 shadowMapSize;
  5683. };
  5684. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5685. #endif
  5686. #if NUM_POINT_LIGHT_SHADOWS > 0
  5687. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5688. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5689. struct PointLightShadow {
  5690. float shadowBias;
  5691. float shadowNormalBias;
  5692. float shadowRadius;
  5693. vec2 shadowMapSize;
  5694. float shadowCameraNear;
  5695. float shadowCameraFar;
  5696. };
  5697. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5698. #endif
  5699. #endif`,VSe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5700. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5701. vec4 shadowWorldPosition;
  5702. #endif
  5703. #if defined( USE_SHADOWMAP )
  5704. #if NUM_DIR_LIGHT_SHADOWS > 0
  5705. #pragma unroll_loop_start
  5706. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5707. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5708. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5709. }
  5710. #pragma unroll_loop_end
  5711. #endif
  5712. #if NUM_POINT_LIGHT_SHADOWS > 0
  5713. #pragma unroll_loop_start
  5714. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5715. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5716. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5717. }
  5718. #pragma unroll_loop_end
  5719. #endif
  5720. #endif
  5721. #if NUM_SPOT_LIGHT_COORDS > 0
  5722. #pragma unroll_loop_start
  5723. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5724. shadowWorldPosition = worldPosition;
  5725. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5726. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5727. #endif
  5728. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5729. }
  5730. #pragma unroll_loop_end
  5731. #endif`,GSe=`float getShadowMask() {
  5732. float shadow = 1.0;
  5733. #ifdef USE_SHADOWMAP
  5734. #if NUM_DIR_LIGHT_SHADOWS > 0
  5735. DirectionalLightShadow directionalLight;
  5736. #pragma unroll_loop_start
  5737. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5738. directionalLight = directionalLightShadows[ i ];
  5739. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5740. }
  5741. #pragma unroll_loop_end
  5742. #endif
  5743. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5744. SpotLightShadow spotLight;
  5745. #pragma unroll_loop_start
  5746. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5747. spotLight = spotLightShadows[ i ];
  5748. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5749. }
  5750. #pragma unroll_loop_end
  5751. #endif
  5752. #if NUM_POINT_LIGHT_SHADOWS > 0
  5753. PointLightShadow pointLight;
  5754. #pragma unroll_loop_start
  5755. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5756. pointLight = pointLightShadows[ i ];
  5757. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5758. }
  5759. #pragma unroll_loop_end
  5760. #endif
  5761. #endif
  5762. return shadow;
  5763. }`,qSe=`#ifdef USE_SKINNING
  5764. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5765. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5766. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5767. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5768. #endif`,WSe=`#ifdef USE_SKINNING
  5769. uniform mat4 bindMatrix;
  5770. uniform mat4 bindMatrixInverse;
  5771. uniform highp sampler2D boneTexture;
  5772. mat4 getBoneMatrix( const in float i ) {
  5773. int size = textureSize( boneTexture, 0 ).x;
  5774. int j = int( i ) * 4;
  5775. int x = j % size;
  5776. int y = j / size;
  5777. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5778. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5779. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5780. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5781. return mat4( v1, v2, v3, v4 );
  5782. }
  5783. #endif`,KSe=`#ifdef USE_SKINNING
  5784. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5785. vec4 skinned = vec4( 0.0 );
  5786. skinned += boneMatX * skinVertex * skinWeight.x;
  5787. skinned += boneMatY * skinVertex * skinWeight.y;
  5788. skinned += boneMatZ * skinVertex * skinWeight.z;
  5789. skinned += boneMatW * skinVertex * skinWeight.w;
  5790. transformed = ( bindMatrixInverse * skinned ).xyz;
  5791. #endif`,XSe=`#ifdef USE_SKINNING
  5792. mat4 skinMatrix = mat4( 0.0 );
  5793. skinMatrix += skinWeight.x * boneMatX;
  5794. skinMatrix += skinWeight.y * boneMatY;
  5795. skinMatrix += skinWeight.z * boneMatZ;
  5796. skinMatrix += skinWeight.w * boneMatW;
  5797. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5798. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5799. #ifdef USE_TANGENT
  5800. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5801. #endif
  5802. #endif`,YSe=`float specularStrength;
  5803. #ifdef USE_SPECULARMAP
  5804. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5805. specularStrength = texelSpecular.r;
  5806. #else
  5807. specularStrength = 1.0;
  5808. #endif`,QSe=`#ifdef USE_SPECULARMAP
  5809. uniform sampler2D specularMap;
  5810. #endif`,ZSe=`#if defined( TONE_MAPPING )
  5811. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5812. #endif`,JSe=`#ifndef saturate
  5813. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5814. #endif
  5815. uniform float toneMappingExposure;
  5816. vec3 LinearToneMapping( vec3 color ) {
  5817. return saturate( toneMappingExposure * color );
  5818. }
  5819. vec3 ReinhardToneMapping( vec3 color ) {
  5820. color *= toneMappingExposure;
  5821. return saturate( color / ( vec3( 1.0 ) + color ) );
  5822. }
  5823. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5824. color *= toneMappingExposure;
  5825. color = max( vec3( 0.0 ), color - 0.004 );
  5826. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5827. }
  5828. vec3 RRTAndODTFit( vec3 v ) {
  5829. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5830. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5831. return a / b;
  5832. }
  5833. vec3 ACESFilmicToneMapping( vec3 color ) {
  5834. const mat3 ACESInputMat = mat3(
  5835. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5836. vec3( 0.04823, 0.01566, 0.83777 )
  5837. );
  5838. const mat3 ACESOutputMat = mat3(
  5839. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5840. vec3( -0.07367, -0.00605, 1.07602 )
  5841. );
  5842. color *= toneMappingExposure / 0.6;
  5843. color = ACESInputMat * color;
  5844. color = RRTAndODTFit( color );
  5845. color = ACESOutputMat * color;
  5846. return saturate( color );
  5847. }
  5848. vec3 CustomToneMapping( vec3 color ) { return color; }`,e1e=`#ifdef USE_TRANSMISSION
  5849. material.transmission = transmission;
  5850. material.transmissionAlpha = 1.0;
  5851. material.thickness = thickness;
  5852. material.attenuationDistance = attenuationDistance;
  5853. material.attenuationColor = attenuationColor;
  5854. #ifdef USE_TRANSMISSIONMAP
  5855. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5856. #endif
  5857. #ifdef USE_THICKNESSMAP
  5858. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5859. #endif
  5860. vec3 pos = vWorldPosition;
  5861. vec3 v = normalize( cameraPosition - pos );
  5862. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5863. vec4 transmitted = getIBLVolumeRefraction(
  5864. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5865. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5866. material.attenuationColor, material.attenuationDistance );
  5867. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5868. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5869. #endif`,t1e=`#ifdef USE_TRANSMISSION
  5870. uniform float transmission;
  5871. uniform float thickness;
  5872. uniform float attenuationDistance;
  5873. uniform vec3 attenuationColor;
  5874. #ifdef USE_TRANSMISSIONMAP
  5875. uniform sampler2D transmissionMap;
  5876. #endif
  5877. #ifdef USE_THICKNESSMAP
  5878. uniform sampler2D thicknessMap;
  5879. #endif
  5880. uniform vec2 transmissionSamplerSize;
  5881. uniform sampler2D transmissionSamplerMap;
  5882. uniform mat4 modelMatrix;
  5883. uniform mat4 projectionMatrix;
  5884. varying vec3 vWorldPosition;
  5885. float w0( float a ) {
  5886. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5887. }
  5888. float w1( float a ) {
  5889. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5890. }
  5891. float w2( float a ){
  5892. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5893. }
  5894. float w3( float a ) {
  5895. return ( 1.0 / 6.0 ) * ( a * a * a );
  5896. }
  5897. float g0( float a ) {
  5898. return w0( a ) + w1( a );
  5899. }
  5900. float g1( float a ) {
  5901. return w2( a ) + w3( a );
  5902. }
  5903. float h0( float a ) {
  5904. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5905. }
  5906. float h1( float a ) {
  5907. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5908. }
  5909. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5910. uv = uv * texelSize.zw + 0.5;
  5911. vec2 iuv = floor( uv );
  5912. vec2 fuv = fract( uv );
  5913. float g0x = g0( fuv.x );
  5914. float g1x = g1( fuv.x );
  5915. float h0x = h0( fuv.x );
  5916. float h1x = h1( fuv.x );
  5917. float h0y = h0( fuv.y );
  5918. float h1y = h1( fuv.y );
  5919. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5920. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5921. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5922. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5923. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  5924. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  5925. }
  5926. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  5927. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  5928. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  5929. vec2 fLodSizeInv = 1.0 / fLodSize;
  5930. vec2 cLodSizeInv = 1.0 / cLodSize;
  5931. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  5932. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  5933. return mix( fSample, cSample, fract( lod ) );
  5934. }
  5935. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  5936. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  5937. vec3 modelScale;
  5938. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  5939. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  5940. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  5941. return normalize( refractionVector ) * thickness * modelScale;
  5942. }
  5943. float applyIorToRoughness( const in float roughness, const in float ior ) {
  5944. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  5945. }
  5946. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  5947. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  5948. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  5949. }
  5950. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  5951. if ( isinf( attenuationDistance ) ) {
  5952. return vec3( 1.0 );
  5953. } else {
  5954. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  5955. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  5956. }
  5957. }
  5958. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  5959. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  5960. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  5961. const in vec3 attenuationColor, const in float attenuationDistance ) {
  5962. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  5963. vec3 refractedRayExit = position + transmissionRay;
  5964. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  5965. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  5966. refractionCoords += 1.0;
  5967. refractionCoords /= 2.0;
  5968. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  5969. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  5970. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  5971. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  5972. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  5973. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  5974. }
  5975. #endif`,n1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  5976. varying vec2 vUv;
  5977. #endif
  5978. #ifdef USE_MAP
  5979. varying vec2 vMapUv;
  5980. #endif
  5981. #ifdef USE_ALPHAMAP
  5982. varying vec2 vAlphaMapUv;
  5983. #endif
  5984. #ifdef USE_LIGHTMAP
  5985. varying vec2 vLightMapUv;
  5986. #endif
  5987. #ifdef USE_AOMAP
  5988. varying vec2 vAoMapUv;
  5989. #endif
  5990. #ifdef USE_BUMPMAP
  5991. varying vec2 vBumpMapUv;
  5992. #endif
  5993. #ifdef USE_NORMALMAP
  5994. varying vec2 vNormalMapUv;
  5995. #endif
  5996. #ifdef USE_EMISSIVEMAP
  5997. varying vec2 vEmissiveMapUv;
  5998. #endif
  5999. #ifdef USE_METALNESSMAP
  6000. varying vec2 vMetalnessMapUv;
  6001. #endif
  6002. #ifdef USE_ROUGHNESSMAP
  6003. varying vec2 vRoughnessMapUv;
  6004. #endif
  6005. #ifdef USE_ANISOTROPYMAP
  6006. varying vec2 vAnisotropyMapUv;
  6007. #endif
  6008. #ifdef USE_CLEARCOATMAP
  6009. varying vec2 vClearcoatMapUv;
  6010. #endif
  6011. #ifdef USE_CLEARCOAT_NORMALMAP
  6012. varying vec2 vClearcoatNormalMapUv;
  6013. #endif
  6014. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6015. varying vec2 vClearcoatRoughnessMapUv;
  6016. #endif
  6017. #ifdef USE_IRIDESCENCEMAP
  6018. varying vec2 vIridescenceMapUv;
  6019. #endif
  6020. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6021. varying vec2 vIridescenceThicknessMapUv;
  6022. #endif
  6023. #ifdef USE_SHEEN_COLORMAP
  6024. varying vec2 vSheenColorMapUv;
  6025. #endif
  6026. #ifdef USE_SHEEN_ROUGHNESSMAP
  6027. varying vec2 vSheenRoughnessMapUv;
  6028. #endif
  6029. #ifdef USE_SPECULARMAP
  6030. varying vec2 vSpecularMapUv;
  6031. #endif
  6032. #ifdef USE_SPECULAR_COLORMAP
  6033. varying vec2 vSpecularColorMapUv;
  6034. #endif
  6035. #ifdef USE_SPECULAR_INTENSITYMAP
  6036. varying vec2 vSpecularIntensityMapUv;
  6037. #endif
  6038. #ifdef USE_TRANSMISSIONMAP
  6039. uniform mat3 transmissionMapTransform;
  6040. varying vec2 vTransmissionMapUv;
  6041. #endif
  6042. #ifdef USE_THICKNESSMAP
  6043. uniform mat3 thicknessMapTransform;
  6044. varying vec2 vThicknessMapUv;
  6045. #endif`,r1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6046. varying vec2 vUv;
  6047. #endif
  6048. #ifdef USE_MAP
  6049. uniform mat3 mapTransform;
  6050. varying vec2 vMapUv;
  6051. #endif
  6052. #ifdef USE_ALPHAMAP
  6053. uniform mat3 alphaMapTransform;
  6054. varying vec2 vAlphaMapUv;
  6055. #endif
  6056. #ifdef USE_LIGHTMAP
  6057. uniform mat3 lightMapTransform;
  6058. varying vec2 vLightMapUv;
  6059. #endif
  6060. #ifdef USE_AOMAP
  6061. uniform mat3 aoMapTransform;
  6062. varying vec2 vAoMapUv;
  6063. #endif
  6064. #ifdef USE_BUMPMAP
  6065. uniform mat3 bumpMapTransform;
  6066. varying vec2 vBumpMapUv;
  6067. #endif
  6068. #ifdef USE_NORMALMAP
  6069. uniform mat3 normalMapTransform;
  6070. varying vec2 vNormalMapUv;
  6071. #endif
  6072. #ifdef USE_DISPLACEMENTMAP
  6073. uniform mat3 displacementMapTransform;
  6074. varying vec2 vDisplacementMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. uniform mat3 emissiveMapTransform;
  6078. varying vec2 vEmissiveMapUv;
  6079. #endif
  6080. #ifdef USE_METALNESSMAP
  6081. uniform mat3 metalnessMapTransform;
  6082. varying vec2 vMetalnessMapUv;
  6083. #endif
  6084. #ifdef USE_ROUGHNESSMAP
  6085. uniform mat3 roughnessMapTransform;
  6086. varying vec2 vRoughnessMapUv;
  6087. #endif
  6088. #ifdef USE_ANISOTROPYMAP
  6089. uniform mat3 anisotropyMapTransform;
  6090. varying vec2 vAnisotropyMapUv;
  6091. #endif
  6092. #ifdef USE_CLEARCOATMAP
  6093. uniform mat3 clearcoatMapTransform;
  6094. varying vec2 vClearcoatMapUv;
  6095. #endif
  6096. #ifdef USE_CLEARCOAT_NORMALMAP
  6097. uniform mat3 clearcoatNormalMapTransform;
  6098. varying vec2 vClearcoatNormalMapUv;
  6099. #endif
  6100. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6101. uniform mat3 clearcoatRoughnessMapTransform;
  6102. varying vec2 vClearcoatRoughnessMapUv;
  6103. #endif
  6104. #ifdef USE_SHEEN_COLORMAP
  6105. uniform mat3 sheenColorMapTransform;
  6106. varying vec2 vSheenColorMapUv;
  6107. #endif
  6108. #ifdef USE_SHEEN_ROUGHNESSMAP
  6109. uniform mat3 sheenRoughnessMapTransform;
  6110. varying vec2 vSheenRoughnessMapUv;
  6111. #endif
  6112. #ifdef USE_IRIDESCENCEMAP
  6113. uniform mat3 iridescenceMapTransform;
  6114. varying vec2 vIridescenceMapUv;
  6115. #endif
  6116. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6117. uniform mat3 iridescenceThicknessMapTransform;
  6118. varying vec2 vIridescenceThicknessMapUv;
  6119. #endif
  6120. #ifdef USE_SPECULARMAP
  6121. uniform mat3 specularMapTransform;
  6122. varying vec2 vSpecularMapUv;
  6123. #endif
  6124. #ifdef USE_SPECULAR_COLORMAP
  6125. uniform mat3 specularColorMapTransform;
  6126. varying vec2 vSpecularColorMapUv;
  6127. #endif
  6128. #ifdef USE_SPECULAR_INTENSITYMAP
  6129. uniform mat3 specularIntensityMapTransform;
  6130. varying vec2 vSpecularIntensityMapUv;
  6131. #endif
  6132. #ifdef USE_TRANSMISSIONMAP
  6133. uniform mat3 transmissionMapTransform;
  6134. varying vec2 vTransmissionMapUv;
  6135. #endif
  6136. #ifdef USE_THICKNESSMAP
  6137. uniform mat3 thicknessMapTransform;
  6138. varying vec2 vThicknessMapUv;
  6139. #endif`,i1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6140. vUv = vec3( uv, 1 ).xy;
  6141. #endif
  6142. #ifdef USE_MAP
  6143. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6144. #endif
  6145. #ifdef USE_ALPHAMAP
  6146. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6147. #endif
  6148. #ifdef USE_LIGHTMAP
  6149. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6150. #endif
  6151. #ifdef USE_AOMAP
  6152. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6153. #endif
  6154. #ifdef USE_BUMPMAP
  6155. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6156. #endif
  6157. #ifdef USE_NORMALMAP
  6158. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6159. #endif
  6160. #ifdef USE_DISPLACEMENTMAP
  6161. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6162. #endif
  6163. #ifdef USE_EMISSIVEMAP
  6164. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6165. #endif
  6166. #ifdef USE_METALNESSMAP
  6167. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6168. #endif
  6169. #ifdef USE_ROUGHNESSMAP
  6170. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6171. #endif
  6172. #ifdef USE_ANISOTROPYMAP
  6173. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6174. #endif
  6175. #ifdef USE_CLEARCOATMAP
  6176. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6177. #endif
  6178. #ifdef USE_CLEARCOAT_NORMALMAP
  6179. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6180. #endif
  6181. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6182. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6183. #endif
  6184. #ifdef USE_IRIDESCENCEMAP
  6185. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6186. #endif
  6187. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6188. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6189. #endif
  6190. #ifdef USE_SHEEN_COLORMAP
  6191. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6192. #endif
  6193. #ifdef USE_SHEEN_ROUGHNESSMAP
  6194. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6195. #endif
  6196. #ifdef USE_SPECULARMAP
  6197. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6198. #endif
  6199. #ifdef USE_SPECULAR_COLORMAP
  6200. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6201. #endif
  6202. #ifdef USE_SPECULAR_INTENSITYMAP
  6203. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6204. #endif
  6205. #ifdef USE_TRANSMISSIONMAP
  6206. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6207. #endif
  6208. #ifdef USE_THICKNESSMAP
  6209. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6210. #endif`,a1e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6211. vec4 worldPosition = vec4( transformed, 1.0 );
  6212. #ifdef USE_BATCHING
  6213. worldPosition = batchingMatrix * worldPosition;
  6214. #endif
  6215. #ifdef USE_INSTANCING
  6216. worldPosition = instanceMatrix * worldPosition;
  6217. #endif
  6218. worldPosition = modelMatrix * worldPosition;
  6219. #endif`;const s1e=`varying vec2 vUv;
  6220. uniform mat3 uvTransform;
  6221. void main() {
  6222. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6223. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6224. }`,o1e=`uniform sampler2D t2D;
  6225. uniform float backgroundIntensity;
  6226. varying vec2 vUv;
  6227. void main() {
  6228. vec4 texColor = texture2D( t2D, vUv );
  6229. #ifdef DECODE_VIDEO_TEXTURE
  6230. 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 );
  6231. #endif
  6232. texColor.rgb *= backgroundIntensity;
  6233. gl_FragColor = texColor;
  6234. #include <tonemapping_fragment>
  6235. #include <colorspace_fragment>
  6236. }`,l1e=`varying vec3 vWorldDirection;
  6237. #include <common>
  6238. void main() {
  6239. vWorldDirection = transformDirection( position, modelMatrix );
  6240. #include <begin_vertex>
  6241. #include <project_vertex>
  6242. gl_Position.z = gl_Position.w;
  6243. }`,c1e=`#ifdef ENVMAP_TYPE_CUBE
  6244. uniform samplerCube envMap;
  6245. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6246. uniform sampler2D envMap;
  6247. #endif
  6248. uniform float flipEnvMap;
  6249. uniform float backgroundBlurriness;
  6250. uniform float backgroundIntensity;
  6251. varying vec3 vWorldDirection;
  6252. #include <cube_uv_reflection_fragment>
  6253. void main() {
  6254. #ifdef ENVMAP_TYPE_CUBE
  6255. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6256. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6257. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6258. #else
  6259. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6260. #endif
  6261. texColor.rgb *= backgroundIntensity;
  6262. gl_FragColor = texColor;
  6263. #include <tonemapping_fragment>
  6264. #include <colorspace_fragment>
  6265. }`,u1e=`varying vec3 vWorldDirection;
  6266. #include <common>
  6267. void main() {
  6268. vWorldDirection = transformDirection( position, modelMatrix );
  6269. #include <begin_vertex>
  6270. #include <project_vertex>
  6271. gl_Position.z = gl_Position.w;
  6272. }`,d1e=`uniform samplerCube tCube;
  6273. uniform float tFlip;
  6274. uniform float opacity;
  6275. varying vec3 vWorldDirection;
  6276. void main() {
  6277. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6278. gl_FragColor = texColor;
  6279. gl_FragColor.a *= opacity;
  6280. #include <tonemapping_fragment>
  6281. #include <colorspace_fragment>
  6282. }`,h1e=`#include <common>
  6283. #include <batching_pars_vertex>
  6284. #include <uv_pars_vertex>
  6285. #include <displacementmap_pars_vertex>
  6286. #include <morphtarget_pars_vertex>
  6287. #include <skinning_pars_vertex>
  6288. #include <logdepthbuf_pars_vertex>
  6289. #include <clipping_planes_pars_vertex>
  6290. varying vec2 vHighPrecisionZW;
  6291. void main() {
  6292. #include <uv_vertex>
  6293. #include <batching_vertex>
  6294. #include <skinbase_vertex>
  6295. #ifdef USE_DISPLACEMENTMAP
  6296. #include <beginnormal_vertex>
  6297. #include <morphnormal_vertex>
  6298. #include <skinnormal_vertex>
  6299. #endif
  6300. #include <begin_vertex>
  6301. #include <morphtarget_vertex>
  6302. #include <skinning_vertex>
  6303. #include <displacementmap_vertex>
  6304. #include <project_vertex>
  6305. #include <logdepthbuf_vertex>
  6306. #include <clipping_planes_vertex>
  6307. vHighPrecisionZW = gl_Position.zw;
  6308. }`,f1e=`#if DEPTH_PACKING == 3200
  6309. uniform float opacity;
  6310. #endif
  6311. #include <common>
  6312. #include <packing>
  6313. #include <uv_pars_fragment>
  6314. #include <map_pars_fragment>
  6315. #include <alphamap_pars_fragment>
  6316. #include <alphatest_pars_fragment>
  6317. #include <alphahash_pars_fragment>
  6318. #include <logdepthbuf_pars_fragment>
  6319. #include <clipping_planes_pars_fragment>
  6320. varying vec2 vHighPrecisionZW;
  6321. void main() {
  6322. #include <clipping_planes_fragment>
  6323. vec4 diffuseColor = vec4( 1.0 );
  6324. #if DEPTH_PACKING == 3200
  6325. diffuseColor.a = opacity;
  6326. #endif
  6327. #include <map_fragment>
  6328. #include <alphamap_fragment>
  6329. #include <alphatest_fragment>
  6330. #include <alphahash_fragment>
  6331. #include <logdepthbuf_fragment>
  6332. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6333. #if DEPTH_PACKING == 3200
  6334. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6335. #elif DEPTH_PACKING == 3201
  6336. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6337. #endif
  6338. }`,m1e=`#define DISTANCE
  6339. varying vec3 vWorldPosition;
  6340. #include <common>
  6341. #include <batching_pars_vertex>
  6342. #include <uv_pars_vertex>
  6343. #include <displacementmap_pars_vertex>
  6344. #include <morphtarget_pars_vertex>
  6345. #include <skinning_pars_vertex>
  6346. #include <clipping_planes_pars_vertex>
  6347. void main() {
  6348. #include <uv_vertex>
  6349. #include <batching_vertex>
  6350. #include <skinbase_vertex>
  6351. #ifdef USE_DISPLACEMENTMAP
  6352. #include <beginnormal_vertex>
  6353. #include <morphnormal_vertex>
  6354. #include <skinnormal_vertex>
  6355. #endif
  6356. #include <begin_vertex>
  6357. #include <morphtarget_vertex>
  6358. #include <skinning_vertex>
  6359. #include <displacementmap_vertex>
  6360. #include <project_vertex>
  6361. #include <worldpos_vertex>
  6362. #include <clipping_planes_vertex>
  6363. vWorldPosition = worldPosition.xyz;
  6364. }`,p1e=`#define DISTANCE
  6365. uniform vec3 referencePosition;
  6366. uniform float nearDistance;
  6367. uniform float farDistance;
  6368. varying vec3 vWorldPosition;
  6369. #include <common>
  6370. #include <packing>
  6371. #include <uv_pars_fragment>
  6372. #include <map_pars_fragment>
  6373. #include <alphamap_pars_fragment>
  6374. #include <alphatest_pars_fragment>
  6375. #include <alphahash_pars_fragment>
  6376. #include <clipping_planes_pars_fragment>
  6377. void main () {
  6378. #include <clipping_planes_fragment>
  6379. vec4 diffuseColor = vec4( 1.0 );
  6380. #include <map_fragment>
  6381. #include <alphamap_fragment>
  6382. #include <alphatest_fragment>
  6383. #include <alphahash_fragment>
  6384. float dist = length( vWorldPosition - referencePosition );
  6385. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6386. dist = saturate( dist );
  6387. gl_FragColor = packDepthToRGBA( dist );
  6388. }`,g1e=`varying vec3 vWorldDirection;
  6389. #include <common>
  6390. void main() {
  6391. vWorldDirection = transformDirection( position, modelMatrix );
  6392. #include <begin_vertex>
  6393. #include <project_vertex>
  6394. }`,b1e=`uniform sampler2D tEquirect;
  6395. varying vec3 vWorldDirection;
  6396. #include <common>
  6397. void main() {
  6398. vec3 direction = normalize( vWorldDirection );
  6399. vec2 sampleUV = equirectUv( direction );
  6400. gl_FragColor = texture2D( tEquirect, sampleUV );
  6401. #include <tonemapping_fragment>
  6402. #include <colorspace_fragment>
  6403. }`,x1e=`uniform float scale;
  6404. attribute float lineDistance;
  6405. varying float vLineDistance;
  6406. #include <common>
  6407. #include <uv_pars_vertex>
  6408. #include <color_pars_vertex>
  6409. #include <fog_pars_vertex>
  6410. #include <morphtarget_pars_vertex>
  6411. #include <logdepthbuf_pars_vertex>
  6412. #include <clipping_planes_pars_vertex>
  6413. void main() {
  6414. vLineDistance = scale * lineDistance;
  6415. #include <uv_vertex>
  6416. #include <color_vertex>
  6417. #include <morphcolor_vertex>
  6418. #include <begin_vertex>
  6419. #include <morphtarget_vertex>
  6420. #include <project_vertex>
  6421. #include <logdepthbuf_vertex>
  6422. #include <clipping_planes_vertex>
  6423. #include <fog_vertex>
  6424. }`,y1e=`uniform vec3 diffuse;
  6425. uniform float opacity;
  6426. uniform float dashSize;
  6427. uniform float totalSize;
  6428. varying float vLineDistance;
  6429. #include <common>
  6430. #include <color_pars_fragment>
  6431. #include <uv_pars_fragment>
  6432. #include <map_pars_fragment>
  6433. #include <fog_pars_fragment>
  6434. #include <logdepthbuf_pars_fragment>
  6435. #include <clipping_planes_pars_fragment>
  6436. void main() {
  6437. #include <clipping_planes_fragment>
  6438. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6439. discard;
  6440. }
  6441. vec3 outgoingLight = vec3( 0.0 );
  6442. vec4 diffuseColor = vec4( diffuse, opacity );
  6443. #include <logdepthbuf_fragment>
  6444. #include <map_fragment>
  6445. #include <color_fragment>
  6446. outgoingLight = diffuseColor.rgb;
  6447. #include <opaque_fragment>
  6448. #include <tonemapping_fragment>
  6449. #include <colorspace_fragment>
  6450. #include <fog_fragment>
  6451. #include <premultiplied_alpha_fragment>
  6452. }`,v1e=`#include <common>
  6453. #include <batching_pars_vertex>
  6454. #include <uv_pars_vertex>
  6455. #include <envmap_pars_vertex>
  6456. #include <color_pars_vertex>
  6457. #include <fog_pars_vertex>
  6458. #include <morphtarget_pars_vertex>
  6459. #include <skinning_pars_vertex>
  6460. #include <logdepthbuf_pars_vertex>
  6461. #include <clipping_planes_pars_vertex>
  6462. void main() {
  6463. #include <uv_vertex>
  6464. #include <color_vertex>
  6465. #include <morphcolor_vertex>
  6466. #include <batching_vertex>
  6467. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6468. #include <beginnormal_vertex>
  6469. #include <morphnormal_vertex>
  6470. #include <skinbase_vertex>
  6471. #include <skinnormal_vertex>
  6472. #include <defaultnormal_vertex>
  6473. #endif
  6474. #include <begin_vertex>
  6475. #include <morphtarget_vertex>
  6476. #include <skinning_vertex>
  6477. #include <project_vertex>
  6478. #include <logdepthbuf_vertex>
  6479. #include <clipping_planes_vertex>
  6480. #include <worldpos_vertex>
  6481. #include <envmap_vertex>
  6482. #include <fog_vertex>
  6483. }`,w1e=`uniform vec3 diffuse;
  6484. uniform float opacity;
  6485. #ifndef FLAT_SHADED
  6486. varying vec3 vNormal;
  6487. #endif
  6488. #include <common>
  6489. #include <dithering_pars_fragment>
  6490. #include <color_pars_fragment>
  6491. #include <uv_pars_fragment>
  6492. #include <map_pars_fragment>
  6493. #include <alphamap_pars_fragment>
  6494. #include <alphatest_pars_fragment>
  6495. #include <alphahash_pars_fragment>
  6496. #include <aomap_pars_fragment>
  6497. #include <lightmap_pars_fragment>
  6498. #include <envmap_common_pars_fragment>
  6499. #include <envmap_pars_fragment>
  6500. #include <fog_pars_fragment>
  6501. #include <specularmap_pars_fragment>
  6502. #include <logdepthbuf_pars_fragment>
  6503. #include <clipping_planes_pars_fragment>
  6504. void main() {
  6505. #include <clipping_planes_fragment>
  6506. vec4 diffuseColor = vec4( diffuse, opacity );
  6507. #include <logdepthbuf_fragment>
  6508. #include <map_fragment>
  6509. #include <color_fragment>
  6510. #include <alphamap_fragment>
  6511. #include <alphatest_fragment>
  6512. #include <alphahash_fragment>
  6513. #include <specularmap_fragment>
  6514. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6515. #ifdef USE_LIGHTMAP
  6516. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6517. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6518. #else
  6519. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6520. #endif
  6521. #include <aomap_fragment>
  6522. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6523. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6524. #include <envmap_fragment>
  6525. #include <opaque_fragment>
  6526. #include <tonemapping_fragment>
  6527. #include <colorspace_fragment>
  6528. #include <fog_fragment>
  6529. #include <premultiplied_alpha_fragment>
  6530. #include <dithering_fragment>
  6531. }`,_1e=`#define LAMBERT
  6532. varying vec3 vViewPosition;
  6533. #include <common>
  6534. #include <batching_pars_vertex>
  6535. #include <uv_pars_vertex>
  6536. #include <displacementmap_pars_vertex>
  6537. #include <envmap_pars_vertex>
  6538. #include <color_pars_vertex>
  6539. #include <fog_pars_vertex>
  6540. #include <normal_pars_vertex>
  6541. #include <morphtarget_pars_vertex>
  6542. #include <skinning_pars_vertex>
  6543. #include <shadowmap_pars_vertex>
  6544. #include <logdepthbuf_pars_vertex>
  6545. #include <clipping_planes_pars_vertex>
  6546. void main() {
  6547. #include <uv_vertex>
  6548. #include <color_vertex>
  6549. #include <morphcolor_vertex>
  6550. #include <batching_vertex>
  6551. #include <beginnormal_vertex>
  6552. #include <morphnormal_vertex>
  6553. #include <skinbase_vertex>
  6554. #include <skinnormal_vertex>
  6555. #include <defaultnormal_vertex>
  6556. #include <normal_vertex>
  6557. #include <begin_vertex>
  6558. #include <morphtarget_vertex>
  6559. #include <skinning_vertex>
  6560. #include <displacementmap_vertex>
  6561. #include <project_vertex>
  6562. #include <logdepthbuf_vertex>
  6563. #include <clipping_planes_vertex>
  6564. vViewPosition = - mvPosition.xyz;
  6565. #include <worldpos_vertex>
  6566. #include <envmap_vertex>
  6567. #include <shadowmap_vertex>
  6568. #include <fog_vertex>
  6569. }`,S1e=`#define LAMBERT
  6570. uniform vec3 diffuse;
  6571. uniform vec3 emissive;
  6572. uniform float opacity;
  6573. #include <common>
  6574. #include <packing>
  6575. #include <dithering_pars_fragment>
  6576. #include <color_pars_fragment>
  6577. #include <uv_pars_fragment>
  6578. #include <map_pars_fragment>
  6579. #include <alphamap_pars_fragment>
  6580. #include <alphatest_pars_fragment>
  6581. #include <alphahash_pars_fragment>
  6582. #include <aomap_pars_fragment>
  6583. #include <lightmap_pars_fragment>
  6584. #include <emissivemap_pars_fragment>
  6585. #include <envmap_common_pars_fragment>
  6586. #include <envmap_pars_fragment>
  6587. #include <fog_pars_fragment>
  6588. #include <bsdfs>
  6589. #include <lights_pars_begin>
  6590. #include <normal_pars_fragment>
  6591. #include <lights_lambert_pars_fragment>
  6592. #include <shadowmap_pars_fragment>
  6593. #include <bumpmap_pars_fragment>
  6594. #include <normalmap_pars_fragment>
  6595. #include <specularmap_pars_fragment>
  6596. #include <logdepthbuf_pars_fragment>
  6597. #include <clipping_planes_pars_fragment>
  6598. void main() {
  6599. #include <clipping_planes_fragment>
  6600. vec4 diffuseColor = vec4( diffuse, opacity );
  6601. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6602. vec3 totalEmissiveRadiance = emissive;
  6603. #include <logdepthbuf_fragment>
  6604. #include <map_fragment>
  6605. #include <color_fragment>
  6606. #include <alphamap_fragment>
  6607. #include <alphatest_fragment>
  6608. #include <alphahash_fragment>
  6609. #include <specularmap_fragment>
  6610. #include <normal_fragment_begin>
  6611. #include <normal_fragment_maps>
  6612. #include <emissivemap_fragment>
  6613. #include <lights_lambert_fragment>
  6614. #include <lights_fragment_begin>
  6615. #include <lights_fragment_maps>
  6616. #include <lights_fragment_end>
  6617. #include <aomap_fragment>
  6618. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6619. #include <envmap_fragment>
  6620. #include <opaque_fragment>
  6621. #include <tonemapping_fragment>
  6622. #include <colorspace_fragment>
  6623. #include <fog_fragment>
  6624. #include <premultiplied_alpha_fragment>
  6625. #include <dithering_fragment>
  6626. }`,N1e=`#define MATCAP
  6627. varying vec3 vViewPosition;
  6628. #include <common>
  6629. #include <batching_pars_vertex>
  6630. #include <uv_pars_vertex>
  6631. #include <color_pars_vertex>
  6632. #include <displacementmap_pars_vertex>
  6633. #include <fog_pars_vertex>
  6634. #include <normal_pars_vertex>
  6635. #include <morphtarget_pars_vertex>
  6636. #include <skinning_pars_vertex>
  6637. #include <logdepthbuf_pars_vertex>
  6638. #include <clipping_planes_pars_vertex>
  6639. void main() {
  6640. #include <uv_vertex>
  6641. #include <color_vertex>
  6642. #include <morphcolor_vertex>
  6643. #include <batching_vertex>
  6644. #include <beginnormal_vertex>
  6645. #include <morphnormal_vertex>
  6646. #include <skinbase_vertex>
  6647. #include <skinnormal_vertex>
  6648. #include <defaultnormal_vertex>
  6649. #include <normal_vertex>
  6650. #include <begin_vertex>
  6651. #include <morphtarget_vertex>
  6652. #include <skinning_vertex>
  6653. #include <displacementmap_vertex>
  6654. #include <project_vertex>
  6655. #include <logdepthbuf_vertex>
  6656. #include <clipping_planes_vertex>
  6657. #include <fog_vertex>
  6658. vViewPosition = - mvPosition.xyz;
  6659. }`,k1e=`#define MATCAP
  6660. uniform vec3 diffuse;
  6661. uniform float opacity;
  6662. uniform sampler2D matcap;
  6663. varying vec3 vViewPosition;
  6664. #include <common>
  6665. #include <dithering_pars_fragment>
  6666. #include <color_pars_fragment>
  6667. #include <uv_pars_fragment>
  6668. #include <map_pars_fragment>
  6669. #include <alphamap_pars_fragment>
  6670. #include <alphatest_pars_fragment>
  6671. #include <alphahash_pars_fragment>
  6672. #include <fog_pars_fragment>
  6673. #include <normal_pars_fragment>
  6674. #include <bumpmap_pars_fragment>
  6675. #include <normalmap_pars_fragment>
  6676. #include <logdepthbuf_pars_fragment>
  6677. #include <clipping_planes_pars_fragment>
  6678. void main() {
  6679. #include <clipping_planes_fragment>
  6680. vec4 diffuseColor = vec4( diffuse, opacity );
  6681. #include <logdepthbuf_fragment>
  6682. #include <map_fragment>
  6683. #include <color_fragment>
  6684. #include <alphamap_fragment>
  6685. #include <alphatest_fragment>
  6686. #include <alphahash_fragment>
  6687. #include <normal_fragment_begin>
  6688. #include <normal_fragment_maps>
  6689. vec3 viewDir = normalize( vViewPosition );
  6690. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6691. vec3 y = cross( viewDir, x );
  6692. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6693. #ifdef USE_MATCAP
  6694. vec4 matcapColor = texture2D( matcap, uv );
  6695. #else
  6696. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6697. #endif
  6698. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6699. #include <opaque_fragment>
  6700. #include <tonemapping_fragment>
  6701. #include <colorspace_fragment>
  6702. #include <fog_fragment>
  6703. #include <premultiplied_alpha_fragment>
  6704. #include <dithering_fragment>
  6705. }`,M1e=`#define NORMAL
  6706. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6707. varying vec3 vViewPosition;
  6708. #endif
  6709. #include <common>
  6710. #include <batching_pars_vertex>
  6711. #include <uv_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <normal_pars_vertex>
  6714. #include <morphtarget_pars_vertex>
  6715. #include <skinning_pars_vertex>
  6716. #include <logdepthbuf_pars_vertex>
  6717. #include <clipping_planes_pars_vertex>
  6718. void main() {
  6719. #include <uv_vertex>
  6720. #include <batching_vertex>
  6721. #include <beginnormal_vertex>
  6722. #include <morphnormal_vertex>
  6723. #include <skinbase_vertex>
  6724. #include <skinnormal_vertex>
  6725. #include <defaultnormal_vertex>
  6726. #include <normal_vertex>
  6727. #include <begin_vertex>
  6728. #include <morphtarget_vertex>
  6729. #include <skinning_vertex>
  6730. #include <displacementmap_vertex>
  6731. #include <project_vertex>
  6732. #include <logdepthbuf_vertex>
  6733. #include <clipping_planes_vertex>
  6734. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6735. vViewPosition = - mvPosition.xyz;
  6736. #endif
  6737. }`,C1e=`#define NORMAL
  6738. uniform float opacity;
  6739. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6740. varying vec3 vViewPosition;
  6741. #endif
  6742. #include <packing>
  6743. #include <uv_pars_fragment>
  6744. #include <normal_pars_fragment>
  6745. #include <bumpmap_pars_fragment>
  6746. #include <normalmap_pars_fragment>
  6747. #include <logdepthbuf_pars_fragment>
  6748. #include <clipping_planes_pars_fragment>
  6749. void main() {
  6750. #include <clipping_planes_fragment>
  6751. #include <logdepthbuf_fragment>
  6752. #include <normal_fragment_begin>
  6753. #include <normal_fragment_maps>
  6754. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6755. #ifdef OPAQUE
  6756. gl_FragColor.a = 1.0;
  6757. #endif
  6758. }`,E1e=`#define PHONG
  6759. varying vec3 vViewPosition;
  6760. #include <common>
  6761. #include <batching_pars_vertex>
  6762. #include <uv_pars_vertex>
  6763. #include <displacementmap_pars_vertex>
  6764. #include <envmap_pars_vertex>
  6765. #include <color_pars_vertex>
  6766. #include <fog_pars_vertex>
  6767. #include <normal_pars_vertex>
  6768. #include <morphtarget_pars_vertex>
  6769. #include <skinning_pars_vertex>
  6770. #include <shadowmap_pars_vertex>
  6771. #include <logdepthbuf_pars_vertex>
  6772. #include <clipping_planes_pars_vertex>
  6773. void main() {
  6774. #include <uv_vertex>
  6775. #include <color_vertex>
  6776. #include <morphcolor_vertex>
  6777. #include <batching_vertex>
  6778. #include <beginnormal_vertex>
  6779. #include <morphnormal_vertex>
  6780. #include <skinbase_vertex>
  6781. #include <skinnormal_vertex>
  6782. #include <defaultnormal_vertex>
  6783. #include <normal_vertex>
  6784. #include <begin_vertex>
  6785. #include <morphtarget_vertex>
  6786. #include <skinning_vertex>
  6787. #include <displacementmap_vertex>
  6788. #include <project_vertex>
  6789. #include <logdepthbuf_vertex>
  6790. #include <clipping_planes_vertex>
  6791. vViewPosition = - mvPosition.xyz;
  6792. #include <worldpos_vertex>
  6793. #include <envmap_vertex>
  6794. #include <shadowmap_vertex>
  6795. #include <fog_vertex>
  6796. }`,A1e=`#define PHONG
  6797. uniform vec3 diffuse;
  6798. uniform vec3 emissive;
  6799. uniform vec3 specular;
  6800. uniform float shininess;
  6801. uniform float opacity;
  6802. #include <common>
  6803. #include <packing>
  6804. #include <dithering_pars_fragment>
  6805. #include <color_pars_fragment>
  6806. #include <uv_pars_fragment>
  6807. #include <map_pars_fragment>
  6808. #include <alphamap_pars_fragment>
  6809. #include <alphatest_pars_fragment>
  6810. #include <alphahash_pars_fragment>
  6811. #include <aomap_pars_fragment>
  6812. #include <lightmap_pars_fragment>
  6813. #include <emissivemap_pars_fragment>
  6814. #include <envmap_common_pars_fragment>
  6815. #include <envmap_pars_fragment>
  6816. #include <fog_pars_fragment>
  6817. #include <bsdfs>
  6818. #include <lights_pars_begin>
  6819. #include <normal_pars_fragment>
  6820. #include <lights_phong_pars_fragment>
  6821. #include <shadowmap_pars_fragment>
  6822. #include <bumpmap_pars_fragment>
  6823. #include <normalmap_pars_fragment>
  6824. #include <specularmap_pars_fragment>
  6825. #include <logdepthbuf_pars_fragment>
  6826. #include <clipping_planes_pars_fragment>
  6827. void main() {
  6828. #include <clipping_planes_fragment>
  6829. vec4 diffuseColor = vec4( diffuse, opacity );
  6830. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6831. vec3 totalEmissiveRadiance = emissive;
  6832. #include <logdepthbuf_fragment>
  6833. #include <map_fragment>
  6834. #include <color_fragment>
  6835. #include <alphamap_fragment>
  6836. #include <alphatest_fragment>
  6837. #include <alphahash_fragment>
  6838. #include <specularmap_fragment>
  6839. #include <normal_fragment_begin>
  6840. #include <normal_fragment_maps>
  6841. #include <emissivemap_fragment>
  6842. #include <lights_phong_fragment>
  6843. #include <lights_fragment_begin>
  6844. #include <lights_fragment_maps>
  6845. #include <lights_fragment_end>
  6846. #include <aomap_fragment>
  6847. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6848. #include <envmap_fragment>
  6849. #include <opaque_fragment>
  6850. #include <tonemapping_fragment>
  6851. #include <colorspace_fragment>
  6852. #include <fog_fragment>
  6853. #include <premultiplied_alpha_fragment>
  6854. #include <dithering_fragment>
  6855. }`,T1e=`#define STANDARD
  6856. varying vec3 vViewPosition;
  6857. #ifdef USE_TRANSMISSION
  6858. varying vec3 vWorldPosition;
  6859. #endif
  6860. #include <common>
  6861. #include <batching_pars_vertex>
  6862. #include <uv_pars_vertex>
  6863. #include <displacementmap_pars_vertex>
  6864. #include <color_pars_vertex>
  6865. #include <fog_pars_vertex>
  6866. #include <normal_pars_vertex>
  6867. #include <morphtarget_pars_vertex>
  6868. #include <skinning_pars_vertex>
  6869. #include <shadowmap_pars_vertex>
  6870. #include <logdepthbuf_pars_vertex>
  6871. #include <clipping_planes_pars_vertex>
  6872. void main() {
  6873. #include <uv_vertex>
  6874. #include <color_vertex>
  6875. #include <morphcolor_vertex>
  6876. #include <batching_vertex>
  6877. #include <beginnormal_vertex>
  6878. #include <morphnormal_vertex>
  6879. #include <skinbase_vertex>
  6880. #include <skinnormal_vertex>
  6881. #include <defaultnormal_vertex>
  6882. #include <normal_vertex>
  6883. #include <begin_vertex>
  6884. #include <morphtarget_vertex>
  6885. #include <skinning_vertex>
  6886. #include <displacementmap_vertex>
  6887. #include <project_vertex>
  6888. #include <logdepthbuf_vertex>
  6889. #include <clipping_planes_vertex>
  6890. vViewPosition = - mvPosition.xyz;
  6891. #include <worldpos_vertex>
  6892. #include <shadowmap_vertex>
  6893. #include <fog_vertex>
  6894. #ifdef USE_TRANSMISSION
  6895. vWorldPosition = worldPosition.xyz;
  6896. #endif
  6897. }`,j1e=`#define STANDARD
  6898. #ifdef PHYSICAL
  6899. #define IOR
  6900. #define USE_SPECULAR
  6901. #endif
  6902. uniform vec3 diffuse;
  6903. uniform vec3 emissive;
  6904. uniform float roughness;
  6905. uniform float metalness;
  6906. uniform float opacity;
  6907. #ifdef IOR
  6908. uniform float ior;
  6909. #endif
  6910. #ifdef USE_SPECULAR
  6911. uniform float specularIntensity;
  6912. uniform vec3 specularColor;
  6913. #ifdef USE_SPECULAR_COLORMAP
  6914. uniform sampler2D specularColorMap;
  6915. #endif
  6916. #ifdef USE_SPECULAR_INTENSITYMAP
  6917. uniform sampler2D specularIntensityMap;
  6918. #endif
  6919. #endif
  6920. #ifdef USE_CLEARCOAT
  6921. uniform float clearcoat;
  6922. uniform float clearcoatRoughness;
  6923. #endif
  6924. #ifdef USE_IRIDESCENCE
  6925. uniform float iridescence;
  6926. uniform float iridescenceIOR;
  6927. uniform float iridescenceThicknessMinimum;
  6928. uniform float iridescenceThicknessMaximum;
  6929. #endif
  6930. #ifdef USE_SHEEN
  6931. uniform vec3 sheenColor;
  6932. uniform float sheenRoughness;
  6933. #ifdef USE_SHEEN_COLORMAP
  6934. uniform sampler2D sheenColorMap;
  6935. #endif
  6936. #ifdef USE_SHEEN_ROUGHNESSMAP
  6937. uniform sampler2D sheenRoughnessMap;
  6938. #endif
  6939. #endif
  6940. #ifdef USE_ANISOTROPY
  6941. uniform vec2 anisotropyVector;
  6942. #ifdef USE_ANISOTROPYMAP
  6943. uniform sampler2D anisotropyMap;
  6944. #endif
  6945. #endif
  6946. varying vec3 vViewPosition;
  6947. #include <common>
  6948. #include <packing>
  6949. #include <dithering_pars_fragment>
  6950. #include <color_pars_fragment>
  6951. #include <uv_pars_fragment>
  6952. #include <map_pars_fragment>
  6953. #include <alphamap_pars_fragment>
  6954. #include <alphatest_pars_fragment>
  6955. #include <alphahash_pars_fragment>
  6956. #include <aomap_pars_fragment>
  6957. #include <lightmap_pars_fragment>
  6958. #include <emissivemap_pars_fragment>
  6959. #include <iridescence_fragment>
  6960. #include <cube_uv_reflection_fragment>
  6961. #include <envmap_common_pars_fragment>
  6962. #include <envmap_physical_pars_fragment>
  6963. #include <fog_pars_fragment>
  6964. #include <lights_pars_begin>
  6965. #include <normal_pars_fragment>
  6966. #include <lights_physical_pars_fragment>
  6967. #include <transmission_pars_fragment>
  6968. #include <shadowmap_pars_fragment>
  6969. #include <bumpmap_pars_fragment>
  6970. #include <normalmap_pars_fragment>
  6971. #include <clearcoat_pars_fragment>
  6972. #include <iridescence_pars_fragment>
  6973. #include <roughnessmap_pars_fragment>
  6974. #include <metalnessmap_pars_fragment>
  6975. #include <logdepthbuf_pars_fragment>
  6976. #include <clipping_planes_pars_fragment>
  6977. void main() {
  6978. #include <clipping_planes_fragment>
  6979. vec4 diffuseColor = vec4( diffuse, opacity );
  6980. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6981. vec3 totalEmissiveRadiance = emissive;
  6982. #include <logdepthbuf_fragment>
  6983. #include <map_fragment>
  6984. #include <color_fragment>
  6985. #include <alphamap_fragment>
  6986. #include <alphatest_fragment>
  6987. #include <alphahash_fragment>
  6988. #include <roughnessmap_fragment>
  6989. #include <metalnessmap_fragment>
  6990. #include <normal_fragment_begin>
  6991. #include <normal_fragment_maps>
  6992. #include <clearcoat_normal_fragment_begin>
  6993. #include <clearcoat_normal_fragment_maps>
  6994. #include <emissivemap_fragment>
  6995. #include <lights_physical_fragment>
  6996. #include <lights_fragment_begin>
  6997. #include <lights_fragment_maps>
  6998. #include <lights_fragment_end>
  6999. #include <aomap_fragment>
  7000. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7001. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7002. #include <transmission_fragment>
  7003. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7004. #ifdef USE_SHEEN
  7005. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7006. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7007. #endif
  7008. #ifdef USE_CLEARCOAT
  7009. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7010. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7011. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7012. #endif
  7013. #include <opaque_fragment>
  7014. #include <tonemapping_fragment>
  7015. #include <colorspace_fragment>
  7016. #include <fog_fragment>
  7017. #include <premultiplied_alpha_fragment>
  7018. #include <dithering_fragment>
  7019. }`,P1e=`#define TOON
  7020. varying vec3 vViewPosition;
  7021. #include <common>
  7022. #include <batching_pars_vertex>
  7023. #include <uv_pars_vertex>
  7024. #include <displacementmap_pars_vertex>
  7025. #include <color_pars_vertex>
  7026. #include <fog_pars_vertex>
  7027. #include <normal_pars_vertex>
  7028. #include <morphtarget_pars_vertex>
  7029. #include <skinning_pars_vertex>
  7030. #include <shadowmap_pars_vertex>
  7031. #include <logdepthbuf_pars_vertex>
  7032. #include <clipping_planes_pars_vertex>
  7033. void main() {
  7034. #include <uv_vertex>
  7035. #include <color_vertex>
  7036. #include <morphcolor_vertex>
  7037. #include <batching_vertex>
  7038. #include <beginnormal_vertex>
  7039. #include <morphnormal_vertex>
  7040. #include <skinbase_vertex>
  7041. #include <skinnormal_vertex>
  7042. #include <defaultnormal_vertex>
  7043. #include <normal_vertex>
  7044. #include <begin_vertex>
  7045. #include <morphtarget_vertex>
  7046. #include <skinning_vertex>
  7047. #include <displacementmap_vertex>
  7048. #include <project_vertex>
  7049. #include <logdepthbuf_vertex>
  7050. #include <clipping_planes_vertex>
  7051. vViewPosition = - mvPosition.xyz;
  7052. #include <worldpos_vertex>
  7053. #include <shadowmap_vertex>
  7054. #include <fog_vertex>
  7055. }`,D1e=`#define TOON
  7056. uniform vec3 diffuse;
  7057. uniform vec3 emissive;
  7058. uniform float opacity;
  7059. #include <common>
  7060. #include <packing>
  7061. #include <dithering_pars_fragment>
  7062. #include <color_pars_fragment>
  7063. #include <uv_pars_fragment>
  7064. #include <map_pars_fragment>
  7065. #include <alphamap_pars_fragment>
  7066. #include <alphatest_pars_fragment>
  7067. #include <alphahash_pars_fragment>
  7068. #include <aomap_pars_fragment>
  7069. #include <lightmap_pars_fragment>
  7070. #include <emissivemap_pars_fragment>
  7071. #include <gradientmap_pars_fragment>
  7072. #include <fog_pars_fragment>
  7073. #include <bsdfs>
  7074. #include <lights_pars_begin>
  7075. #include <normal_pars_fragment>
  7076. #include <lights_toon_pars_fragment>
  7077. #include <shadowmap_pars_fragment>
  7078. #include <bumpmap_pars_fragment>
  7079. #include <normalmap_pars_fragment>
  7080. #include <logdepthbuf_pars_fragment>
  7081. #include <clipping_planes_pars_fragment>
  7082. void main() {
  7083. #include <clipping_planes_fragment>
  7084. vec4 diffuseColor = vec4( diffuse, opacity );
  7085. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7086. vec3 totalEmissiveRadiance = emissive;
  7087. #include <logdepthbuf_fragment>
  7088. #include <map_fragment>
  7089. #include <color_fragment>
  7090. #include <alphamap_fragment>
  7091. #include <alphatest_fragment>
  7092. #include <alphahash_fragment>
  7093. #include <normal_fragment_begin>
  7094. #include <normal_fragment_maps>
  7095. #include <emissivemap_fragment>
  7096. #include <lights_toon_fragment>
  7097. #include <lights_fragment_begin>
  7098. #include <lights_fragment_maps>
  7099. #include <lights_fragment_end>
  7100. #include <aomap_fragment>
  7101. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7102. #include <opaque_fragment>
  7103. #include <tonemapping_fragment>
  7104. #include <colorspace_fragment>
  7105. #include <fog_fragment>
  7106. #include <premultiplied_alpha_fragment>
  7107. #include <dithering_fragment>
  7108. }`,R1e=`uniform float size;
  7109. uniform float scale;
  7110. #include <common>
  7111. #include <color_pars_vertex>
  7112. #include <fog_pars_vertex>
  7113. #include <morphtarget_pars_vertex>
  7114. #include <logdepthbuf_pars_vertex>
  7115. #include <clipping_planes_pars_vertex>
  7116. #ifdef USE_POINTS_UV
  7117. varying vec2 vUv;
  7118. uniform mat3 uvTransform;
  7119. #endif
  7120. void main() {
  7121. #ifdef USE_POINTS_UV
  7122. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7123. #endif
  7124. #include <color_vertex>
  7125. #include <morphcolor_vertex>
  7126. #include <begin_vertex>
  7127. #include <morphtarget_vertex>
  7128. #include <project_vertex>
  7129. gl_PointSize = size;
  7130. #ifdef USE_SIZEATTENUATION
  7131. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7132. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7133. #endif
  7134. #include <logdepthbuf_vertex>
  7135. #include <clipping_planes_vertex>
  7136. #include <worldpos_vertex>
  7137. #include <fog_vertex>
  7138. }`,L1e=`uniform vec3 diffuse;
  7139. uniform float opacity;
  7140. #include <common>
  7141. #include <color_pars_fragment>
  7142. #include <map_particle_pars_fragment>
  7143. #include <alphatest_pars_fragment>
  7144. #include <alphahash_pars_fragment>
  7145. #include <fog_pars_fragment>
  7146. #include <logdepthbuf_pars_fragment>
  7147. #include <clipping_planes_pars_fragment>
  7148. void main() {
  7149. #include <clipping_planes_fragment>
  7150. vec3 outgoingLight = vec3( 0.0 );
  7151. vec4 diffuseColor = vec4( diffuse, opacity );
  7152. #include <logdepthbuf_fragment>
  7153. #include <map_particle_fragment>
  7154. #include <color_fragment>
  7155. #include <alphatest_fragment>
  7156. #include <alphahash_fragment>
  7157. outgoingLight = diffuseColor.rgb;
  7158. #include <opaque_fragment>
  7159. #include <tonemapping_fragment>
  7160. #include <colorspace_fragment>
  7161. #include <fog_fragment>
  7162. #include <premultiplied_alpha_fragment>
  7163. }`,O1e=`#include <common>
  7164. #include <batching_pars_vertex>
  7165. #include <fog_pars_vertex>
  7166. #include <morphtarget_pars_vertex>
  7167. #include <skinning_pars_vertex>
  7168. #include <logdepthbuf_pars_vertex>
  7169. #include <shadowmap_pars_vertex>
  7170. void main() {
  7171. #include <batching_vertex>
  7172. #include <beginnormal_vertex>
  7173. #include <morphnormal_vertex>
  7174. #include <skinbase_vertex>
  7175. #include <skinnormal_vertex>
  7176. #include <defaultnormal_vertex>
  7177. #include <begin_vertex>
  7178. #include <morphtarget_vertex>
  7179. #include <skinning_vertex>
  7180. #include <project_vertex>
  7181. #include <logdepthbuf_vertex>
  7182. #include <worldpos_vertex>
  7183. #include <shadowmap_vertex>
  7184. #include <fog_vertex>
  7185. }`,F1e=`uniform vec3 color;
  7186. uniform float opacity;
  7187. #include <common>
  7188. #include <packing>
  7189. #include <fog_pars_fragment>
  7190. #include <bsdfs>
  7191. #include <lights_pars_begin>
  7192. #include <logdepthbuf_pars_fragment>
  7193. #include <shadowmap_pars_fragment>
  7194. #include <shadowmask_pars_fragment>
  7195. void main() {
  7196. #include <logdepthbuf_fragment>
  7197. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7198. #include <tonemapping_fragment>
  7199. #include <colorspace_fragment>
  7200. #include <fog_fragment>
  7201. }`,I1e=`uniform float rotation;
  7202. uniform vec2 center;
  7203. #include <common>
  7204. #include <uv_pars_vertex>
  7205. #include <fog_pars_vertex>
  7206. #include <logdepthbuf_pars_vertex>
  7207. #include <clipping_planes_pars_vertex>
  7208. void main() {
  7209. #include <uv_vertex>
  7210. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7211. vec2 scale;
  7212. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7213. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7214. #ifndef USE_SIZEATTENUATION
  7215. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7216. if ( isPerspective ) scale *= - mvPosition.z;
  7217. #endif
  7218. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7219. vec2 rotatedPosition;
  7220. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7221. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7222. mvPosition.xy += rotatedPosition;
  7223. gl_Position = projectionMatrix * mvPosition;
  7224. #include <logdepthbuf_vertex>
  7225. #include <clipping_planes_vertex>
  7226. #include <fog_vertex>
  7227. }`,z1e=`uniform vec3 diffuse;
  7228. uniform float opacity;
  7229. #include <common>
  7230. #include <uv_pars_fragment>
  7231. #include <map_pars_fragment>
  7232. #include <alphamap_pars_fragment>
  7233. #include <alphatest_pars_fragment>
  7234. #include <alphahash_pars_fragment>
  7235. #include <fog_pars_fragment>
  7236. #include <logdepthbuf_pars_fragment>
  7237. #include <clipping_planes_pars_fragment>
  7238. void main() {
  7239. #include <clipping_planes_fragment>
  7240. vec3 outgoingLight = vec3( 0.0 );
  7241. vec4 diffuseColor = vec4( diffuse, opacity );
  7242. #include <logdepthbuf_fragment>
  7243. #include <map_fragment>
  7244. #include <alphamap_fragment>
  7245. #include <alphatest_fragment>
  7246. #include <alphahash_fragment>
  7247. outgoingLight = diffuseColor.rgb;
  7248. #include <opaque_fragment>
  7249. #include <tonemapping_fragment>
  7250. #include <colorspace_fragment>
  7251. #include <fog_fragment>
  7252. }`,Dn={alphahash_fragment:o_e,alphahash_pars_fragment:l_e,alphamap_fragment:c_e,alphamap_pars_fragment:u_e,alphatest_fragment:d_e,alphatest_pars_fragment:h_e,aomap_fragment:f_e,aomap_pars_fragment:m_e,batching_pars_vertex:p_e,batching_vertex:g_e,begin_vertex:b_e,beginnormal_vertex:x_e,bsdfs:y_e,iridescence_fragment:v_e,bumpmap_pars_fragment:w_e,clipping_planes_fragment:__e,clipping_planes_pars_fragment:S_e,clipping_planes_pars_vertex:N_e,clipping_planes_vertex:k_e,color_fragment:M_e,color_pars_fragment:C_e,color_pars_vertex:E_e,color_vertex:A_e,common:T_e,cube_uv_reflection_fragment:j_e,defaultnormal_vertex:P_e,displacementmap_pars_vertex:D_e,displacementmap_vertex:R_e,emissivemap_fragment:L_e,emissivemap_pars_fragment:O_e,colorspace_fragment:F_e,colorspace_pars_fragment:I_e,envmap_fragment:z_e,envmap_common_pars_fragment:U_e,envmap_pars_fragment:B_e,envmap_pars_vertex:$_e,envmap_physical_pars_fragment:eSe,envmap_vertex:H_e,fog_vertex:V_e,fog_pars_vertex:G_e,fog_fragment:q_e,fog_pars_fragment:W_e,gradientmap_pars_fragment:K_e,lightmap_fragment:X_e,lightmap_pars_fragment:Y_e,lights_lambert_fragment:Q_e,lights_lambert_pars_fragment:Z_e,lights_pars_begin:J_e,lights_toon_fragment:tSe,lights_toon_pars_fragment:nSe,lights_phong_fragment:rSe,lights_phong_pars_fragment:iSe,lights_physical_fragment:aSe,lights_physical_pars_fragment:sSe,lights_fragment_begin:oSe,lights_fragment_maps:lSe,lights_fragment_end:cSe,logdepthbuf_fragment:uSe,logdepthbuf_pars_fragment:dSe,logdepthbuf_pars_vertex:hSe,logdepthbuf_vertex:fSe,map_fragment:mSe,map_pars_fragment:pSe,map_particle_fragment:gSe,map_particle_pars_fragment:bSe,metalnessmap_fragment:xSe,metalnessmap_pars_fragment:ySe,morphcolor_vertex:vSe,morphnormal_vertex:wSe,morphtarget_pars_vertex:_Se,morphtarget_vertex:SSe,normal_fragment_begin:NSe,normal_fragment_maps:kSe,normal_pars_fragment:MSe,normal_pars_vertex:CSe,normal_vertex:ESe,normalmap_pars_fragment:ASe,clearcoat_normal_fragment_begin:TSe,clearcoat_normal_fragment_maps:jSe,clearcoat_pars_fragment:PSe,iridescence_pars_fragment:DSe,opaque_fragment:RSe,packing:LSe,premultiplied_alpha_fragment:OSe,project_vertex:FSe,dithering_fragment:ISe,dithering_pars_fragment:zSe,roughnessmap_fragment:USe,roughnessmap_pars_fragment:BSe,shadowmap_pars_fragment:$Se,shadowmap_pars_vertex:HSe,shadowmap_vertex:VSe,shadowmask_pars_fragment:GSe,skinbase_vertex:qSe,skinning_pars_vertex:WSe,skinning_vertex:KSe,skinnormal_vertex:XSe,specularmap_fragment:YSe,specularmap_pars_fragment:QSe,tonemapping_fragment:ZSe,tonemapping_pars_fragment:JSe,transmission_fragment:e1e,transmission_pars_fragment:t1e,uv_pars_fragment:n1e,uv_pars_vertex:r1e,uv_vertex:i1e,worldpos_vertex:a1e,background_vert:s1e,background_frag:o1e,backgroundCube_vert:l1e,backgroundCube_frag:c1e,cube_vert:u1e,cube_frag:d1e,depth_vert:h1e,depth_frag:f1e,distanceRGBA_vert:m1e,distanceRGBA_frag:p1e,equirect_vert:g1e,equirect_frag:b1e,linedashed_vert:x1e,linedashed_frag:y1e,meshbasic_vert:v1e,meshbasic_frag:w1e,meshlambert_vert:_1e,meshlambert_frag:S1e,meshmatcap_vert:N1e,meshmatcap_frag:k1e,meshnormal_vert:M1e,meshnormal_frag:C1e,meshphong_vert:E1e,meshphong_frag:A1e,meshphysical_vert:T1e,meshphysical_frag:j1e,meshtoon_vert:P1e,meshtoon_frag:D1e,points_vert:R1e,points_frag:L1e,shadow_vert:O1e,shadow_frag:F1e,sprite_vert:I1e,sprite_frag:z1e},Ot={common:{diffuse:{value:new cn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Bn},alphaMap:{value:null},alphaMapTransform:{value:new Bn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Bn}},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 Bn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Bn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Bn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Bn},normalScale:{value:new Sn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Bn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Bn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Bn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Bn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new cn(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 cn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Bn},alphaTest:{value:0},uvTransform:{value:new Bn}},sprite:{diffuse:{value:new cn(16777215)},opacity:{value:1},center:{value:new Sn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Bn},alphaMap:{value:null},alphaMapTransform:{value:new Bn},alphaTest:{value:0}}},Ws={basic:{uniforms:Ns([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.fog]),vertexShader:Dn.meshbasic_vert,fragmentShader:Dn.meshbasic_frag},lambert:{uniforms:Ns([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,Ot.lights,{emissive:{value:new cn(0)}}]),vertexShader:Dn.meshlambert_vert,fragmentShader:Dn.meshlambert_frag},phong:{uniforms:Ns([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,Ot.lights,{emissive:{value:new cn(0)},specular:{value:new cn(1118481)},shininess:{value:30}}]),vertexShader:Dn.meshphong_vert,fragmentShader:Dn.meshphong_frag},standard:{uniforms:Ns([Ot.common,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.roughnessmap,Ot.metalnessmap,Ot.fog,Ot.lights,{emissive:{value:new cn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Dn.meshphysical_vert,fragmentShader:Dn.meshphysical_frag},toon:{uniforms:Ns([Ot.common,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.gradientmap,Ot.fog,Ot.lights,{emissive:{value:new cn(0)}}]),vertexShader:Dn.meshtoon_vert,fragmentShader:Dn.meshtoon_frag},matcap:{uniforms:Ns([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,{matcap:{value:null}}]),vertexShader:Dn.meshmatcap_vert,fragmentShader:Dn.meshmatcap_frag},points:{uniforms:Ns([Ot.points,Ot.fog]),vertexShader:Dn.points_vert,fragmentShader:Dn.points_frag},dashed:{uniforms:Ns([Ot.common,Ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Dn.linedashed_vert,fragmentShader:Dn.linedashed_frag},depth:{uniforms:Ns([Ot.common,Ot.displacementmap]),vertexShader:Dn.depth_vert,fragmentShader:Dn.depth_frag},normal:{uniforms:Ns([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,{opacity:{value:1}}]),vertexShader:Dn.meshnormal_vert,fragmentShader:Dn.meshnormal_frag},sprite:{uniforms:Ns([Ot.sprite,Ot.fog]),vertexShader:Dn.sprite_vert,fragmentShader:Dn.sprite_frag},background:{uniforms:{uvTransform:{value:new Bn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Dn.background_vert,fragmentShader:Dn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Dn.backgroundCube_vert,fragmentShader:Dn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Dn.cube_vert,fragmentShader:Dn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Dn.equirect_vert,fragmentShader:Dn.equirect_frag},distanceRGBA:{uniforms:Ns([Ot.common,Ot.displacementmap,{referencePosition:{value:new We},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Dn.distanceRGBA_vert,fragmentShader:Dn.distanceRGBA_frag},shadow:{uniforms:Ns([Ot.lights,Ot.fog,{color:{value:new cn(0)},opacity:{value:1}}]),vertexShader:Dn.shadow_vert,fragmentShader:Dn.shadow_frag}};Ws.physical={uniforms:Ns([Ws.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Bn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Bn},clearcoatNormalScale:{value:new Sn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Bn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Bn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Bn},sheen:{value:0},sheenColor:{value:new cn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Bn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Bn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Bn},transmissionSamplerSize:{value:new Sn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Bn},attenuationDistance:{value:0},attenuationColor:{value:new cn(0)},specularColor:{value:new cn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Bn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Bn},anisotropyVector:{value:new Sn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Bn}}]),vertexShader:Dn.meshphysical_vert,fragmentShader:Dn.meshphysical_frag};const B_={r:0,b:0,g:0};function U1e(t,e,n,r,i,s,o){const l=new cn(0);let c=s===!0?0:1,u,d,h=null,p=0,m=null;function x(b,v){let S=!1,k=v.isScene===!0?v.background:null;k&&k.isTexture&&(k=(v.backgroundBlurriness>0?n:e).get(k)),k===null?y(l,c):k&&k.isColor&&(y(k,1),S=!0);const E=t.xr.getEnvironmentBlendMode();E==="additive"?r.buffers.color.setClear(0,0,0,1,o):E==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||S)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),k&&(k.isCubeTexture||k.mapping===Gk)?(d===void 0&&(d=new Gl(new Z0(1,1,1),new $h({name:"BackgroundCubeMaterial",uniforms:ub(Ws.backgroundCube.uniforms),vertexShader:Ws.backgroundCube.vertexShader,fragmentShader:Ws.backgroundCube.fragmentShader,side:Zs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(N,A,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=k,d.material.uniforms.flipEnvMap.value=k.isCubeTexture&&k.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=jr.getTransfer(k.colorSpace)!==ei,(h!==k||p!==k.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,h=k,p=k.version,m=t.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):k&&k.isTexture&&(u===void 0&&(u=new Gl(new I4(2,2),new $h({name:"BackgroundMaterial",uniforms:ub(Ws.background.uniforms),vertexShader:Ws.background.vertexShader,fragmentShader:Ws.background.fragmentShader,side:Bh,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=k,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=jr.getTransfer(k.colorSpace)!==ei,k.matrixAutoUpdate===!0&&k.updateMatrix(),u.material.uniforms.uvTransform.value.copy(k.matrix),(h!==k||p!==k.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=k,p=k.version,m=t.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null))}function y(b,v){b.getRGB(B_,NX(t)),r.buffers.color.setClear(B_.r,B_.g,B_.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 B1e(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,l={},c=b(null);let u=c,d=!1;function h(D,H,q,I,K){let Z=!1;if(o){const se=y(I,q,H);u!==se&&(u=se,m(u.object)),Z=v(D,I,q,K),Z&&S(D,I,q,K)}else{const se=H.wireframe===!0;(u.geometry!==I.id||u.program!==q.id||u.wireframe!==se)&&(u.geometry=I.id,u.program=q.id,u.wireframe=se,Z=!0)}K!==null&&n.update(K,t.ELEMENT_ARRAY_BUFFER),(Z||d)&&(d=!1,P(D,H,q,I),K!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(K).buffer))}function p(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function m(D){return r.isWebGL2?t.bindVertexArray(D):s.bindVertexArrayOES(D)}function x(D){return r.isWebGL2?t.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function y(D,H,q){const I=q.wireframe===!0;let K=l[D.id];K===void 0&&(K={},l[D.id]=K);let Z=K[H.id];Z===void 0&&(Z={},K[H.id]=Z);let se=Z[I];return se===void 0&&(se=b(p()),Z[I]=se),se}function b(D){const H=[],q=[],I=[];for(let K=0;K<i;K++)H[K]=0,q[K]=0,I[K]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:q,attributeDivisors:I,object:D,attributes:{},index:null}}function v(D,H,q,I){const K=u.attributes,Z=H.attributes;let se=0;const V=q.getAttributes();for(const W in V)if(V[W].location>=0){const J=K[W];let pe=Z[W];if(pe===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(pe=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(pe=D.instanceColor)),J===void 0||J.attribute!==pe||pe&&J.data!==pe.data)return!0;se++}return u.attributesNum!==se||u.index!==I}function S(D,H,q,I){const K={},Z=H.attributes;let se=0;const V=q.getAttributes();for(const W in V)if(V[W].location>=0){let J=Z[W];J===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(J=D.instanceColor));const pe={};pe.attribute=J,J&&J.data&&(pe.data=J.data),K[W]=pe,se++}u.attributes=K,u.attributesNum=se,u.index=I}function k(){const D=u.newAttributes;for(let H=0,q=D.length;H<q;H++)D[H]=0}function E(D){N(D,0)}function N(D,H){const q=u.newAttributes,I=u.enabledAttributes,K=u.attributeDivisors;q[D]=1,I[D]===0&&(t.enableVertexAttribArray(D),I[D]=1),K[D]!==H&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,H),K[D]=H)}function A(){const D=u.newAttributes,H=u.enabledAttributes;for(let q=0,I=H.length;q<I;q++)H[q]!==D[q]&&(t.disableVertexAttribArray(q),H[q]=0)}function M(D,H,q,I,K,Z,se){se===!0?t.vertexAttribIPointer(D,H,q,K,Z):t.vertexAttribPointer(D,H,q,I,K,Z)}function P(D,H,q,I){if(r.isWebGL2===!1&&(D.isInstancedMesh||I.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;k();const K=I.attributes,Z=q.getAttributes(),se=H.defaultAttributeValues;for(const V in Z){const W=Z[V];if(W.location>=0){let ie=K[V];if(ie===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(ie=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(ie=D.instanceColor)),ie!==void 0){const J=ie.normalized,pe=ie.itemSize,fe=n.get(ie);if(fe===void 0)continue;const ve=fe.buffer,Le=fe.type,de=fe.bytesPerElement,ce=r.isWebGL2===!0&&(Le===t.INT||Le===t.UNSIGNED_INT||ie.gpuType===iX);if(ie.isInterleavedBufferAttribute){const Ae=ie.data,re=Ae.stride,Ie=ie.offset;if(Ae.isInstancedInterleavedBuffer){for(let G=0;G<W.locationSize;G++)N(W.location+G,Ae.meshPerAttribute);D.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=Ae.meshPerAttribute*Ae.count)}else for(let G=0;G<W.locationSize;G++)E(W.location+G);t.bindBuffer(t.ARRAY_BUFFER,ve);for(let G=0;G<W.locationSize;G++)M(W.location+G,pe/W.locationSize,Le,J,re*de,(Ie+pe/W.locationSize*G)*de,ce)}else{if(ie.isInstancedBufferAttribute){for(let Ae=0;Ae<W.locationSize;Ae++)N(W.location+Ae,ie.meshPerAttribute);D.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let Ae=0;Ae<W.locationSize;Ae++)E(W.location+Ae);t.bindBuffer(t.ARRAY_BUFFER,ve);for(let Ae=0;Ae<W.locationSize;Ae++)M(W.location+Ae,pe/W.locationSize,Le,J,pe*de,pe/W.locationSize*Ae*de,ce)}}else if(se!==void 0){const J=se[V];if(J!==void 0)switch(J.length){case 2:t.vertexAttrib2fv(W.location,J);break;case 3:t.vertexAttrib3fv(W.location,J);break;case 4:t.vertexAttrib4fv(W.location,J);break;default:t.vertexAttrib1fv(W.location,J)}}}}A()}function T(){F();for(const D in l){const H=l[D];for(const q in H){const I=H[q];for(const K in I)x(I[K].object),delete I[K];delete H[q]}delete l[D]}}function j(D){if(l[D.id]===void 0)return;const H=l[D.id];for(const q in H){const I=H[q];for(const K in I)x(I[K].object),delete I[K];delete H[q]}delete l[D.id]}function z(D){for(const H in l){const q=l[H];if(q[D.id]===void 0)continue;const I=q[D.id];for(const K in I)x(I[K].object),delete I[K];delete q[D.id]}}function F(){$(),d=!0,u!==c&&(u=c,m(u.object))}function $(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:F,resetDefaultState:$,dispose:T,releaseStatesOfGeometry:j,releaseStatesOfProgram:z,initAttributes:k,enableAttribute:E,disableUnusedAttributes:A}}function $1e(t,e,n,r){const i=r.isWebGL2;let s;function o(d){s=d}function l(d,h){t.drawArrays(s,d,h),n.update(h,s,1)}function c(d,h,p){if(p===0)return;let m,x;if(i)m=t,x="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[x](s,d,h,p),n.update(h,s,p)}function u(d,h,p){if(p===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<p;x++)this.render(d[x],h[x]);else{m.multiDrawArraysWEBGL(s,d,0,h,0,p);let x=0;for(let y=0;y<p;y++)x+=h[y];n.update(x,s,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function H1e(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const M=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(M){if(M==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="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=s(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,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=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),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),k=p>0,E=o||e.has("OES_texture_float"),N=k&&E,A=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:l,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:b,maxVaryings:v,maxFragmentUniforms:S,vertexTextures:k,floatFragmentTextures:E,floatVertexTextures:N,maxSamples:A}}function V1e(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new rh,l=new Bn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const m=h.length!==0||p||r!==0||i;return i=p,r=h.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){n=d(h,p,0)},this.setState=function(h,p,m){const x=h.clippingPlanes,y=h.clipIntersection,b=h.clipShadows,v=t.get(h);if(!i||x===null||x.length===0||s&&!b)s?d(null):u();else{const S=s?0:r,k=S*4;let E=v.clippingState||null;c.value=E,E=d(x,p,k,m);for(let N=0;N!==k;++N)E[N]=n[N];v.clippingState=E,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(h,p,m,x){const y=h!==null?h.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=m+y*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(b===null||b.length<v)&&(b=new Float32Array(v));for(let k=0,E=m;k!==y;++k,E+=4)o.copy(h[k]).applyMatrix4(S,l),o.normal.toArray(b,E),b[E+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function G1e(t){let e=new WeakMap;function n(o,l){return l===z3?o.mapping=ob:l===U3&&(o.mapping=lb),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===z3||l===U3)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 r_e(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 s(){e=new WeakMap}return{get:r,dispose:s}}class q1e extends kX{constructor(e=-1,n=1,r=1,i=-1,s=.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=s,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,s,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=s,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 s=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;s+=u*this.view.offsetX,o=s+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(s,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 Eg=4,A6=[.125,.215,.35,.446,.526,.582],Gf=20,EA=new q1e,T6=new cn;let AA=null,TA=0,jA=0;const If=(1+Math.sqrt(5))/2,og=1/If,j6=[new We(1,1,1),new We(-1,1,1),new We(1,1,-1),new We(-1,1,-1),new We(0,If,og),new We(0,If,-og),new We(og,0,If),new We(-og,0,If),new We(If,og,0),new We(-If,og,0)];class P6{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){AA=this._renderer.getRenderTarget(),TA=this._renderer.getActiveCubeFace(),jA=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),n>0&&this._blur(s,0,0,n),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=L6(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=R6(),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(AA,TA,jA),e.scissorTest=!1,$_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===ob||e.mapping===lb?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),AA=this._renderer.getRenderTarget(),TA=this._renderer.getActiveCubeFace(),jA=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:al,minFilter:al,generateMipmaps:!1,type:d0,format:sl,colorSpace:td,depthBuffer:!1},i=D6(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=D6(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=W1e(s)),this._blurMaterial=K1e(s,e,n)}return i}_compileMaterial(e){const n=new Gl(this._lodPlanes[0],e);this._renderer.compile(n,EA)}_sceneToCubeUV(e,n,r,i){const l=new wo(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,h=d.autoClear,p=d.toneMapping;d.getClearColor(T6),d.toneMapping=Th,d.autoClear=!1;const m=new wX({name:"PMREM.Background",side:Zs,depthWrite:!1,depthTest:!1}),x=new Gl(new Z0,m);let y=!1;const b=e.background;b?b.isColor&&(m.color.copy(b),e.background=null,y=!0):(m.color.copy(T6),y=!0);for(let v=0;v<6;v++){const S=v%3;S===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):S===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const k=this._cubeSize;$_(i,S*k,v>2?k:0,k,k),d.setRenderTarget(i),y&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=p,d.autoClear=h,e.background=b}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===ob||e.mapping===lb;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=L6()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=R6());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Gl(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;$_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,EA)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=j6[(i-1)%j6.length];this._blur(e,i-1,i,s,o)}n.autoClear=r}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,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,h=new Gl(this._lodPlanes[i],u),p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Gf-1),y=s/x,b=isFinite(s)?1+Math.floor(d*y):Gf;b>Gf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Gf}`);const v=[];let S=0;for(let M=0;M<Gf;++M){const P=M/y,T=Math.exp(-P*P/2);v.push(T),M===0?S+=T:M<b&&(S+=2*T)}for(let M=0;M<v.length;M++)v[M]=v[M]/S;p.envMap.value=e.texture,p.samples.value=b,p.weights.value=v,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:k}=this;p.dTheta.value=x,p.mipInt.value=k-r;const E=this._sizeLods[i],N=3*E*(i>k-Eg?i-k+Eg:0),A=4*(this._cubeSize-E);$_(n,N,A,3*E,2*E),c.setRenderTarget(n),c.render(h,EA)}}function W1e(t){const e=[],n=[],r=[];let i=t;const s=t-Eg+1+A6.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Eg?c=A6[o-t+Eg-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,h=1+u,p=[d,d,h,d,h,h,d,d,h,h,d,h],m=6,x=6,y=3,b=2,v=1,S=new Float32Array(y*x*m),k=new Float32Array(b*x*m),E=new Float32Array(v*x*m);for(let A=0;A<m;A++){const M=A%3*2/3-1,P=A>2?0:-1,T=[M,P,0,M+2/3,P,0,M+2/3,P+1,0,M,P,0,M+2/3,P+1,0,M,P+1,0];S.set(T,y*x*A),k.set(p,b*x*A);const j=[A,A,A,A,A,A];E.set(j,v*x*A)}const N=new bs;N.setAttribute("position",new Co(S,y)),N.setAttribute("uv",new Co(k,b)),N.setAttribute("faceIndex",new Co(E,v)),e.push(N),i>Eg&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function D6(t,e,n){const r=new Tm(t,e,n);return r.texture.mapping=Gk,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function $_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function K1e(t,e,n){const r=new Float32Array(Gf),i=new We(0,1,0);return new $h({name:"SphericalGaussianBlur",defines:{n:Gf,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:z4(),fragmentShader:`
  7253. precision mediump float;
  7254. precision mediump int;
  7255. varying vec3 vOutputDirection;
  7256. uniform sampler2D envMap;
  7257. uniform int samples;
  7258. uniform float weights[ n ];
  7259. uniform bool latitudinal;
  7260. uniform float dTheta;
  7261. uniform float mipInt;
  7262. uniform vec3 poleAxis;
  7263. #define ENVMAP_TYPE_CUBE_UV
  7264. #include <cube_uv_reflection_fragment>
  7265. vec3 getSample( float theta, vec3 axis ) {
  7266. float cosTheta = cos( theta );
  7267. // Rodrigues' axis-angle rotation
  7268. vec3 sampleDirection = vOutputDirection * cosTheta
  7269. + cross( axis, vOutputDirection ) * sin( theta )
  7270. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7271. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7272. }
  7273. void main() {
  7274. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7275. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7276. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7277. }
  7278. axis = normalize( axis );
  7279. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7280. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7281. for ( int i = 1; i < n; i++ ) {
  7282. if ( i >= samples ) {
  7283. break;
  7284. }
  7285. float theta = dTheta * float( i );
  7286. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7287. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7288. }
  7289. }
  7290. `,blending:Ah,depthTest:!1,depthWrite:!1})}function R6(){return new $h({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:z4(),fragmentShader:`
  7291. precision mediump float;
  7292. precision mediump int;
  7293. varying vec3 vOutputDirection;
  7294. uniform sampler2D envMap;
  7295. #include <common>
  7296. void main() {
  7297. vec3 outputDirection = normalize( vOutputDirection );
  7298. vec2 uv = equirectUv( outputDirection );
  7299. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7300. }
  7301. `,blending:Ah,depthTest:!1,depthWrite:!1})}function L6(){return new $h({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:z4(),fragmentShader:`
  7302. precision mediump float;
  7303. precision mediump int;
  7304. uniform float flipEnvMap;
  7305. varying vec3 vOutputDirection;
  7306. uniform samplerCube envMap;
  7307. void main() {
  7308. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7309. }
  7310. `,blending:Ah,depthTest:!1,depthWrite:!1})}function z4(){return`
  7311. precision mediump float;
  7312. precision mediump int;
  7313. attribute float faceIndex;
  7314. varying vec3 vOutputDirection;
  7315. // RH coordinate system; PMREM face-indexing convention
  7316. vec3 getDirection( vec2 uv, float face ) {
  7317. uv = 2.0 * uv - 1.0;
  7318. vec3 direction = vec3( uv, 1.0 );
  7319. if ( face == 0.0 ) {
  7320. direction = direction.zyx; // ( 1, v, u ) pos x
  7321. } else if ( face == 1.0 ) {
  7322. direction = direction.xzy;
  7323. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7324. } else if ( face == 2.0 ) {
  7325. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7326. } else if ( face == 3.0 ) {
  7327. direction = direction.zyx;
  7328. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7329. } else if ( face == 4.0 ) {
  7330. direction = direction.xzy;
  7331. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7332. } else if ( face == 5.0 ) {
  7333. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7334. }
  7335. return direction;
  7336. }
  7337. void main() {
  7338. vOutputDirection = getDirection( uv, faceIndex );
  7339. gl_Position = vec4( position, 1.0 );
  7340. }
  7341. `}function X1e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===z3||c===U3,d=c===ob||c===lb;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let h=e.get(l);return n===null&&(n=new P6(t)),h=u?n.fromEquirectangular(l,h):n.fromCubemap(l,h),e.set(l,h),h.texture}else{if(e.has(l))return e.get(l).texture;{const h=l.image;if(u&&h&&h.height>0||d&&h&&i(h)){n===null&&(n=new P6(t));const p=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,p),l.addEventListener("dispose",s),p.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 s(l){const c=l.target;c.removeEventListener("dispose",s);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 Y1e(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 Q1e(t,e,n,r){const i={},s=new WeakMap;function o(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const x in p.attributes)e.remove(p.attributes[x]);for(const x in p.morphAttributes){const y=p.morphAttributes[x];for(let b=0,v=y.length;b<v;b++)e.remove(y[b])}p.removeEventListener("dispose",o),delete i[p.id];const m=s.get(p);m&&(e.remove(m),s.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(h,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(h){const p=h.attributes;for(const x in p)e.update(p[x],t.ARRAY_BUFFER);const m=h.morphAttributes;for(const x in m){const y=m[x];for(let b=0,v=y.length;b<v;b++)e.update(y[b],t.ARRAY_BUFFER)}}function u(h){const p=[],m=h.index,x=h.attributes.position;let y=0;if(m!==null){const S=m.array;y=m.version;for(let k=0,E=S.length;k<E;k+=3){const N=S[k+0],A=S[k+1],M=S[k+2];p.push(N,A,A,M,M,N)}}else if(x!==void 0){const S=x.array;y=x.version;for(let k=0,E=S.length/3-1;k<E;k+=3){const N=k+0,A=k+1,M=k+2;p.push(N,A,A,M,M,N)}}else return;const b=new(pX(p)?SX:_X)(p,1);b.version=y;const v=s.get(h);v&&e.remove(v),s.set(h,b)}function d(h){const p=s.get(h);if(p){const m=h.index;m!==null&&p.version<m.version&&u(h)}else u(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:d}}function Z1e(t,e,n,r){const i=r.isWebGL2;let s;function o(m){s=m}let l,c;function u(m){l=m.type,c=m.bytesPerElement}function d(m,x){t.drawElements(s,x,l,m*c),n.update(x,s,1)}function h(m,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](s,x,l,m*c,y),n.update(x,s,y)}function p(m,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(m[v]/c,x[v]);else{b.multiDrawElementsWEBGL(s,x,0,l,m,0,y);let v=0;for(let S=0;S<y;S++)v+=x[S];n.update(v,s,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=h,this.renderMultiDraw=p}function J1e(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(s/3);break;case t.LINES:n.lines+=l*(s/2);break;case t.LINE_STRIP:n.lines+=l*(s-1);break;case t.LINE_LOOP:n.lines+=l*s;break;case t.POINTS:n.points+=l*s;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 eNe(t,e){return t[0]-e[0]}function tNe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function nNe(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,o=new Dr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,h){const p=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=s.get(d);if(b===void 0||b.count!==y){let H=function(){$.dispose(),s.delete(d),d.removeEventListener("dispose",H)};var m=H;b!==void 0&&b.texture.dispose();const k=d.morphAttributes.position!==void 0,E=d.morphAttributes.normal!==void 0,N=d.morphAttributes.color!==void 0,A=d.morphAttributes.position||[],M=d.morphAttributes.normal||[],P=d.morphAttributes.color||[];let T=0;k===!0&&(T=1),E===!0&&(T=2),N===!0&&(T=3);let j=d.attributes.position.count*T,z=1;j>e.maxTextureSize&&(z=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const F=new Float32Array(j*z*4*y),$=new xX(F,j,z,y);$.type=Ou,$.needsUpdate=!0;const D=T*4;for(let q=0;q<y;q++){const I=A[q],K=M[q],Z=P[q],se=j*z*4*q;for(let V=0;V<I.count;V++){const W=V*D;k===!0&&(o.fromBufferAttribute(I,V),F[se+W+0]=o.x,F[se+W+1]=o.y,F[se+W+2]=o.z,F[se+W+3]=0),E===!0&&(o.fromBufferAttribute(K,V),F[se+W+4]=o.x,F[se+W+5]=o.y,F[se+W+6]=o.z,F[se+W+7]=0),N===!0&&(o.fromBufferAttribute(Z,V),F[se+W+8]=o.x,F[se+W+9]=o.y,F[se+W+10]=o.z,F[se+W+11]=Z.itemSize===4?o.w:1)}}b={count:y,texture:$,size:new Sn(j,z)},s.set(d,b),d.addEventListener("dispose",H)}let v=0;for(let k=0;k<p.length;k++)v+=p[k];const S=d.morphTargetsRelative?1:1-v;h.getUniforms().setValue(t,"morphTargetBaseInfluence",S),h.getUniforms().setValue(t,"morphTargetInfluences",p),h.getUniforms().setValue(t,"morphTargetsTexture",b.texture,n),h.getUniforms().setValue(t,"morphTargetsTextureSize",b.size)}else{const x=p===void 0?0:p.length;let y=r[d.id];if(y===void 0||y.length!==x){y=[];for(let E=0;E<x;E++)y[E]=[E,0];r[d.id]=y}for(let E=0;E<x;E++){const N=y[E];N[0]=E,N[1]=p[E]}y.sort(tNe);for(let E=0;E<8;E++)E<x&&y[E][1]?(l[E][0]=y[E][0],l[E][1]=y[E][1]):(l[E][0]=Number.MAX_SAFE_INTEGER,l[E][1]=0);l.sort(eNe);const b=d.morphAttributes.position,v=d.morphAttributes.normal;let S=0;for(let E=0;E<8;E++){const N=l[E],A=N[0],M=N[1];A!==Number.MAX_SAFE_INTEGER&&M?(b&&d.getAttribute("morphTarget"+E)!==b[A]&&d.setAttribute("morphTarget"+E,b[A]),v&&d.getAttribute("morphNormal"+E)!==v[A]&&d.setAttribute("morphNormal"+E,v[A]),i[E]=M,S+=M):(b&&d.hasAttribute("morphTarget"+E)===!0&&d.deleteAttribute("morphTarget"+E),v&&d.hasAttribute("morphNormal"+E)===!0&&d.deleteAttribute("morphNormal"+E),i[E]=0)}const k=d.morphTargetsRelative?1:1-S;h.getUniforms().setValue(t,"morphTargetBaseInfluence",k),h.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function rNe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,h=e.get(c,d);if(i.get(h)!==u&&(e.update(h),i.set(h,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 p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return h}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:s,dispose:o}}class EX extends Js{constructor(e,n,r,i,s,o,l,c,u,d){if(d=d!==void 0?d:om,d!==om&&d!==cb)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===om&&(r=gh),r===void 0&&d===cb&&(r=sm),super(null,i,s,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:Ka,this.minFilter=c!==void 0?c:Ka,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 AX=new Js,TX=new EX(1,1);TX.compareFunction=fX;const jX=new xX,PX=new Bwe,DX=new MX,O6=[],F6=[],I6=new Float32Array(16),z6=new Float32Array(9),U6=new Float32Array(4);function Ib(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=O6[i];if(s===void 0&&(s=new Float32Array(i),O6[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function fa(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 ma(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function Kk(t,e){let n=F6[e];n===void 0&&(n=new Int32Array(e),F6[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function iNe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function aNe(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(fa(n,e))return;t.uniform2fv(this.addr,e),ma(n,e)}}function sNe(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(fa(n,e))return;t.uniform3fv(this.addr,e),ma(n,e)}}function oNe(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(fa(n,e))return;t.uniform4fv(this.addr,e),ma(n,e)}}function lNe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(fa(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ma(n,e)}else{if(fa(n,r))return;U6.set(r),t.uniformMatrix2fv(this.addr,!1,U6),ma(n,r)}}function cNe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(fa(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ma(n,e)}else{if(fa(n,r))return;z6.set(r),t.uniformMatrix3fv(this.addr,!1,z6),ma(n,r)}}function uNe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(fa(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ma(n,e)}else{if(fa(n,r))return;I6.set(r),t.uniformMatrix4fv(this.addr,!1,I6),ma(n,r)}}function dNe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function hNe(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(fa(n,e))return;t.uniform2iv(this.addr,e),ma(n,e)}}function fNe(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(fa(n,e))return;t.uniform3iv(this.addr,e),ma(n,e)}}function mNe(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(fa(n,e))return;t.uniform4iv(this.addr,e),ma(n,e)}}function pNe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function gNe(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(fa(n,e))return;t.uniform2uiv(this.addr,e),ma(n,e)}}function bNe(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(fa(n,e))return;t.uniform3uiv(this.addr,e),ma(n,e)}}function xNe(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(fa(n,e))return;t.uniform4uiv(this.addr,e),ma(n,e)}}function yNe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const s=this.type===t.SAMPLER_2D_SHADOW?TX:AX;n.setTexture2D(e||s,i)}function vNe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||PX,i)}function wNe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||DX,i)}function _Ne(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||jX,i)}function SNe(t){switch(t){case 5126:return iNe;case 35664:return aNe;case 35665:return sNe;case 35666:return oNe;case 35674:return lNe;case 35675:return cNe;case 35676:return uNe;case 5124:case 35670:return dNe;case 35667:case 35671:return hNe;case 35668:case 35672:return fNe;case 35669:case 35673:return mNe;case 5125:return pNe;case 36294:return gNe;case 36295:return bNe;case 36296:return xNe;case 35678:case 36198:case 36298:case 36306:case 35682:return yNe;case 35679:case 36299:case 36307:return vNe;case 35680:case 36300:case 36308:case 36293:return wNe;case 36289:case 36303:case 36311:case 36292:return _Ne}}function NNe(t,e){t.uniform1fv(this.addr,e)}function kNe(t,e){const n=Ib(e,this.size,2);t.uniform2fv(this.addr,n)}function MNe(t,e){const n=Ib(e,this.size,3);t.uniform3fv(this.addr,n)}function CNe(t,e){const n=Ib(e,this.size,4);t.uniform4fv(this.addr,n)}function ENe(t,e){const n=Ib(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ANe(t,e){const n=Ib(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function TNe(t,e){const n=Ib(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function jNe(t,e){t.uniform1iv(this.addr,e)}function PNe(t,e){t.uniform2iv(this.addr,e)}function DNe(t,e){t.uniform3iv(this.addr,e)}function RNe(t,e){t.uniform4iv(this.addr,e)}function LNe(t,e){t.uniform1uiv(this.addr,e)}function ONe(t,e){t.uniform2uiv(this.addr,e)}function FNe(t,e){t.uniform3uiv(this.addr,e)}function INe(t,e){t.uniform4uiv(this.addr,e)}function zNe(t,e,n){const r=this.cache,i=e.length,s=Kk(n,i);fa(r,s)||(t.uniform1iv(this.addr,s),ma(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||AX,s[o])}function UNe(t,e,n){const r=this.cache,i=e.length,s=Kk(n,i);fa(r,s)||(t.uniform1iv(this.addr,s),ma(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||PX,s[o])}function BNe(t,e,n){const r=this.cache,i=e.length,s=Kk(n,i);fa(r,s)||(t.uniform1iv(this.addr,s),ma(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||DX,s[o])}function $Ne(t,e,n){const r=this.cache,i=e.length,s=Kk(n,i);fa(r,s)||(t.uniform1iv(this.addr,s),ma(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||jX,s[o])}function HNe(t){switch(t){case 5126:return NNe;case 35664:return kNe;case 35665:return MNe;case 35666:return CNe;case 35674:return ENe;case 35675:return ANe;case 35676:return TNe;case 5124:case 35670:return jNe;case 35667:case 35671:return PNe;case 35668:case 35672:return DNe;case 35669:case 35673:return RNe;case 5125:return LNe;case 36294:return ONe;case 36295:return FNe;case 36296:return INe;case 35678:case 36198:case 36298:case 36306:case 35682:return zNe;case 35679:case 36299:case 36307:return UNe;case 35680:case 36300:case 36308:case 36293:return BNe;case 36289:case 36303:case 36311:case 36292:return $Ne}}class VNe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=SNe(n.type)}}class GNe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=HNe(n.type)}}class qNe{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const l=i[s];l.setValue(e,n[l.id],r)}}}const PA=/(\w+)(\])?(\[|\.)?/g;function B6(t,e){t.seq.push(e),t.map[e.id]=e}function WNe(t,e,n){const r=t.name,i=r.length;for(PA.lastIndex=0;;){const s=PA.exec(r),o=PA.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){B6(n,u===void 0?new VNe(l,t,e):new GNe(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new qNe(l),B6(n,h)),n=h}}}class HS{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),o=e.getUniformLocation(n,s.name);WNe(s,o,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.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 s=0,o=n.length;s!==o;++s){const l=n[s],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function $6(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const KNe=37297;let XNe=0;function YNe(t,e){const n=t.split(`
  7342. `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  7343. `)}function QNe(t){const e=jr.getPrimaries(jr.workingColorSpace),n=jr.getPrimaries(t);let r;switch(e===n?r="":e===_1&&n===w1?r="LinearDisplayP3ToLinearSRGB":e===w1&&n===_1&&(r="LinearSRGBToLinearDisplayP3"),t){case td:case qk:return[r,"LinearTransferOETF"];case Xa:case R4:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function H6(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
  7344. `+i+`
  7345. `+YNe(t.getShaderSource(e),o)}else return i}function ZNe(t,e){const n=QNe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function JNe(t,e){let n;switch(e){case Zve:n="Linear";break;case Jve:n="Reinhard";break;case ewe:n="OptimizedCineon";break;case twe:n="ACESFilmic";break;case nwe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function eke(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(by).join(`
  7346. `)}function tke(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7347. `)}function nke(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let l=1;s.type===t.FLOAT_MAT2&&(l=2),s.type===t.FLOAT_MAT3&&(l=3),s.type===t.FLOAT_MAT4&&(l=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function by(t){return t!==""}function V6(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 G6(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const rke=/^[ \t]*#include +<([\w\d./]+)>/gm;function q3(t){return t.replace(rke,ake)}const ike=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function ake(t,e){let n=Dn[e];if(n===void 0){const r=ike.get(e);if(r!==void 0)n=Dn[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 q3(n)}const ske=/#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 q6(t){return t.replace(ske,oke)}function oke(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function W6(t){let e="precision "+t.precision+` float;
  7348. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7349. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7350. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7351. #define LOW_PRECISION`),e}function lke(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===nX?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Mve?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Su&&(e="SHADOWMAP_TYPE_VSM"),e}function cke(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case ob:case lb:e="ENVMAP_TYPE_CUBE";break;case Gk:e="ENVMAP_TYPE_CUBE_UV";break}return e}function uke(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case lb:e="ENVMAP_MODE_REFRACTION";break}return e}function dke(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case P4:e="ENVMAP_BLENDING_MULTIPLY";break;case Yve:e="ENVMAP_BLENDING_MIX";break;case Qve:e="ENVMAP_BLENDING_ADD";break}return e}function hke(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 fke(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=lke(n),u=cke(n),d=uke(n),h=dke(n),p=hke(n),m=n.isWebGL2?"":eke(n),x=tke(s),y=i.createProgram();let b,v,S=n.glslVersion?"#version "+n.glslVersion+`
  7352. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(by).join(`
  7353. `),b.length>0&&(b+=`
  7354. `),v=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(by).join(`
  7355. `),v.length>0&&(v+=`
  7356. `)):(b=[W6(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",`
  7357. `].filter(by).join(`
  7358. `),v=[m,W6(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 "+h:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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!==Th?"#define TONE_MAPPING":"",n.toneMapping!==Th?Dn.tonemapping_pars_fragment:"",n.toneMapping!==Th?JNe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Dn.colorspace_pars_fragment,ZNe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7359. `].filter(by).join(`
  7360. `)),o=q3(o),o=V6(o,n),o=G6(o,n),l=q3(l),l=V6(l,n),l=G6(l,n),o=q6(o),l=q6(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  7361. `,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7362. `)+`
  7363. `+b,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===d6?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===d6?"":"#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(`
  7364. `)+`
  7365. `+v);const k=S+b+o,E=S+v+l,N=$6(i,i.VERTEX_SHADER,k),A=$6(i,i.FRAGMENT_SHADER,E);i.attachShader(y,N),i.attachShader(y,A),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function M(z){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(y).trim(),$=i.getShaderInfoLog(N).trim(),D=i.getShaderInfoLog(A).trim();let H=!0,q=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(H=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,N,A);else{const I=H6(i,N,"vertex"),K=H6(i,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  7366. Program Info Log: `+F+`
  7367. `+I+`
  7368. `+K)}else F!==""?console.warn("THREE.WebGLProgram: Program Info Log:",F):($===""||D==="")&&(q=!1);q&&(z.diagnostics={runnable:H,programLog:F,vertexShader:{log:$,prefix:b},fragmentShader:{log:D,prefix:v}})}i.deleteShader(N),i.deleteShader(A),P=new HS(i,y),T=nke(i,y)}let P;this.getUniforms=function(){return P===void 0&&M(this),P};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let j=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return j===!1&&(j=i.getProgramParameter(y,KNe)),j},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=XNe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=N,this.fragmentShader=A,this}let mke=0;class pke{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.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 gke(e),n.set(e,r)),r}}class gke{constructor(e){this.id=mke++,this.code=e,this.usedTimes=0}}function bke(t,e,n,r,i,s,o){const l=new yX,c=new pke,u=[],d=i.isWebGL2,h=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=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(T){return T===0?"uv":`uv${T}`}function b(T,j,z,F,$){const D=F.fog,H=$.geometry,q=T.isMeshStandardMaterial?F.environment:null,I=(T.isMeshStandardMaterial?n:e).get(T.envMap||q),K=I&&I.mapping===Gk?I.image.height:null,Z=x[T.type];T.precision!==null&&(m=i.getMaxPrecision(T.precision),m!==T.precision&&console.warn("THREE.WebGLProgram.getParameters:",T.precision,"not supported, using",m,"instead."));const se=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,V=se!==void 0?se.length:0;let W=0;H.morphAttributes.position!==void 0&&(W=1),H.morphAttributes.normal!==void 0&&(W=2),H.morphAttributes.color!==void 0&&(W=3);let ie,J,pe,fe;if(Z){const an=Ws[Z];ie=an.vertexShader,J=an.fragmentShader}else ie=T.vertexShader,J=T.fragmentShader,c.update(T),pe=c.getVertexShaderID(T),fe=c.getFragmentShaderID(T);const ve=t.getRenderTarget(),Le=$.isInstancedMesh===!0,de=$.isBatchedMesh===!0,ce=!!T.map,Ae=!!T.matcap,re=!!I,Ie=!!T.aoMap,G=!!T.lightMap,Y=!!T.bumpMap,ue=!!T.normalMap,B=!!T.displacementMap,ee=!!T.emissiveMap,Q=!!T.metalnessMap,le=!!T.roughnessMap,he=T.anisotropy>0,te=T.clearcoat>0,U=T.iridescence>0,L=T.sheen>0,X=T.transmission>0,ge=he&&!!T.anisotropyMap,_e=te&&!!T.clearcoatMap,Ee=te&&!!T.clearcoatNormalMap,$e=te&&!!T.clearcoatRoughnessMap,Ce=U&&!!T.iridescenceMap,He=U&&!!T.iridescenceThicknessMap,Qe=L&&!!T.sheenColorMap,xe=L&&!!T.sheenRoughnessMap,ye=!!T.specularMap,we=!!T.specularColorMap,Ue=!!T.specularIntensityMap,Pe=X&&!!T.transmissionMap,Ve=X&&!!T.thicknessMap,ke=!!T.gradientMap,Ze=!!T.alphaMap,je=T.alphaTest>0,Xe=!!T.alphaHash,Re=!!T.extensions,Oe=!!H.attributes.uv1,Ne=!!H.attributes.uv2,Je=!!H.attributes.uv3;let yt=Th;return T.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(yt=t.toneMapping),{isWebGL2:d,shaderID:Z,shaderType:T.type,shaderName:T.name,vertexShader:ie,fragmentShader:J,defines:T.defines,customVertexShaderID:pe,customFragmentShaderID:fe,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:m,batching:de,instancing:Le,instancingColor:Le&&$.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:ve===null?t.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:td,map:ce,matcap:Ae,envMap:re,envMapMode:re&&I.mapping,envMapCubeUVHeight:K,aoMap:Ie,lightMap:G,bumpMap:Y,normalMap:ue,displacementMap:p&&B,emissiveMap:ee,normalMapObjectSpace:ue&&T.normalMapType===mwe,normalMapTangentSpace:ue&&T.normalMapType===hX,metalnessMap:Q,roughnessMap:le,anisotropy:he,anisotropyMap:ge,clearcoat:te,clearcoatMap:_e,clearcoatNormalMap:Ee,clearcoatRoughnessMap:$e,iridescence:U,iridescenceMap:Ce,iridescenceThicknessMap:He,sheen:L,sheenColorMap:Qe,sheenRoughnessMap:xe,specularMap:ye,specularColorMap:we,specularIntensityMap:Ue,transmission:X,transmissionMap:Pe,thicknessMap:Ve,gradientMap:ke,opaque:T.transparent===!1&&T.blending===Ug,alphaMap:Ze,alphaTest:je,alphaHash:Xe,combine:T.combine,mapUv:ce&&y(T.map.channel),aoMapUv:Ie&&y(T.aoMap.channel),lightMapUv:G&&y(T.lightMap.channel),bumpMapUv:Y&&y(T.bumpMap.channel),normalMapUv:ue&&y(T.normalMap.channel),displacementMapUv:B&&y(T.displacementMap.channel),emissiveMapUv:ee&&y(T.emissiveMap.channel),metalnessMapUv:Q&&y(T.metalnessMap.channel),roughnessMapUv:le&&y(T.roughnessMap.channel),anisotropyMapUv:ge&&y(T.anisotropyMap.channel),clearcoatMapUv:_e&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:Ee&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$e&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Ce&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:He&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:Qe&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:xe&&y(T.sheenRoughnessMap.channel),specularMapUv:ye&&y(T.specularMap.channel),specularColorMapUv:we&&y(T.specularColorMap.channel),specularIntensityMapUv:Ue&&y(T.specularIntensityMap.channel),transmissionMapUv:Pe&&y(T.transmissionMap.channel),thicknessMapUv:Ve&&y(T.thicknessMap.channel),alphaMapUv:Ze&&y(T.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(ue||he),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,vertexUv1s:Oe,vertexUv2s:Ne,vertexUv3s:Je,pointsUvs:$.isPoints===!0&&!!H.attributes.uv&&(ce||Ze),fog:!!D,useFog:T.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:T.flatShading===!0,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:$.isSkinnedMesh===!0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:V,morphTextureStride:W,numDirLights:j.directional.length,numPointLights:j.point.length,numSpotLights:j.spot.length,numSpotLightMaps:j.spotLightMap.length,numRectAreaLights:j.rectArea.length,numHemiLights:j.hemi.length,numDirLightShadows:j.directionalShadowMap.length,numPointLightShadows:j.pointShadowMap.length,numSpotLightShadows:j.spotShadowMap.length,numSpotLightShadowsWithMaps:j.numSpotLightShadowsWithMaps,numLightProbes:j.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:yt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ce&&T.map.isVideoTexture===!0&&jr.getTransfer(T.map.colorSpace)===ei,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Eu,flipSided:T.side===Zs,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionDerivatives:Re&&T.extensions.derivatives===!0,extensionFragDepth:Re&&T.extensions.fragDepth===!0,extensionDrawBuffers:Re&&T.extensions.drawBuffers===!0,extensionShaderTextureLOD:Re&&T.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()}}function v(T){const j=[];if(T.shaderID?j.push(T.shaderID):(j.push(T.customVertexShaderID),j.push(T.customFragmentShaderID)),T.defines!==void 0)for(const z in T.defines)j.push(z),j.push(T.defines[z]);return T.isRawShaderMaterial===!1&&(S(j,T),k(j,T),j.push(t.outputColorSpace)),j.push(T.customProgramCacheKey),j.join()}function S(T,j){T.push(j.precision),T.push(j.outputColorSpace),T.push(j.envMapMode),T.push(j.envMapCubeUVHeight),T.push(j.mapUv),T.push(j.alphaMapUv),T.push(j.lightMapUv),T.push(j.aoMapUv),T.push(j.bumpMapUv),T.push(j.normalMapUv),T.push(j.displacementMapUv),T.push(j.emissiveMapUv),T.push(j.metalnessMapUv),T.push(j.roughnessMapUv),T.push(j.anisotropyMapUv),T.push(j.clearcoatMapUv),T.push(j.clearcoatNormalMapUv),T.push(j.clearcoatRoughnessMapUv),T.push(j.iridescenceMapUv),T.push(j.iridescenceThicknessMapUv),T.push(j.sheenColorMapUv),T.push(j.sheenRoughnessMapUv),T.push(j.specularMapUv),T.push(j.specularColorMapUv),T.push(j.specularIntensityMapUv),T.push(j.transmissionMapUv),T.push(j.thicknessMapUv),T.push(j.combine),T.push(j.fogExp2),T.push(j.sizeAttenuation),T.push(j.morphTargetsCount),T.push(j.morphAttributeCount),T.push(j.numDirLights),T.push(j.numPointLights),T.push(j.numSpotLights),T.push(j.numSpotLightMaps),T.push(j.numHemiLights),T.push(j.numRectAreaLights),T.push(j.numDirLightShadows),T.push(j.numPointLightShadows),T.push(j.numSpotLightShadows),T.push(j.numSpotLightShadowsWithMaps),T.push(j.numLightProbes),T.push(j.shadowMapType),T.push(j.toneMapping),T.push(j.numClippingPlanes),T.push(j.numClipIntersection),T.push(j.depthPacking)}function k(T,j){l.disableAll(),j.isWebGL2&&l.enable(0),j.supportsVertexTextures&&l.enable(1),j.instancing&&l.enable(2),j.instancingColor&&l.enable(3),j.matcap&&l.enable(4),j.envMap&&l.enable(5),j.normalMapObjectSpace&&l.enable(6),j.normalMapTangentSpace&&l.enable(7),j.clearcoat&&l.enable(8),j.iridescence&&l.enable(9),j.alphaTest&&l.enable(10),j.vertexColors&&l.enable(11),j.vertexAlphas&&l.enable(12),j.vertexUv1s&&l.enable(13),j.vertexUv2s&&l.enable(14),j.vertexUv3s&&l.enable(15),j.vertexTangents&&l.enable(16),j.anisotropy&&l.enable(17),j.alphaHash&&l.enable(18),j.batching&&l.enable(19),T.push(l.mask),l.disableAll(),j.fog&&l.enable(0),j.useFog&&l.enable(1),j.flatShading&&l.enable(2),j.logarithmicDepthBuffer&&l.enable(3),j.skinning&&l.enable(4),j.morphTargets&&l.enable(5),j.morphNormals&&l.enable(6),j.morphColors&&l.enable(7),j.premultipliedAlpha&&l.enable(8),j.shadowMapEnabled&&l.enable(9),j.useLegacyLights&&l.enable(10),j.doubleSided&&l.enable(11),j.flipSided&&l.enable(12),j.useDepthPacking&&l.enable(13),j.dithering&&l.enable(14),j.transmission&&l.enable(15),j.sheen&&l.enable(16),j.opaque&&l.enable(17),j.pointsUvs&&l.enable(18),j.decodeVideoTexture&&l.enable(19),T.push(l.mask)}function E(T){const j=x[T.type];let z;if(j){const F=Ws[j];z=F4.clone(F.uniforms)}else z=T.uniforms;return z}function N(T,j){let z;for(let F=0,$=u.length;F<$;F++){const D=u[F];if(D.cacheKey===j){z=D,++z.usedTimes;break}}return z===void 0&&(z=new fke(t,j,T,s),u.push(z)),z}function A(T){if(--T.usedTimes===0){const j=u.indexOf(T);u[j]=u[u.length-1],u.pop(),T.destroy()}}function M(T){c.remove(T)}function P(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:E,acquireProgram:N,releaseProgram:A,releaseShaderCache:M,programs:u,dispose:P}}function xke(){let t=new WeakMap;function e(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function n(s){t.delete(s)}function r(s,o,l){t.get(s)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function yke(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 K6(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 X6(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(h,p,m,x,y,b){let v=t[e];return v===void 0?(v={id:h.id,object:h,geometry:p,material:m,groupOrder:x,renderOrder:h.renderOrder,z:y,group:b},t[e]=v):(v.id=h.id,v.object=h,v.geometry=p,v.material=m,v.groupOrder=x,v.renderOrder=h.renderOrder,v.z=y,v.group=b),e++,v}function l(h,p,m,x,y,b){const v=o(h,p,m,x,y,b);m.transmission>0?r.push(v):m.transparent===!0?i.push(v):n.push(v)}function c(h,p,m,x,y,b){const v=o(h,p,m,x,y,b);m.transmission>0?r.unshift(v):m.transparent===!0?i.unshift(v):n.unshift(v)}function u(h,p){n.length>1&&n.sort(h||yke),r.length>1&&r.sort(p||K6),i.length>1&&i.sort(p||K6)}function d(){for(let h=e,p=t.length;h<p;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function vke(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new X6,t.set(r,[o])):i>=s.length?(o=new X6,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function wke(){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 We,color:new cn};break;case"SpotLight":n={position:new We,direction:new We,color:new cn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new We,color:new cn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new We,skyColor:new cn,groundColor:new cn};break;case"RectAreaLight":n={color:new cn,position:new We,halfWidth:new We,halfHeight:new We};break}return t[e.id]=n,n}}}function _ke(){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 Sn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Sn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Sn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Ske=0;function Nke(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function kke(t,e){const n=new wke,r=_ke(),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 We);const s=new We,o=new Xr,l=new Xr;function c(d,h){let p=0,m=0,x=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let y=0,b=0,v=0,S=0,k=0,E=0,N=0,A=0,M=0,P=0,T=0;d.sort(Nke);const j=h===!0?Math.PI:1;for(let F=0,$=d.length;F<$;F++){const D=d[F],H=D.color,q=D.intensity,I=D.distance,K=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)p+=H.r*q*j,m+=H.g*q*j,x+=H.b*q*j;else if(D.isLightProbe){for(let Z=0;Z<9;Z++)i.probe[Z].addScaledVector(D.sh.coefficients[Z],q);T++}else if(D.isDirectionalLight){const Z=n.get(D);if(Z.color.copy(D.color).multiplyScalar(D.intensity*j),D.castShadow){const se=D.shadow,V=r.get(D);V.shadowBias=se.bias,V.shadowNormalBias=se.normalBias,V.shadowRadius=se.radius,V.shadowMapSize=se.mapSize,i.directionalShadow[y]=V,i.directionalShadowMap[y]=K,i.directionalShadowMatrix[y]=D.shadow.matrix,E++}i.directional[y]=Z,y++}else if(D.isSpotLight){const Z=n.get(D);Z.position.setFromMatrixPosition(D.matrixWorld),Z.color.copy(H).multiplyScalar(q*j),Z.distance=I,Z.coneCos=Math.cos(D.angle),Z.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),Z.decay=D.decay,i.spot[v]=Z;const se=D.shadow;if(D.map&&(i.spotLightMap[M]=D.map,M++,se.updateMatrices(D),D.castShadow&&P++),i.spotLightMatrix[v]=se.matrix,D.castShadow){const V=r.get(D);V.shadowBias=se.bias,V.shadowNormalBias=se.normalBias,V.shadowRadius=se.radius,V.shadowMapSize=se.mapSize,i.spotShadow[v]=V,i.spotShadowMap[v]=K,A++}v++}else if(D.isRectAreaLight){const Z=n.get(D);Z.color.copy(H).multiplyScalar(q),Z.halfWidth.set(D.width*.5,0,0),Z.halfHeight.set(0,D.height*.5,0),i.rectArea[S]=Z,S++}else if(D.isPointLight){const Z=n.get(D);if(Z.color.copy(D.color).multiplyScalar(D.intensity*j),Z.distance=D.distance,Z.decay=D.decay,D.castShadow){const se=D.shadow,V=r.get(D);V.shadowBias=se.bias,V.shadowNormalBias=se.normalBias,V.shadowRadius=se.radius,V.shadowMapSize=se.mapSize,V.shadowCameraNear=se.camera.near,V.shadowCameraFar=se.camera.far,i.pointShadow[b]=V,i.pointShadowMap[b]=K,i.pointShadowMatrix[b]=D.shadow.matrix,N++}i.point[b]=Z,b++}else if(D.isHemisphereLight){const Z=n.get(D);Z.skyColor.copy(D.color).multiplyScalar(q*j),Z.groundColor.copy(D.groundColor).multiplyScalar(q*j),i.hemi[k]=Z,k++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ot.LTC_FLOAT_1,i.rectAreaLTC2=Ot.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Ot.LTC_HALF_1,i.rectAreaLTC2=Ot.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=x;const z=i.hash;(z.directionalLength!==y||z.pointLength!==b||z.spotLength!==v||z.rectAreaLength!==S||z.hemiLength!==k||z.numDirectionalShadows!==E||z.numPointShadows!==N||z.numSpotShadows!==A||z.numSpotMaps!==M||z.numLightProbes!==T)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=S,i.point.length=b,i.hemi.length=k,i.directionalShadow.length=E,i.directionalShadowMap.length=E,i.pointShadow.length=N,i.pointShadowMap.length=N,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=E,i.pointShadowMatrix.length=N,i.spotLightMatrix.length=A+M-P,i.spotLightMap.length=M,i.numSpotLightShadowsWithMaps=P,i.numLightProbes=T,z.directionalLength=y,z.pointLength=b,z.spotLength=v,z.rectAreaLength=S,z.hemiLength=k,z.numDirectionalShadows=E,z.numPointShadows=N,z.numSpotShadows=A,z.numSpotMaps=M,z.numLightProbes=T,i.version=Ske++)}function u(d,h){let p=0,m=0,x=0,y=0,b=0;const v=h.matrixWorldInverse;for(let S=0,k=d.length;S<k;S++){const E=d[S];if(E.isDirectionalLight){const N=i.directional[p];N.direction.setFromMatrixPosition(E.matrixWorld),s.setFromMatrixPosition(E.target.matrixWorld),N.direction.sub(s),N.direction.transformDirection(v),p++}else if(E.isSpotLight){const N=i.spot[x];N.position.setFromMatrixPosition(E.matrixWorld),N.position.applyMatrix4(v),N.direction.setFromMatrixPosition(E.matrixWorld),s.setFromMatrixPosition(E.target.matrixWorld),N.direction.sub(s),N.direction.transformDirection(v),x++}else if(E.isRectAreaLight){const N=i.rectArea[y];N.position.setFromMatrixPosition(E.matrixWorld),N.position.applyMatrix4(v),l.identity(),o.copy(E.matrixWorld),o.premultiply(v),l.extractRotation(o),N.halfWidth.set(E.width*.5,0,0),N.halfHeight.set(0,E.height*.5,0),N.halfWidth.applyMatrix4(l),N.halfHeight.applyMatrix4(l),y++}else if(E.isPointLight){const N=i.point[m];N.position.setFromMatrixPosition(E.matrixWorld),N.position.applyMatrix4(v),m++}else if(E.isHemisphereLight){const N=i.hemi[b];N.direction.setFromMatrixPosition(E.matrixWorld),N.direction.transformDirection(v),b++}}}return{setup:c,setupView:u,state:i}}function Y6(t,e){const n=new kke(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function o(h){r.push(h)}function l(h){i.push(h)}function c(h){n.setup(r,h)}function u(h){n.setupView(r,h)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function Mke(t,e){let n=new WeakMap;function r(s,o=0){const l=n.get(s);let c;return l===void 0?(c=new Y6(t,e),n.set(s,[c])):o>=l.length?(c=new Y6(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class Cke extends Fb{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=hwe,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 Eke extends Fb{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 Ake=`void main() {
  7369. gl_Position = vec4( position, 1.0 );
  7370. }`,Tke=`uniform sampler2D shadow_pass;
  7371. uniform vec2 resolution;
  7372. uniform float radius;
  7373. #include <packing>
  7374. void main() {
  7375. const float samples = float( VSM_SAMPLES );
  7376. float mean = 0.0;
  7377. float squared_mean = 0.0;
  7378. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7379. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7380. for ( float i = 0.0; i < samples; i ++ ) {
  7381. float uvOffset = uvStart + i * uvStride;
  7382. #ifdef HORIZONTAL_PASS
  7383. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7384. mean += distribution.x;
  7385. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7386. #else
  7387. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7388. mean += depth;
  7389. squared_mean += depth * depth;
  7390. #endif
  7391. }
  7392. mean = mean / samples;
  7393. squared_mean = squared_mean / samples;
  7394. float std_dev = sqrt( squared_mean - mean * mean );
  7395. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7396. }`;function jke(t,e,n){let r=new Wk;const i=new Sn,s=new Sn,o=new Dr,l=new Cke({depthPacking:fwe}),c=new Eke,u={},d=n.maxTextureSize,h={[Bh]:Zs,[Zs]:Bh,[Eu]:Eu},p=new $h({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Sn},radius:{value:4}},vertexShader:Ake,fragmentShader:Tke}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new bs;x.setAttribute("position",new Co(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Gl(x,p),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=nX;let v=this.type;this.render=function(N,A,M){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||N.length===0)return;const P=t.getRenderTarget(),T=t.getActiveCubeFace(),j=t.getActiveMipmapLevel(),z=t.state;z.setBlending(Ah),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const F=v!==Su&&this.type===Su,$=v===Su&&this.type!==Su;for(let D=0,H=N.length;D<H;D++){const q=N[D],I=q.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",q,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;i.copy(I.mapSize);const K=I.getFrameExtents();if(i.multiply(K),s.copy(I.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/K.x),i.x=s.x*K.x,I.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/K.y),i.y=s.y*K.y,I.mapSize.y=s.y)),I.map===null||F===!0||$===!0){const se=this.type!==Su?{minFilter:Ka,magFilter:Ka}:{};I.map!==null&&I.map.dispose(),I.map=new Tm(i.x,i.y,se),I.map.texture.name=q.name+".shadowMap",I.camera.updateProjectionMatrix()}t.setRenderTarget(I.map),t.clear();const Z=I.getViewportCount();for(let se=0;se<Z;se++){const V=I.getViewport(se);o.set(s.x*V.x,s.y*V.y,s.x*V.z,s.y*V.w),z.viewport(o),I.updateMatrices(q,se),r=I.getFrustum(),E(A,M,I.camera,q,this.type)}I.isPointLightShadow!==!0&&this.type===Su&&S(I,M),I.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(P,T,j)};function S(N,A){const M=e.update(y);p.defines.VSM_SAMPLES!==N.blurSamples&&(p.defines.VSM_SAMPLES=N.blurSamples,m.defines.VSM_SAMPLES=N.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),N.mapPass===null&&(N.mapPass=new Tm(i.x,i.y)),p.uniforms.shadow_pass.value=N.map.texture,p.uniforms.resolution.value=N.mapSize,p.uniforms.radius.value=N.radius,t.setRenderTarget(N.mapPass),t.clear(),t.renderBufferDirect(A,null,M,p,y,null),m.uniforms.shadow_pass.value=N.mapPass.texture,m.uniforms.resolution.value=N.mapSize,m.uniforms.radius.value=N.radius,t.setRenderTarget(N.map),t.clear(),t.renderBufferDirect(A,null,M,m,y,null)}function k(N,A,M,P){let T=null;const j=M.isPointLight===!0?N.customDistanceMaterial:N.customDepthMaterial;if(j!==void 0)T=j;else if(T=M.isPointLight===!0?c:l,t.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0){const z=T.uuid,F=A.uuid;let $=u[z];$===void 0&&($={},u[z]=$);let D=$[F];D===void 0&&(D=T.clone(),$[F]=D),T=D}if(T.visible=A.visible,T.wireframe=A.wireframe,P===Su?T.side=A.shadowSide!==null?A.shadowSide:A.side:T.side=A.shadowSide!==null?A.shadowSide:h[A.side],T.alphaMap=A.alphaMap,T.alphaTest=A.alphaTest,T.map=A.map,T.clipShadows=A.clipShadows,T.clippingPlanes=A.clippingPlanes,T.clipIntersection=A.clipIntersection,T.displacementMap=A.displacementMap,T.displacementScale=A.displacementScale,T.displacementBias=A.displacementBias,T.wireframeLinewidth=A.wireframeLinewidth,T.linewidth=A.linewidth,M.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const z=t.properties.get(T);z.light=M}return T}function E(N,A,M,P,T){if(N.visible===!1)return;if(N.layers.test(A.layers)&&(N.isMesh||N.isLine||N.isPoints)&&(N.castShadow||N.receiveShadow&&T===Su)&&(!N.frustumCulled||r.intersectsObject(N))){N.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,N.matrixWorld);const F=e.update(N),$=N.material;if(Array.isArray($)){const D=F.groups;for(let H=0,q=D.length;H<q;H++){const I=D[H],K=$[I.materialIndex];if(K&&K.visible){const Z=k(N,K,P,T);N.onBeforeShadow(t,N,A,M,F,Z,I),t.renderBufferDirect(M,null,F,Z,N,I),N.onAfterShadow(t,N,A,M,F,Z,I)}}}else if($.visible){const D=k(N,$,P,T);N.onBeforeShadow(t,N,A,M,F,D,null),t.renderBufferDirect(M,null,F,D,N,null),N.onAfterShadow(t,N,A,M,F,D,null)}}const z=N.children;for(let F=0,$=z.length;F<$;F++)E(z[F],A,M,P,T)}}function Pke(t,e,n){const r=n.isWebGL2;function i(){let je=!1;const Xe=new Dr;let Re=null;const Oe=new Dr(0,0,0,0);return{setMask:function(Ne){Re!==Ne&&!je&&(t.colorMask(Ne,Ne,Ne,Ne),Re=Ne)},setLocked:function(Ne){je=Ne},setClear:function(Ne,Je,yt,Et,an){an===!0&&(Ne*=Et,Je*=Et,yt*=Et),Xe.set(Ne,Je,yt,Et),Oe.equals(Xe)===!1&&(t.clearColor(Ne,Je,yt,Et),Oe.copy(Xe))},reset:function(){je=!1,Re=null,Oe.set(-1,0,0,0)}}}function s(){let je=!1,Xe=null,Re=null,Oe=null;return{setTest:function(Ne){Ne?de(t.DEPTH_TEST):ce(t.DEPTH_TEST)},setMask:function(Ne){Xe!==Ne&&!je&&(t.depthMask(Ne),Xe=Ne)},setFunc:function(Ne){if(Re!==Ne){switch(Ne){case Hve:t.depthFunc(t.NEVER);break;case Vve:t.depthFunc(t.ALWAYS);break;case Gve:t.depthFunc(t.LESS);break;case y1:t.depthFunc(t.LEQUAL);break;case qve:t.depthFunc(t.EQUAL);break;case Wve:t.depthFunc(t.GEQUAL);break;case Kve:t.depthFunc(t.GREATER);break;case Xve:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Re=Ne}},setLocked:function(Ne){je=Ne},setClear:function(Ne){Oe!==Ne&&(t.clearDepth(Ne),Oe=Ne)},reset:function(){je=!1,Xe=null,Re=null,Oe=null}}}function o(){let je=!1,Xe=null,Re=null,Oe=null,Ne=null,Je=null,yt=null,Et=null,an=null;return{setTest:function(jt){je||(jt?de(t.STENCIL_TEST):ce(t.STENCIL_TEST))},setMask:function(jt){Xe!==jt&&!je&&(t.stencilMask(jt),Xe=jt)},setFunc:function(jt,Fe,gt){(Re!==jt||Oe!==Fe||Ne!==gt)&&(t.stencilFunc(jt,Fe,gt),Re=jt,Oe=Fe,Ne=gt)},setOp:function(jt,Fe,gt){(Je!==jt||yt!==Fe||Et!==gt)&&(t.stencilOp(jt,Fe,gt),Je=jt,yt=Fe,Et=gt)},setLocked:function(jt){je=jt},setClear:function(jt){an!==jt&&(t.clearStencil(jt),an=jt)},reset:function(){je=!1,Xe=null,Re=null,Oe=null,Ne=null,Je=null,yt=null,Et=null,an=null}}}const l=new i,c=new s,u=new o,d=new WeakMap,h=new WeakMap;let p={},m={},x=new WeakMap,y=[],b=null,v=!1,S=null,k=null,E=null,N=null,A=null,M=null,P=null,T=new cn(0,0,0),j=0,z=!1,F=null,$=null,D=null,H=null,q=null;const I=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,Z=0;const se=t.getParameter(t.VERSION);se.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(se)[1]),K=Z>=1):se.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),K=Z>=2);let V=null,W={};const ie=t.getParameter(t.SCISSOR_BOX),J=t.getParameter(t.VIEWPORT),pe=new Dr().fromArray(ie),fe=new Dr().fromArray(J);function ve(je,Xe,Re,Oe){const Ne=new Uint8Array(4),Je=t.createTexture();t.bindTexture(je,Je),t.texParameteri(je,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(je,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let yt=0;yt<Re;yt++)r&&(je===t.TEXTURE_3D||je===t.TEXTURE_2D_ARRAY)?t.texImage3D(Xe,0,t.RGBA,1,1,Oe,0,t.RGBA,t.UNSIGNED_BYTE,Ne):t.texImage2D(Xe+yt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ne);return Je}const Le={};Le[t.TEXTURE_2D]=ve(t.TEXTURE_2D,t.TEXTURE_2D,1),Le[t.TEXTURE_CUBE_MAP]=ve(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Le[t.TEXTURE_2D_ARRAY]=ve(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Le[t.TEXTURE_3D]=ve(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),de(t.DEPTH_TEST),c.setFunc(y1),ee(!1),Q(P8),de(t.CULL_FACE),ue(Ah);function de(je){p[je]!==!0&&(t.enable(je),p[je]=!0)}function ce(je){p[je]!==!1&&(t.disable(je),p[je]=!1)}function Ae(je,Xe){return m[je]!==Xe?(t.bindFramebuffer(je,Xe),m[je]=Xe,r&&(je===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Xe),je===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Xe)),!0):!1}function re(je,Xe){let Re=y,Oe=!1;if(je)if(Re=x.get(Xe),Re===void 0&&(Re=[],x.set(Xe,Re)),je.isWebGLMultipleRenderTargets){const Ne=je.texture;if(Re.length!==Ne.length||Re[0]!==t.COLOR_ATTACHMENT0){for(let Je=0,yt=Ne.length;Je<yt;Je++)Re[Je]=t.COLOR_ATTACHMENT0+Je;Re.length=Ne.length,Oe=!0}}else Re[0]!==t.COLOR_ATTACHMENT0&&(Re[0]=t.COLOR_ATTACHMENT0,Oe=!0);else Re[0]!==t.BACK&&(Re[0]=t.BACK,Oe=!0);Oe&&(n.isWebGL2?t.drawBuffers(Re):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Re))}function Ie(je){return b!==je?(t.useProgram(je),b=je,!0):!1}const G={[Vf]:t.FUNC_ADD,[Eve]:t.FUNC_SUBTRACT,[Ave]:t.FUNC_REVERSE_SUBTRACT};if(r)G[O8]=t.MIN,G[F8]=t.MAX;else{const je=e.get("EXT_blend_minmax");je!==null&&(G[O8]=je.MIN_EXT,G[F8]=je.MAX_EXT)}const Y={[Tve]:t.ZERO,[jve]:t.ONE,[Pve]:t.SRC_COLOR,[F3]:t.SRC_ALPHA,[Ive]:t.SRC_ALPHA_SATURATE,[Ove]:t.DST_COLOR,[Rve]:t.DST_ALPHA,[Dve]:t.ONE_MINUS_SRC_COLOR,[I3]:t.ONE_MINUS_SRC_ALPHA,[Fve]:t.ONE_MINUS_DST_COLOR,[Lve]:t.ONE_MINUS_DST_ALPHA,[zve]:t.CONSTANT_COLOR,[Uve]:t.ONE_MINUS_CONSTANT_COLOR,[Bve]:t.CONSTANT_ALPHA,[$ve]:t.ONE_MINUS_CONSTANT_ALPHA};function ue(je,Xe,Re,Oe,Ne,Je,yt,Et,an,jt){if(je===Ah){v===!0&&(ce(t.BLEND),v=!1);return}if(v===!1&&(de(t.BLEND),v=!0),je!==Cve){if(je!==S||jt!==z){if((k!==Vf||A!==Vf)&&(t.blendEquation(t.FUNC_ADD),k=Vf,A=Vf),jt)switch(je){case Ug:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case D8:t.blendFunc(t.ONE,t.ONE);break;case R8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case L8:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",je);break}else switch(je){case Ug:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case D8:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case R8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case L8:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",je);break}E=null,N=null,M=null,P=null,T.set(0,0,0),j=0,S=je,z=jt}return}Ne=Ne||Xe,Je=Je||Re,yt=yt||Oe,(Xe!==k||Ne!==A)&&(t.blendEquationSeparate(G[Xe],G[Ne]),k=Xe,A=Ne),(Re!==E||Oe!==N||Je!==M||yt!==P)&&(t.blendFuncSeparate(Y[Re],Y[Oe],Y[Je],Y[yt]),E=Re,N=Oe,M=Je,P=yt),(Et.equals(T)===!1||an!==j)&&(t.blendColor(Et.r,Et.g,Et.b,an),T.copy(Et),j=an),S=je,z=!1}function B(je,Xe){je.side===Eu?ce(t.CULL_FACE):de(t.CULL_FACE);let Re=je.side===Zs;Xe&&(Re=!Re),ee(Re),je.blending===Ug&&je.transparent===!1?ue(Ah):ue(je.blending,je.blendEquation,je.blendSrc,je.blendDst,je.blendEquationAlpha,je.blendSrcAlpha,je.blendDstAlpha,je.blendColor,je.blendAlpha,je.premultipliedAlpha),c.setFunc(je.depthFunc),c.setTest(je.depthTest),c.setMask(je.depthWrite),l.setMask(je.colorWrite);const Oe=je.stencilWrite;u.setTest(Oe),Oe&&(u.setMask(je.stencilWriteMask),u.setFunc(je.stencilFunc,je.stencilRef,je.stencilFuncMask),u.setOp(je.stencilFail,je.stencilZFail,je.stencilZPass)),he(je.polygonOffset,je.polygonOffsetFactor,je.polygonOffsetUnits),je.alphaToCoverage===!0?de(t.SAMPLE_ALPHA_TO_COVERAGE):ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function ee(je){F!==je&&(je?t.frontFace(t.CW):t.frontFace(t.CCW),F=je)}function Q(je){je!==Nve?(de(t.CULL_FACE),je!==$&&(je===P8?t.cullFace(t.BACK):je===kve?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ce(t.CULL_FACE),$=je}function le(je){je!==D&&(K&&t.lineWidth(je),D=je)}function he(je,Xe,Re){je?(de(t.POLYGON_OFFSET_FILL),(H!==Xe||q!==Re)&&(t.polygonOffset(Xe,Re),H=Xe,q=Re)):ce(t.POLYGON_OFFSET_FILL)}function te(je){je?de(t.SCISSOR_TEST):ce(t.SCISSOR_TEST)}function U(je){je===void 0&&(je=t.TEXTURE0+I-1),V!==je&&(t.activeTexture(je),V=je)}function L(je,Xe,Re){Re===void 0&&(V===null?Re=t.TEXTURE0+I-1:Re=V);let Oe=W[Re];Oe===void 0&&(Oe={type:void 0,texture:void 0},W[Re]=Oe),(Oe.type!==je||Oe.texture!==Xe)&&(V!==Re&&(t.activeTexture(Re),V=Re),t.bindTexture(je,Xe||Le[je]),Oe.type=je,Oe.texture=Xe)}function X(){const je=W[V];je!==void 0&&je.type!==void 0&&(t.bindTexture(je.type,null),je.type=void 0,je.texture=void 0)}function ge(){try{t.compressedTexImage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function _e(){try{t.compressedTexImage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function Ee(){try{t.texSubImage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function $e(){try{t.texSubImage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function Ce(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function He(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function Qe(){try{t.texStorage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function xe(){try{t.texStorage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function ye(){try{t.texImage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function we(){try{t.texImage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function Ue(je){pe.equals(je)===!1&&(t.scissor(je.x,je.y,je.z,je.w),pe.copy(je))}function Pe(je){fe.equals(je)===!1&&(t.viewport(je.x,je.y,je.z,je.w),fe.copy(je))}function Ve(je,Xe){let Re=h.get(Xe);Re===void 0&&(Re=new WeakMap,h.set(Xe,Re));let Oe=Re.get(je);Oe===void 0&&(Oe=t.getUniformBlockIndex(Xe,je.name),Re.set(je,Oe))}function ke(je,Xe){const Oe=h.get(Xe).get(je);d.get(Xe)!==Oe&&(t.uniformBlockBinding(Xe,Oe,je.__bindingPointIndex),d.set(Xe,Oe))}function Ze(){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),p={},V=null,W={},m={},x=new WeakMap,y=[],b=null,v=!1,S=null,k=null,E=null,N=null,A=null,M=null,P=null,T=new cn(0,0,0),j=0,z=!1,F=null,$=null,D=null,H=null,q=null,pe.set(0,0,t.canvas.width,t.canvas.height),fe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:de,disable:ce,bindFramebuffer:Ae,drawBuffers:re,useProgram:Ie,setBlending:ue,setMaterial:B,setFlipSided:ee,setCullFace:Q,setLineWidth:le,setPolygonOffset:he,setScissorTest:te,activeTexture:U,bindTexture:L,unbindTexture:X,compressedTexImage2D:ge,compressedTexImage3D:_e,texImage2D:ye,texImage3D:we,updateUBOMapping:Ve,uniformBlockBinding:ke,texStorage2D:Qe,texStorage3D:xe,texSubImage2D:Ee,texSubImage3D:$e,compressedTexSubImage2D:Ce,compressedTexSubImage3D:He,scissor:Ue,viewport:Pe,reset:Ze}}function Dke(t,e,n,r,i,s,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,h=i.maxSamples,p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=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 S(U,L){return v?new OffscreenCanvas(U,L):N1("canvas")}function k(U,L,X,ge){let _e=1;if((U.width>ge||U.height>ge)&&(_e=ge/Math.max(U.width,U.height)),_e<1||L===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const Ee=L?S1:Math.floor,$e=Ee(_e*U.width),Ce=Ee(_e*U.height);y===void 0&&(y=S($e,Ce));const He=X?S($e,Ce):y;return He.width=$e,He.height=Ce,He.getContext("2d").drawImage(U,0,0,$e,Ce),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+$e+"x"+Ce+")."),He}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function E(U){return G3(U.width)&&G3(U.height)}function N(U){return l?!1:U.wrapS!==zl||U.wrapT!==zl||U.minFilter!==Ka&&U.minFilter!==al}function A(U,L){return U.generateMipmaps&&L&&U.minFilter!==Ka&&U.minFilter!==al}function M(U){t.generateMipmap(U)}function P(U,L,X,ge,_e=!1){if(l===!1)return L;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 Ee=L;if(L===t.RED&&(X===t.FLOAT&&(Ee=t.R32F),X===t.HALF_FLOAT&&(Ee=t.R16F),X===t.UNSIGNED_BYTE&&(Ee=t.R8)),L===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(Ee=t.R8UI),X===t.UNSIGNED_SHORT&&(Ee=t.R16UI),X===t.UNSIGNED_INT&&(Ee=t.R32UI),X===t.BYTE&&(Ee=t.R8I),X===t.SHORT&&(Ee=t.R16I),X===t.INT&&(Ee=t.R32I)),L===t.RG&&(X===t.FLOAT&&(Ee=t.RG32F),X===t.HALF_FLOAT&&(Ee=t.RG16F),X===t.UNSIGNED_BYTE&&(Ee=t.RG8)),L===t.RGBA){const $e=_e?v1:jr.getTransfer(ge);X===t.FLOAT&&(Ee=t.RGBA32F),X===t.HALF_FLOAT&&(Ee=t.RGBA16F),X===t.UNSIGNED_BYTE&&(Ee=$e===ei?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(Ee=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(Ee=t.RGB5_A1)}return(Ee===t.R16F||Ee===t.R32F||Ee===t.RG16F||Ee===t.RG32F||Ee===t.RGBA16F||Ee===t.RGBA32F)&&e.get("EXT_color_buffer_float"),Ee}function T(U,L,X){return A(U,X)===!0||U.isFramebufferTexture&&U.minFilter!==Ka&&U.minFilter!==al?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function j(U){return U===Ka||U===I8||U===aA?t.NEAREST:t.LINEAR}function z(U){const L=U.target;L.removeEventListener("dispose",z),$(L),L.isVideoTexture&&x.delete(L)}function F(U){const L=U.target;L.removeEventListener("dispose",F),H(L)}function $(U){const L=r.get(U);if(L.__webglInit===void 0)return;const X=U.source,ge=b.get(X);if(ge){const _e=ge[L.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&D(U),Object.keys(ge).length===0&&b.delete(X)}r.remove(U)}function D(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const X=U.source,ge=b.get(X);delete ge[L.__cacheKey],o.memory.textures--}function H(U){const L=U.texture,X=r.get(U),ge=r.get(L);if(ge.__webglTexture!==void 0&&(t.deleteTexture(ge.__webglTexture),o.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(X.__webglFramebuffer[_e]))for(let Ee=0;Ee<X.__webglFramebuffer[_e].length;Ee++)t.deleteFramebuffer(X.__webglFramebuffer[_e][Ee]);else t.deleteFramebuffer(X.__webglFramebuffer[_e]);X.__webglDepthbuffer&&t.deleteRenderbuffer(X.__webglDepthbuffer[_e])}else{if(Array.isArray(X.__webglFramebuffer))for(let _e=0;_e<X.__webglFramebuffer.length;_e++)t.deleteFramebuffer(X.__webglFramebuffer[_e]);else t.deleteFramebuffer(X.__webglFramebuffer);if(X.__webglDepthbuffer&&t.deleteRenderbuffer(X.__webglDepthbuffer),X.__webglMultisampledFramebuffer&&t.deleteFramebuffer(X.__webglMultisampledFramebuffer),X.__webglColorRenderbuffer)for(let _e=0;_e<X.__webglColorRenderbuffer.length;_e++)X.__webglColorRenderbuffer[_e]&&t.deleteRenderbuffer(X.__webglColorRenderbuffer[_e]);X.__webglDepthRenderbuffer&&t.deleteRenderbuffer(X.__webglDepthRenderbuffer)}if(U.isWebGLMultipleRenderTargets)for(let _e=0,Ee=L.length;_e<Ee;_e++){const $e=r.get(L[_e]);$e.__webglTexture&&(t.deleteTexture($e.__webglTexture),o.memory.textures--),r.remove(L[_e])}r.remove(L),r.remove(U)}let q=0;function I(){q=0}function K(){const U=q;return U>=c&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+c),q+=1,U}function Z(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function se(U,L){const X=r.get(U);if(U.isVideoTexture&&he(U),U.isRenderTargetTexture===!1&&U.version>0&&X.__version!==U.version){const ge=U.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{de(X,U,L);return}}n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+L)}function V(U,L){const X=r.get(U);if(U.version>0&&X.__version!==U.version){de(X,U,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+L)}function W(U,L){const X=r.get(U);if(U.version>0&&X.__version!==U.version){de(X,U,L);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+L)}function ie(U,L){const X=r.get(U);if(U.version>0&&X.__version!==U.version){ce(X,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+L)}const J={[B3]:t.REPEAT,[zl]:t.CLAMP_TO_EDGE,[$3]:t.MIRRORED_REPEAT},pe={[Ka]:t.NEAREST,[I8]:t.NEAREST_MIPMAP_NEAREST,[aA]:t.NEAREST_MIPMAP_LINEAR,[al]:t.LINEAR,[rwe]:t.LINEAR_MIPMAP_NEAREST,[u0]:t.LINEAR_MIPMAP_LINEAR},fe={[pwe]:t.NEVER,[wwe]:t.ALWAYS,[gwe]:t.LESS,[fX]:t.LEQUAL,[bwe]:t.EQUAL,[vwe]:t.GEQUAL,[xwe]:t.GREATER,[ywe]:t.NOTEQUAL};function ve(U,L,X){if(X?(t.texParameteri(U,t.TEXTURE_WRAP_S,J[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,J[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,J[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,pe[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,pe[L.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),(L.wrapS!==zl||L.wrapT!==zl)&&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,j(L.magFilter)),t.texParameteri(U,t.TEXTURE_MIN_FILTER,j(L.minFilter)),L.minFilter!==Ka&&L.minFilter!==al&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,fe[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ge=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Ka||L.minFilter!==aA&&L.minFilter!==u0||L.type===Ou&&e.has("OES_texture_float_linear")===!1||l===!1&&L.type===d0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(U,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Le(U,L){let X=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",z));const ge=L.source;let _e=b.get(ge);_e===void 0&&(_e={},b.set(ge,_e));const Ee=Z(L);if(Ee!==U.__cacheKey){_e[Ee]===void 0&&(_e[Ee]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,X=!0),_e[Ee].usedTimes++;const $e=_e[U.__cacheKey];$e!==void 0&&(_e[U.__cacheKey].usedTimes--,$e.usedTimes===0&&D(L)),U.__cacheKey=Ee,U.__webglTexture=_e[Ee].texture}return X}function de(U,L,X){let ge=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ge=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ge=t.TEXTURE_3D);const _e=Le(U,L),Ee=L.source;n.bindTexture(ge,U.__webglTexture,t.TEXTURE0+X);const $e=r.get(Ee);if(Ee.version!==$e.__version||_e===!0){n.activeTexture(t.TEXTURE0+X);const Ce=jr.getPrimaries(jr.workingColorSpace),He=L.colorSpace===ol?null:jr.getPrimaries(L.colorSpace),Qe=L.colorSpace===ol||Ce===He?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Qe);const xe=N(L)&&E(L.image)===!1;let ye=k(L.image,xe,!1,d);ye=te(L,ye);const we=E(ye)||l,Ue=s.convert(L.format,L.colorSpace);let Pe=s.convert(L.type),Ve=P(L.internalFormat,Ue,Pe,L.colorSpace,L.isVideoTexture);ve(ge,L,we);let ke;const Ze=L.mipmaps,je=l&&L.isVideoTexture!==!0&&Ve!==uX,Xe=$e.__version===void 0||_e===!0,Re=T(L,ye,we);if(L.isDepthTexture)Ve=t.DEPTH_COMPONENT,l?L.type===Ou?Ve=t.DEPTH_COMPONENT32F:L.type===gh?Ve=t.DEPTH_COMPONENT24:L.type===sm?Ve=t.DEPTH24_STENCIL8:Ve=t.DEPTH_COMPONENT16:L.type===Ou&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===om&&Ve===t.DEPTH_COMPONENT&&L.type!==D4&&L.type!==gh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=gh,Pe=s.convert(L.type)),L.format===cb&&Ve===t.DEPTH_COMPONENT&&(Ve=t.DEPTH_STENCIL,L.type!==sm&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=sm,Pe=s.convert(L.type))),Xe&&(je?n.texStorage2D(t.TEXTURE_2D,1,Ve,ye.width,ye.height):n.texImage2D(t.TEXTURE_2D,0,Ve,ye.width,ye.height,0,Ue,Pe,null));else if(L.isDataTexture)if(Ze.length>0&&we){je&&Xe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,Ze[0].width,Ze[0].height);for(let Oe=0,Ne=Ze.length;Oe<Ne;Oe++)ke=Ze[Oe],je?n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,ke.width,ke.height,Ue,Pe,ke.data):n.texImage2D(t.TEXTURE_2D,Oe,Ve,ke.width,ke.height,0,Ue,Pe,ke.data);L.generateMipmaps=!1}else je?(Xe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,ye.width,ye.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ye.width,ye.height,Ue,Pe,ye.data)):n.texImage2D(t.TEXTURE_2D,0,Ve,ye.width,ye.height,0,Ue,Pe,ye.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){je&&Xe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Re,Ve,Ze[0].width,Ze[0].height,ye.depth);for(let Oe=0,Ne=Ze.length;Oe<Ne;Oe++)ke=Ze[Oe],L.format!==sl?Ue!==null?je?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Oe,0,0,0,ke.width,ke.height,ye.depth,Ue,ke.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Oe,Ve,ke.width,ke.height,ye.depth,0,ke.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):je?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Oe,0,0,0,ke.width,ke.height,ye.depth,Ue,Pe,ke.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Oe,Ve,ke.width,ke.height,ye.depth,0,Ue,Pe,ke.data)}else{je&&Xe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,Ze[0].width,Ze[0].height);for(let Oe=0,Ne=Ze.length;Oe<Ne;Oe++)ke=Ze[Oe],L.format!==sl?Ue!==null?je?n.compressedTexSubImage2D(t.TEXTURE_2D,Oe,0,0,ke.width,ke.height,Ue,ke.data):n.compressedTexImage2D(t.TEXTURE_2D,Oe,Ve,ke.width,ke.height,0,ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):je?n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,ke.width,ke.height,Ue,Pe,ke.data):n.texImage2D(t.TEXTURE_2D,Oe,Ve,ke.width,ke.height,0,Ue,Pe,ke.data)}else if(L.isDataArrayTexture)je?(Xe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Re,Ve,ye.width,ye.height,ye.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ye.width,ye.height,ye.depth,Ue,Pe,ye.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ve,ye.width,ye.height,ye.depth,0,Ue,Pe,ye.data);else if(L.isData3DTexture)je?(Xe&&n.texStorage3D(t.TEXTURE_3D,Re,Ve,ye.width,ye.height,ye.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ye.width,ye.height,ye.depth,Ue,Pe,ye.data)):n.texImage3D(t.TEXTURE_3D,0,Ve,ye.width,ye.height,ye.depth,0,Ue,Pe,ye.data);else if(L.isFramebufferTexture){if(Xe)if(je)n.texStorage2D(t.TEXTURE_2D,Re,Ve,ye.width,ye.height);else{let Oe=ye.width,Ne=ye.height;for(let Je=0;Je<Re;Je++)n.texImage2D(t.TEXTURE_2D,Je,Ve,Oe,Ne,0,Ue,Pe,null),Oe>>=1,Ne>>=1}}else if(Ze.length>0&&we){je&&Xe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,Ze[0].width,Ze[0].height);for(let Oe=0,Ne=Ze.length;Oe<Ne;Oe++)ke=Ze[Oe],je?n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,Ue,Pe,ke):n.texImage2D(t.TEXTURE_2D,Oe,Ve,Ue,Pe,ke);L.generateMipmaps=!1}else je?(Xe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,ye.width,ye.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Ue,Pe,ye)):n.texImage2D(t.TEXTURE_2D,0,Ve,Ue,Pe,ye);A(L,we)&&M(ge),$e.__version=Ee.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function ce(U,L,X){if(L.image.length!==6)return;const ge=Le(U,L),_e=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+X);const Ee=r.get(_e);if(_e.version!==Ee.__version||ge===!0){n.activeTexture(t.TEXTURE0+X);const $e=jr.getPrimaries(jr.workingColorSpace),Ce=L.colorSpace===ol?null:jr.getPrimaries(L.colorSpace),He=L.colorSpace===ol||$e===Ce?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);const Qe=L.isCompressedTexture||L.image[0].isCompressedTexture,xe=L.image[0]&&L.image[0].isDataTexture,ye=[];for(let Oe=0;Oe<6;Oe++)!Qe&&!xe?ye[Oe]=k(L.image[Oe],!1,!0,u):ye[Oe]=xe?L.image[Oe].image:L.image[Oe],ye[Oe]=te(L,ye[Oe]);const we=ye[0],Ue=E(we)||l,Pe=s.convert(L.format,L.colorSpace),Ve=s.convert(L.type),ke=P(L.internalFormat,Pe,Ve,L.colorSpace),Ze=l&&L.isVideoTexture!==!0,je=Ee.__version===void 0||ge===!0;let Xe=T(L,we,Ue);ve(t.TEXTURE_CUBE_MAP,L,Ue);let Re;if(Qe){Ze&&je&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Xe,ke,we.width,we.height);for(let Oe=0;Oe<6;Oe++){Re=ye[Oe].mipmaps;for(let Ne=0;Ne<Re.length;Ne++){const Je=Re[Ne];L.format!==sl?Pe!==null?Ze?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne,0,0,Je.width,Je.height,Pe,Je.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne,ke,Je.width,Je.height,0,Je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne,0,0,Je.width,Je.height,Pe,Ve,Je.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne,ke,Je.width,Je.height,0,Pe,Ve,Je.data)}}}else{Re=L.mipmaps,Ze&&je&&(Re.length>0&&Xe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Xe,ke,ye[0].width,ye[0].height));for(let Oe=0;Oe<6;Oe++)if(xe){Ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0,0,0,ye[Oe].width,ye[Oe].height,Pe,Ve,ye[Oe].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0,ke,ye[Oe].width,ye[Oe].height,0,Pe,Ve,ye[Oe].data);for(let Ne=0;Ne<Re.length;Ne++){const yt=Re[Ne].image[Oe].image;Ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne+1,0,0,yt.width,yt.height,Pe,Ve,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne+1,ke,yt.width,yt.height,0,Pe,Ve,yt.data)}}else{Ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0,0,0,Pe,Ve,ye[Oe]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,0,ke,Pe,Ve,ye[Oe]);for(let Ne=0;Ne<Re.length;Ne++){const Je=Re[Ne];Ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne+1,0,0,Pe,Ve,Je.image[Oe]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ne+1,ke,Pe,Ve,Je.image[Oe])}}}A(L,Ue)&&M(t.TEXTURE_CUBE_MAP),Ee.__version=_e.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Ae(U,L,X,ge,_e,Ee){const $e=s.convert(X.format,X.colorSpace),Ce=s.convert(X.type),He=P(X.internalFormat,$e,Ce,X.colorSpace);if(!r.get(L).__hasExternalTextures){const xe=Math.max(1,L.width>>Ee),ye=Math.max(1,L.height>>Ee);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,Ee,He,xe,ye,L.depth,0,$e,Ce,null):n.texImage2D(_e,Ee,He,xe,ye,0,$e,Ce,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),le(L)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ge,_e,r.get(X).__webglTexture,0,Q(L)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ge,_e,r.get(X).__webglTexture,Ee),n.bindFramebuffer(t.FRAMEBUFFER,null)}function re(U,L,X){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer&&!L.stencilBuffer){let ge=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(X||le(L)){const _e=L.depthTexture;_e&&_e.isDepthTexture&&(_e.type===Ou?ge=t.DEPTH_COMPONENT32F:_e.type===gh&&(ge=t.DEPTH_COMPONENT24));const Ee=Q(L);le(L)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ee,ge,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,Ee,ge,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ge,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,U)}else if(L.depthBuffer&&L.stencilBuffer){const ge=Q(L);X&&le(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,t.DEPTH24_STENCIL8,L.width,L.height):le(L)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,U)}else{const ge=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let _e=0;_e<ge.length;_e++){const Ee=ge[_e],$e=s.convert(Ee.format,Ee.colorSpace),Ce=s.convert(Ee.type),He=P(Ee.internalFormat,$e,Ce,Ee.colorSpace),Qe=Q(L);X&&le(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Qe,He,L.width,L.height):le(L)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Qe,He,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,He,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ie(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),se(L.depthTexture,0);const ge=r.get(L.depthTexture).__webglTexture,_e=Q(L);if(L.depthTexture.format===om)le(L)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0);else if(L.depthTexture.format===cb)le(L)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0);else throw new Error("Unknown depthTexture format")}function G(U){const L=r.get(U),X=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");Ie(L.__webglFramebuffer,U)}else if(X){L.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ge]),L.__webglDepthbuffer[ge]=t.createRenderbuffer(),re(L.__webglDepthbuffer[ge],U,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),re(L.__webglDepthbuffer,U,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function Y(U,L,X){const ge=r.get(U);L!==void 0&&Ae(ge.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&G(U)}function ue(U){const L=U.texture,X=r.get(U),ge=r.get(L);U.addEventListener("dispose",F),U.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=t.createTexture()),ge.__version=L.version,o.memory.textures++);const _e=U.isWebGLCubeRenderTarget===!0,Ee=U.isWebGLMultipleRenderTargets===!0,$e=E(U)||l;if(_e){X.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)if(l&&L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer[Ce]=[];for(let He=0;He<L.mipmaps.length;He++)X.__webglFramebuffer[Ce][He]=t.createFramebuffer()}else X.__webglFramebuffer[Ce]=t.createFramebuffer()}else{if(l&&L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer=[];for(let Ce=0;Ce<L.mipmaps.length;Ce++)X.__webglFramebuffer[Ce]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if(Ee)if(i.drawBuffers){const Ce=U.texture;for(let He=0,Qe=Ce.length;He<Qe;He++){const xe=r.get(Ce[He]);xe.__webglTexture===void 0&&(xe.__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&&le(U)===!1){const Ce=Ee?L:[L];X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let He=0;He<Ce.length;He++){const Qe=Ce[He];X.__webglColorRenderbuffer[He]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[He]);const xe=s.convert(Qe.format,Qe.colorSpace),ye=s.convert(Qe.type),we=P(Qe.internalFormat,xe,ye,Qe.colorSpace,U.isXRRenderTarget===!0),Ue=Q(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ue,we,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.RENDERBUFFER,X.__webglColorRenderbuffer[He])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),re(X.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,ge.__webglTexture),ve(t.TEXTURE_CUBE_MAP,L,$e);for(let Ce=0;Ce<6;Ce++)if(l&&L.mipmaps&&L.mipmaps.length>0)for(let He=0;He<L.mipmaps.length;He++)Ae(X.__webglFramebuffer[Ce][He],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,He);else Ae(X.__webglFramebuffer[Ce],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0);A(L,$e)&&M(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ee){const Ce=U.texture;for(let He=0,Qe=Ce.length;He<Qe;He++){const xe=Ce[He],ye=r.get(xe);n.bindTexture(t.TEXTURE_2D,ye.__webglTexture),ve(t.TEXTURE_2D,xe,$e),Ae(X.__webglFramebuffer,U,xe,t.COLOR_ATTACHMENT0+He,t.TEXTURE_2D,0),A(xe,$e)&&M(t.TEXTURE_2D)}n.unbindTexture()}else{let Ce=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(l?Ce=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ce,ge.__webglTexture),ve(Ce,L,$e),l&&L.mipmaps&&L.mipmaps.length>0)for(let He=0;He<L.mipmaps.length;He++)Ae(X.__webglFramebuffer[He],U,L,t.COLOR_ATTACHMENT0,Ce,He);else Ae(X.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Ce,0);A(L,$e)&&M(Ce),n.unbindTexture()}U.depthBuffer&&G(U)}function B(U){const L=E(U)||l,X=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let ge=0,_e=X.length;ge<_e;ge++){const Ee=X[ge];if(A(Ee,L)){const $e=U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ce=r.get(Ee).__webglTexture;n.bindTexture($e,Ce),M($e),n.unbindTexture()}}}function ee(U){if(l&&U.samples>0&&le(U)===!1){const L=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],X=U.width,ge=U.height;let _e=t.COLOR_BUFFER_BIT;const Ee=[],$e=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ce=r.get(U),He=U.isWebGLMultipleRenderTargets===!0;if(He)for(let Qe=0;Qe<L.length;Qe++)n.bindFramebuffer(t.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ce.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer);for(let Qe=0;Qe<L.length;Qe++){Ee.push(t.COLOR_ATTACHMENT0+Qe),U.depthBuffer&&Ee.push($e);const xe=Ce.__ignoreDepthValues!==void 0?Ce.__ignoreDepthValues:!1;if(xe===!1&&(U.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),He&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ce.__webglColorRenderbuffer[Qe]),xe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[$e]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[$e])),He){const ye=r.get(L[Qe]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ye,0)}t.blitFramebuffer(0,0,X,ge,0,0,X,ge,_e,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,Ee)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),He)for(let Qe=0;Qe<L.length;Qe++){n.bindFramebuffer(t.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.RENDERBUFFER,Ce.__webglColorRenderbuffer[Qe]);const xe=r.get(L[Qe]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ce.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.TEXTURE_2D,xe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer)}}function Q(U){return Math.min(h,U.samples)}function le(U){const L=r.get(U);return l&&U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function he(U){const L=o.render.frame;x.get(U)!==L&&(x.set(U,L),U.update())}function te(U,L){const X=U.colorSpace,ge=U.format,_e=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===V3||X!==td&&X!==ol&&(jr.getTransfer(X)===ei?l===!1?e.has("EXT_sRGB")===!0&&ge===sl?(U.format=V3,U.minFilter=al,U.generateMipmaps=!1):L=gX.sRGBToLinear(L):(ge!==sl||_e!==jh)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),L}this.allocateTextureUnit=K,this.resetTextureUnits=I,this.setTexture2D=se,this.setTexture2DArray=V,this.setTexture3D=W,this.setTextureCube=ie,this.rebindTextures=Y,this.setupRenderTarget=ue,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=ee,this.setupDepthRenderbuffer=G,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=le}function Rke(t,e,n){const r=n.isWebGL2;function i(s,o=ol){let l;const c=jr.getTransfer(o);if(s===jh)return t.UNSIGNED_BYTE;if(s===aX)return t.UNSIGNED_SHORT_4_4_4_4;if(s===sX)return t.UNSIGNED_SHORT_5_5_5_1;if(s===iwe)return t.BYTE;if(s===awe)return t.SHORT;if(s===D4)return t.UNSIGNED_SHORT;if(s===iX)return t.INT;if(s===gh)return t.UNSIGNED_INT;if(s===Ou)return t.FLOAT;if(s===d0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(s===swe)return t.ALPHA;if(s===sl)return t.RGBA;if(s===owe)return t.LUMINANCE;if(s===lwe)return t.LUMINANCE_ALPHA;if(s===om)return t.DEPTH_COMPONENT;if(s===cb)return t.DEPTH_STENCIL;if(s===V3)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(s===cwe)return t.RED;if(s===oX)return t.RED_INTEGER;if(s===uwe)return t.RG;if(s===lX)return t.RG_INTEGER;if(s===cX)return t.RGBA_INTEGER;if(s===sA||s===oA||s===lA||s===cA)if(c===ei)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(s===sA)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===oA)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===lA)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===cA)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(s===sA)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===oA)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===lA)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===cA)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===z8||s===U8||s===B8||s===$8)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(s===z8)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===U8)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===B8)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===$8)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===uX)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===H8||s===V8)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(s===H8)return c===ei?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(s===V8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===G8||s===q8||s===W8||s===K8||s===X8||s===Y8||s===Q8||s===Z8||s===J8||s===e6||s===t6||s===n6||s===r6||s===i6)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(s===G8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===q8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===W8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===K8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===X8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Y8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Q8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Z8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===J8)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===e6)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===t6)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===n6)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===r6)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===i6)return c===ei?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===uA||s===a6||s===s6)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(s===uA)return c===ei?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===a6)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===s6)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===dwe||s===o6||s===l6||s===c6)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(s===uA)return l.COMPRESSED_RED_RGTC1_EXT;if(s===o6)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===l6)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===c6)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===sm?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[s]!==void 0?t[s]:null}return{convert:i}}class Lke extends wo{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class xy extends js{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Oke={type:"move"};class DA{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new xy,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 xy,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new We,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new We),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new xy,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new We,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new We),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,s=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"],h=u.joints["thumb-tip"],p=d.position.distanceTo(h.position),m=.02,x=.005;u.inputState.pinching&&p>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),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(Oke)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new xy;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class Fke extends Wm{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,h=null,p=null,m=null,x=null;const y=n.getContextAttributes();let b=null,v=null;const S=[],k=[],E=new Sn;let N=null;const A=new wo;A.layers.enable(1),A.viewport=new Dr;const M=new wo;M.layers.enable(2),M.viewport=new Dr;const P=[A,M],T=new Lke;T.layers.enable(1),T.layers.enable(2);let j=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ie){let J=S[ie];return J===void 0&&(J=new DA,S[ie]=J),J.getTargetRaySpace()},this.getControllerGrip=function(ie){let J=S[ie];return J===void 0&&(J=new DA,S[ie]=J),J.getGripSpace()},this.getHand=function(ie){let J=S[ie];return J===void 0&&(J=new DA,S[ie]=J),J.getHandSpace()};function F(ie){const J=k.indexOf(ie.inputSource);if(J===-1)return;const pe=S[J];pe!==void 0&&(pe.update(ie.inputSource,ie.frame,u||o),pe.dispatchEvent({type:ie.type,data:ie.inputSource}))}function $(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",$),i.removeEventListener("inputsourceschange",D);for(let ie=0;ie<S.length;ie++){const J=k[ie];J!==null&&(k[ie]=null,S[ie].disconnect(J))}j=null,z=null,e.setRenderTarget(b),m=null,p=null,h=null,i=null,v=null,W.stop(),r.isPresenting=!1,e.setPixelRatio(N),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){s=ie,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){l=ie,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ie){u=ie},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return h},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ie){if(i=ie,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",$),i.addEventListener("inputsourceschange",D),y.xrCompatible!==!0&&await n.makeXRCompatible(),N=e.getPixelRatio(),e.getSize(E),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const J={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,J),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),v=new Tm(m.framebufferWidth,m.framebufferHeight,{format:sl,type:jh,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let J=null,pe=null,fe=null;y.depth&&(fe=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,J=y.stencil?cb:om,pe=y.stencil?sm:gh);const ve={colorFormat:n.RGBA8,depthFormat:fe,scaleFactor:s};h=new XRWebGLBinding(i,n),p=h.createProjectionLayer(ve),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),v=new Tm(p.textureWidth,p.textureHeight,{format:sl,type:jh,depthTexture:new EX(p.textureWidth,p.textureHeight,pe,void 0,void 0,void 0,void 0,void 0,void 0,J),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Le=e.properties.get(v);Le.__ignoreDepthValues=p.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),W.setContext(i),W.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function D(ie){for(let J=0;J<ie.removed.length;J++){const pe=ie.removed[J],fe=k.indexOf(pe);fe>=0&&(k[fe]=null,S[fe].disconnect(pe))}for(let J=0;J<ie.added.length;J++){const pe=ie.added[J];let fe=k.indexOf(pe);if(fe===-1){for(let Le=0;Le<S.length;Le++)if(Le>=k.length){k.push(pe),fe=Le;break}else if(k[Le]===null){k[Le]=pe,fe=Le;break}if(fe===-1)break}const ve=S[fe];ve&&ve.connect(pe)}}const H=new We,q=new We;function I(ie,J,pe){H.setFromMatrixPosition(J.matrixWorld),q.setFromMatrixPosition(pe.matrixWorld);const fe=H.distanceTo(q),ve=J.projectionMatrix.elements,Le=pe.projectionMatrix.elements,de=ve[14]/(ve[10]-1),ce=ve[14]/(ve[10]+1),Ae=(ve[9]+1)/ve[5],re=(ve[9]-1)/ve[5],Ie=(ve[8]-1)/ve[0],G=(Le[8]+1)/Le[0],Y=de*Ie,ue=de*G,B=fe/(-Ie+G),ee=B*-Ie;J.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(ee),ie.translateZ(B),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert();const Q=de+B,le=ce+B,he=Y-ee,te=ue+(fe-ee),U=Ae*ce/le*Q,L=re*ce/le*Q;ie.projectionMatrix.makePerspective(he,te,U,L,Q,le),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}function K(ie,J){J===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(J.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(i===null)return;T.near=M.near=A.near=ie.near,T.far=M.far=A.far=ie.far,(j!==T.near||z!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),j=T.near,z=T.far);const J=ie.parent,pe=T.cameras;K(T,J);for(let fe=0;fe<pe.length;fe++)K(pe[fe],J);pe.length===2?I(T,A,M):T.projectionMatrix.copy(A.projectionMatrix),Z(ie,T,J)};function Z(ie,J,pe){pe===null?ie.matrix.copy(J.matrixWorld):(ie.matrix.copy(pe.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(J.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(J.projectionMatrix),ie.projectionMatrixInverse.copy(J.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=f0*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(ie){c=ie,p!==null&&(p.fixedFoveation=ie),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ie)};let se=null;function V(ie,J){if(d=J.getViewerPose(u||o),x=J,d!==null){const pe=d.views;m!==null&&(e.setRenderTargetFramebuffer(v,m.framebuffer),e.setRenderTarget(v));let fe=!1;pe.length!==T.cameras.length&&(T.cameras.length=0,fe=!0);for(let ve=0;ve<pe.length;ve++){const Le=pe[ve];let de=null;if(m!==null)de=m.getViewport(Le);else{const Ae=h.getViewSubImage(p,Le);de=Ae.viewport,ve===0&&(e.setRenderTargetTextures(v,Ae.colorTexture,p.ignoreDepthValues?void 0:Ae.depthStencilTexture),e.setRenderTarget(v))}let ce=P[ve];ce===void 0&&(ce=new wo,ce.layers.enable(ve),ce.viewport=new Dr,P[ve]=ce),ce.matrix.fromArray(Le.transform.matrix),ce.matrix.decompose(ce.position,ce.quaternion,ce.scale),ce.projectionMatrix.fromArray(Le.projectionMatrix),ce.projectionMatrixInverse.copy(ce.projectionMatrix).invert(),ce.viewport.set(de.x,de.y,de.width,de.height),ve===0&&(T.matrix.copy(ce.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),fe===!0&&T.cameras.push(ce)}}for(let pe=0;pe<S.length;pe++){const fe=k[pe],ve=S[pe];fe!==null&&ve!==void 0&&ve.update(fe,J,u||o)}se&&se(ie,J),J.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:J}),x=null}const W=new CX;W.setAnimationLoop(V),this.setAnimationLoop=function(ie){se=ie},this.dispose=function(){}}}function Ike(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,NX(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,S,k,E){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(b,v):v.isMeshToonMaterial?(s(b,v),h(b,v)):v.isMeshPhongMaterial?(s(b,v),d(b,v)):v.isMeshStandardMaterial?(s(b,v),p(b,v),v.isMeshPhysicalMaterial&&m(b,v,E)):v.isMeshMatcapMaterial?(s(b,v),x(b,v)):v.isMeshDepthMaterial?s(b,v):v.isMeshDistanceMaterial?(s(b,v),y(b,v)):v.isMeshNormalMaterial?s(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,S,k):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(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===Zs&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===Zs&&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 S=e.get(v).envMap;if(S&&(b.envMap.value=S,b.flipEnvMap.value=S.isCubeTexture&&S.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 k=t._useLegacyLights===!0?Math.PI:1;b.lightMapIntensity.value=v.lightMapIntensity*k,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,S,k){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*S,b.scale.value=k*.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 h(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function p(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 m(b,v,S){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===Zs&&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=S.texture,b.transmissionSamplerSize.value.set(S.width,S.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 S=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(S.matrixWorld),b.nearDistance.value=S.shadow.camera.near,b.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function zke(t,e,n,r){let i={},s={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,k){const E=k.program;r.uniformBlockBinding(S,E)}function u(S,k){let E=i[S.id];E===void 0&&(x(S),E=d(S),i[S.id]=E,S.addEventListener("dispose",b));const N=k.program;r.updateUBOMapping(S,N);const A=e.render.frame;s[S.id]!==A&&(p(S),s[S.id]=A)}function d(S){const k=h();S.__bindingPointIndex=k;const E=t.createBuffer(),N=S.__size,A=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,E),t.bufferData(t.UNIFORM_BUFFER,N,A),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,k,E),E}function h(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const k=i[S.id],E=S.uniforms,N=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,k);for(let A=0,M=E.length;A<M;A++){const P=E[A];if(m(P,A,N)===!0){const T=P.__offset,j=Array.isArray(P.value)?P.value:[P.value];let z=0;for(let F=0;F<j.length;F++){const $=j[F],D=y($);typeof $=="number"?(P.__data[0]=$,t.bufferSubData(t.UNIFORM_BUFFER,T+z,P.__data)):$.isMatrix3?(P.__data[0]=$.elements[0],P.__data[1]=$.elements[1],P.__data[2]=$.elements[2],P.__data[3]=$.elements[0],P.__data[4]=$.elements[3],P.__data[5]=$.elements[4],P.__data[6]=$.elements[5],P.__data[7]=$.elements[0],P.__data[8]=$.elements[6],P.__data[9]=$.elements[7],P.__data[10]=$.elements[8],P.__data[11]=$.elements[0]):($.toArray(P.__data,z),z+=D.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,T,P.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,k,E){const N=S.value;if(E[k]===void 0){if(typeof N=="number")E[k]=N;else{const A=Array.isArray(N)?N:[N],M=[];for(let P=0;P<A.length;P++)M.push(A[P].clone());E[k]=M}return!0}else if(typeof N=="number"){if(E[k]!==N)return E[k]=N,!0}else{const A=Array.isArray(E[k])?E[k]:[E[k]],M=Array.isArray(N)?N:[N];for(let P=0;P<A.length;P++){const T=A[P];if(T.equals(M[P])===!1)return T.copy(M[P]),!0}}return!1}function x(S){const k=S.uniforms;let E=0;const N=16;let A=0;for(let M=0,P=k.length;M<P;M++){const T=k[M],j={boundary:0,storage:0},z=Array.isArray(T.value)?T.value:[T.value];for(let F=0,$=z.length;F<$;F++){const D=z[F],H=y(D);j.boundary+=H.boundary,j.storage+=H.storage}if(T.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=E,M>0){A=E%N;const F=N-A;A!==0&&F-j.boundary<0&&(E+=N-A,T.__offset=E)}E+=j.storage}return A=E%N,A>0&&(E+=N-A),S.__size=E,S.__cache={},this}function y(S){const k={boundary:0,storage:0};return typeof S=="number"?(k.boundary=4,k.storage=4):S.isVector2?(k.boundary=8,k.storage=8):S.isVector3||S.isColor?(k.boundary=16,k.storage=12):S.isVector4?(k.boundary=16,k.storage=16):S.isMatrix3?(k.boundary=48,k.storage=48):S.isMatrix4?(k.boundary=64,k.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),k}function b(S){const k=S.target;k.removeEventListener("dispose",b);const E=o.indexOf(k.__bindingPointIndex);o.splice(E,1),t.deleteBuffer(i[k.id]),delete i[k.id],delete s[k.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},s={}}return{bind:c,update:u,dispose:v}}class W3{constructor(e={}){const{canvas:n=Owe(),context:r=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let p;r!==null?p=r.getContextAttributes().alpha:p=o;const m=new Uint32Array(4),x=new Int32Array(4);let y=null,b=null;const v=[],S=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Xa,this._useLegacyLights=!1,this.toneMapping=Th,this.toneMappingExposure=1;const k=this;let E=!1,N=0,A=0,M=null,P=-1,T=null;const j=new Dr,z=new Dr;let F=null;const $=new cn(0);let D=0,H=n.width,q=n.height,I=1,K=null,Z=null;const se=new Dr(0,0,H,q),V=new Dr(0,0,H,q);let W=!1;const ie=new Wk;let J=!1,pe=!1,fe=null;const ve=new Xr,Le=new Sn,de=new We,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ae(){return M===null?I:1}let re=r;function Ie(De,nt){for(let dt=0;dt<De.length;dt++){const pt=De[dt],ot=n.getContext(pt,nt);if(ot!==null)return ot}return null}try{const De={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${Vk}`),n.addEventListener("webglcontextlost",Ze,!1),n.addEventListener("webglcontextrestored",je,!1),n.addEventListener("webglcontextcreationerror",Xe,!1),re===null){const nt=["webgl2","webgl","experimental-webgl"];if(k.isWebGL1Renderer===!0&&nt.shift(),re=Ie(nt,De),re===null)throw Ie(nt)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&re instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),re.getShaderPrecisionFormat===void 0&&(re.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(De){throw console.error("THREE.WebGLRenderer: "+De.message),De}let G,Y,ue,B,ee,Q,le,he,te,U,L,X,ge,_e,Ee,$e,Ce,He,Qe,xe,ye,we,Ue,Pe;function Ve(){G=new Y1e(re),Y=new H1e(re,G,e),G.init(Y),we=new Rke(re,G,Y),ue=new Pke(re,G,Y),B=new J1e(re),ee=new xke,Q=new Dke(re,G,ue,ee,Y,we,B),le=new G1e(k),he=new X1e(k),te=new s_e(re,Y),Ue=new B1e(re,G,te,Y),U=new Q1e(re,te,B,Ue),L=new rNe(re,U,te,B),Qe=new nNe(re,Y,Q),$e=new V1e(ee),X=new bke(k,le,he,G,Y,Ue,$e),ge=new Ike(k,ee),_e=new vke,Ee=new Mke(G,Y),He=new U1e(k,le,he,ue,L,p,c),Ce=new jke(k,L,Y),Pe=new zke(re,B,Y,ue),xe=new $1e(re,G,B,Y),ye=new Z1e(re,G,B,Y),B.programs=X.programs,k.capabilities=Y,k.extensions=G,k.properties=ee,k.renderLists=_e,k.shadowMap=Ce,k.state=ue,k.info=B}Ve();const ke=new Fke(k,re);this.xr=ke,this.getContext=function(){return re},this.getContextAttributes=function(){return re.getContextAttributes()},this.forceContextLoss=function(){const De=G.get("WEBGL_lose_context");De&&De.loseContext()},this.forceContextRestore=function(){const De=G.get("WEBGL_lose_context");De&&De.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(De){De!==void 0&&(I=De,this.setSize(H,q,!1))},this.getSize=function(De){return De.set(H,q)},this.setSize=function(De,nt,dt=!0){if(ke.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}H=De,q=nt,n.width=Math.floor(De*I),n.height=Math.floor(nt*I),dt===!0&&(n.style.width=De+"px",n.style.height=nt+"px"),this.setViewport(0,0,De,nt)},this.getDrawingBufferSize=function(De){return De.set(H*I,q*I).floor()},this.setDrawingBufferSize=function(De,nt,dt){H=De,q=nt,I=dt,n.width=Math.floor(De*dt),n.height=Math.floor(nt*dt),this.setViewport(0,0,De,nt)},this.getCurrentViewport=function(De){return De.copy(j)},this.getViewport=function(De){return De.copy(se)},this.setViewport=function(De,nt,dt,pt){De.isVector4?se.set(De.x,De.y,De.z,De.w):se.set(De,nt,dt,pt),ue.viewport(j.copy(se).multiplyScalar(I).floor())},this.getScissor=function(De){return De.copy(V)},this.setScissor=function(De,nt,dt,pt){De.isVector4?V.set(De.x,De.y,De.z,De.w):V.set(De,nt,dt,pt),ue.scissor(z.copy(V).multiplyScalar(I).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(De){ue.setScissorTest(W=De)},this.setOpaqueSort=function(De){K=De},this.setTransparentSort=function(De){Z=De},this.getClearColor=function(De){return De.copy(He.getClearColor())},this.setClearColor=function(){He.setClearColor.apply(He,arguments)},this.getClearAlpha=function(){return He.getClearAlpha()},this.setClearAlpha=function(){He.setClearAlpha.apply(He,arguments)},this.clear=function(De=!0,nt=!0,dt=!0){let pt=0;if(De){let ot=!1;if(M!==null){const Lt=M.texture.format;ot=Lt===cX||Lt===lX||Lt===oX}if(ot){const Lt=M.texture.type,me=Lt===jh||Lt===gh||Lt===D4||Lt===sm||Lt===aX||Lt===sX,ze=He.getClearColor(),Ke=He.getClearAlpha(),Ge=ze.r,be=ze.g,at=ze.b;me?(m[0]=Ge,m[1]=be,m[2]=at,m[3]=Ke,re.clearBufferuiv(re.COLOR,0,m)):(x[0]=Ge,x[1]=be,x[2]=at,x[3]=Ke,re.clearBufferiv(re.COLOR,0,x))}else pt|=re.COLOR_BUFFER_BIT}nt&&(pt|=re.DEPTH_BUFFER_BIT),dt&&(pt|=re.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),re.clear(pt)},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",Ze,!1),n.removeEventListener("webglcontextrestored",je,!1),n.removeEventListener("webglcontextcreationerror",Xe,!1),_e.dispose(),Ee.dispose(),ee.dispose(),le.dispose(),he.dispose(),L.dispose(),Ue.dispose(),Pe.dispose(),X.dispose(),ke.dispose(),ke.removeEventListener("sessionstart",an),ke.removeEventListener("sessionend",jt),fe&&(fe.dispose(),fe=null),Fe.stop()};function Ze(De){De.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),E=!0}function je(){console.log("THREE.WebGLRenderer: Context Restored."),E=!1;const De=B.autoReset,nt=Ce.enabled,dt=Ce.autoUpdate,pt=Ce.needsUpdate,ot=Ce.type;Ve(),B.autoReset=De,Ce.enabled=nt,Ce.autoUpdate=dt,Ce.needsUpdate=pt,Ce.type=ot}function Xe(De){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",De.statusMessage)}function Re(De){const nt=De.target;nt.removeEventListener("dispose",Re),Oe(nt)}function Oe(De){Ne(De),ee.remove(De)}function Ne(De){const nt=ee.get(De).programs;nt!==void 0&&(nt.forEach(function(dt){X.releaseProgram(dt)}),De.isShaderMaterial&&X.releaseShaderCache(De))}this.renderBufferDirect=function(De,nt,dt,pt,ot,Lt){nt===null&&(nt=ce);const me=ot.isMesh&&ot.matrixWorld.determinant()<0,ze=sr(De,nt,dt,pt,ot);ue.setMaterial(pt,me);let Ke=dt.index,Ge=1;if(pt.wireframe===!0){if(Ke=U.getWireframeAttribute(dt),Ke===void 0)return;Ge=2}const be=dt.drawRange,at=dt.attributes.position;let ht=be.start*Ge,rt=(be.start+be.count)*Ge;Lt!==null&&(ht=Math.max(ht,Lt.start*Ge),rt=Math.min(rt,(Lt.start+Lt.count)*Ge)),Ke!==null?(ht=Math.max(ht,0),rt=Math.min(rt,Ke.count)):at!=null&&(ht=Math.max(ht,0),rt=Math.min(rt,at.count));const Ct=rt-ht;if(Ct<0||Ct===1/0)return;Ue.setup(ot,pt,ze,dt,Ke);let Vt,Dt=xe;if(Ke!==null&&(Vt=te.get(Ke),Dt=ye,Dt.setIndex(Vt)),ot.isMesh)pt.wireframe===!0?(ue.setLineWidth(pt.wireframeLinewidth*Ae()),Dt.setMode(re.LINES)):Dt.setMode(re.TRIANGLES);else if(ot.isLine){let Tt=pt.linewidth;Tt===void 0&&(Tt=1),ue.setLineWidth(Tt*Ae()),ot.isLineSegments?Dt.setMode(re.LINES):ot.isLineLoop?Dt.setMode(re.LINE_LOOP):Dt.setMode(re.LINE_STRIP)}else ot.isPoints?Dt.setMode(re.POINTS):ot.isSprite&&Dt.setMode(re.TRIANGLES);if(ot.isBatchedMesh)Dt.renderMultiDraw(ot._multiDrawStarts,ot._multiDrawCounts,ot._multiDrawCount);else if(ot.isInstancedMesh)Dt.renderInstances(ht,Ct,ot.count);else if(dt.isInstancedBufferGeometry){const Tt=dt._maxInstanceCount!==void 0?dt._maxInstanceCount:1/0,Jt=Math.min(dt.instanceCount,Tt);Dt.renderInstances(ht,Ct,Jt)}else Dt.render(ht,Ct)};function Je(De,nt,dt){De.transparent===!0&&De.side===Eu&&De.forceSinglePass===!1?(De.side=Zs,De.needsUpdate=!0,gr(De,nt,dt),De.side=Bh,De.needsUpdate=!0,gr(De,nt,dt),De.side=Eu):gr(De,nt,dt)}this.compile=function(De,nt,dt=null){dt===null&&(dt=De),b=Ee.get(dt),b.init(),S.push(b),dt.traverseVisible(function(ot){ot.isLight&&ot.layers.test(nt.layers)&&(b.pushLight(ot),ot.castShadow&&b.pushShadow(ot))}),De!==dt&&De.traverseVisible(function(ot){ot.isLight&&ot.layers.test(nt.layers)&&(b.pushLight(ot),ot.castShadow&&b.pushShadow(ot))}),b.setupLights(k._useLegacyLights);const pt=new Set;return De.traverse(function(ot){const Lt=ot.material;if(Lt)if(Array.isArray(Lt))for(let me=0;me<Lt.length;me++){const ze=Lt[me];Je(ze,dt,ot),pt.add(ze)}else Je(Lt,dt,ot),pt.add(Lt)}),S.pop(),b=null,pt},this.compileAsync=function(De,nt,dt=null){const pt=this.compile(De,nt,dt);return new Promise(ot=>{function Lt(){if(pt.forEach(function(me){ee.get(me).currentProgram.isReady()&&pt.delete(me)}),pt.size===0){ot(De);return}setTimeout(Lt,10)}G.get("KHR_parallel_shader_compile")!==null?Lt():setTimeout(Lt,10)})};let yt=null;function Et(De){yt&&yt(De)}function an(){Fe.stop()}function jt(){Fe.start()}const Fe=new CX;Fe.setAnimationLoop(Et),typeof self<"u"&&Fe.setContext(self),this.setAnimationLoop=function(De){yt=De,ke.setAnimationLoop(De),De===null?Fe.stop():Fe.start()},ke.addEventListener("sessionstart",an),ke.addEventListener("sessionend",jt),this.render=function(De,nt){if(nt!==void 0&&nt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;De.matrixWorldAutoUpdate===!0&&De.updateMatrixWorld(),nt.parent===null&&nt.matrixWorldAutoUpdate===!0&&nt.updateMatrixWorld(),ke.enabled===!0&&ke.isPresenting===!0&&(ke.cameraAutoUpdate===!0&&ke.updateCamera(nt),nt=ke.getCamera()),De.isScene===!0&&De.onBeforeRender(k,De,nt,M),b=Ee.get(De,S.length),b.init(),S.push(b),ve.multiplyMatrices(nt.projectionMatrix,nt.matrixWorldInverse),ie.setFromProjectionMatrix(ve),pe=this.localClippingEnabled,J=$e.init(this.clippingPlanes,pe),y=_e.get(De,v.length),y.init(),v.push(y),gt(De,nt,0,k.sortObjects),y.finish(),k.sortObjects===!0&&y.sort(K,Z),this.info.render.frame++,J===!0&&$e.beginShadows();const dt=b.state.shadowsArray;if(Ce.render(dt,De,nt),J===!0&&$e.endShadows(),this.info.autoReset===!0&&this.info.reset(),He.render(y,De),b.setupLights(k._useLegacyLights),nt.isArrayCamera){const pt=nt.cameras;for(let ot=0,Lt=pt.length;ot<Lt;ot++){const me=pt[ot];Qt(y,De,me,me.viewport)}}else Qt(y,De,nt);M!==null&&(Q.updateMultisampleRenderTarget(M),Q.updateRenderTargetMipmap(M)),De.isScene===!0&&De.onAfterRender(k,De,nt),Ue.resetDefaultState(),P=-1,T=null,S.pop(),S.length>0?b=S[S.length-1]:b=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function gt(De,nt,dt,pt){if(De.visible===!1)return;if(De.layers.test(nt.layers)){if(De.isGroup)dt=De.renderOrder;else if(De.isLOD)De.autoUpdate===!0&&De.update(nt);else if(De.isLight)b.pushLight(De),De.castShadow&&b.pushShadow(De);else if(De.isSprite){if(!De.frustumCulled||ie.intersectsSprite(De)){pt&&de.setFromMatrixPosition(De.matrixWorld).applyMatrix4(ve);const me=L.update(De),ze=De.material;ze.visible&&y.push(De,me,ze,dt,de.z,null)}}else if((De.isMesh||De.isLine||De.isPoints)&&(!De.frustumCulled||ie.intersectsObject(De))){const me=L.update(De),ze=De.material;if(pt&&(De.boundingSphere!==void 0?(De.boundingSphere===null&&De.computeBoundingSphere(),de.copy(De.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),de.copy(me.boundingSphere.center)),de.applyMatrix4(De.matrixWorld).applyMatrix4(ve)),Array.isArray(ze)){const Ke=me.groups;for(let Ge=0,be=Ke.length;Ge<be;Ge++){const at=Ke[Ge],ht=ze[at.materialIndex];ht&&ht.visible&&y.push(De,me,ht,dt,de.z,at)}}else ze.visible&&y.push(De,me,ze,dt,de.z,null)}}const Lt=De.children;for(let me=0,ze=Lt.length;me<ze;me++)gt(Lt[me],nt,dt,pt)}function Qt(De,nt,dt,pt){const ot=De.opaque,Lt=De.transmissive,me=De.transparent;b.setupLightsView(dt),J===!0&&$e.setGlobalState(k.clippingPlanes,dt),Lt.length>0&&tn(ot,Lt,nt,dt),pt&&ue.viewport(j.copy(pt)),ot.length>0&&un(ot,nt,dt),Lt.length>0&&un(Lt,nt,dt),me.length>0&&un(me,nt,dt),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function tn(De,nt,dt,pt){if((dt.isScene===!0?dt.overrideMaterial:null)!==null)return;const Lt=Y.isWebGL2;fe===null&&(fe=new Tm(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?d0:jh,minFilter:u0,samples:Lt?4:0})),k.getDrawingBufferSize(Le),Lt?fe.setSize(Le.x,Le.y):fe.setSize(S1(Le.x),S1(Le.y));const me=k.getRenderTarget();k.setRenderTarget(fe),k.getClearColor($),D=k.getClearAlpha(),D<1&&k.setClearColor(16777215,.5),k.clear();const ze=k.toneMapping;k.toneMapping=Th,un(De,dt,pt),Q.updateMultisampleRenderTarget(fe),Q.updateRenderTargetMipmap(fe);let Ke=!1;for(let Ge=0,be=nt.length;Ge<be;Ge++){const at=nt[Ge],ht=at.object,rt=at.geometry,Ct=at.material,Vt=at.group;if(Ct.side===Eu&&ht.layers.test(pt.layers)){const Dt=Ct.side;Ct.side=Zs,Ct.needsUpdate=!0,dr(ht,dt,pt,rt,Ct,Vt),Ct.side=Dt,Ct.needsUpdate=!0,Ke=!0}}Ke===!0&&(Q.updateMultisampleRenderTarget(fe),Q.updateRenderTargetMipmap(fe)),k.setRenderTarget(me),k.setClearColor($,D),k.toneMapping=ze}function un(De,nt,dt){const pt=nt.isScene===!0?nt.overrideMaterial:null;for(let ot=0,Lt=De.length;ot<Lt;ot++){const me=De[ot],ze=me.object,Ke=me.geometry,Ge=pt===null?me.material:pt,be=me.group;ze.layers.test(dt.layers)&&dr(ze,nt,dt,Ke,Ge,be)}}function dr(De,nt,dt,pt,ot,Lt){De.onBeforeRender(k,nt,dt,pt,ot,Lt),De.modelViewMatrix.multiplyMatrices(dt.matrixWorldInverse,De.matrixWorld),De.normalMatrix.getNormalMatrix(De.modelViewMatrix),ot.onBeforeRender(k,nt,dt,pt,De,Lt),ot.transparent===!0&&ot.side===Eu&&ot.forceSinglePass===!1?(ot.side=Zs,ot.needsUpdate=!0,k.renderBufferDirect(dt,nt,pt,ot,De,Lt),ot.side=Bh,ot.needsUpdate=!0,k.renderBufferDirect(dt,nt,pt,ot,De,Lt),ot.side=Eu):k.renderBufferDirect(dt,nt,pt,ot,De,Lt),De.onAfterRender(k,nt,dt,pt,ot,Lt)}function gr(De,nt,dt){nt.isScene!==!0&&(nt=ce);const pt=ee.get(De),ot=b.state.lights,Lt=b.state.shadowsArray,me=ot.state.version,ze=X.getParameters(De,ot.state,Lt,nt,dt),Ke=X.getProgramCacheKey(ze);let Ge=pt.programs;pt.environment=De.isMeshStandardMaterial?nt.environment:null,pt.fog=nt.fog,pt.envMap=(De.isMeshStandardMaterial?he:le).get(De.envMap||pt.environment),Ge===void 0&&(De.addEventListener("dispose",Re),Ge=new Map,pt.programs=Ge);let be=Ge.get(Ke);if(be!==void 0){if(pt.currentProgram===be&&pt.lightsStateVersion===me)return Xt(De,ze),be}else ze.uniforms=X.getUniforms(De),De.onBuild(dt,ze,k),De.onBeforeCompile(ze,k),be=X.acquireProgram(ze,Ke),Ge.set(Ke,be),pt.uniforms=ze.uniforms;const at=pt.uniforms;return(!De.isShaderMaterial&&!De.isRawShaderMaterial||De.clipping===!0)&&(at.clippingPlanes=$e.uniform),Xt(De,ze),pt.needsLights=Fa(De),pt.lightsStateVersion=me,pt.needsLights&&(at.ambientLightColor.value=ot.state.ambient,at.lightProbe.value=ot.state.probe,at.directionalLights.value=ot.state.directional,at.directionalLightShadows.value=ot.state.directionalShadow,at.spotLights.value=ot.state.spot,at.spotLightShadows.value=ot.state.spotShadow,at.rectAreaLights.value=ot.state.rectArea,at.ltc_1.value=ot.state.rectAreaLTC1,at.ltc_2.value=ot.state.rectAreaLTC2,at.pointLights.value=ot.state.point,at.pointLightShadows.value=ot.state.pointShadow,at.hemisphereLights.value=ot.state.hemi,at.directionalShadowMap.value=ot.state.directionalShadowMap,at.directionalShadowMatrix.value=ot.state.directionalShadowMatrix,at.spotShadowMap.value=ot.state.spotShadowMap,at.spotLightMatrix.value=ot.state.spotLightMatrix,at.spotLightMap.value=ot.state.spotLightMap,at.pointShadowMap.value=ot.state.pointShadowMap,at.pointShadowMatrix.value=ot.state.pointShadowMatrix),pt.currentProgram=be,pt.uniformsList=null,be}function ar(De){if(De.uniformsList===null){const nt=De.currentProgram.getUniforms();De.uniformsList=HS.seqWithValue(nt.seq,De.uniforms)}return De.uniformsList}function Xt(De,nt){const dt=ee.get(De);dt.outputColorSpace=nt.outputColorSpace,dt.batching=nt.batching,dt.instancing=nt.instancing,dt.instancingColor=nt.instancingColor,dt.skinning=nt.skinning,dt.morphTargets=nt.morphTargets,dt.morphNormals=nt.morphNormals,dt.morphColors=nt.morphColors,dt.morphTargetsCount=nt.morphTargetsCount,dt.numClippingPlanes=nt.numClippingPlanes,dt.numIntersection=nt.numClipIntersection,dt.vertexAlphas=nt.vertexAlphas,dt.vertexTangents=nt.vertexTangents,dt.toneMapping=nt.toneMapping}function sr(De,nt,dt,pt,ot){nt.isScene!==!0&&(nt=ce),Q.resetTextureUnits();const Lt=nt.fog,me=pt.isMeshStandardMaterial?nt.environment:null,ze=M===null?k.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:td,Ke=(pt.isMeshStandardMaterial?he:le).get(pt.envMap||me),Ge=pt.vertexColors===!0&&!!dt.attributes.color&&dt.attributes.color.itemSize===4,be=!!dt.attributes.tangent&&(!!pt.normalMap||pt.anisotropy>0),at=!!dt.morphAttributes.position,ht=!!dt.morphAttributes.normal,rt=!!dt.morphAttributes.color;let Ct=Th;pt.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(Ct=k.toneMapping);const Vt=dt.morphAttributes.position||dt.morphAttributes.normal||dt.morphAttributes.color,Dt=Vt!==void 0?Vt.length:0,Tt=ee.get(pt),Jt=b.state.lights;if(J===!0&&(pe===!0||De!==T)){const Vr=De===T&&pt.id===P;$e.setState(pt,De,Vr)}let Kt=!1;pt.version===Tt.__version?(Tt.needsLights&&Tt.lightsStateVersion!==Jt.state.version||Tt.outputColorSpace!==ze||ot.isBatchedMesh&&Tt.batching===!1||!ot.isBatchedMesh&&Tt.batching===!0||ot.isInstancedMesh&&Tt.instancing===!1||!ot.isInstancedMesh&&Tt.instancing===!0||ot.isSkinnedMesh&&Tt.skinning===!1||!ot.isSkinnedMesh&&Tt.skinning===!0||ot.isInstancedMesh&&Tt.instancingColor===!0&&ot.instanceColor===null||ot.isInstancedMesh&&Tt.instancingColor===!1&&ot.instanceColor!==null||Tt.envMap!==Ke||pt.fog===!0&&Tt.fog!==Lt||Tt.numClippingPlanes!==void 0&&(Tt.numClippingPlanes!==$e.numPlanes||Tt.numIntersection!==$e.numIntersection)||Tt.vertexAlphas!==Ge||Tt.vertexTangents!==be||Tt.morphTargets!==at||Tt.morphNormals!==ht||Tt.morphColors!==rt||Tt.toneMapping!==Ct||Y.isWebGL2===!0&&Tt.morphTargetsCount!==Dt)&&(Kt=!0):(Kt=!0,Tt.__version=pt.version);let fn=Tt.currentProgram;Kt===!0&&(fn=gr(pt,nt,ot));let Cn=!1,gn=!1,Gt=!1;const mn=fn.getUniforms(),pn=Tt.uniforms;if(ue.useProgram(fn.program)&&(Cn=!0,gn=!0,Gt=!0),pt.id!==P&&(P=pt.id,gn=!0),Cn||T!==De){mn.setValue(re,"projectionMatrix",De.projectionMatrix),mn.setValue(re,"viewMatrix",De.matrixWorldInverse);const Vr=mn.map.cameraPosition;Vr!==void 0&&Vr.setValue(re,de.setFromMatrixPosition(De.matrixWorld)),Y.logarithmicDepthBuffer&&mn.setValue(re,"logDepthBufFC",2/(Math.log(De.far+1)/Math.LN2)),(pt.isMeshPhongMaterial||pt.isMeshToonMaterial||pt.isMeshLambertMaterial||pt.isMeshBasicMaterial||pt.isMeshStandardMaterial||pt.isShaderMaterial)&&mn.setValue(re,"isOrthographic",De.isOrthographicCamera===!0),T!==De&&(T=De,gn=!0,Gt=!0)}if(ot.isSkinnedMesh){mn.setOptional(re,ot,"bindMatrix"),mn.setOptional(re,ot,"bindMatrixInverse");const Vr=ot.skeleton;Vr&&(Y.floatVertexTextures?(Vr.boneTexture===null&&Vr.computeBoneTexture(),mn.setValue(re,"boneTexture",Vr.boneTexture,Q)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}ot.isBatchedMesh&&(mn.setOptional(re,ot,"batchingTexture"),mn.setValue(re,"batchingTexture",ot._matricesTexture,Q));const Hr=dt.morphAttributes;if((Hr.position!==void 0||Hr.normal!==void 0||Hr.color!==void 0&&Y.isWebGL2===!0)&&Qe.update(ot,dt,fn),(gn||Tt.receiveShadow!==ot.receiveShadow)&&(Tt.receiveShadow=ot.receiveShadow,mn.setValue(re,"receiveShadow",ot.receiveShadow)),pt.isMeshGouraudMaterial&&pt.envMap!==null&&(pn.envMap.value=Ke,pn.flipEnvMap.value=Ke.isCubeTexture&&Ke.isRenderTargetTexture===!1?-1:1),gn&&(mn.setValue(re,"toneMappingExposure",k.toneMappingExposure),Tt.needsLights&&vi(pn,Gt),Lt&&pt.fog===!0&&ge.refreshFogUniforms(pn,Lt),ge.refreshMaterialUniforms(pn,pt,I,q,fe),HS.upload(re,ar(Tt),pn,Q)),pt.isShaderMaterial&&pt.uniformsNeedUpdate===!0&&(HS.upload(re,ar(Tt),pn,Q),pt.uniformsNeedUpdate=!1),pt.isSpriteMaterial&&mn.setValue(re,"center",ot.center),mn.setValue(re,"modelViewMatrix",ot.modelViewMatrix),mn.setValue(re,"normalMatrix",ot.normalMatrix),mn.setValue(re,"modelMatrix",ot.matrixWorld),pt.isShaderMaterial||pt.isRawShaderMaterial){const Vr=pt.uniformsGroups;for(let Tn=0,_n=Vr.length;Tn<_n;Tn++)if(Y.isWebGL2){const $n=Vr[Tn];Pe.update($n,fn),Pe.bind($n,fn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return fn}function vi(De,nt){De.ambientLightColor.needsUpdate=nt,De.lightProbe.needsUpdate=nt,De.directionalLights.needsUpdate=nt,De.directionalLightShadows.needsUpdate=nt,De.pointLights.needsUpdate=nt,De.pointLightShadows.needsUpdate=nt,De.spotLights.needsUpdate=nt,De.spotLightShadows.needsUpdate=nt,De.rectAreaLights.needsUpdate=nt,De.hemisphereLights.needsUpdate=nt}function Fa(De){return De.isMeshLambertMaterial||De.isMeshToonMaterial||De.isMeshPhongMaterial||De.isMeshStandardMaterial||De.isShadowMaterial||De.isShaderMaterial&&De.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(De,nt,dt){ee.get(De.texture).__webglTexture=nt,ee.get(De.depthTexture).__webglTexture=dt;const pt=ee.get(De);pt.__hasExternalTextures=!0,pt.__hasExternalTextures&&(pt.__autoAllocateDepthBuffer=dt===void 0,pt.__autoAllocateDepthBuffer||G.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),pt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(De,nt){const dt=ee.get(De);dt.__webglFramebuffer=nt,dt.__useDefaultFramebuffer=nt===void 0},this.setRenderTarget=function(De,nt=0,dt=0){M=De,N=nt,A=dt;let pt=!0,ot=null,Lt=!1,me=!1;if(De){const Ke=ee.get(De);Ke.__useDefaultFramebuffer!==void 0?(ue.bindFramebuffer(re.FRAMEBUFFER,null),pt=!1):Ke.__webglFramebuffer===void 0?Q.setupRenderTarget(De):Ke.__hasExternalTextures&&Q.rebindTextures(De,ee.get(De.texture).__webglTexture,ee.get(De.depthTexture).__webglTexture);const Ge=De.texture;(Ge.isData3DTexture||Ge.isDataArrayTexture||Ge.isCompressedArrayTexture)&&(me=!0);const be=ee.get(De).__webglFramebuffer;De.isWebGLCubeRenderTarget?(Array.isArray(be[nt])?ot=be[nt][dt]:ot=be[nt],Lt=!0):Y.isWebGL2&&De.samples>0&&Q.useMultisampledRTT(De)===!1?ot=ee.get(De).__webglMultisampledFramebuffer:Array.isArray(be)?ot=be[dt]:ot=be,j.copy(De.viewport),z.copy(De.scissor),F=De.scissorTest}else j.copy(se).multiplyScalar(I).floor(),z.copy(V).multiplyScalar(I).floor(),F=W;if(ue.bindFramebuffer(re.FRAMEBUFFER,ot)&&Y.drawBuffers&&pt&&ue.drawBuffers(De,ot),ue.viewport(j),ue.scissor(z),ue.setScissorTest(F),Lt){const Ke=ee.get(De.texture);re.framebufferTexture2D(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0,re.TEXTURE_CUBE_MAP_POSITIVE_X+nt,Ke.__webglTexture,dt)}else if(me){const Ke=ee.get(De.texture),Ge=nt||0;re.framebufferTextureLayer(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0,Ke.__webglTexture,dt||0,Ge)}P=-1},this.readRenderTargetPixels=function(De,nt,dt,pt,ot,Lt,me){if(!(De&&De.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ze=ee.get(De).__webglFramebuffer;if(De.isWebGLCubeRenderTarget&&me!==void 0&&(ze=ze[me]),ze){ue.bindFramebuffer(re.FRAMEBUFFER,ze);try{const Ke=De.texture,Ge=Ke.format,be=Ke.type;if(Ge!==sl&&we.convert(Ge)!==re.getParameter(re.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const at=be===d0&&(G.has("EXT_color_buffer_half_float")||Y.isWebGL2&&G.has("EXT_color_buffer_float"));if(be!==jh&&we.convert(be)!==re.getParameter(re.IMPLEMENTATION_COLOR_READ_TYPE)&&!(be===Ou&&(Y.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!at){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}nt>=0&&nt<=De.width-pt&&dt>=0&&dt<=De.height-ot&&re.readPixels(nt,dt,pt,ot,we.convert(Ge),we.convert(be),Lt)}finally{const Ke=M!==null?ee.get(M).__webglFramebuffer:null;ue.bindFramebuffer(re.FRAMEBUFFER,Ke)}}},this.copyFramebufferToTexture=function(De,nt,dt=0){const pt=Math.pow(2,-dt),ot=Math.floor(nt.image.width*pt),Lt=Math.floor(nt.image.height*pt);Q.setTexture2D(nt,0),re.copyTexSubImage2D(re.TEXTURE_2D,dt,0,0,De.x,De.y,ot,Lt),ue.unbindTexture()},this.copyTextureToTexture=function(De,nt,dt,pt=0){const ot=nt.image.width,Lt=nt.image.height,me=we.convert(dt.format),ze=we.convert(dt.type);Q.setTexture2D(dt,0),re.pixelStorei(re.UNPACK_FLIP_Y_WEBGL,dt.flipY),re.pixelStorei(re.UNPACK_PREMULTIPLY_ALPHA_WEBGL,dt.premultiplyAlpha),re.pixelStorei(re.UNPACK_ALIGNMENT,dt.unpackAlignment),nt.isDataTexture?re.texSubImage2D(re.TEXTURE_2D,pt,De.x,De.y,ot,Lt,me,ze,nt.image.data):nt.isCompressedTexture?re.compressedTexSubImage2D(re.TEXTURE_2D,pt,De.x,De.y,nt.mipmaps[0].width,nt.mipmaps[0].height,me,nt.mipmaps[0].data):re.texSubImage2D(re.TEXTURE_2D,pt,De.x,De.y,me,ze,nt.image),pt===0&&dt.generateMipmaps&&re.generateMipmap(re.TEXTURE_2D),ue.unbindTexture()},this.copyTextureToTexture3D=function(De,nt,dt,pt,ot=0){if(k.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Lt=De.max.x-De.min.x+1,me=De.max.y-De.min.y+1,ze=De.max.z-De.min.z+1,Ke=we.convert(pt.format),Ge=we.convert(pt.type);let be;if(pt.isData3DTexture)Q.setTexture3D(pt,0),be=re.TEXTURE_3D;else if(pt.isDataArrayTexture)Q.setTexture2DArray(pt,0),be=re.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}re.pixelStorei(re.UNPACK_FLIP_Y_WEBGL,pt.flipY),re.pixelStorei(re.UNPACK_PREMULTIPLY_ALPHA_WEBGL,pt.premultiplyAlpha),re.pixelStorei(re.UNPACK_ALIGNMENT,pt.unpackAlignment);const at=re.getParameter(re.UNPACK_ROW_LENGTH),ht=re.getParameter(re.UNPACK_IMAGE_HEIGHT),rt=re.getParameter(re.UNPACK_SKIP_PIXELS),Ct=re.getParameter(re.UNPACK_SKIP_ROWS),Vt=re.getParameter(re.UNPACK_SKIP_IMAGES),Dt=dt.isCompressedTexture?dt.mipmaps[0]:dt.image;re.pixelStorei(re.UNPACK_ROW_LENGTH,Dt.width),re.pixelStorei(re.UNPACK_IMAGE_HEIGHT,Dt.height),re.pixelStorei(re.UNPACK_SKIP_PIXELS,De.min.x),re.pixelStorei(re.UNPACK_SKIP_ROWS,De.min.y),re.pixelStorei(re.UNPACK_SKIP_IMAGES,De.min.z),dt.isDataTexture||dt.isData3DTexture?re.texSubImage3D(be,ot,nt.x,nt.y,nt.z,Lt,me,ze,Ke,Ge,Dt.data):dt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),re.compressedTexSubImage3D(be,ot,nt.x,nt.y,nt.z,Lt,me,ze,Ke,Dt.data)):re.texSubImage3D(be,ot,nt.x,nt.y,nt.z,Lt,me,ze,Ke,Ge,Dt),re.pixelStorei(re.UNPACK_ROW_LENGTH,at),re.pixelStorei(re.UNPACK_IMAGE_HEIGHT,ht),re.pixelStorei(re.UNPACK_SKIP_PIXELS,rt),re.pixelStorei(re.UNPACK_SKIP_ROWS,Ct),re.pixelStorei(re.UNPACK_SKIP_IMAGES,Vt),ot===0&&pt.generateMipmaps&&re.generateMipmap(be),ue.unbindTexture()},this.initTexture=function(De){De.isCubeTexture?Q.setTextureCube(De,0):De.isData3DTexture?Q.setTexture3D(De,0):De.isDataArrayTexture||De.isCompressedArrayTexture?Q.setTexture2DArray(De,0):Q.setTexture2D(De,0),ue.unbindTexture()},this.resetState=function(){N=0,A=0,M=null,ue.reset(),Ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Sc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===R4?"display-p3":"srgb",n.unpackColorSpace=jr.workingColorSpace===qk?"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===Xa?lm:dX}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===lm?Xa:td}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 Uke extends W3{}Uke.prototype.isWebGL1Renderer=!0;class U4{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new cn(e),this.near=n,this.far=r}clone(){return new U4(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Bke extends js{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.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 $ke{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=H3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Hu()}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,s=this.stride;i<s;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=Hu()),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=Hu()),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 _s=new We;class bh{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++)_s.fromBufferAttribute(this,n),_s.applyMatrix4(e),this.setXYZ(n,_s.x,_s.y,_s.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)_s.fromBufferAttribute(this,n),_s.applyNormalMatrix(e),this.setXYZ(n,_s.x,_s.y,_s.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)_s.fromBufferAttribute(this,n),_s.transformDirection(e),this.setXYZ(n,_s.x,_s.y,_s.z);return this}setX(e,n){return this.normalized&&(n=Tr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Tr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Tr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Tr(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=yc(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=yc(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=yc(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=yc(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Tr(n,this.array),r=Tr(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=Tr(n,this.array),r=Tr(r,this.array),i=Tr(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,s){return e=e*this.data.stride+this.offset,this.normalized&&(n=Tr(n,this.array),r=Tr(r,this.array),i=Tr(i,this.array),s=Tr(s,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]=s,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 s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return new Co(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 bh(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 s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}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 Hke extends Js{constructor(e=null,n=1,r=1,i,s,o,l,c,u=Ka,d=Ka,h,p){super(null,o,l,c,u,d,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function Vke(t,e){return t.z-e.z}function Gke(t,e){return e.z-t.z}class qke{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 s=r[this.index];i.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=n}reset(){this.list.length=0,this.index=0}}const lg="batchId",Yd=new Xr,Q6=new Xr,Wke=new Xr,Z6=new Xr,RA=new Wk,H_=new hl,Df=new Mc,ty=new We,LA=new qke,ls=new Gl,V_=[];function Kke(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let s=0;s<i;s++)for(let o=0;o<r;o++)e.setComponent(s+n,o,t.getComponent(s,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class Xke extends Gl{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new bs,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 Hke(n,e,e,sl,Ou);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:h}=c,p=new u.constructor(r*d),m=new c.constructor(p,d,h);m.setUsage(c.usage),n.setAttribute(l,m)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new Co(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(lg,new Co(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(lg))throw new Error(`BatchedMesh: Geometry cannot use attribute "${lg}"`);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===lg)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=n.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.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 hl);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,Yd),this.getBoundingBoxAt(i,H_).applyMatrix4(Yd),n.union(H_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Mc);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,Yd),this.getBoundingSphereAt(i,Df).applyMatrix4(Yd),n.union(Df))}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 s=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,s===null?i.vertexStart=0:i.vertexStart=s.vertexStart+s.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,s===null?i.indexStart=0:i.indexStart=s.indexStart+s.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 h=this._visibility,p=this._active,m=this._matricesTexture,x=this._matricesTexture.image.data;h.push(!0),p.push(!0);const y=this._geometryCount;this._geometryCount++,Wke.toArray(x,y*16),m.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new hl,sphereInitialized:!1,sphere:new Mc});const b=this.geometry.getAttribute(lg);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,s=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 m in r.attributes){if(m===lg)continue;const x=n.getAttribute(m),y=r.getAttribute(m);Kke(x,y,c);const b=x.itemSize;for(let v=x.count,S=u;v<S;v++){const k=c+v;for(let E=0;E<b;E++)y.setComponent(k,E,0)}y.needsUpdate=!0}if(i){const m=l.indexStart;for(let x=0;x<o.count;x++)s.setX(m+x,c+o.getX(x));for(let x=o.count,y=l.indexCount;x<y;x++)s.setX(m+x,c);s.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 h=this._drawRanges[e],p=n.getAttribute("position");return h.count=i?o.count:p.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],s=i.box,o=this.geometry;if(i.boxInitialized===!1){s.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,h=u.start+u.count;d<h;d++){let p=d;l&&(p=l.getX(p)),s.expandByPoint(ty.fromBufferAttribute(c,p))}i.boxInitialized=!0}return n.copy(s),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,H_),H_.getCenter(s.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let h=u.start,p=u.start+u.count;h<p;h++){let m=h;l&&(m=l.getX(m)),ty.fromBufferAttribute(c,m),d=Math.max(d,s.center.distanceToSquared(ty))}s.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(s),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(s,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,s=this._geometryCount;return e>=s||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,s=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;ls.material=this.material,ls.geometry.index=c.index,ls.geometry.attributes=c.attributes,ls.geometry.boundingBox===null&&(ls.geometry.boundingBox=new hl),ls.geometry.boundingSphere===null&&(ls.geometry.boundingSphere=new Mc);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=s[u];ls.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ls.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,ls.geometry.boundingBox),this.getBoundingSphereAt(u,ls.geometry.boundingSphere),ls.raycast(e,V_);for(let h=0,p=V_.length;h<p;h++){const m=V_[h];m.object=this,m.batchId=u,n.push(m)}V_.length=0}ls.material=null,ls.geometry.index=null,ls.geometry.attributes={},ls.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,s){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,h=this._drawRanges,p=this.perObjectFrustumCulled;p&&(Z6.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),RA.setFromProjectionMatrix(Z6,e.isWebGPURenderer?h0:Sc));let m=0;if(this.sortObjects){Q6.copy(this.matrixWorld).invert(),ty.setFromMatrixPosition(r.matrixWorld).applyMatrix4(Q6);for(let b=0,v=c.length;b<v;b++)if(c[b]){this.getMatrixAt(b,Yd),this.getBoundingSphereAt(b,Df).applyMatrix4(Yd);let S=!1;if(p&&(S=!RA.intersectsSphere(Df)),!S){const k=ty.distanceTo(Df.center);LA.push(h[b],k)}}const x=LA.list,y=this.customSort;y===null?x.sort(s.transparent?Gke:Vke):y.call(this,x,r);for(let b=0,v=x.length;b<v;b++){const S=x[b];u[m]=S.start*l,d[m]=S.count,m++}LA.reset()}else for(let x=0,y=c.length;x<y;x++)if(c[x]){let b=!1;if(p&&(this.getMatrixAt(x,Yd),this.getBoundingSphereAt(x,Df).applyMatrix4(Yd),b=!RA.intersectsSphere(Df)),!b){const v=h[x];u[m]=v.start*l,d[m]=v.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,o){this.onBeforeRender(e,null,i,s,o)}}class J0 extends Fb{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new cn(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 J6=new We,e$=new We,t$=new Xr,OA=new O4,G_=new Mc;let Yke=class extends js{constructor(e=new bs,n=new J0){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,s=n.count;i<s;i++)J6.fromBufferAttribute(n,i-1),e$.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=J6.distanceTo(e$);e.setAttribute("lineDistance",new Bi(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,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),G_.copy(r.boundingSphere),G_.applyMatrix4(i),G_.radius+=s,e.ray.intersectsSphere(G_)===!1)return;t$.copy(i).invert(),OA.copy(e.ray).applyMatrix4(t$);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new We,d=new We,h=new We,p=new We,m=this.isLineSegments?2:1,x=r.index,b=r.attributes.position;if(x!==null){const v=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let k=v,E=S-1;k<E;k+=m){const N=x.getX(k),A=x.getX(k+1);if(u.fromBufferAttribute(b,N),d.fromBufferAttribute(b,A),OA.distanceSqToSegment(u,d,p,h)>c)continue;p.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(p);P<e.near||P>e.far||n.push({distance:P,point:h.clone().applyMatrix4(this.matrixWorld),index:k,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),S=Math.min(b.count,o.start+o.count);for(let k=v,E=S-1;k<E;k+=m){if(u.fromBufferAttribute(b,k),d.fromBufferAttribute(b,k+1),OA.distanceSqToSegment(u,d,p,h)>c)continue;p.applyMatrix4(this.matrixWorld);const A=e.ray.origin.distanceTo(p);A<e.near||A>e.far||n.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:k,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 s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}};const n$=new We,r$=new We;class Xk extends Yke{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,s=n.count;i<s;i+=2)n$.fromBufferAttribute(n,i),r$.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+n$.distanceTo(r$);e.setAttribute("lineDistance",new Bi(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Qke extends bs{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new We,s=new We;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 h=c[u],p=h.start,m=h.count;for(let x=p,y=p+m;x<y;x+=3)for(let b=0;b<3;b++){const v=l.getX(x+b),S=l.getX(x+(b+1)%3);i.fromBufferAttribute(o,v),s.fromBufferAttribute(o,S),i$(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.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,h=3*l+(u+1)%3;i.fromBufferAttribute(o,d),s.fromBufferAttribute(o,h),i$(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Bi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function i$(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 Zke extends Fb{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new cn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hX,this.normalScale=new Sn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=P4,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 Jke extends J0{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 RX extends js{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new cn(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 FA=new Xr,a$=new We,s$=new We;class eMe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Sn(512,512),this.map=null,this.mapPass=null,this.matrix=new Xr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wk,this._frameExtents=new Sn(1,1),this._viewportCount=1,this._viewports=[new Dr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;a$.setFromMatrixPosition(e.matrixWorld),n.position.copy(a$),s$.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(s$),n.updateMatrixWorld(),FA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(FA),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(FA)}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 o$=new Xr,ny=new We,IA=new We;class tMe extends eMe{constructor(){super(new wo(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Sn(4,2),this._viewportCount=6,this._viewports=[new Dr(2,1,1,1),new Dr(0,1,1,1),new Dr(3,1,1,1),new Dr(1,1,1,1),new Dr(3,0,1,1),new Dr(1,0,1,1)],this._cubeDirections=[new We(1,0,0),new We(-1,0,0),new We(0,0,1),new We(0,0,-1),new We(0,1,0),new We(0,-1,0)],this._cubeUps=[new We(0,1,0),new We(0,1,0),new We(0,1,0),new We(0,1,0),new We(0,0,1),new We(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),ny.setFromMatrixPosition(e.matrixWorld),r.position.copy(ny),IA.copy(r.position),IA.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(IA),r.updateMatrixWorld(),i.makeTranslation(-ny.x,-ny.y,-ny.z),o$.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(o$)}}class nMe extends RX{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 tMe}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 rMe extends RX{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class iMe extends bs{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 K3 extends $ke{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 l${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(Ya(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const c$=new We,q_=new We;class aMe{constructor(e=new We,n=new We){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){c$.subVectors(e,this.start),q_.subVectors(this.end,this.start);const r=q_.dot(q_);let s=q_.dot(c$)/r;return n&&(s=Ya(s,0,1)),s}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 sMe extends Xk{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 bs;i.setAttribute("position",new Bi(n,3)),i.setAttribute("color",new Bi(r,3));const s=new J0({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new cn,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(n),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,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:Vk}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Vk);class Cc{constructor(e,n,r,i,s="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(s),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Cc.nextNameID=Cc.nextNameID||0,this.$name.id=`lil-gui-name-${++Cc.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 oMe extends Cc{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 X3(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 lMe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:X3,toHexString:X3},m0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},cMe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=m0.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 m0.toHexString(i)}},uMe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=m0.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 m0.toHexString(i)}},dMe=[lMe,m0,cMe,uMe];function hMe(t){return dMe.find(e=>e.match(t))}class fMe extends Cc{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=hMe(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 s=X3(this.$text.value);s&&this._setValueFromHexString(s)}),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 zA extends Cc{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 mMe extends Cc{constructor(e,n,r,i,s,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(s);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let S=parseFloat(this.$input.value);isNaN(S)||(this._stepExplicit&&(S=this._snap(S)),this.setValue(this._clamp(S)))},r=S=>{const k=parseFloat(this.$input.value);isNaN(k)||(this._snapClampSetValue(k+S),this.$input.value=this.getValue())},i=S=>{S.key==="Enter"&&this.$input.blur(),S.code==="ArrowUp"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S))),S.code==="ArrowDown"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S)*-1))},s=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,h;const p=5,m=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),h=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=S=>{if(o){const k=S.clientX-l,E=S.clientY-c;Math.abs(E)>p?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(k)>p&&y()}if(!o){const k=S.clientY-u;h-=k*this._step*this._arrowKeyMultiplier(S),d+h>this._max?h=this._max-d:d+h<this._min&&(h=this._min-d),this._snapClampSetValue(d+h)}u=S.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",s,{passive:!1}),this.$input.addEventListener("mousedown",m),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,S,k,E,N)=>(v-S)/(k-S)*(N-E)+E,n=v=>{const S=this.$slider.getBoundingClientRect();let k=e(v,S.left,S.right,this._min,this._max);this._snapClampSetValue(k)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=v=>{n(v.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};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",h,{passive:!1}),window.addEventListener("touchend",p))},h=v=>{if(o){const S=v.touches[0].clientX-l,k=v.touches[0].clientY-c;Math.abs(S)>Math.abs(k)?u(v):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",p))}else v.preventDefault(),n(v.touches[0].clientX)},p=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",p)},m=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 k=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+k),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(m,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 pMe extends Cc{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 gMe extends Cc{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 bMe=`.lil-gui {
  7397. font-family: var(--font-family);
  7398. font-size: var(--font-size);
  7399. line-height: 1;
  7400. font-weight: normal;
  7401. font-style: normal;
  7402. text-align: left;
  7403. color: var(--text-color);
  7404. user-select: none;
  7405. -webkit-user-select: none;
  7406. touch-action: manipulation;
  7407. --background-color: #1f1f1f;
  7408. --text-color: #ebebeb;
  7409. --title-background-color: #111111;
  7410. --title-text-color: #ebebeb;
  7411. --widget-color: #424242;
  7412. --hover-color: #4f4f4f;
  7413. --focus-color: #595959;
  7414. --number-color: #2cc9ff;
  7415. --string-color: #a2db3c;
  7416. --font-size: 11px;
  7417. --input-font-size: 11px;
  7418. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7419. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7420. --padding: 4px;
  7421. --spacing: 4px;
  7422. --widget-height: 20px;
  7423. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7424. --name-width: 45%;
  7425. --slider-knob-width: 2px;
  7426. --slider-input-width: 27%;
  7427. --color-input-width: 27%;
  7428. --slider-input-min-width: 45px;
  7429. --color-input-min-width: 45px;
  7430. --folder-indent: 7px;
  7431. --widget-padding: 0 0 0 3px;
  7432. --widget-border-radius: 2px;
  7433. --checkbox-size: calc(0.75 * var(--widget-height));
  7434. --scrollbar-width: 5px;
  7435. }
  7436. .lil-gui, .lil-gui * {
  7437. box-sizing: border-box;
  7438. margin: 0;
  7439. padding: 0;
  7440. }
  7441. .lil-gui.root {
  7442. width: var(--width, 245px);
  7443. display: flex;
  7444. flex-direction: column;
  7445. background: var(--background-color);
  7446. }
  7447. .lil-gui.root > .title {
  7448. background: var(--title-background-color);
  7449. color: var(--title-text-color);
  7450. }
  7451. .lil-gui.root > .children {
  7452. overflow-x: hidden;
  7453. overflow-y: auto;
  7454. }
  7455. .lil-gui.root > .children::-webkit-scrollbar {
  7456. width: var(--scrollbar-width);
  7457. height: var(--scrollbar-width);
  7458. background: var(--background-color);
  7459. }
  7460. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7461. border-radius: var(--scrollbar-width);
  7462. background: var(--focus-color);
  7463. }
  7464. @media (pointer: coarse) {
  7465. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7466. --widget-height: 28px;
  7467. --padding: 6px;
  7468. --spacing: 6px;
  7469. --font-size: 13px;
  7470. --input-font-size: 16px;
  7471. --folder-indent: 10px;
  7472. --scrollbar-width: 7px;
  7473. --slider-input-min-width: 50px;
  7474. --color-input-min-width: 65px;
  7475. }
  7476. }
  7477. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7478. --widget-height: 28px;
  7479. --padding: 6px;
  7480. --spacing: 6px;
  7481. --font-size: 13px;
  7482. --input-font-size: 16px;
  7483. --folder-indent: 10px;
  7484. --scrollbar-width: 7px;
  7485. --slider-input-min-width: 50px;
  7486. --color-input-min-width: 65px;
  7487. }
  7488. .lil-gui.autoPlace {
  7489. max-height: 100%;
  7490. position: fixed;
  7491. top: 0;
  7492. right: 15px;
  7493. z-index: 1001;
  7494. }
  7495. .lil-gui .controller {
  7496. display: flex;
  7497. align-items: center;
  7498. padding: 0 var(--padding);
  7499. margin: var(--spacing) 0;
  7500. }
  7501. .lil-gui .controller.disabled {
  7502. opacity: 0.5;
  7503. }
  7504. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7505. pointer-events: none !important;
  7506. }
  7507. .lil-gui .controller > .name {
  7508. min-width: var(--name-width);
  7509. flex-shrink: 0;
  7510. white-space: pre;
  7511. padding-right: var(--spacing);
  7512. line-height: var(--widget-height);
  7513. }
  7514. .lil-gui .controller .widget {
  7515. position: relative;
  7516. display: flex;
  7517. align-items: center;
  7518. width: 100%;
  7519. min-height: var(--widget-height);
  7520. }
  7521. .lil-gui .controller.string input {
  7522. color: var(--string-color);
  7523. }
  7524. .lil-gui .controller.boolean {
  7525. cursor: pointer;
  7526. }
  7527. .lil-gui .controller.color .display {
  7528. width: 100%;
  7529. height: var(--widget-height);
  7530. border-radius: var(--widget-border-radius);
  7531. position: relative;
  7532. }
  7533. @media (hover: hover) {
  7534. .lil-gui .controller.color .display:hover:before {
  7535. content: " ";
  7536. display: block;
  7537. position: absolute;
  7538. border-radius: var(--widget-border-radius);
  7539. border: 1px solid #fff9;
  7540. top: 0;
  7541. right: 0;
  7542. bottom: 0;
  7543. left: 0;
  7544. }
  7545. }
  7546. .lil-gui .controller.color input[type=color] {
  7547. opacity: 0;
  7548. width: 100%;
  7549. height: 100%;
  7550. cursor: pointer;
  7551. }
  7552. .lil-gui .controller.color input[type=text] {
  7553. margin-left: var(--spacing);
  7554. font-family: var(--font-family-mono);
  7555. min-width: var(--color-input-min-width);
  7556. width: var(--color-input-width);
  7557. flex-shrink: 0;
  7558. }
  7559. .lil-gui .controller.option select {
  7560. opacity: 0;
  7561. position: absolute;
  7562. width: 100%;
  7563. max-width: 100%;
  7564. }
  7565. .lil-gui .controller.option .display {
  7566. position: relative;
  7567. pointer-events: none;
  7568. border-radius: var(--widget-border-radius);
  7569. height: var(--widget-height);
  7570. line-height: var(--widget-height);
  7571. max-width: 100%;
  7572. overflow: hidden;
  7573. word-break: break-all;
  7574. padding-left: 0.55em;
  7575. padding-right: 1.75em;
  7576. background: var(--widget-color);
  7577. }
  7578. @media (hover: hover) {
  7579. .lil-gui .controller.option .display.focus {
  7580. background: var(--focus-color);
  7581. }
  7582. }
  7583. .lil-gui .controller.option .display.active {
  7584. background: var(--focus-color);
  7585. }
  7586. .lil-gui .controller.option .display:after {
  7587. font-family: "lil-gui";
  7588. content: "↕";
  7589. position: absolute;
  7590. top: 0;
  7591. right: 0;
  7592. bottom: 0;
  7593. padding-right: 0.375em;
  7594. }
  7595. .lil-gui .controller.option .widget,
  7596. .lil-gui .controller.option select {
  7597. cursor: pointer;
  7598. }
  7599. @media (hover: hover) {
  7600. .lil-gui .controller.option .widget:hover .display {
  7601. background: var(--hover-color);
  7602. }
  7603. }
  7604. .lil-gui .controller.number input {
  7605. color: var(--number-color);
  7606. }
  7607. .lil-gui .controller.number.hasSlider input {
  7608. margin-left: var(--spacing);
  7609. width: var(--slider-input-width);
  7610. min-width: var(--slider-input-min-width);
  7611. flex-shrink: 0;
  7612. }
  7613. .lil-gui .controller.number .slider {
  7614. width: 100%;
  7615. height: var(--widget-height);
  7616. background: var(--widget-color);
  7617. border-radius: var(--widget-border-radius);
  7618. padding-right: var(--slider-knob-width);
  7619. overflow: hidden;
  7620. cursor: ew-resize;
  7621. touch-action: pan-y;
  7622. }
  7623. @media (hover: hover) {
  7624. .lil-gui .controller.number .slider:hover {
  7625. background: var(--hover-color);
  7626. }
  7627. }
  7628. .lil-gui .controller.number .slider.active {
  7629. background: var(--focus-color);
  7630. }
  7631. .lil-gui .controller.number .slider.active .fill {
  7632. opacity: 0.95;
  7633. }
  7634. .lil-gui .controller.number .fill {
  7635. height: 100%;
  7636. border-right: var(--slider-knob-width) solid var(--number-color);
  7637. box-sizing: content-box;
  7638. }
  7639. .lil-gui-dragging .lil-gui {
  7640. --hover-color: var(--widget-color);
  7641. }
  7642. .lil-gui-dragging * {
  7643. cursor: ew-resize !important;
  7644. }
  7645. .lil-gui-dragging.lil-gui-vertical * {
  7646. cursor: ns-resize !important;
  7647. }
  7648. .lil-gui .title {
  7649. height: var(--title-height);
  7650. line-height: calc(var(--title-height) - 4px);
  7651. font-weight: 600;
  7652. padding: 0 var(--padding);
  7653. -webkit-tap-highlight-color: transparent;
  7654. cursor: pointer;
  7655. outline: none;
  7656. text-decoration-skip: objects;
  7657. }
  7658. .lil-gui .title:before {
  7659. font-family: "lil-gui";
  7660. content: "▾";
  7661. padding-right: 2px;
  7662. display: inline-block;
  7663. }
  7664. .lil-gui .title:active {
  7665. background: var(--title-background-color);
  7666. opacity: 0.75;
  7667. }
  7668. @media (hover: hover) {
  7669. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7670. background: var(--title-background-color);
  7671. opacity: 0.85;
  7672. }
  7673. .lil-gui .title:focus {
  7674. text-decoration: underline var(--focus-color);
  7675. }
  7676. }
  7677. .lil-gui.root > .title:focus {
  7678. text-decoration: none !important;
  7679. }
  7680. .lil-gui.closed > .title:before {
  7681. content: "▸";
  7682. }
  7683. .lil-gui.closed > .children {
  7684. transform: translateY(-7px);
  7685. opacity: 0;
  7686. }
  7687. .lil-gui.closed:not(.transition) > .children {
  7688. display: none;
  7689. }
  7690. .lil-gui.transition > .children {
  7691. transition-duration: 300ms;
  7692. transition-property: height, opacity, transform;
  7693. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7694. overflow: hidden;
  7695. pointer-events: none;
  7696. }
  7697. .lil-gui .children:empty:before {
  7698. content: "Empty";
  7699. padding: 0 var(--padding);
  7700. margin: var(--spacing) 0;
  7701. display: block;
  7702. height: var(--widget-height);
  7703. font-style: italic;
  7704. line-height: var(--widget-height);
  7705. opacity: 0.5;
  7706. }
  7707. .lil-gui.root > .children > .lil-gui > .title {
  7708. border: 0 solid var(--widget-color);
  7709. border-width: 1px 0;
  7710. transition: border-color 300ms;
  7711. }
  7712. .lil-gui.root > .children > .lil-gui.closed > .title {
  7713. border-bottom-color: transparent;
  7714. }
  7715. .lil-gui + .controller {
  7716. border-top: 1px solid var(--widget-color);
  7717. margin-top: 0;
  7718. padding-top: var(--spacing);
  7719. }
  7720. .lil-gui .lil-gui .lil-gui > .title {
  7721. border: none;
  7722. }
  7723. .lil-gui .lil-gui .lil-gui > .children {
  7724. border: none;
  7725. margin-left: var(--folder-indent);
  7726. border-left: 2px solid var(--widget-color);
  7727. }
  7728. .lil-gui .lil-gui .controller {
  7729. border: none;
  7730. }
  7731. .lil-gui label, .lil-gui input, .lil-gui button {
  7732. -webkit-tap-highlight-color: transparent;
  7733. }
  7734. .lil-gui input {
  7735. border: 0;
  7736. outline: none;
  7737. font-family: var(--font-family);
  7738. font-size: var(--input-font-size);
  7739. border-radius: var(--widget-border-radius);
  7740. height: var(--widget-height);
  7741. background: var(--widget-color);
  7742. color: var(--text-color);
  7743. width: 100%;
  7744. }
  7745. @media (hover: hover) {
  7746. .lil-gui input:hover {
  7747. background: var(--hover-color);
  7748. }
  7749. .lil-gui input:active {
  7750. background: var(--focus-color);
  7751. }
  7752. }
  7753. .lil-gui input:disabled {
  7754. opacity: 1;
  7755. }
  7756. .lil-gui input[type=text],
  7757. .lil-gui input[type=number] {
  7758. padding: var(--widget-padding);
  7759. -moz-appearance: textfield;
  7760. }
  7761. .lil-gui input[type=text]:focus,
  7762. .lil-gui input[type=number]:focus {
  7763. background: var(--focus-color);
  7764. }
  7765. .lil-gui input[type=checkbox] {
  7766. appearance: none;
  7767. width: var(--checkbox-size);
  7768. height: var(--checkbox-size);
  7769. border-radius: var(--widget-border-radius);
  7770. text-align: center;
  7771. cursor: pointer;
  7772. }
  7773. .lil-gui input[type=checkbox]:checked:before {
  7774. font-family: "lil-gui";
  7775. content: "✓";
  7776. font-size: var(--checkbox-size);
  7777. line-height: var(--checkbox-size);
  7778. }
  7779. @media (hover: hover) {
  7780. .lil-gui input[type=checkbox]:focus {
  7781. box-shadow: inset 0 0 0 1px var(--focus-color);
  7782. }
  7783. }
  7784. .lil-gui button {
  7785. outline: none;
  7786. cursor: pointer;
  7787. font-family: var(--font-family);
  7788. font-size: var(--font-size);
  7789. color: var(--text-color);
  7790. width: 100%;
  7791. height: var(--widget-height);
  7792. text-transform: none;
  7793. background: var(--widget-color);
  7794. border-radius: var(--widget-border-radius);
  7795. border: none;
  7796. }
  7797. @media (hover: hover) {
  7798. .lil-gui button:hover {
  7799. background: var(--hover-color);
  7800. }
  7801. .lil-gui button:focus {
  7802. box-shadow: inset 0 0 0 1px var(--focus-color);
  7803. }
  7804. }
  7805. .lil-gui button:active {
  7806. background: var(--focus-color);
  7807. }
  7808. @font-face {
  7809. font-family: "lil-gui";
  7810. 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");
  7811. }`;function xMe(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 u$=!1;class k1{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:s="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(s),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"),!u$&&l&&(xMe(bMe),u$=!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,s){if(Object(r)===r)return new pMe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new mMe(this,e,n,r,i,s);case"boolean":return new oMe(this,e,n);case"string":return new gMe(this,e,n);case"function":return new zA(this,e,n)}console.error(`gui.add failed
  7812. property:`,n,`
  7813. object:`,e,`
  7814. value:`,o)}addColor(e,n,r=1){return new fMe(this,e,n,r)}addFolder(e){const n=new k1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof zA||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 zA)){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=s=>{s.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 UA(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(h){h(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class B4{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 B4(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 $4{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class d$ extends $4{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Qd extends $4{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class h${constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class M1{constructor(e){this.lines=[],this.preamble=new h$(-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(`
  7815. `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((s=>s.comment))).thumbnails;for(const[s,o]of Object.entries(i))this.metadata.thumbnails[s]=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(";"),s=i[0],o=n&&i[1]||void 0,l=s.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 d$(e,c,u,o);case"t0":return new Qd(e,c,o,0);case"t1":return new Qd(e,c,o,1);case"t2":return new Qd(e,c,o,2);case"t3":return new Qd(e,c,o,3);case"t4":return new Qd(e,c,o,4);case"t5":return new Qd(e,c,o,5);case"t6":return new Qd(e,c,o,6);case"t7":return new Qd(e,c,o,7);default:return new $4(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,s)=>{if(i%2==0)return n;let o=s[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 d$){const s=i.params;if(s.z&&(this.curZ=s.z),((n=s.e)!==null&&n!==void 0?n:0)>0&&(s.x!=null||s.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 h$(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 s=i.comment;if(!s)continue;const o=s.indexOf("thumbnail begin"),l=s.indexOf("thumbnail end");o>-1?r=B4.parse(s.slice(o+15).trim()):r&&(l==-1?r.chars+=s.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}M1.prototype.parseGcode=M1.prototype.parseGCode;const f$={type:"change"},BA={type:"start"},m$={type:"end"},W_=new O4,p$=new rh,yMe=Math.cos(70*mX.DEG2RAD);class vMe extends Wm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new We,this.cursor=new We,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:Vp.ROTATE,MIDDLE:Vp.DOLLY,RIGHT:Vp.PAN},this.touches={ONE:Gp.ROTATE,TWO:Gp.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(Y){Y.addEventListener("keydown",Ae),this._domElementKeyEvents=Y},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ae),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(f$),r.update(),s=i.NONE},this.update=(function(){const Y=new We,ue=new jm().setFromUnitVectors(e.up,new We(0,1,0)),B=ue.clone().invert(),ee=new We,Q=new jm,le=new We,he=2*Math.PI;return function(te=null){const U=r.object.position;Y.copy(U).sub(r.target),Y.applyQuaternion(ue),l.setFromVector3(Y),r.autoRotate&&s===i.NONE&&j((function(_e){return _e!==null?2*Math.PI/60*r.autoRotateSpeed*_e:2*Math.PI/60/60*r.autoRotateSpeed})(te)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let L=r.minAzimuthAngle,X=r.maxAzimuthAngle;isFinite(L)&&isFinite(X)&&(L<-Math.PI?L+=he:L>Math.PI&&(L-=he),X<-Math.PI?X+=he:X>Math.PI&&(X-=he),l.theta=L<=X?Math.max(L,Math.min(X,l.theta)):l.theta>(L+X)/2?Math.max(L,l.theta):Math.min(X,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&&A||r.object.isOrthographicCamera?l.radius=K(l.radius):l.radius=K(l.radius*u),Y.setFromSpherical(l),Y.applyQuaternion(B),U.copy(r.target).add(Y),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let ge=!1;if(r.zoomToCursor&&A){let _e=null;if(r.object.isPerspectiveCamera){const Ee=Y.length();_e=K(Ee*u);const $e=Ee-_e;r.object.position.addScaledVector(E,$e),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const Ee=new We(N.x,N.y,0);Ee.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ge=!0;const $e=new We(N.x,N.y,0);$e.unproject(r.object),r.object.position.sub($e).add(Ee),r.object.updateMatrixWorld(),_e=Y.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;_e!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(_e).add(r.object.position):(W_.origin.copy(r.object.position),W_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(W_.direction))<yMe?e.lookAt(r.target):(p$.setFromNormalAndCoplanarPoint(r.object.up,r.target),W_.intersectPlane(p$,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ge=!0);return u=1,A=!1,!!(ge||ee.distanceToSquared(r.object.position)>o||8*(1-Q.dot(r.object.quaternion))>o||le.distanceToSquared(r.target)>0)&&(r.dispatchEvent(f$),ee.copy(r.object.position),Q.copy(r.object.quaternion),le.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",re),r.domElement.removeEventListener("pointerdown",ve),r.domElement.removeEventListener("pointercancel",de),r.domElement.removeEventListener("wheel",ce),r.domElement.removeEventListener("pointermove",Le),r.domElement.removeEventListener("pointerup",de),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Ae),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 s=i.NONE;const o=1e-6,l=new l$,c=new l$;let u=1;const d=new We,h=new Sn,p=new Sn,m=new Sn,x=new Sn,y=new Sn,b=new Sn,v=new Sn,S=new Sn,k=new Sn,E=new We,N=new Sn;let A=!1;const M=[],P={};function T(){return Math.pow(.95,r.zoomSpeed)}function j(Y){c.theta-=Y}function z(Y){c.phi-=Y}const F=(function(){const Y=new We;return function(ue,B){Y.setFromMatrixColumn(B,0),Y.multiplyScalar(-ue),d.add(Y)}})(),$=(function(){const Y=new We;return function(ue,B){r.screenSpacePanning===!0?Y.setFromMatrixColumn(B,1):(Y.setFromMatrixColumn(B,0),Y.crossVectors(r.object.up,Y)),Y.multiplyScalar(ue),d.add(Y)}})(),D=(function(){const Y=new We;return function(ue,B){const ee=r.domElement;if(r.object.isPerspectiveCamera){const Q=r.object.position;Y.copy(Q).sub(r.target);let le=Y.length();le*=Math.tan(r.object.fov/2*Math.PI/180),F(2*ue*le/ee.clientHeight,r.object.matrix),$(2*B*le/ee.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(F(ue*(r.object.right-r.object.left)/r.object.zoom/ee.clientWidth,r.object.matrix),$(B*(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 H(Y){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function q(Y){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function I(Y){if(!r.zoomToCursor)return;A=!0;const ue=r.domElement.getBoundingClientRect(),B=Y.clientX-ue.left,ee=Y.clientY-ue.top,Q=ue.width,le=ue.height;N.x=B/Q*2-1,N.y=-ee/le*2+1,E.set(N.x,N.y,1).unproject(r.object).sub(r.object.position).normalize()}function K(Y){return Math.max(r.minDistance,Math.min(r.maxDistance,Y))}function Z(Y){h.set(Y.clientX,Y.clientY)}function se(Y){x.set(Y.clientX,Y.clientY)}function V(){if(M.length===1)h.set(M[0].pageX,M[0].pageY);else{const Y=.5*(M[0].pageX+M[1].pageX),ue=.5*(M[0].pageY+M[1].pageY);h.set(Y,ue)}}function W(){if(M.length===1)x.set(M[0].pageX,M[0].pageY);else{const Y=.5*(M[0].pageX+M[1].pageX),ue=.5*(M[0].pageY+M[1].pageY);x.set(Y,ue)}}function ie(){const Y=M[0].pageX-M[1].pageX,ue=M[0].pageY-M[1].pageY,B=Math.sqrt(Y*Y+ue*ue);v.set(0,B)}function J(Y){if(M.length==1)p.set(Y.pageX,Y.pageY);else{const B=G(Y),ee=.5*(Y.pageX+B.x),Q=.5*(Y.pageY+B.y);p.set(ee,Q)}m.subVectors(p,h).multiplyScalar(r.rotateSpeed);const ue=r.domElement;j(2*Math.PI*m.x/ue.clientHeight),z(2*Math.PI*m.y/ue.clientHeight),h.copy(p)}function pe(Y){if(M.length===1)y.set(Y.pageX,Y.pageY);else{const ue=G(Y),B=.5*(Y.pageX+ue.x),ee=.5*(Y.pageY+ue.y);y.set(B,ee)}b.subVectors(y,x).multiplyScalar(r.panSpeed),D(b.x,b.y),x.copy(y)}function fe(Y){const ue=G(Y),B=Y.pageX-ue.x,ee=Y.pageY-ue.y,Q=Math.sqrt(B*B+ee*ee);S.set(0,Q),k.set(0,Math.pow(S.y/v.y,r.zoomSpeed)),H(k.y),v.copy(S)}function ve(Y){r.enabled!==!1&&(M.length===0&&(r.domElement.setPointerCapture(Y.pointerId),r.domElement.addEventListener("pointermove",Le),r.domElement.addEventListener("pointerup",de)),(function(ue){M.push(ue)})(Y),Y.pointerType==="touch"?(function(ue){switch(Ie(ue),M.length){case 1:switch(r.touches.ONE){case Gp.ROTATE:if(r.enableRotate===!1)return;V(),s=i.TOUCH_ROTATE;break;case Gp.PAN:if(r.enablePan===!1)return;W(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case Gp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ie(),r.enablePan&&W(),s=i.TOUCH_DOLLY_PAN;break;case Gp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ie(),r.enableRotate&&V(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(BA)})(Y):(function(ue){let B;switch(ue.button){case 0:B=r.mouseButtons.LEFT;break;case 1:B=r.mouseButtons.MIDDLE;break;case 2:B=r.mouseButtons.RIGHT;break;default:B=-1}switch(B){case Vp.DOLLY:if(r.enableZoom===!1)return;(function(ee){I(ee),v.set(ee.clientX,ee.clientY)})(ue),s=i.DOLLY;break;case Vp.ROTATE:if(ue.ctrlKey||ue.metaKey||ue.shiftKey){if(r.enablePan===!1)return;se(ue),s=i.PAN}else{if(r.enableRotate===!1)return;Z(ue),s=i.ROTATE}break;case Vp.PAN:if(ue.ctrlKey||ue.metaKey||ue.shiftKey){if(r.enableRotate===!1)return;Z(ue),s=i.ROTATE}else{if(r.enablePan===!1)return;se(ue),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(BA)})(Y))}function Le(Y){r.enabled!==!1&&(Y.pointerType==="touch"?(function(ue){switch(Ie(ue),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;J(ue),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;pe(ue),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(B){r.enableZoom&&fe(B),r.enablePan&&pe(B)})(ue),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(B){r.enableZoom&&fe(B),r.enableRotate&&J(B)})(ue),r.update();break;default:s=i.NONE}})(Y):(function(ue){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(B){p.set(B.clientX,B.clientY),m.subVectors(p,h).multiplyScalar(r.rotateSpeed);const ee=r.domElement;j(2*Math.PI*m.x/ee.clientHeight),z(2*Math.PI*m.y/ee.clientHeight),h.copy(p),r.update()})(ue);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(B){S.set(B.clientX,B.clientY),k.subVectors(S,v),k.y>0?H(T()):k.y<0&&q(T()),v.copy(S),r.update()})(ue);break;case i.PAN:if(r.enablePan===!1)return;(function(B){y.set(B.clientX,B.clientY),b.subVectors(y,x).multiplyScalar(r.panSpeed),D(b.x,b.y),x.copy(y),r.update()})(ue)}})(Y))}function de(Y){(function(ue){delete P[ue.pointerId];for(let B=0;B<M.length;B++)if(M[B].pointerId==ue.pointerId)return void M.splice(B,1)})(Y),M.length===0&&(r.domElement.releasePointerCapture(Y.pointerId),r.domElement.removeEventListener("pointermove",Le),r.domElement.removeEventListener("pointerup",de)),r.dispatchEvent(m$),s=i.NONE}function ce(Y){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(Y.preventDefault(),r.dispatchEvent(BA),(function(ue){I(ue),ue.deltaY<0?q(T()):ue.deltaY>0&&H(T()),r.update()})(Y),r.dispatchEvent(m$))}function Ae(Y){r.enabled!==!1&&r.enablePan!==!1&&(function(ue){let B=!1;switch(ue.code){case r.keys.UP:ue.ctrlKey||ue.metaKey||ue.shiftKey?z(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,r.keyPanSpeed),B=!0;break;case r.keys.BOTTOM:ue.ctrlKey||ue.metaKey||ue.shiftKey?z(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,-r.keyPanSpeed),B=!0;break;case r.keys.LEFT:ue.ctrlKey||ue.metaKey||ue.shiftKey?j(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(r.keyPanSpeed,0),B=!0;break;case r.keys.RIGHT:ue.ctrlKey||ue.metaKey||ue.shiftKey?j(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(-r.keyPanSpeed,0),B=!0}B&&(ue.preventDefault(),r.update())})(Y)}function re(Y){r.enabled!==!1&&Y.preventDefault()}function Ie(Y){let ue=P[Y.pointerId];ue===void 0&&(ue=new Sn,P[Y.pointerId]=ue),ue.set(Y.pageX,Y.pageY)}function G(Y){const ue=Y.pointerId===M[0].pointerId?M[1]:M[0];return P[ue.pointerId]}r.domElement.addEventListener("contextmenu",re),r.domElement.addEventListener("pointerdown",ve),r.domElement.addEventListener("pointercancel",de),r.domElement.addEventListener("wheel",ce,{passive:!1}),this.update()}}Ot.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Sn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Ws.line={uniforms:F4.merge([Ot.common,Ot.fog,Ot.line]),vertexShader:`
  7816. #include <common>
  7817. #include <color_pars_vertex>
  7818. #include <fog_pars_vertex>
  7819. #include <logdepthbuf_pars_vertex>
  7820. #include <clipping_planes_pars_vertex>
  7821. uniform float linewidth;
  7822. uniform vec2 resolution;
  7823. attribute vec3 instanceStart;
  7824. attribute vec3 instanceEnd;
  7825. attribute vec3 instanceColorStart;
  7826. attribute vec3 instanceColorEnd;
  7827. #ifdef WORLD_UNITS
  7828. varying vec4 worldPos;
  7829. varying vec3 worldStart;
  7830. varying vec3 worldEnd;
  7831. #ifdef USE_DASH
  7832. varying vec2 vUv;
  7833. #endif
  7834. #else
  7835. varying vec2 vUv;
  7836. #endif
  7837. #ifdef USE_DASH
  7838. uniform float dashScale;
  7839. attribute float instanceDistanceStart;
  7840. attribute float instanceDistanceEnd;
  7841. varying float vLineDistance;
  7842. #endif
  7843. void trimSegment( const in vec4 start, inout vec4 end ) {
  7844. // trim end segment so it terminates between the camera plane and the near plane
  7845. // conservative estimate of the near plane
  7846. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7847. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7848. float nearEstimate = - 0.5 * b / a;
  7849. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7850. end.xyz = mix( start.xyz, end.xyz, alpha );
  7851. }
  7852. void main() {
  7853. #ifdef USE_COLOR
  7854. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7855. #endif
  7856. #ifdef USE_DASH
  7857. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7858. vUv = uv;
  7859. #endif
  7860. float aspect = resolution.x / resolution.y;
  7861. // camera space
  7862. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7863. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7864. #ifdef WORLD_UNITS
  7865. worldStart = start.xyz;
  7866. worldEnd = end.xyz;
  7867. #else
  7868. vUv = uv;
  7869. #endif
  7870. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7871. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7872. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7873. // perhaps there is a more elegant solution -- WestLangley
  7874. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7875. if ( perspective ) {
  7876. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7877. trimSegment( start, end );
  7878. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7879. trimSegment( end, start );
  7880. }
  7881. }
  7882. // clip space
  7883. vec4 clipStart = projectionMatrix * start;
  7884. vec4 clipEnd = projectionMatrix * end;
  7885. // ndc space
  7886. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7887. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7888. // direction
  7889. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7890. // account for clip-space aspect ratio
  7891. dir.x *= aspect;
  7892. dir = normalize( dir );
  7893. #ifdef WORLD_UNITS
  7894. // get the offset direction as perpendicular to the view vector
  7895. vec3 worldDir = normalize( end.xyz - start.xyz );
  7896. vec3 offset;
  7897. if ( position.y < 0.5 ) {
  7898. offset = normalize( cross( start.xyz, worldDir ) );
  7899. } else {
  7900. offset = normalize( cross( end.xyz, worldDir ) );
  7901. }
  7902. // sign flip
  7903. if ( position.x < 0.0 ) offset *= - 1.0;
  7904. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7905. // don't extend the line if we're rendering dashes because we
  7906. // won't be rendering the endcaps
  7907. #ifndef USE_DASH
  7908. // extend the line bounds to encompass endcaps
  7909. start.xyz += - worldDir * linewidth * 0.5;
  7910. end.xyz += worldDir * linewidth * 0.5;
  7911. // shift the position of the quad so it hugs the forward edge of the line
  7912. offset.xy -= dir * forwardOffset;
  7913. offset.z += 0.5;
  7914. #endif
  7915. // endcaps
  7916. if ( position.y > 1.0 || position.y < 0.0 ) {
  7917. offset.xy += dir * 2.0 * forwardOffset;
  7918. }
  7919. // adjust for linewidth
  7920. offset *= linewidth * 0.5;
  7921. // set the world position
  7922. worldPos = ( position.y < 0.5 ) ? start : end;
  7923. worldPos.xyz += offset;
  7924. // project the worldpos
  7925. vec4 clip = projectionMatrix * worldPos;
  7926. // shift the depth of the projected points so the line
  7927. // segments overlap neatly
  7928. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  7929. clip.z = clipPose.z * clip.w;
  7930. #else
  7931. vec2 offset = vec2( dir.y, - dir.x );
  7932. // undo aspect ratio adjustment
  7933. dir.x /= aspect;
  7934. offset.x /= aspect;
  7935. // sign flip
  7936. if ( position.x < 0.0 ) offset *= - 1.0;
  7937. // endcaps
  7938. if ( position.y < 0.0 ) {
  7939. offset += - dir;
  7940. } else if ( position.y > 1.0 ) {
  7941. offset += dir;
  7942. }
  7943. // adjust for linewidth
  7944. offset *= linewidth;
  7945. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  7946. offset /= resolution.y;
  7947. // select end
  7948. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  7949. // back to clip space
  7950. offset *= clip.w;
  7951. clip.xy += offset;
  7952. #endif
  7953. gl_Position = clip;
  7954. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  7955. #include <logdepthbuf_vertex>
  7956. #include <clipping_planes_vertex>
  7957. #include <fog_vertex>
  7958. }
  7959. `,fragmentShader:`
  7960. uniform vec3 diffuse;
  7961. uniform float opacity;
  7962. uniform float linewidth;
  7963. #ifdef USE_DASH
  7964. uniform float dashOffset;
  7965. uniform float dashSize;
  7966. uniform float gapSize;
  7967. #endif
  7968. varying float vLineDistance;
  7969. #ifdef WORLD_UNITS
  7970. varying vec4 worldPos;
  7971. varying vec3 worldStart;
  7972. varying vec3 worldEnd;
  7973. #ifdef USE_DASH
  7974. varying vec2 vUv;
  7975. #endif
  7976. #else
  7977. varying vec2 vUv;
  7978. #endif
  7979. #include <common>
  7980. #include <color_pars_fragment>
  7981. #include <fog_pars_fragment>
  7982. #include <logdepthbuf_pars_fragment>
  7983. #include <clipping_planes_pars_fragment>
  7984. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  7985. float mua;
  7986. float mub;
  7987. vec3 p13 = p1 - p3;
  7988. vec3 p43 = p4 - p3;
  7989. vec3 p21 = p2 - p1;
  7990. float d1343 = dot( p13, p43 );
  7991. float d4321 = dot( p43, p21 );
  7992. float d1321 = dot( p13, p21 );
  7993. float d4343 = dot( p43, p43 );
  7994. float d2121 = dot( p21, p21 );
  7995. float denom = d2121 * d4343 - d4321 * d4321;
  7996. float numer = d1343 * d4321 - d1321 * d4343;
  7997. mua = numer / denom;
  7998. mua = clamp( mua, 0.0, 1.0 );
  7999. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8000. mub = clamp( mub, 0.0, 1.0 );
  8001. return vec2( mua, mub );
  8002. }
  8003. void main() {
  8004. #include <clipping_planes_fragment>
  8005. #ifdef USE_DASH
  8006. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8007. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8008. #endif
  8009. float alpha = opacity;
  8010. #ifdef WORLD_UNITS
  8011. // Find the closest points on the view ray and the line segment
  8012. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8013. vec3 lineDir = worldEnd - worldStart;
  8014. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8015. vec3 p1 = worldStart + lineDir * params.x;
  8016. vec3 p2 = rayEnd * params.y;
  8017. vec3 delta = p1 - p2;
  8018. float len = length( delta );
  8019. float norm = len / linewidth;
  8020. #ifndef USE_DASH
  8021. #ifdef USE_ALPHA_TO_COVERAGE
  8022. float dnorm = fwidth( norm );
  8023. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8024. #else
  8025. if ( norm > 0.5 ) {
  8026. discard;
  8027. }
  8028. #endif
  8029. #endif
  8030. #else
  8031. #ifdef USE_ALPHA_TO_COVERAGE
  8032. // artifacts appear on some hardware if a derivative is taken within a conditional
  8033. float a = vUv.x;
  8034. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8035. float len2 = a * a + b * b;
  8036. float dlen = fwidth( len2 );
  8037. if ( abs( vUv.y ) > 1.0 ) {
  8038. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8039. }
  8040. #else
  8041. if ( abs( vUv.y ) > 1.0 ) {
  8042. float a = vUv.x;
  8043. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8044. float len2 = a * a + b * b;
  8045. if ( len2 > 1.0 ) discard;
  8046. }
  8047. #endif
  8048. #endif
  8049. vec4 diffuseColor = vec4( diffuse, alpha );
  8050. #include <logdepthbuf_fragment>
  8051. #include <color_fragment>
  8052. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8053. #include <tonemapping_fragment>
  8054. #include <colorspace_fragment>
  8055. #include <fog_fragment>
  8056. #include <premultiplied_alpha_fragment>
  8057. }
  8058. `};class LX extends $h{constructor(e){super({type:"LineMaterial",uniforms:F4.clone(Ws.line.uniforms),vertexShader:Ws.line.vertexShader,fragmentShader:Ws.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 g$=new hl,K_=new We;class OX extends iMe{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 Bi([-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 Bi([-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 K3(n,6,1);return this.setAttribute("instanceStart",new bh(r,3,0)),this.setAttribute("instanceEnd",new bh(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 K3(n,6,1);return this.setAttribute("instanceColorStart",new bh(r,3,0)),this.setAttribute("instanceColorEnd",new bh(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 Qke(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new hl);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),g$.setFromBufferAttribute(n),this.boundingBox.union(g$))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Mc),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 s=0,o=e.count;s<o;s++)K_.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(K_)),K_.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(K_));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 b$=new We,x$=new We,Ha=new Dr,Va=new Dr,uc=new Dr,$A=new We,HA=new Xr,Ga=new aMe,y$=new We,X_=new hl,Y_=new Mc,dc=new Dr;let hc,qf;function v$(t,e,n){return dc.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),dc.multiplyScalar(1/dc.w),dc.x=qf/n.width,dc.y=qf/n.height,dc.applyMatrix4(t.projectionMatrixInverse),dc.multiplyScalar(1/dc.w),Math.abs(Math.max(dc.x,dc.y))}class wMe extends Gl{constructor(e=new OX,n=new LX({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)b$.fromBufferAttribute(n,o),x$.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+b$.distanceTo(x$);const s=new K3(i,2,1);return e.setAttribute("instanceDistanceStart",new bh(s,1,0)),e.setAttribute("instanceDistanceEnd",new bh(s,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 s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;hc=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;qf=c.linewidth+s,l.boundingSphere===null&&l.computeBoundingSphere(),Y_.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*qf:u=v$(i,Math.max(i.near,Y_.distanceToPoint(hc.origin)),c.resolution),Y_.radius+=u,hc.intersectsSphere(Y_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),X_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*qf:d=v$(i,Math.max(i.near,X_.distanceToPoint(hc.origin)),c.resolution),X_.expandByScalar(d),hc.intersectsBox(X_)!==!1&&(r?(function(h,p){const m=h.matrixWorld,x=h.geometry,y=x.attributes.instanceStart,b=x.attributes.instanceEnd;for(let v=0,S=Math.min(x.instanceCount,y.count);v<S;v++){Ga.start.fromBufferAttribute(y,v),Ga.end.fromBufferAttribute(b,v),Ga.applyMatrix4(m);const k=new We,E=new We;hc.distanceSqToSegment(Ga.start,Ga.end,E,k),E.distanceTo(k)<.5*qf&&p.push({point:E,pointOnLine:k,distance:hc.origin.distanceTo(E),object:h,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(h,p,m){const x=p.projectionMatrix,y=h.material.resolution,b=h.matrixWorld,v=h.geometry,S=v.attributes.instanceStart,k=v.attributes.instanceEnd,E=Math.min(v.instanceCount,S.count),N=-p.near;hc.at(1,uc),uc.w=1,uc.applyMatrix4(p.matrixWorldInverse),uc.applyMatrix4(x),uc.multiplyScalar(1/uc.w),uc.x*=y.x/2,uc.y*=y.y/2,uc.z=0,$A.copy(uc),HA.multiplyMatrices(p.matrixWorldInverse,b);for(let A=0,M=E;A<M;A++){if(Ha.fromBufferAttribute(S,A),Va.fromBufferAttribute(k,A),Ha.w=1,Va.w=1,Ha.applyMatrix4(HA),Va.applyMatrix4(HA),Ha.z>N&&Va.z>N)continue;if(Ha.z>N){const F=Ha.z-Va.z,$=(Ha.z-N)/F;Ha.lerp(Va,$)}else if(Va.z>N){const F=Va.z-Ha.z,$=(Va.z-N)/F;Va.lerp(Ha,$)}Ha.applyMatrix4(x),Va.applyMatrix4(x),Ha.multiplyScalar(1/Ha.w),Va.multiplyScalar(1/Va.w),Ha.x*=y.x/2,Ha.y*=y.y/2,Va.x*=y.x/2,Va.y*=y.y/2,Ga.start.copy(Ha),Ga.start.z=0,Ga.end.copy(Va),Ga.end.z=0;const P=Ga.closestPointToPointParameter($A,!0);Ga.at(P,y$);const T=mX.lerp(Ha.z,Va.z,P),j=T>=-1&&T<=1,z=$A.distanceTo(y$)<.5*qf;if(j&&z){Ga.start.fromBufferAttribute(S,A),Ga.end.fromBufferAttribute(k,A),Ga.start.applyMatrix4(b),Ga.end.applyMatrix4(b);const F=new We,$=new We;hc.distanceSqToSegment(Ga.start,Ga.end,$,F),m.push({point:$,pointOnLine:F,distance:hc.origin.distanceTo($),object:h,face:null,faceIndex:A,uv:null,uv1:null})}}})(this,i,n)))}}class _Me extends Xk{constructor(e,n,r,i,s=4473924,o=8947848){s=new cn(s),o=new cn(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let p=-1*(e=l*n/2);p<=e;p+=n){c.push(p,0,-1*r,p,0,r);const m=p===0?s:o;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}for(let p=-1*r;p<=r;p+=i){c.push(-1*e,0,p,e,0,p);const m=p===0?s:o;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}const h=new bs;h.setAttribute("position",new Bi(c,3)),h.setAttribute("color",new Bi(u,3)),super(h,new J0({vertexColors:!0,toneMapped:!1}))}}function SMe(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new bs,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 Bi(d,3)),u})(t,e,n),s=new Xk(i,new Jke({color:new cn(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var Ry=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===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(),s=i,o=0,l=n(new Ry.Panel("FPS","#0ff","#002")),c=n(new Ry.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Ry.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>=s+1e3&&(l.update(1e3*o/(d-s),100),s=d,o=0,u)){var h=performance.memory;u.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};Ry.Panel=function(t,e,n){var r=1/0,i=0,s=Math.round,o=s(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,h=3*o,p=15*o,m=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(h,p,m,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(h,p,m,x),{dom:y,update:function(v,S){r=Math.min(r,v),i=Math.max(i,v),b.fillStyle=n,b.globalAlpha=1,b.fillRect(0,0,l,p),b.fillStyle=e,b.fillText(s(v)+" "+t+" ("+s(r)+"-"+s(i)+")",u,d),b.drawImage(y,h+o,p,m-o,x,h,p,m-o,x),b.fillRect(h+m-o,p,o,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(h+m-o,p,o,s((1-v/S)*x))}}};var NMe=Ry;class w${constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new k1,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 k1,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 kMe extends bs{constructor(e=[new We],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const s=new We,o=new We,l=new Sn,c=[],u=[],d=[],h=[];function p(m){const[x,y,b]=(function(v){const S=e[v],k=new We,E=new We,N=new We,A=new We;k.copy(S).sub(e[v-1]||S).normalize().add((e[v+1]||S).clone().sub(S).normalize()).normalize();let M=Number.MAX_VALUE;const P=Math.abs(k.x),T=Math.abs(k.y),j=Math.abs(k.z);return P<=M&&(M=P,E.set(1,0,0)),T<=M&&(M=T,E.set(0,1,0)),j<=M&&E.set(0,0,1),A.crossVectors(k,E).normalize(),E.crossVectors(k,A),N.crossVectors(k,E),[S,E,N]})(m);for(let v=0;v<=i;v++){const S=v/i*Math.PI*2,k=Math.sin(S),E=-Math.cos(S);o.x=E*y.x+k*b.x,o.y=E*y.y+k*b.y,o.z=E*y.z+k*b.z,o.normalize(),u.push(o.x,o.y,o.z),s.x=x.x+n*o.x*.5,s.y=x.y+n*o.y*.5,s.z=x.z+r*o.z*.5,c.push(s.x,s.y,s.z)}}(function(){for(let m=0;m<e.length;m++)p(m);p(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let x=0;x<=i;x++)l.x=m/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let m=1;m<e.length;m++)for(let x=1;x<=i;x++){const y=(i+1)*(m-1)+(x-1),b=(i+1)*m+(x-1),v=(i+1)*m+x,S=(i+1)*(m-1)+x;h.push(y,b,S),h.push(b,v,S)}})()})(),this.setIndex(h),this.setAttribute("position",new Bi(c,3)),this.setAttribute("normal",new Bi(u,3)),this.setAttribute("uv",new Bi(d,2))}}class Ly{static get initial(){const e=new Ly;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const VA={h:0,s:0,l:0};class $g{constructor(e){var n,r,i,s,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=Ly.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=$g.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new cn(14737632),this._travelColor=new cn(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 M1(this.minLayerThreshold),this.scene=new Bke,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new cn(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=(s=e.renderExtrusion)!==null&&s!==void 0?s: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 NMe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new cn(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new cn(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new cn(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,x]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new cn(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+Vk),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 W3({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new W3({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new wo(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const h=this.camera.far,p=.8*h;this.scene.fog=new U4(this._backgroundColor,p,h),this.resize(),this.controls=new vMe(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 cn(r)}else this._extrusionColor=new cn(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?$g.defaultExtrusionColor:this._extrusionColor instanceof cn?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:$g.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new cn(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new cn(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new cn(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new cn(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 sMe(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 rMe(13421772,.3*Math.PI),n=new nMe(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 xy;return n.name=e,n.quaternion.setFromEuler(new Q0(-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=Ly.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 UA(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,s,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],h={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const p of d.commands)if(p.gcode!="g20"){if(p.gcode.startsWith("t")){this.doRenderExtrusion(h,e),h.extrusion=[];const m=p;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(p.gcode)>-1){const m=p,x={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(s=m.params.r)!==null&&s!==void 0?s:this.state.r,e:(o=m.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=m.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=m.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=m.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(p.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(p.gcode=="g2"||p.gcode=="g3"||p.gcode=="g02"||p.gcode=="g03"?this.addArcSegment(h,this.state,x,y,p.gcode=="g2"||p.gcode=="g02"):this.addLineSegment(h,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(h,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let s=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;s.getHSL(VA),s=new cn().setHSL(VA.h,VA.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:s,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,s.getHex(),e.height):this.addLine(e.extrusion,s.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 _Me(this.buildVolume.x,10,this.buildVolume.y,10));const e=SMe(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 M1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Ly.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,s){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,h=r.y,p=r.z;let m=r.r,x=r.i,y=r.j;if(m){const H=d-l,q=h-c,I=Math.sqrt(Math.pow(H/2,2)+Math.pow(q/2,2));m=Math.max(m,I);const K=Math.pow(H,2)+Math.pow(q,2),Z=Math.pow(m,2)-K/4;let se=Math.sqrt(Z/K);(s&&m<0||!s&&m>0)&&(se=-se),x=H/2+q*se,y=q/2-H*se}const b=l==d&&c==h,v=l+x,S=c+y,k=Math.sqrt(x*x+y*y),E=Math.atan2(-y,-x),N=Math.atan2(h-S,d-v);let A;b?A=2*Math.PI:(A=s?E-N:N-E,A<0&&(A+=2*Math.PI));let M=k*A/1.8;this.inches&&(M*=25),M<1&&(M=1);let P=A/M;P*=s?-1:1;const T=[];T.push({x:l,y:c,z:u});const j=(u-p)/M;let z=l,F=c,$=u,D=E;for(let H=0;H<M-1;H++)D+=P,z=v+k*Math.cos(D),F=S+k*Math.sin(D),$+=j,T.push({x:z,y:F,z:$});T.push({x:r.x,y:r.y,z:r.z});for(let H=0;H<T.length-1;H++)o.push(T[H].x,T[H].y,T[H].z,T[H+1].x,T[H+1].y,T[H+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new bs;i.setAttribute("position",new Bi(e,3)),this.disposables.push(i);const s=new J0({color:n});this.disposables.push(s);const o=new Xk(i,s);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const s=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new We(l[0],l[1],l[2]),u=new We(l[3],l[4],l[5]),d=new We(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),s.push(i),i=[])}s.forEach((o=>{var l;const c=new kMe(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 OX;this.disposables.push(i);const s=new LX({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const o=new wMe(i,s);(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=>UA(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 Zke({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new Xke(r.length,s,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 UA(this,void 0,void 0,(function*(){const i=e.getReader();let s,o="",l=0;do{console.debug("reading from stream"),s=yield i.read(),l+=(r=(n=s.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=s.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
  8059. `),h=u.slice(0,d);this.parser.parseGCode(o+h),o=u.slice(d)}while(!s.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new w$(this):typeof this.devMode=="object"&&(this.devGui=new w$(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())}}$g.defaultExtrusionColor=new cn("hotpink");function FX({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),s=w.useRef(null),o=w.useRef(null),l=w.useRef(!1),[c,u]=w.useState(!0),[d,h]=w.useState(null),[p,m]=w.useState(!1),[x,y]=w.useState(0),[b,v]=w.useState(0),S=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const N=i.current,A=N.parentElement?.getBoundingClientRect();A&&(N.width=A.width,N.height=A.height);const M=n&&n.length>1,P=n?.[0]||"#00ae42",T=new $g({canvas:N,buildVolume:e,backgroundColor:1710618,extrusionColor:M?n:P,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});s.current=T;const j={},z=Ju();z&&(j.Authorization=`Bearer ${z}`),fetch(t,{headers:j}).then(async $=>{if(!$.ok)throw $.status===404&&(await $.json().catch(()=>({}))).detail?.includes("sliced")?(m(!0),new Error("not_sliced")):new Error("Failed to load G-code");return $.text()}).then($=>{const D=new Set,H=/^(\s*)T(\d+)(\s*;.*)?$/gim;let q;for(;(q=H.exec($))!==null;){const W=parseInt(q[2],10);W<=15&&D.add(W)}const I=new Map,K=Array.from(D).sort((W,ie)=>W-ie);K.forEach((W,ie)=>{I.set(W,ie%8)});const Z=[];K.forEach((W,ie)=>{const J=n?.[W]||"#00ae42";Z[ie%8]=J});const se=$.split(`
  8060. `).map(W=>{const ie=W.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(ie){const J=parseInt(ie[2],10);if(J>15)return`; FILTERED: ${W.trim()}`;const pe=I.get(J)??0;return`${ie[1]}T${pe}${ie[3]||""}`}return W}).join(`
  8061. `);Z.length>0&&(T.extrusionColor=Z),T.processGCode(se);const V=T.layers?.length||0;v(V),y(V),T.render(),u(!1)}).catch($=>{$.message!=="not_sliced"&&h($.message),u(!1)});const F=()=>{if(N.parentElement&&s.current){const $=N.parentElement.getBoundingClientRect();N.width=$.width,N.height=$.height,s.current.resize()}};return window.addEventListener("resize",F),()=>{window.removeEventListener("resize",F),o.current&&cancelAnimationFrame(o.current),s.current&&(s.current.dispose(),s.current=null),l.current=!1}},[t,S]);const k=w.useCallback(N=>{if(!s.current)return;const A=Math.max(1,Math.min(N,b));y(A),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{s.current&&(s.current.endLayer=A,s.current.render())})},[b]),E=N=>{k(parseInt(N.target.value,10))};return a.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[a.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsxs("div",{className:"text-center",children:[a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),p&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsxs("div",{className:"text-center max-w-sm px-4",children:[a.jsx(vde,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),a.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),a.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&&!p&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("div",{className:"text-center text-red-400",children:a.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!p&&b>0&&a.jsx("div",{className:"mt-4 px-2",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ja,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("button",{onClick:()=>k(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(Tc,{className:"w-4 h-4"})}),a.jsx("input",{type:"range",min:1,max:b,value:x,onChange:E,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),a.jsx("button",{onClick:()=>k(x+1),disabled:x>=b,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(La,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",b]})]})})]})}function MMe({printerId:t,filePath:e,filename:n,onClose:r}){const[i,s]=w.useState(null),[o,l]=w.useState([]),[c,u]=w.useState(!1),[d,h]=w.useState(null),p=n.toLowerCase().split(".").pop()||"",m=p==="3mf"||p==="stl",x=p==="gcode"||p==="3mf";w.useEffect(()=>{s(m?"3d":x?"gcode":null)},[m,x]),w.useEffect(()=>{l([]),h(null),m&&(u(!0),ae.getPrinterFilePlates(t,e).then(v=>l(v.plates||[])).catch(()=>l([])).finally(()=>u(!1)))},[e,m,t]);const y=o.length>1,b=d==null?null:o.find(v=>v.index===d)??null;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-6",onClick:r,children:a.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:v=>v.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:n}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>m&&s("3d"),disabled:!m,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="3d"?"text-bambu-green border-b-2 border-bambu-green":m?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Yi,{className:"w-4 h-4"}),"3D Model",!m&&a.jsx("span",{className:"text-xs",children:"(not available)"})]}),a.jsxs("button",{onClick:()=>x&&s("gcode"),disabled:!x,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="gcode"?"text-bambu-green border-b-2 border-bambu-green":x?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Ms,{className:"w-4 h-4"}),"G-code Preview",!x&&a.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:i==="3d"&&m?a.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[y&&a.jsxs("div",{className:"rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:[a.jsx(Yi,{className:"w-4 h-4"}),"Plates",c&&a.jsx(it,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>h(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d==null?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(Yi,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:"All Plates"}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[o.length," plate",o.length!==1?"s":""]})]}),d==null&&a.jsx(to,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]}),o.map(v=>a.jsxs("button",{type:"button",onClick:()=>h(v.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d===v.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[v.has_thumbnail?a.jsx("img",{src:ae.getPrinterFilePlateThumbnail(t,v.index,e),alt:`Plate ${v.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(Yi,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:v.name||`Plate ${v.index}`}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:v.objects.length>0?v.objects.slice(0,2).join(", ")+(v.objects.length>2?"…":""):`${v.filaments.length} filament${v.filaments.length!==1?"s":""}`})]}),d===v.index&&a.jsx(to,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},v.index))]}),b&&a.jsxs("div",{className:"mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1",children:[a.jsxs("span",{children:["Plate ",b.index]}),b.print_time_seconds!=null&&a.jsxs("span",{children:["ETA ",Math.round(b.print_time_seconds/60)," min"]}),b.filament_used_grams!=null&&a.jsxs("span",{children:[b.filament_used_grams.toFixed(1)," g"]}),b.filaments.length>0&&a.jsxs("span",{children:[b.filaments.length," filament",b.filaments.length!==1?"s":""]})]})]}),a.jsx("div",{className:"flex-1",children:a.jsx(tX,{url:ae.getPrinterFileDownloadUrl(t,e),fileType:p,selectedPlateId:d,className:"w-full h-full"})})]}):i==="gcode"&&x?a.jsx(FX,{gcodeUrl:ae.getPrinterFileGcodeUrl(t,e),className:"w-full h-full"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function CMe(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 _$(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 EMe(t,e){if(e)return eK;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return am;case"gcode":return Ms;case"mp4":case"avi":return Sh;case"png":case"jpg":case"jpeg":return Yu;default:return Ek}}const AMe=[{value:"name-asc",label:"Name (A-Z)"},{value:"name-desc",label:"Name (Z-A)"},{value:"size-asc",label:"Size (smallest)"},{value:"size-desc",label:"Size (largest)"},{value:"date-asc",label:"Date (oldest)"},{value:"date-desc",label:"Date (newest)"}];function TMe({printerId:t,printerName:e,onClose:n}){const{t:r}=Ut(),{showToast:i}=hn(),s=Zt(),[o,l]=w.useState("/"),[c,u]=w.useState(new Set),[d,h]=w.useState(""),[p,m]=w.useState([]),[x,y]=w.useState("name-asc"),[b,v]=w.useState(null),[S,k]=w.useState(null);w.useEffect(()=>{const I=K=>{K.key==="Escape"&&n()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[n]);const{data:E,isLoading:N,refetch:A}=et({queryKey:["printerFiles",t,o],queryFn:()=>ae.getPrinterFiles(t,o)}),{data:M}=et({queryKey:["printerStorage",t],queryFn:()=>ae.getPrinterStorage(t),staleTime:3e4}),P=st({mutationFn:async I=>{for(const K of I)await ae.deletePrinterFile(t,K)},onSuccess:()=>{i(r("printerFiles.toast.filesDeleted",{count:p.length})),s.invalidateQueries({queryKey:["printerFiles",t]}),u(new Set),m([])},onError:I=>{i(r("printerFiles.toast.deleteFailed",{error:I.message}),"error")}}),T=I=>{l(I),u(new Set)},j=()=>{if(o==="/")return;const I=o.split("/").filter(Boolean);I.pop(),l(I.length?"/"+I.join("/"):"/"),u(new Set)},z=(I,K)=>{K.stopPropagation(),u(Z=>{const se=new Set(Z);return se.has(I)?se.delete(I):se.add(I),se})},F=()=>{if(!E?.files)return;const I=E.files.filter(K=>!K.is_directory&&(!d||K.name.toLowerCase().includes(d.toLowerCase()))).map(K=>K.path);u(new Set(I))},$=()=>{u(new Set)},D=async()=>{if(c.size===0)return;const I=Array.from(c);if(I.length===1){ae.downloadPrinterFile(t,I[0]).catch(K=>{console.error("Printer file download failed:",K)}),u(new Set);return}v({current:0,total:I.length});try{const K=await ae.downloadPrinterFilesAsZip(t,I),Z=URL.createObjectURL(K),se=document.createElement("a");se.href=Z,se.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(se),se.click(),document.body.removeChild(se),URL.revokeObjectURL(Z),i(`Downloaded ${I.length} files as ZIP`),u(new Set)}catch(K){i(`Download failed: ${K instanceof Error?K.message:"Unknown error"}`,"error")}finally{v(null)}},H=()=>{c.size!==0&&m(Array.from(c))},q=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[a.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:I=>I.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Pb,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("printerFiles.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[M&&(M.used_bytes!=null||M.free_bytes!=null)&&a.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[M.used_bytes!=null&&a.jsxs("span",{children:[r("printerFiles.storageUsed")," ",_$(M.used_bytes)]}),M.used_bytes!=null&&M.free_bytes!=null&&a.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),M.free_bytes!=null&&a.jsxs("span",{children:[r("printerFiles.storageFree")," ",_$(M.free_bytes)]})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",title:"Close file manager","aria-label":"Close file manager",children:a.jsx(Rt,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[q.map(I=>a.jsx("button",{onClick:()=>{T(I.path),h("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===I.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:I.label},I.path)),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:r("printerFiles.filterPlaceholder"),value:d,onChange:I=>h(I.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"})]}),a.jsxs("div",{className:"relative flex items-center gap-1",children:[a.jsx(i4,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("select",{value:x,onChange:I=>y(I.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",title:"Sort files","aria-label":"Sort files",children:AMe.map(I=>a.jsx("option",{value:I.value,children:I.label},I.value))})]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>A(),disabled:N,children:a.jsx(Ir,{className:`w-4 h-4 ${N?"animate-spin":""}`})})]}),a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[a.jsx("button",{onClick:j,disabled:o==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",title:"Go to parent folder","aria-label":"Go to parent folder",children:a.jsx(Tc,{className:"w-4 h-4"})}),a.jsx("span",{className:"text-bambu-gray font-mono",children:o})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:N?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):E?.files?.length?a.jsx("div",{className:"space-y-1",children:[...E.files].filter(I=>!d||I.name.toLowerCase().includes(d.toLowerCase())).sort((I,K)=>{if(I.is_directory&&!K.is_directory)return-1;if(!I.is_directory&&K.is_directory)return 1;switch(x){case"name-asc":return I.name.localeCompare(K.name);case"name-desc":return K.name.localeCompare(I.name);case"size-asc":return I.size-K.size;case"size-desc":return K.size-I.size;case"date-asc":{const Z=I.mtime?new Date(I.mtime).getTime():0,se=K.mtime?new Date(K.mtime).getTime():0;return Z-se}case"date-desc":{const Z=I.mtime?new Date(I.mtime).getTime():0;return(K.mtime?new Date(K.mtime).getTime():0)-Z}default:return I.name.localeCompare(K.name)}}).map(I=>{const K=EMe(I.name,I.is_directory),Z=c.has(I.path);return a.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${Z?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{I.is_directory&&T(I.path)},children:[I.is_directory?null:a.jsx("button",{onClick:se=>z(I.path,se),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:Z?a.jsx(to,{className:"w-5 h-5 text-bambu-green"}):a.jsx(pl,{className:"w-5 h-5"})}),a.jsx(K,{className:`w-5 h-5 flex-shrink-0 ${I.is_directory?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:"flex-1 text-white truncate",children:I.name}),!I.is_directory&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:CMe(I.size)}),(I.name.toLowerCase().endsWith(".3mf")||I.name.toLowerCase().endsWith(".gcode")||I.name.toLowerCase().endsWith(".stl"))&&a.jsx("button",{onClick:se=>{se.stopPropagation(),k({path:I.path,name:I.name})},className:"p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green",title:"3D View",children:a.jsx(Yi,{className:"w-4 h-4"})})]}),I.is_directory&&a.jsx(Tc,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},I.path)})}):a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"text-sm text-bambu-gray",children:c.size>0?`${c.size} selected`:d?`${E?.files?.filter(I=>I.name.toLowerCase().includes(d.toLowerCase())).length||0} of ${E?.files?.length||0} items`:`${E?.files?.length||0} items`}),E?.files?.some(I=>!I.is_directory)&&a.jsx("div",{className:"flex items-center gap-2",children:c.size>0?a.jsxs("button",{onClick:$,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Cfe,{className:"w-4 h-4"}),"Deselect All"]}):a.jsxs("button",{onClick:F,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(to,{className:"w-4 h-4"}),"Select All"]})})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",disabled:c.size===0||b!==null,onClick:D,children:b?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),b.current,"/",b.total]}):a.jsxs(a.Fragment,{children:[a.jsx(hi,{className:"w-4 h-4"}),"Download",c.size>1?` (${c.size})`:""]})}),a.jsxs(Me,{variant:"secondary",disabled:c.size===0||P.isPending,onClick:H,className:"text-red-400 hover:text-red-300",children:[P.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4"}),r("printerFiles.deleteButton"),c.size>1?` (${c.size})`:""]})]})]})]}),p.length>0&&a.jsx(On,{title:p.length>1?r("printerFiles.deleteFiles",{count:p.length}):r("fileManager.deleteFile"),message:p.length>1?r("printerFiles.deleteFilesConfirm",{count:p.length}):r("printerFiles.deleteFileConfirm",{name:p[0].split("/").pop()}),confirmText:r("common.delete"),variant:"danger",onConfirm:()=>{P.mutate(p)},onCancel:()=>m([])}),S&&a.jsx(MMe,{printerId:t,filePath:S.path,filename:S.name,onClose:()=>k(null)})]})}function H4({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return a.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[a.jsxs("g",{stroke:r,opacity:i,children:[a.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),a.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),a.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),a.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),a.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}),a.jsx("path",{d:"M12 24h8",stroke:r}),a.jsx("path",{d:"M12 27h8",stroke:r}),a.jsx("path",{d:"M13 30h6",stroke:r})]})}const Yk=({className:t})=>a.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[a.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),a.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),a.jsx("polyline",{points:"12,10 14,12 12,14"})]});function V4({printerId:t,isOpen:e,onClose:n}){const{t:r}=Ut(),{showToast:i}=hn(),{hasPermission:s}=Rr(),[o,l]=w.useState(null),{data:c}=et({queryKey:["printerStatus",t],queryFn:()=>ae.getPrinterStatus(t),refetchInterval:3e4,enabled:e}),{data:u,refetch:d}=et({queryKey:["printableObjects",t],queryFn:()=>ae.getPrintableObjects(t),enabled:e,refetchInterval:e?5e3:!1}),h=st({mutationFn:p=>ae.skipObjects(t,p),onSuccess:p=>{i(p.message||r("printers.skipObjects.objectsSkipped")),l(null),d()},onError:p=>i(p.message||r("printers.toast.failedToSkipObjects"),"error")});return e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,onKeyDown:p=>p.key==="Escape"&&n(),tabIndex:-1,ref:p=>p?.focus(),children:[a.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),a.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] max-h-[85vh] flex flex-col overflow-hidden",onClick:p=>p.stopPropagation(),children:[a.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yk,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:r("printers.skipObjects.title")})]}),a.jsx("button",{onClick:n,className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),u?u.objects.length===0?a.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[a.jsx("p",{className:"text-sm",children:r("printers.noObjectsFound")}),a.jsx("p",{className:"text-xs mt-1 opacity-70",children:r("printers.objectsLoadedOnPrintStart")})]}):a.jsxs("div",{className:"flex flex-col overflow-hidden",children:[a.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:[a.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:a.jsx(Rhe,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:r("printers.skipObjects.matchIdsInfo")}),a.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:r("printers.skipObjects.printerShowsIds")})]}),a.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[u.skipped_count,"/",u.total," ",r("printers.skipObjects.skipped")]})]}),(c?.layer_num??0)<=1&&a.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:[a.jsx(Ui,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),a.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:r("printers.skipObjects.waitForLayer",{layer:c?.layer_num??0})})]}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary overflow-y-auto",children:a.jsxs("div",{className:"relative",children:[c?.cover_url?a.jsx("img",{src:`${c.cover_url}?view=top`,alt:r("printers.printPreview"),className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):a.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:a.jsx(Yi,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),u.objects.length>0&&a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:u.objects.map((p,m)=>{let x,y;if(p.x!=null&&p.y!=null&&u.bbox_all){const[b,v,S,k]=u.bbox_all,E=S-b,N=k-v,A=8,M=100-A*2;x=A+(p.x-b)/E*M,y=A+(k-p.y)/N*M,x=Math.max(5,Math.min(95,x)),y=Math.max(5,Math.min(95,y))}else if(p.x!=null&&p.y!=null)x=p.x/256*100,y=100-p.y/256*100,x=Math.max(5,Math.min(95,x)),y=Math.max(5,Math.min(95,y));else{const b=Math.ceil(Math.sqrt(u.objects.length)),v=Math.floor(m/b),S=m%b,k=Math.ceil(u.objects.length/b);x=15+S*(70/b)+35/b,y=15+v*(70/k)+35/k}return a.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${p.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${x}%`,top:`${y}%`,transform:"translate(-50%, -50%)"},title:p.name,children:p.id},p.id)})}),a.jsx("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:r("printers.skipObjects.activeCount",{count:u.objects.filter(p=>!p.skipped).length})})]})}),a.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:u.objects.map(p=>a.jsxs("div",{className:`
  8062. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  8063. ${p.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  8064. `,children:[a.jsxs("div",{className:`
  8065. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  8066. ${p.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"}
  8067. `,children:[a.jsx("span",{className:`text-lg font-mono font-bold ${p.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:p.id}),a.jsx("span",{className:`text-[8px] uppercase tracking-wider ${p.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:`block text-sm truncate ${p.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:p.name}),p.skipped&&a.jsx("span",{className:"text-[10px] text-red-400/60",children:r("printers.willBeSkipped")})]}),p.skipped?a.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:r("printers.skipObjects.skipped")}):a.jsx("button",{onClick:()=>l({id:p.id,name:p.name}),disabled:h.isPending||(c?.layer_num??0)<=1||!s("printers:control"),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(c?.layer_num??0)<=1||!s("printers:control")?"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:s("printers:control")?(c?.layer_num??0)<=1?r("printers.skipObjects.waitForLayer",{layer:c?.layer_num??0}):r("printers.skipObjects.skip"):r("printers.permission.noControl"),children:r("printers.skipObjects.skip")})]},p.id))})]})]}):a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(it,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),o&&a.jsx(On,{variant:"warning",title:r("printers.skipObjects.confirmTitle"),message:r("printers.skipObjects.confirmMessage",{name:o.name}),confirmText:r("printers.skipObjects.skip"),isLoading:h.isPending,onConfirm:()=>h.mutate([o.id]),onCancel:()=>l(null)})]}):null}const jMe="embeddedCameraState_",S$=5,PMe=2e3,DMe=3e4,RMe=5e3,GA={x:window.innerWidth-420,y:20,width:400,height:300};function LMe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const{t:i}=Ut(),s=Zt(),{showToast:o}=hn(),{hasPermission:l}=Rr(),c=`${jMe}${t}`,u=()=>{try{const Oe=localStorage.getItem(c);if(Oe){const Ne=JSON.parse(Oe);return{x:Math.min(Math.max(0,Ne.x),window.innerWidth-100),y:Math.min(Math.max(0,Ne.y),window.innerHeight-100),width:Math.max(200,Math.min(Ne.width,window.innerWidth-20)),height:Math.max(150,Math.min(Ne.height,window.innerHeight-20))}}}catch{}const Re=n*30;return{...GA,x:Math.max(0,GA.x-Re),y:Math.max(0,GA.y+Re)}},[d,h]=w.useState(u),[p,m]=w.useState(!1),[x,y]=w.useState(!1),[b,v]=w.useState({x:0,y:0}),[S,k]=w.useState(!1),[E,N]=w.useState(!1),[A,M]=w.useState(1),[P,T]=w.useState({x:0,y:0}),[j,z]=w.useState(!1),[F,$]=w.useState({x:0,y:0}),[D,H]=w.useState(null),[q,I]=w.useState(null),[K,Z]=w.useState(!1),[se,V]=w.useState(!0),[W,ie]=w.useState(Date.now()),[J,pe]=w.useState(0),[fe,ve]=w.useState(!1),[Le,de]=w.useState(0),ce=w.useRef(null),Ae=w.useRef(null),re=w.useRef(null),Ie=w.useRef(null),G=w.useRef(null),[Y,ue]=w.useState(!1),{data:B}=et({queryKey:["printer",t],queryFn:()=>ae.getPrinter(t),enabled:t>0}),{data:ee}=et({queryKey:["printerStatus",t],queryFn:()=>ae.getPrinterStatus(t),refetchInterval:3e4,enabled:t>0}),Q=st({mutationFn:Re=>ae.setChamberLight(t,Re),onMutate:async Re=>{await s.cancelQueries({queryKey:["printerStatus",t]});const Oe=s.getQueryData(["printerStatus",t]);return s.setQueryData(["printerStatus",t],Ne=>({...Ne,chamber_light:Re})),{previousStatus:Oe}},onSuccess:(Re,Oe)=>{o(`Chamber light ${Oe?"on":"off"}`)},onError:(Re,Oe,Ne)=>{Ne?.previousStatus&&s.setQueryData(["printerStatus",t],Ne.previousStatus),o(Re.message||i("printers.toast.failedToControlChamberLight"),"error")}}),le=(ee?.state==="RUNNING"||ee?.state==="PAUSE"||ee?.state==="PAUSED")&&(ee?.printable_objects_count??0)>=2;w.useEffect(()=>{const Re=setTimeout(()=>{localStorage.setItem(c,JSON.stringify(d))},500);return()=>clearTimeout(Re)},[d,c]);const he=w.useRef(!1);w.useEffect(()=>{he.current=!1;const Re=`/api/v1/printers/${t}/camera/stop`,Oe=()=>{if(t>0&&!he.current){he.current=!0;const Je={},yt=Ju();yt&&(Je.Authorization=`Bearer ${yt}`),fetch(Re,{method:"POST",keepalive:!0,headers:Je}).catch(()=>{})}},Ne=Ae.current;return()=>{Ne&&(Ne.src=""),Oe(),re.current&&clearTimeout(re.current),Ie.current&&clearInterval(Ie.current),G.current&&clearInterval(G.current)}},[t]),w.useEffect(()=>{if(se){const Re=setTimeout(()=>V(!1),3e3);return()=>clearTimeout(Re)}},[se,W]);const te=w.useCallback(()=>{if(J>=S$){ve(!1),Z(!0);return}const Re=Math.min(PMe*Math.pow(2,J),DMe);ve(!0),de(Math.ceil(Re/1e3)),Ie.current=setInterval(()=>{de(Oe=>Oe<=1?(Ie.current&&clearInterval(Ie.current),0):Oe-1)},1e3),re.current=setTimeout(()=>{pe(Oe=>Oe+1),ve(!1),V(!0),Z(!1),Ae.current&&(Ae.current.src=""),ie(Date.now())},Re)},[J]);w.useEffect(()=>{if(se||fe||S){G.current&&(clearInterval(G.current),G.current=null);return}return G.current=setInterval(async()=>{try{const Re=await ae.getCameraStatus(t);(Re.stalled||!Re.active&&!K)&&(G.current&&(clearInterval(G.current),G.current=null),V(!1),te())}catch{}},RMe),()=>{G.current&&(clearInterval(G.current),G.current=null)}},[se,K,fe,S,t,te]),w.useEffect(()=>{const Re=()=>{const Oe=!!document.fullscreenElement;N(Oe),Oe||(M(1),T({x:0,y:0}))};return document.addEventListener("fullscreenchange",Re),()=>document.removeEventListener("fullscreenchange",Re)},[]);const U=()=>{ce.current&&(document.fullscreenElement?document.exitFullscreen():ce.current.requestFullscreen())},L=()=>{M(Re=>Math.min(Re+.5,4))},X=()=>{M(Re=>{const Oe=Math.max(Re-.5,1);return Oe===1&&T({x:0,y:0}),Oe})},ge=Re=>{Re.preventDefault(),Re.deltaY<0?L():X()},_e=Re=>{A>1&&(Re.preventDefault(),z(!0),$({x:Re.clientX-P.x,y:Re.clientY-P.y}))},Ee=w.useCallback(()=>{if(!ce.current||!Ae.current)return{x:200,y:150};const Re=ce.current.getBoundingClientRect(),Oe=Re.width*(A-1)/2,Ne=Re.height*(A-1)/2;return{x:Math.max(50,Oe),y:Math.max(50,Ne)}},[A]),$e=Re=>{if(j&&A>1){const Oe=Re.clientX-F.x,Ne=Re.clientY-F.y,Je=Ee();T({x:Math.max(-Je.x,Math.min(Je.x,Oe)),y:Math.max(-Je.y,Math.min(Je.y,Ne))})}},Ce=()=>{z(!1)},He=Re=>{if(Re.length<2)return 0;const Oe=Re[0].clientX-Re[1].clientX,Ne=Re[0].clientY-Re[1].clientY;return Math.sqrt(Oe*Oe+Ne*Ne)},Qe=Re=>Re.length<2?{x:Re[0].clientX,y:Re[0].clientY}:{x:(Re[0].clientX+Re[1].clientX)/2,y:(Re[0].clientY+Re[1].clientY)/2},xe=Re=>{Re.touches.length===2?(Re.preventDefault(),H(He(Re.touches)),I(Qe(Re.touches))):Re.touches.length===1&&A>1&&(Re.preventDefault(),z(!0),$({x:Re.touches[0].clientX-P.x,y:Re.touches[0].clientY-P.y}))},ye=Re=>{if(Re.touches.length===2&&D!==null){Re.preventDefault();const Oe=He(Re.touches),Ne=Oe/D;M(yt=>{const Et=Math.max(1,Math.min(4,yt*Ne));return Et===1&&T({x:0,y:0}),Et}),H(Oe);const Je=Qe(Re.touches);if(q){const yt=Ee();T(Et=>({x:Math.max(-yt.x,Math.min(yt.x,Et.x+(Je.x-q.x))),y:Math.max(-yt.y,Math.min(yt.y,Et.y+(Je.y-q.y)))}))}I(Je)}else if(Re.touches.length===1&&j&&A>1){Re.preventDefault();const Oe=Re.touches[0].clientX-F.x,Ne=Re.touches[0].clientY-F.y,Je=Ee();T({x:Math.max(-Je.x,Math.min(Je.x,Oe)),y:Math.max(-Je.y,Math.min(Je.y,Ne))})}},we=Re=>{Re.touches.length<2&&(H(null),I(null)),Re.touches.length===0&&z(!1)},Ue=()=>{M(1),T({x:0,y:0})},Pe=()=>{V(!1),J<S$?te():Z(!0)},Ve=()=>{V(!1),Z(!1),pe(0),ve(!1),re.current&&clearTimeout(re.current),Ie.current&&clearInterval(Ie.current)},ke=()=>{V(!0),Z(!1),pe(0),ve(!1),re.current&&clearTimeout(re.current),Ie.current&&clearInterval(Ie.current);const Re={},Oe=Ju();Oe&&(Re.Authorization=`Bearer ${Oe}`),fetch(`/api/v1/printers/${t}/camera/stop`,{method:"POST",headers:Re}).catch(()=>{}),Ae.current&&(Ae.current.src=""),setTimeout(()=>ie(Date.now()),100)},Ze=Re=>{Re.target.closest(".no-drag")||(m(!0),v({x:Re.clientX-d.x,y:Re.clientY-d.y}))},je=Re=>{Re.stopPropagation(),y(!0)};w.useEffect(()=>{const Re=Ne=>{if(p)h(Je=>({...Je,x:Math.max(0,Math.min(Ne.clientX-b.x,window.innerWidth-Je.width)),y:Math.max(0,Math.min(Ne.clientY-b.y,window.innerHeight-Je.height))}));else if(x&&ce.current){const Je=ce.current.getBoundingClientRect();h(yt=>({...yt,width:Math.max(200,Math.min(Ne.clientX-Je.left,window.innerWidth-yt.x-10)),height:Math.max(150,Math.min(Ne.clientY-Je.top,window.innerHeight-yt.y-10))}))}},Oe=()=>{m(!1),y(!1)};if(p||x)return document.addEventListener("mousemove",Re),document.addEventListener("mouseup",Oe),()=>{document.removeEventListener("mousemove",Re),document.removeEventListener("mouseup",Oe)}},[p,x,b]);const Xe=`/api/v1/printers/${t}/camera/stream?fps=15&t=${W}`;return a.jsxs("div",{ref:ce,className:`${E?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:E?void 0:{left:d.x,top:d.y,width:S?200:d.width,height:S?40:d.height,cursor:p?"grabbing":"default"},children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:Ze,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[a.jsx(kh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:B?.name||e})]}),a.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[a.jsx("button",{onClick:()=>Q.mutate(!ee?.chamber_light),disabled:!ee?.connected||Q.isPending||!l("printers:control"),className:`p-1 rounded disabled:opacity-50 ${ee?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:l("printers:control")?i("camera.chamberLight"):i("printers.permission.noControl"),children:a.jsx(H4,{on:ee?.chamber_light??!1,className:"w-3.5 h-3.5"})}),a.jsx("button",{onClick:()=>ue(!0),disabled:!le||!l("printers:control"),className:`p-1 rounded disabled:opacity-50 ${le&&l("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:l("printers:control")?i(le?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):i("printers.permission.noControl"),children:a.jsx(Yk,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:ke,disabled:se||fe,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:a.jsx(Ir,{className:`w-3.5 h-3.5 text-bambu-gray ${se?"animate-spin":""}`})}),a.jsx("button",{onClick:U,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:E?"Exit fullscreen":"Fullscreen",children:E?a.jsx(rK,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(Lde,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:()=>k(!S),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:S?"Expand":"Minimize",children:S?a.jsx(s4,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(o4,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:a.jsx(Rt,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!S&&a.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:ge,onMouseMove:$e,onMouseUp:Ce,onMouseLeave:Ce,onTouchStart:xe,onTouchMove:ye,onTouchEnd:we,style:{touchAction:"none"},children:[se&&!fe&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsx(Ir,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),fe&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-2",children:[a.jsx(km,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",Le,"s..."]})]})}),K&&!fe&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-2",children:[a.jsx(kn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),a.jsx("button",{onClick:ke,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),a.jsx("img",{ref:Ae,src:Xe,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${A}) translate(${P.x/A}px, ${P.y/A}px)`,cursor:A>1?j?"grabbing":"grab":"default"},onError:Pe,onLoad:Ve,onMouseDown:_e,draggable:!1},W),a.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[a.jsx("button",{onClick:X,disabled:A<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(f4,{className:"w-3.5 h-3.5 text-white"})}),a.jsxs("button",{onClick:Ue,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(A*100),"%"]}),a.jsx("button",{onClick:L,disabled:A>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(h4,{className:"w-3.5 h-3.5 text-white"})})]}),!E&&a.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:je,title:"Drag to resize",children:a.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:a.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]}),a.jsx(V4,{printerId:t,isOpen:Y,onClose:()=>ue(!1)})]})}function OMe({printerId:t,printerName:e,onClose:n}){const{t:r}=Ut(),i=Zt(),[s,o]=w.useState(!0),[l,c]=w.useState(new Set),[u,d]=w.useState(""),[h,p]=w.useState("all"),m=w.useRef(null),{data:x,isLoading:y,refetch:b}=et({queryKey:["mqtt-logs",t],queryFn:()=>ae.getMQTTLogs(t),refetchInterval:1e3}),v=st({mutationFn:()=>ae.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=st({mutationFn:()=>ae.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),k=st({mutationFn:()=>ae.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const j=z=>{z.key==="Escape"&&n()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n]),w.useEffect(()=>{s&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[x?.logs,s]);const E=j=>{c(z=>{const F=new Set(z);return F.has(j)?F.delete(j):F.add(j),F})},N=j=>new Date(j).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),A=(j,z)=>{if(j==null)return"<empty>";const F=typeof j=="string"?JSON.parse(j):j,$=JSON.stringify(F,null,z?2:0);return!z&&$.length>100?$.substring(0,100)+"...":$},M=x?.logging_enabled??!1,P=w.useMemo(()=>x?.logs??[],[x?.logs]),T=w.useMemo(()=>P.filter(j=>{if(h!=="all"&&j.direction!==h)return!1;if(u.trim()){const z=u.toLowerCase(),F=j.topic.toLowerCase().includes(z),D=JSON.stringify(j.payload).toLowerCase().includes(z);return F||D}return!0}),[P,u,h]);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("mqttDebug.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[M?a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending,children:[a.jsx(pl,{className:"w-4 h-4"}),r("mqttDebug.stopLogging")]}):a.jsxs(Me,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[a.jsx(jo,{className:"w-4 h-4"}),r("mqttDebug.startLogging")]}),a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>k.mutate(),disabled:k.isPending||P.length===0,children:[a.jsx(en,{className:"w-4 h-4"}),r("mqttDebug.clearLog")]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>b(),disabled:y,children:a.jsx(Ir,{className:`w-4 h-4 ${y?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:s,onChange:j=>o(j.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[T.length,"/",P.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(zr,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:r("mqttDebug.searchPlaceholder"),value:u,onChange:j=>d(j.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"}),u&&a.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>p("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${h==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:r("mqttDebug.all")}),a.jsxs("button",{onClick:()=>p("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${h==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[a.jsx(Yg,{className:"w-3 h-3"}),r("mqttDebug.incoming")]}),a.jsxs("button",{onClick:()=>p("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${h==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[a.jsx(_m,{className:"w-3 h-3"}),r("mqttDebug.outgoing")]})]})]})]}),a.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:P.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessages")}),!M&&a.jsx("p",{className:"text-sm",children:r("mqttDebug.startLoggingHint")})]}):T.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessagesMatch")}),a.jsx("p",{className:"text-sm",children:r("mqttDebug.adjustFilterHint")})]}):a.jsx("div",{className:"space-y-1",children:T.map((j,z)=>{const F=l.has(z),$=j.direction==="in";return a.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>E(z),children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray shrink-0",children:N(j.timestamp)}),a.jsx("span",{className:`shrink-0 ${$?"text-blue-400":"text-green-400"}`,title:r($?"mqttDebug.incoming":"mqttDebug.outgoing"),children:$?a.jsx(Yg,{className:"w-3 h-3"}):a.jsx(_m,{className:"w-3 h-3"})}),a.jsx("span",{className:"text-purple-400 shrink-0",children:j.topic})]}),F?a.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:A(j.payload,!0)}):a.jsx("pre",{className:"mt-1 text-white/80 truncate",children:A(j.payload,!1)})]},z)})})}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-sm text-bambu-gray",children:M?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),r("mqttDebug.loggingActive")]}):a.jsx("span",{children:r("mqttDebug.loggingStopped")})}),a.jsx(Me,{variant:"secondary",onClick:n,children:r("common.close")})]})]})})}const Y3={"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 FMe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:kn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:kn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Ui};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Xs}}}function Q3(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 IMe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=Q3(e.attr,n);return Y3[r]!==void 0})}function zMe(){return"https://wiki.bambulab.com/en/hms/home"}function UMe({printerName:t,errors:e,onClose:n}){const{t:r}=Ut();console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const i=e.filter(s=>{const o=parseInt(s.code.replace("0x",""),16)||0,l=Q3(s.attr,o);return Y3[l]!==void 0});return w.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kn,{className:"w-5 h-5 text-orange-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("hmsErrors.title",{name:t})})]}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Ui,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{children:r("hmsErrors.noErrors")})]}):a.jsx("div",{className:"space-y-3",children:i.map((s,o)=>{const{label:l,color:c,bgColor:u,Icon:d}=FMe(s.severity),h=parseInt(s.code.replace("0x",""),16)||0,p=Q3(s.attr,h),m=Y3[p],x=zMe(),y=p.replace("_","-");return a.jsx("div",{className:`p-4 rounded-lg ${u} border border-white/10`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(d,{className:`w-5 h-5 ${c} flex-shrink-0 mt-0.5`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("span",{className:`font-mono text-sm ${c}`,children:["[",y,"]"]}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${u} ${c}`,children:l})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),a.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[a.jsx(Wr,{className:"w-3 h-3"}),r("hmsErrors.viewOnWiki")]})]})]})},`${s.code}-${o}`)})})}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:r("hmsErrors.clearInstructions")})})]})})}function BMe(t){if(!t)return"ASAP";const e=Qi(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 $Me({printerId:t,printerState:e}){const{t:n}=Ut(),r=Zt(),{showToast:i}=hn(),{hasPermission:s}=Rr(),{data:o}=et({queryKey:["queue",t,"pending"],queryFn:()=>ae.getQueue(t,"pending"),refetchInterval:3e4}),l=st({mutationFn:()=>ae.clearPlate(t),onSuccess:()=>{r.invalidateQueries({queryKey:["queue",t]}),r.invalidateQueries({queryKey:["printerStatus",t]}),i(n("queue.clearPlateSuccess"),"success")},onError:h=>{i(h.message,"error")}}),c=o?.[0],u=o?.length||0;return u===0?null:e==="FINISH"||e==="FAILED"?a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-yellow-400/30",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx(ri,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("queue.nextInQueue")}),a.jsx("p",{className:"text-sm text-white truncate",children:c?.archive_name||`Archive #${c?.archive_id}`})]}),u>1&&a.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded flex-shrink-0",children:["+",u-1]})]}),l.isSuccess?a.jsxs("div",{className:"w-full py-2 px-3 rounded-lg bg-bambu-green/10 border border-bambu-green/20 text-bambu-green text-sm flex items-center justify-center gap-2",children:[a.jsx(Zg,{className:"w-4 h-4"}),n("queue.plateReady")]}):a.jsxs("button",{onClick:()=>l.mutate(),disabled:l.isPending||!s("printers:control"),className:"w-full py-2 px-3 rounded-lg bg-bambu-green/20 border border-bambu-green/40 text-bambu-green hover:bg-bambu-green/30 transition-colors text-sm font-medium flex items-center justify-center gap-2 disabled:opacity-50",children:[l.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Zg,{className:"w-4 h-4"}),n("queue.clearPlate")]})]}):a.jsx(qs,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx(ri,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("queue.nextInQueue")}),a.jsx("p",{className:"text-sm text-white truncate",children:c?.archive_name||`Archive #${c?.archive_id}`})]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),BMe(c?.scheduled_time||null)]}),u>1&&a.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",u-1]}),a.jsx(La,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function IX(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=IX(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function ir(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=IX(t))&&(r&&(r+=" "),r+=e);return r}var HMe=["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 G4(t){if(typeof t!="string")return!1;var e=HMe;return e.includes(t)}var VMe=["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"],GMe=new Set(VMe);function zX(t){return typeof t!="string"?!1:GMe.has(t)}function UX(t){return typeof t=="string"&&t.startsWith("data-")}function Ps(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(zX(n)||UX(n))&&(e[n]=t[n]);return e}function Pm(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ps(e)}return typeof t=="object"&&!Array.isArray(t)?Ps(t):null}function es(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(zX(n)||UX(n)||G4(n))&&(e[n]=t[n]);return e}function qMe(t){return t==null?null:w.isValidElement(t)?es(t.props):typeof t=="object"&&!Array.isArray(t)?es(t):null}var WMe=["children","width","height","viewBox","className","style","title","desc"];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 KMe(t,e){if(t==null)return{};var n,r,i=XMe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function XMe(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 q4=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:o,style:l,title:c,desc:u}=t,d=KMe(t,WMe),h=s||{width:r,height:i,x:0,y:0},p=ir("recharts-surface",o);return w.createElement("svg",Z3({},es(d),{className:p,width:r,height:i,style:l,viewBox:"".concat(h.x," ").concat(h.y," ").concat(h.width," ").concat(h.height),ref:e}),w.createElement("title",null,c),w.createElement("desc",null,u),n)}),YMe=["children","className"];function J3(){return J3=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},J3.apply(null,arguments)}function QMe(t,e){if(t==null)return{};var n,r,i=ZMe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ZMe(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 gi=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=QMe(t,YMe),s=ir("recharts-layer",r);return w.createElement("g",J3({className:s},es(i),{ref:e}),n)}),BX=w.createContext(null),JMe=()=>w.useContext(BX);function qr(t){return function(){return t}}const $X=Math.cos,C1=Math.sin,tc=Math.sqrt,E1=Math.PI,Qk=2*E1,eD=Math.PI,tD=2*eD,zf=1e-6,eCe=tD-zf;function HX(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function tCe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return HX;const n=10**e;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class nCe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?HX:tCe(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,s,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+s},${this._y1=+o}`}arcTo(e,n,r,i,s){if(e=+e,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,h=l-n,p=d*d+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(p>zf)if(!(Math.abs(h*c-u*d)>zf)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-o,x=i-l,y=c*c+u*u,b=m*m+x*x,v=Math.sqrt(y),S=Math.sqrt(p),k=s*Math.tan((eD-Math.acos((y+p-b)/(2*v*S)))/2),E=k/S,N=k/v;Math.abs(E-1)>zf&&this._append`L${e+E*d},${n+E*h}`,this._append`A${s},${s},0,0,${+(h*m>d*x)},${this._x1=e+N*c},${this._y1=n+N*u}`}}arc(e,n,r,i,s,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,h=1^o,p=o?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>zf||Math.abs(this._y1-d)>zf)&&this._append`L${u},${d}`,r&&(p<0&&(p=p%tD+tD),p>eCe?this._append`A${r},${r},0,1,${h},${e-l},${n-c}A${r},${r},0,1,${h},${this._x1=u},${this._y1=d}`:p>zf&&this._append`A${r},${r},0,${+(p>=eD)},${h},${this._x1=e+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}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 W4(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 nCe(e)}function K4(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function VX(t){this._context=t}VX.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 Zk(t){return new VX(t)}function GX(t){return t[0]}function qX(t){return t[1]}function WX(t,e){var n=qr(!0),r=null,i=Zk,s=null,o=W4(l);t=typeof t=="function"?t:t===void 0?GX:qr(t),e=typeof e=="function"?e:e===void 0?qX:qr(e);function l(c){var u,d=(c=K4(c)).length,h,p=!1,m;for(r==null&&(s=i(m=o())),u=0;u<=d;++u)!(u<d&&n(h=c[u],u,c))===p&&((p=!p)?s.lineStart():s.lineEnd()),p&&s.point(+t(h,u,c),+e(h,u,c));if(m)return s=null,m+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:qr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:qr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:qr(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(s=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=s=null:s=i(r=c),l):r},l}function Q_(t,e,n){var r=null,i=qr(!0),s=null,o=Zk,l=null,c=W4(u);t=typeof t=="function"?t:t===void 0?GX:qr(+t),e=typeof e=="function"?e:qr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?qX:qr(+n);function u(h){var p,m,x,y=(h=K4(h)).length,b,v=!1,S,k=new Array(y),E=new Array(y);for(s==null&&(l=o(S=c())),p=0;p<=y;++p){if(!(p<y&&i(b=h[p],p,h))===v)if(v=!v)m=p,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=p-1;x>=m;--x)l.point(k[x],E[x]);l.lineEnd(),l.areaEnd()}v&&(k[p]=+t(b,p,h),E[p]=+e(b,p,h),l.point(r?+r(b,p,h):k[p],n?+n(b,p,h):E[p]))}if(S)return l=null,S+""||null}function d(){return WX().defined(i).curve(o).context(s)}return u.x=function(h){return arguments.length?(t=typeof h=="function"?h:qr(+h),r=null,u):t},u.x0=function(h){return arguments.length?(t=typeof h=="function"?h:qr(+h),u):t},u.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:qr(+h),u):r},u.y=function(h){return arguments.length?(e=typeof h=="function"?h:qr(+h),n=null,u):e},u.y0=function(h){return arguments.length?(e=typeof h=="function"?h:qr(+h),u):e},u.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:qr(+h),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(h){return arguments.length?(i=typeof h=="function"?h:qr(!!h),u):i},u.curve=function(h){return arguments.length?(o=h,s!=null&&(l=o(s)),u):o},u.context=function(h){return arguments.length?(h==null?s=l=null:l=o(s=h),u):s},u}class KX{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 rCe(t){return new KX(t,!0)}function iCe(t){return new KX(t,!1)}const X4={draw(t,e){const n=tc(e/E1);t.moveTo(n,0),t.arc(0,0,n,0,Qk)}},aCe={draw(t,e){const n=tc(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()}},XX=tc(1/3),sCe=XX*2,oCe={draw(t,e){const n=tc(e/sCe),r=n*XX;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},lCe={draw(t,e){const n=tc(e),r=-n/2;t.rect(r,r,n,n)}},cCe=.8908130915292852,YX=C1(E1/10)/C1(7*E1/10),uCe=C1(Qk/10)*YX,dCe=-$X(Qk/10)*YX,hCe={draw(t,e){const n=tc(e*cCe),r=uCe*n,i=dCe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const o=Qk*s/5,l=$X(o),c=C1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},qA=tc(3),fCe={draw(t,e){const n=-tc(e/(qA*3));t.moveTo(0,n*2),t.lineTo(-qA*n,-n),t.lineTo(qA*n,-n),t.closePath()}},Ko=-.5,Xo=tc(3)/2,nD=1/tc(12),mCe=(nD/2+1)*3,pCe={draw(t,e){const n=tc(e/mCe),r=n/2,i=n*nD,s=r,o=n*nD+n,l=-s,c=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(l,c),t.lineTo(Ko*r-Xo*i,Xo*r+Ko*i),t.lineTo(Ko*s-Xo*o,Xo*s+Ko*o),t.lineTo(Ko*l-Xo*c,Xo*l+Ko*c),t.lineTo(Ko*r+Xo*i,Ko*i-Xo*r),t.lineTo(Ko*s+Xo*o,Ko*o-Xo*s),t.lineTo(Ko*l+Xo*c,Ko*c-Xo*l),t.closePath()}};function gCe(t,e){let n=null,r=W4(i);t=typeof t=="function"?t:qr(t||X4),e=typeof e=="function"?e:qr(e===void 0?64:+e);function i(){let s;if(n||(n=s=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(t=typeof s=="function"?s:qr(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:qr(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function A1(){}function T1(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 QX(t){this._context=t}QX.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:T1(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:T1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function bCe(t){return new QX(t)}function ZX(t){this._context=t}ZX.prototype={areaStart:A1,areaEnd:A1,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:T1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function xCe(t){return new ZX(t)}function JX(t){this._context=t}JX.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:T1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function yCe(t){return new JX(t)}function eY(t){this._context=t}eY.prototype={areaStart:A1,areaEnd:A1,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 vCe(t){return new eY(t)}function N$(t){return t<0?-1:1}function k$(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(s*i+o*r)/(r+i);return(N$(s)+N$(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function M$(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function WA(t,e,n){var r=t._x0,i=t._y0,s=t._x1,o=t._y1,l=(s-r)/3;t._context.bezierCurveTo(r+l,i+l*e,s-l,o-l*n,s,o)}function j1(t){this._context=t}j1.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:WA(this,this._t0,M$(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,WA(this,M$(this,n=k$(this,t,e)),n);break;default:WA(this,this._t0,n=k$(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function tY(t){this._context=new nY(t)}(tY.prototype=Object.create(j1.prototype)).point=function(t,e){j1.prototype.point.call(this,e,t)};function nY(t){this._context=t}nY.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,s){this._context.bezierCurveTo(e,t,r,n,s,i)}};function wCe(t){return new j1(t)}function _Ce(t){return new tY(t)}function rY(t){this._context=t}rY.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=C$(t),i=C$(e),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],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 C$(t){var e,n=t.length-1,r,i=new Array(n),s=new Array(n),o=new Array(n);for(i[0]=0,s[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,s[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,s[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/s[e-1],s[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/s[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/s[e];for(s[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)s[e]=2*t[e+1]-i[e+1];return[i,s]}function SCe(t){return new rY(t)}function Jk(t,e){this._context=t,this._t=e}Jk.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 NCe(t){return new Jk(t,.5)}function kCe(t){return new Jk(t,0)}function MCe(t){return new Jk(t,1)}function db(t,e){if((o=t.length)>1)for(var n=1,r,i,s=t[e[0]],o,l=s.length;n<o;++n)for(i=s,s=t[e[n]],r=0;r<l;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function rD(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function CCe(t,e){return t[e]}function ECe(t){const e=[];return e.key=t,e}function ACe(){var t=qr([]),e=rD,n=db,r=CCe;function i(s){var o=Array.from(t.apply(this,arguments),ECe),l,c=o.length,u=-1,d;for(const h of s)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(h,o[l].key,u,s)]).data=h;for(l=0,d=K4(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:qr(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:qr(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?rD:typeof s=="function"?s:qr(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??db,i):n},i}function TCe(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,o;i<s;++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}db(t,e)}}function jCe(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,s=r.length;n<s;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}db(t,e)}}function PCe(t,e){if(!(!((o=t.length)>0)||!((s=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,s,o;r<s;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],h=d[r][1]||0,p=d[r-1][1]||0,m=(h-p)/2,x=0;x<l;++x){var y=t[e[x]],b=y[r][1]||0,v=y[r-1][1]||0;m+=b-v}c+=h,u+=m*h}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,db(t,e)}}var KA={},XA={},E$;function DCe(){return E$||(E$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(XA)),XA}var YA={},A$;function iY(){return A$||(A$=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})(YA)),YA}var QA={},T$;function Y4(){return T$||(T$=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})(QA)),QA}var ZA={},JA={},j$;function RCe(){return j$||(j$=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})(JA)),JA}var P$;function Q4(){return P$||(P$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RCe(),n=Y4();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const s=[],o=i.length;if(o===0)return s;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(s.push(""),l++);l<o;){const h=i[l];u?h==="\\"&&l+1<o?(l++,c+=i[l]):h===u?u="":c+=h:d?h==='"'||h==="'"?u=h:h==="]"?(d=!1,s.push(c),c=""):c+=h:h==="["?(d=!0,c&&(s.push(c),c="")):h==="."?c&&(s.push(c),c=""):c+=h,l++}return c&&s.push(c),s}t.toPath=r})(ZA)),ZA}var D$;function Z4(){return D$||(D$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=DCe(),n=iY(),r=Y4(),i=Q4();function s(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)?s(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 h=0;h<c.length;h++){if(d==null||e.isUnsafeProperty(c[h]))return u;d=d[c[h]]}return d===void 0?u:d}t.get=s})(KA)),KA}var eT,R$;function LCe(){return R$||(R$=1,eT=Z4().get),eT}var OCe=LCe();const Dm=wl(OCe);var Pa=t=>t===0?0:t>0?1:-1,no=t=>typeof t=="number"&&t!=+t,nd=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ht=t=>(typeof t=="number"||t instanceof Number)&&!no(t),xl=t=>Ht(t)||typeof t=="string",FCe=0,p0=t=>{var e=++FCe;return"".concat(t||"").concat(e)},gs=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(!Ht(e)&&typeof e!="string")return r;var s;if(nd(e)){if(n==null)return r;var o=e.indexOf("%");s=n*parseFloat(e.slice(0,o))/100}else s=+e;return no(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},aY=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 pr(t,e,n){return Ht(t)&&Ht(e)?t+n*(e-t):e}function sY(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Dm(r,e))===n)}var ii=t=>t===null||typeof t>"u",ev=t=>ii(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function ICe(t){return t!=null}function tv(){}var zCe=["type","size","sizeType"];function iD(){return iD=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},iD.apply(null,arguments)}function L$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function O$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L$(Object(n),!0).forEach(function(r){UCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function UCe(t,e,n){return(e=BCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BCe(t){var e=$Ce(t,"string");return typeof e=="symbol"?e:e+""}function $Ce(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function HCe(t,e){if(t==null)return{};var n,r,i=VCe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function VCe(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 oY={symbolCircle:X4,symbolCross:aCe,symbolDiamond:oCe,symbolSquare:lCe,symbolStar:hCe,symbolTriangle:fCe,symbolWye:pCe},GCe=Math.PI/180,qCe=t=>{var e="symbol".concat(ev(t));return oY[e]||X4},WCe=(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*GCe;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}},KCe=(t,e)=>{oY["symbol".concat(ev(t))]=e},J4=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=HCe(t,zCe),s=O$(O$({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var p=qCe(o),m=gCe().type(p).size(WCe(n,r,o)),x=m();if(x!==null)return x},{className:c,cx:u,cy:d}=s,h=es(s);return Ht(u)&&Ht(d)&&Ht(n)?w.createElement("path",iD({},h,{className:ir("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};J4.registerSymbol=KCe;var lY=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,eL=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(w.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{G4(i)&&(r[i]=(s=>n[i](n,s)))}),r},XCe=(t,e,n)=>r=>(t(e,n,r),null),nv=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var s=t[i];G4(i)&&typeof s=="function"&&(r||(r={}),r[i]=XCe(s,e,n))}),r};function F$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function YCe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F$(Object(n),!0).forEach(function(r){QCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QCe(t,e,n){return(e=ZCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZCe(t){var e=JCe(t,"string");return typeof e=="symbol"?e:e+""}function JCe(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 bi(t,e){var n=YCe({},t),r=e,i=Object.keys(e),s=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return s}function P1(){return P1=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},P1.apply(null,arguments)}function I$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function e2e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I$(Object(n),!0).forEach(function(r){t2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t2e(t,e,n){return(e=n2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n2e(t){var e=r2e(t,"string");return typeof e=="symbol"?e:e+""}function r2e(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 Zo=32,i2e={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function a2e(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Zo/2,s=Zo/6,o=Zo/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return w.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Zo,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
  8068. A`).concat(s,",").concat(s,",0,1,1,").concat(2*o,",").concat(i,`
  8069. H`).concat(Zo,"M").concat(2*o,",").concat(i,`
  8070. A`).concat(s,",").concat(s,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(Zo/8,"h").concat(Zo,"v").concat(Zo*3/4,"h").concat(-Zo,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=e2e({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(J4,{fill:l,cx:i,cy:i,size:Zo,sizeType:"diameter",type:c})}function s2e(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:o}=t,l={x:0,y:0,width:Zo,height:Zo},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,h)=>{var p=d.formatter||i,m=ir({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?s:d.color,y=p?p(d.value,d,h):d.value;return w.createElement("li",P1({className:m,style:c,key:"legend-item-".concat(h)},nv(t,d,h)),w.createElement(q4,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},w.createElement(a2e,{data:d,iconType:o,inactiveColor:s})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var o2e=t=>{var e=bi(t,i2e),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var s={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return w.createElement("ul",{className:"recharts-default-legend",style:s},w.createElement(s2e,P1({},e,{payload:n})))},tT={},nT={},z$;function l2e(){return z$||(z$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let s=0;s<n.length;s++){const o=n[s],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(nT)),nT}var rT={},U$;function cY(){return U$||(U$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(rT)),rT}var iT={},aT={},sT={},B$;function c2e(){return B$||(B$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(sT)),sT}var $$;function tL(){return $$||($$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=c2e();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(aT)),aT}var oT={},H$;function u2e(){return H$||(H$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(oT)),oT}var V$;function d2e(){return V$||(V$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tL(),n=u2e();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(iT)),iT}var lT={},cT={},G$;function h2e(){return G$||(G$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Z4();function n(r){return function(i){return e.get(i,r)}}t.property=n})(cT)),cT}var uT={},dT={},hT={},fT={},q$;function uY(){return q$||(q$=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})(fT)),fT}var mT={},W$;function dY(){return W$||(W$=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})(mT)),mT}var pT={},K$;function hY(){return K$||(K$=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})(pT)),pT}var X$;function f2e(){return X$||(X$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uY(),n=dY(),r=hY();function i(d,h,p){return typeof p!="function"?i(d,h,()=>{}):s(d,h,function m(x,y,b,v,S,k){const E=p(x,y,b,v,S,k);return E!==void 0?!!E:s(x,y,m,k)},new Map)}function s(d,h,p,m){if(h===d)return!0;switch(typeof h){case"object":return o(d,h,p,m);case"function":return Object.keys(h).length>0?s(d,{...h},p,m):r.eq(d,h);default:return e.isObject(d)?typeof h=="string"?h==="":!0:r.eq(d,h)}}function o(d,h,p,m){if(h==null)return!0;if(Array.isArray(h))return c(d,h,p,m);if(h instanceof Map)return l(d,h,p,m);if(h instanceof Set)return u(d,h,p,m);const x=Object.keys(h);if(d==null)return x.length===0;if(x.length===0)return!0;if(m?.has(h))return m.get(h)===d;m?.set(h,d);try{for(let y=0;y<x.length;y++){const b=x[y];if(!n.isPrimitive(d)&&!(b in d)||h[b]===void 0&&d[b]!==void 0||h[b]===null&&d[b]!==null||!p(d[b],h[b],b,d,h,m))return!1}return!0}finally{m?.delete(h)}}function l(d,h,p,m){if(h.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,y]of h.entries()){const b=d.get(x);if(p(b,y,x,d,h,m)===!1)return!1}return!0}function c(d,h,p,m){if(h.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let y=0;y<h.length;y++){const b=h[y];let v=!1;for(let S=0;S<d.length;S++){if(x.has(S))continue;const k=d[S];let E=!1;if(p(k,b,y,d,h,m)&&(E=!0),E){x.add(S),v=!0;break}}if(!v)return!1}return!0}function u(d,h,p,m){return h.size===0?!0:d instanceof Set?c([...d],[...h],p,m):!1}t.isMatchWith=i,t.isSetMatch=u})(hT)),hT}var Y$;function fY(){return Y$||(Y$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=f2e();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(dT)),dT}var gT={},bT={},xT={},Q$;function m2e(){return Q$||(Q$=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})(xT)),xT}var yT={},Z$;function mY(){return Z$||(Z$=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})(yT)),yT}var vT={},J$;function pY(){return J$||(J$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",s="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",h="[object Function]",p="[object ArrayBuffer]",m="[object Object]",x="[object Error]",y="[object DataView]",b="[object Uint8Array]",v="[object Uint8ClampedArray]",S="[object Uint16Array]",k="[object Uint32Array]",E="[object BigUint64Array]",N="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",P="[object BigInt64Array]",T="[object Float32Array]",j="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=p,t.arrayTag=d,t.bigInt64ArrayTag=P,t.bigUint64ArrayTag=E,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=T,t.float64ArrayTag=j,t.functionTag=h,t.int16ArrayTag=A,t.int32ArrayTag=M,t.int8ArrayTag=N,t.mapTag=c,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=S,t.uint32ArrayTag=k,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=v})(vT)),vT}var wT={},eH;function p2e(){return eH||(eH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(wT)),wT}var tH;function gY(){return tH||(tH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=m2e(),n=mY(),r=pY(),i=dY(),s=p2e();function o(d,h){return l(d,void 0,d,new Map,h)}function l(d,h,p,m=new Map,x=void 0){const y=x?.(d,h,p,m);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const b=new Array(d.length);m.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,p,m,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;m.set(d,b);for(const[v,S]of d)b.set(v,l(S,v,p,m,x));return b}if(d instanceof Set){const b=new Set;m.set(d,b);for(const v of d)b.add(l(v,void 0,p,m,x));return b}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const b=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,p,m,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 m.set(d,b),c(b,d,p,m,x),b}if(typeof File<"u"&&d instanceof File){const b=new File([d],d.name,{type:d.type});return m.set(d,b),c(b,d,p,m,x),b}if(typeof Blob<"u"&&d instanceof Blob){const b=new Blob([d],{type:d.type});return m.set(d,b),c(b,d,p,m,x),b}if(d instanceof Error){const b=new d.constructor;return m.set(d,b),b.message=d.message,b.name=d.name,b.stack=d.stack,b.cause=d.cause,c(b,d,p,m,x),b}if(d instanceof Boolean){const b=new Boolean(d.valueOf());return m.set(d,b),c(b,d,p,m,x),b}if(d instanceof Number){const b=new Number(d.valueOf());return m.set(d,b),c(b,d,p,m,x),b}if(d instanceof String){const b=new String(d.valueOf());return m.set(d,b),c(b,d,p,m,x),b}if(typeof d=="object"&&u(d)){const b=Object.create(Object.getPrototypeOf(d));return m.set(d,b),c(b,d,p,m,x),b}return d}function c(d,h,p=d,m,x){const y=[...Object.keys(h),...e.getSymbols(h)];for(let b=0;b<y.length;b++){const v=y[b],S=Object.getOwnPropertyDescriptor(d,v);(S==null||S.writable)&&(d[v]=l(h[v],v,p,m,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})(bT)),bT}var nH;function g2e(){return nH||(nH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gY();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(gT)),gT}var rH;function b2e(){return rH||(rH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fY(),n=g2e();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(uT)),uT}var _T={},ST={},NT={},iH;function x2e(){return iH||(iH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gY(),n=pY();function r(i,s){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=s?.(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 h=new i.constructor(i?.valueOf());return e.copyProperties(h,i),h}case n.argumentsTag:{const h={};return e.copyProperties(h,i),h.length=i.length,h[Symbol.iterator]=i[Symbol.iterator],h}default:return}})}t.cloneDeepWith=r})(NT)),NT}var aH;function y2e(){return aH||(aH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=x2e();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(ST)),ST}var kT={},MT={},sH;function bY(){return sH||(sH=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})(MT)),MT}var CT={},oH;function v2e(){return oH||(oH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mY();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(CT)),CT}var lH;function w2e(){return lH||(lH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iY(),n=bY(),r=v2e(),i=Q4();function s(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 h=c[d];if((u==null||!Object.hasOwn(u,h))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(h)&&h<u.length))return!1;u=u[h]}return!0}t.has=s})(kT)),kT}var cH;function _2e(){return cH||(cH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fY(),n=Y4(),r=y2e(),i=Z4(),s=w2e();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?s.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(_T)),_T}var uH;function S2e(){return uH||(uH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cY(),n=h2e(),r=b2e(),i=_2e();function s(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=s})(lT)),lT}var dH;function N2e(){return dH||(dH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=l2e(),n=cY(),r=d2e(),i=S2e();function s(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=s})(tT)),tT}var ET,hH;function k2e(){return hH||(hH=1,ET=N2e().uniqBy),ET}var M2e=k2e();const fH=wl(M2e);function xY(t,e,n){return e===!0?fH(t,n):typeof e=="function"?fH(t,e):t}var AT={exports:{}},TT={};var mH;function C2e(){if(mH)return TT;mH=1;var t=Cb(),e=cW();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,s=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return TT.useSyncExternalStoreWithSelector=function(u,d,h,p,m){var x=s(null);if(x.current===null){var y={hasValue:!1,value:null};x.current=y}else y=x.current;x=l(function(){function v(A){if(!S){if(S=!0,k=A,A=p(A),m!==void 0&&y.hasValue){var M=y.value;if(m(M,A))return E=M}return E=A}if(M=E,r(k,A))return M;var P=p(A);return m!==void 0&&m(M,P)?(k=A,M):(k=A,E=P)}var S=!1,k,E,N=h===void 0?null:h;return[function(){return v(d())},N===null?void 0:function(){return v(N())}]},[d,h,p,m]);var b=i(u,x[0],x[1]);return o(function(){y.hasValue=!0,y.value=b},[b]),c(b),b},TT}var pH;function E2e(){return pH||(pH=1,AT.exports=C2e()),AT.exports}var yY=E2e(),nL=w.createContext(null),A2e=t=>t,$r=()=>{var t=w.useContext(nL);return t?t.store.dispatch:A2e},VS=()=>{},T2e=()=>VS,j2e=(t,e)=>t===e;function zt(t){var e=w.useContext(nL);return yY.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:T2e,e?e.store.getState:VS,e?e.store.getState:VS,e?t:VS,j2e)}function P2e(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function D2e(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function R2e(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 gH=t=>Array.isArray(t)?t:[t];function L2e(t){const e=Array.isArray(t[0])?t[0]:t;return R2e(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function O2e(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var F2e=class{constructor(t){this.value=t}deref(){return this.value}},I2e=typeof WeakRef<"u"?WeakRef:F2e,z2e=0,bH=1;function Z_(){return{s:z2e,v:void 0,o:null,p:null}}function vY(t,e={}){let n=Z_();const{resultEqualityCheck:r}=e;let i,s=0;function o(){let l=n;const{length:c}=arguments;for(let h=0,p=c;h<p;h++){const m=arguments[h];if(typeof m=="function"||typeof m=="object"&&m!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const y=x.get(m);y===void 0?(l=Z_(),x.set(m,l)):l=y}else{let x=l.p;x===null&&(l.p=x=new Map);const y=x.get(m);y===void 0?(l=Z_(),x.set(m,l)):l=y}}const u=l;let d;if(l.s===bH)d=l.v;else if(d=t.apply(null,arguments),s++,r){const h=i?.deref?.()??i;h!=null&&r(h,d)&&(d=h,s!==0&&s--),i=typeof d=="object"&&d!==null||typeof d=="function"?new I2e(d):d}return u.s=bH,u.v=d,d}return o.clearCache=()=>{n=Z_(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function U2e(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),P2e(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:h,memoizeOptions:p=[],argsMemoize:m=vY,argsMemoizeOptions:x=[]}=d,y=gH(p),b=gH(x),v=L2e(i),S=h(function(){return s++,u.apply(null,arguments)},...y),k=m(function(){o++;const N=O2e(v,arguments);return l=S.apply(null,N),l},...b);return Object.assign(k,{resultFunc:u,memoizedResultFunc:S,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:h,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var lt=U2e(vY),B2e=Object.assign((t,e=lt)=>{D2e(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(s=>t[s]);return e(r,(...s)=>s.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>B2e}),jT={},PT={},DT={},xH;function $2e(){return xH||(xH=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,s)=>{if(r!==i){const o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return s==="desc"?1:-1;if(r>i)return s==="desc"?-1:1}return s==="desc"?l-o:o-l}return 0};t.compareValues=n})(DT)),DT}var RT={},LT={},yH;function wY(){return yH||(yH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(LT)),LT}var vH;function H2e(){return vH||(vH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wY(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,o){return Array.isArray(s)?!1:typeof s=="number"||typeof s=="boolean"||s==null||e.isSymbol(s)?!0:typeof s=="string"&&(r.test(s)||!n.test(s))||o!=null&&Object.hasOwn(o,s)}t.isKey=i})(RT)),RT}var wH;function V2e(){return wH||(wH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$2e(),n=H2e(),r=Q4();function i(s,o,l,c){if(s==null)return[];l=c?void 0:l,Array.isArray(s)||(s=Object.values(s)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(m=>String(m));const u=(m,x)=>{let y=m;for(let b=0;b<x.length&&y!=null;++b)y=y[x[b]];return y},d=(m,x)=>x==null||m==null?x:typeof m=="object"&&"key"in m?Object.hasOwn(x,m.key)?x[m.key]:u(x,m.path):typeof m=="function"?m(x):Array.isArray(m)?u(x,m):typeof x=="object"?x[m]:x,h=o.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return s.map(m=>({original:m,criteria:h.map(x=>d(x,m))})).slice().sort((m,x)=>{for(let y=0;y<h.length;y++){const b=e.compareValues(m.criteria[y],x.criteria[y],l[y]);if(b!==0)return b}return 0}).map(m=>m.original)}t.orderBy=i})(PT)),PT}var OT={},_H;function G2e(){return _H||(_H=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],s=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<s?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(OT)),OT}var FT={},SH;function _Y(){return SH||(SH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bY(),n=tL(),r=uY(),i=hY();function s(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=s})(FT)),FT}var NH;function q2e(){return NH||(NH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=V2e(),n=G2e(),r=_Y();function i(s,...o){const l=o.length;return l>1&&r.isIterateeCall(s,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(s,n.flatten(o),["asc"])}t.sortBy=i})(jT)),jT}var IT,kH;function W2e(){return kH||(kH=1,IT=q2e().sortBy),IT}var K2e=W2e();const eM=wl(K2e);var SY=t=>t.legend.settings,X2e=t=>t.legend.size,Y2e=t=>t.legend.payload,Q2e=lt([Y2e,SY],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?eM(r,n):r});function Z2e(){return zt(Q2e)}var J_=1;function NY(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=w.useState({height:0,left:0,top:0,width:0}),r=w.useCallback(i=>{if(i!=null){var s=i.getBoundingClientRect(),o={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(o.height-e.height)>J_||Math.abs(o.left-e.left)>J_||Math.abs(o.top-e.top)>J_||Math.abs(o.width-e.width)>J_)&&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 qa(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 J2e=typeof Symbol=="function"&&Symbol.observable||"@@observable",MH=J2e,zT=()=>Math.random().toString(36).substring(7).split("").join("."),eEe={INIT:`@@redux/INIT${zT()}`,REPLACE:`@@redux/REPLACE${zT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${zT()}`},D1=eEe;function rL(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 kY(t,e,n){if(typeof t!="function")throw new Error(qa(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(qa(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(qa(1));return n(kY)(t,e)}let r=t,i=e,s=new Map,o=s,l=0,c=!1;function u(){o===s&&(o=new Map,s.forEach((b,v)=>{o.set(v,b)}))}function d(){if(c)throw new Error(qa(3));return i}function h(b){if(typeof b!="function")throw new Error(qa(4));if(c)throw new Error(qa(5));let v=!0;u();const S=l++;return o.set(S,b),function(){if(v){if(c)throw new Error(qa(6));v=!1,u(),o.delete(S),s=null}}}function p(b){if(!rL(b))throw new Error(qa(7));if(typeof b.type>"u")throw new Error(qa(8));if(typeof b.type!="string")throw new Error(qa(17));if(c)throw new Error(qa(9));try{c=!0,i=r(i,b)}finally{c=!1}return(s=o).forEach(S=>{S()}),b}function m(b){if(typeof b!="function")throw new Error(qa(10));r=b,p({type:D1.REPLACE})}function x(){const b=h;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(qa(11));function S(){const E=v;E.next&&E.next(d())}return S(),{unsubscribe:b(S)}},[MH](){return this}}}return p({type:D1.INIT}),{dispatch:p,subscribe:h,getState:d,replaceReducer:m,[MH]:x}}function tEe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:D1.INIT})>"u")throw new Error(qa(12));if(typeof n(void 0,{type:D1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(qa(13))})}function MY(t){const e=Object.keys(t),n={};for(let s=0;s<e.length;s++){const o=e[s];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{tEe(n)}catch(s){i=s}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const h=r[d],p=n[h],m=o[h],x=p(m,l);if(typeof x>"u")throw l&&l.type,new Error(qa(14));u[h]=x,c=c||x!==m}return c=c||r.length!==Object.keys(o).length,c?u:o}}function R1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function nEe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(qa(15))};const o={getState:i.getState,dispatch:(c,...u)=>s(c,...u)},l=t.map(c=>c(o));return s=R1(...l)(i.dispatch),{...i,dispatch:s}}}function CY(t){return rL(t)&&"type"in t&&typeof t.type=="string"}var EY=Symbol.for("immer-nothing"),CH=Symbol.for("immer-draftable"),Ds=Symbol.for("immer-state");function Ul(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var No=Object,hb=No.getPrototypeOf,L1="constructor",tM="prototype",aD="configurable",O1="enumerable",GS="writable",g0="value",rd=t=>!!t&&!!t[Ds];function Zl(t){return t?AY(t)||nM(t)||!!t[CH]||!!t[L1]?.[CH]||rM(t)||iM(t):!1}var rEe=No[tM][L1].toString(),EH=new WeakMap;function AY(t){if(!t||!iL(t))return!1;const e=hb(t);if(e===null||e===No[tM])return!0;const n=No.hasOwnProperty.call(e,L1)&&e[L1];if(n===Object)return!0;if(!vg(n))return!1;let r=EH.get(n);return r===void 0&&(r=Function.toString.call(n),EH.set(n,r)),r===rEe}function rv(t,e,n=!0){iv(t)===0?(n?Reflect.ownKeys(t):No.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function iv(t){const e=t[Ds];return e?e.type_:nM(t)?1:rM(t)?2:iM(t)?3:0}var AH=(t,e,n=iv(t))=>n===2?t.has(e):No[tM].hasOwnProperty.call(t,e),sD=(t,e,n=iv(t))=>n===2?t.get(e):t[e],F1=(t,e,n,r=iv(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function iEe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var nM=Array.isArray,rM=t=>t instanceof Map,iM=t=>t instanceof Set,iL=t=>typeof t=="object",vg=t=>typeof t=="function",UT=t=>typeof t=="boolean",Cu=t=>t.copy_||t.base_,aL=t=>t.modified_?t.copy_:t.base_;function oD(t,e){if(rM(t))return new Map(t);if(iM(t))return new Set(t);if(nM(t))return Array[tM].slice.call(t);const n=AY(t);if(e===!0||e==="class_only"&&!n){const r=No.getOwnPropertyDescriptors(t);delete r[Ds];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l[GS]===!1&&(l[GS]=!0,l[aD]=!0),(l.get||l.set)&&(r[o]={[aD]:!0,[GS]:!0,[O1]:l[O1],[g0]:t[o]})}return No.create(hb(t),r)}else{const r=hb(t);if(r!==null&&n)return{...t};const i=No.create(r);return No.assign(i,t)}}function sL(t,e=!1){return aM(t)||rd(t)||!Zl(t)||(iv(t)>1&&No.defineProperties(t,{set:eS,add:eS,clear:eS,delete:eS}),No.freeze(t),e&&rv(t,(n,r)=>{sL(r,!0)},!1)),t}function aEe(){Ul(2)}var eS={[g0]:aEe};function aM(t){return t===null||!iL(t)?!0:No.isFrozen(t)}var I1="MapSet",lD="Patches",TY={};function fb(t){const e=TY[t];return e||Ul(0,t),e}var sEe=t=>!!TY[t],b0,jY=()=>b0,oEe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:sEe(I1)?fb(I1):void 0});function TH(t,e){e&&(t.patchPlugin_=fb(lD),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function cD(t){uD(t),t.drafts_.forEach(lEe),t.drafts_=null}function uD(t){t===b0&&(b0=t.parent_)}var jH=t=>b0=oEe(b0,t);function lEe(t){const e=t[Ds];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function PH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ds].modified_&&(cD(e),Ul(4)),Zl(t)&&(t=DH(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ds].base_,t,e)}else t=DH(e,n);return cEe(e,t,!0),cD(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==EY?t:void 0}function DH(t,e){if(aM(e))return e;const n=e[Ds];if(!n)return oL(e,t.handledSet_,t);if(!sM(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);RY(n,t)}return n.copy_}function cEe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&sL(e,n)}function PY(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var sM=(t,e)=>t.scope_===e,uEe=[];function DY(t,e,n,r){const i=Cu(t),s=t.type_;if(r!==void 0&&sD(i,r,s)===e){F1(i,r,n,s);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;rv(i,(c,u)=>{if(rd(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??uEe;for(const l of o)F1(i,l,n,s)}function dEe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!sM(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const o=aL(s);DY(t,s.draft_??s,o,n),RY(s,i)})}function RY(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)}PY(t)}}function hEe(t,e,n){const{scope_:r}=t;if(rd(n)){const i=n[Ds];sM(i,r)&&i.callbacks_.push(function(){qS(t);const o=aL(i);DY(t,n,o,e)})}else Zl(n)&&t.callbacks_.push(function(){const s=Cu(t);sD(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&oL(sD(t.copy_,e,t.type_),r.handledSet_,r)})}function oL(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||rd(t)||e.has(t)||!Zl(t)||aM(t)||(e.add(t),rv(t,(r,i)=>{if(rd(i)){const s=i[Ds];if(sM(s,n)){const o=aL(s);F1(t,r,o,t.type_),PY(s)}}else Zl(i)&&oL(i,e,n)})),t}function fEe(t,e){const n=nM(t),r={type_:n?1:0,scope_:e?e.scope_:jY(),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,s=lL;n&&(i=[r],s=x0);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,[l,r]}var lL={get(t,e){if(e===Ds)return t;const n=Cu(t);if(!AH(n,e,t.type_))return mEe(t,n,e);const r=n[e];if(t.finalized_||!Zl(r))return r;if(r===BT(t.base_,e)){qS(t);const i=t.type_===1?+e:e,s=hD(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in Cu(t)},ownKeys(t){return Reflect.ownKeys(Cu(t))},set(t,e,n){const r=LY(Cu(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=BT(Cu(t),e),s=i?.[Ds];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(iEe(n,i)&&(n!==void 0||AH(t.base_,e,t.type_)))return!0;qS(t),dD(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),hEe(t,e,n)),!0},deleteProperty(t,e){return qS(t),BT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),dD(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Cu(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[GS]:!0,[aD]:t.type_!==1||e!=="length",[O1]:r[O1],[g0]:n[e]}},defineProperty(){Ul(11)},getPrototypeOf(t){return hb(t.base_)},setPrototypeOf(){Ul(12)}},x0={};rv(lL,(t,e)=>{x0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});x0.deleteProperty=function(t,e){return x0.set.call(this,t,e,void 0)};x0.set=function(t,e,n){return lL.set.call(this,t[0],e,n,t[0])};function BT(t,e){const n=t[Ds];return(n?Cu(n):t)[e]}function mEe(t,e,n){const r=LY(e,n);return r?g0 in r?r[g0]:r.get?.call(t.draft_):void 0}function LY(t,e){if(!(e in t))return;let n=hb(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=hb(n)}}function dD(t){t.modified_||(t.modified_=!0,t.parent_&&dD(t.parent_))}function qS(t){t.copy_||(t.assigned_=new Map,t.copy_=oD(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var pEe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(vg(n)&&!vg(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,h=>r.call(this,h,...d))}}vg(r)||Ul(6),i!==void 0&&!vg(i)&&Ul(7);let s;if(Zl(n)){const o=jH(this),l=hD(o,n,void 0);let c=!0;try{s=r(l),c=!1}finally{c?cD(o):uD(o)}return TH(o,i),PH(s,o)}else if(!n||!iL(n)){if(s=r(n),s===void 0&&(s=n),s===EY&&(s=void 0),this.autoFreeze_&&sL(s,!0),i){const o=[],l=[];fb(lD).generateReplacementPatches_(n,s,{patches_:o,inversePatches_:l}),i(o,l)}return s}else Ul(1,n)},this.produceWithPatches=(n,r)=>{if(vg(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,s;return[this.produce(n,r,(l,c)=>{i=l,s=c}),i,s]},UT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),UT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),UT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Zl(e)||Ul(8),rd(e)&&(e=Wl(e));const n=jH(this),r=hD(n,e,void 0);return r[Ds].isManual_=!0,uD(n),r}finishDraft(e,n){const r=e&&e[Ds];(!r||!r.isManual_)&&Ul(9);const{scope_:i}=r;return TH(i,n),PH(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 s=n[r];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}r>-1&&(n=n.slice(r+1));const i=fb(lD).applyPatches_;return rd(e)?i(e,n):this.produce(e,s=>i(s,n))}};function hD(t,e,n,r){const[i,s]=rM(e)?fb(I1).proxyMap_(e,n):iM(e)?fb(I1).proxySet_(e,n):fEe(e,n);return(n?.scope_??jY()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?dEe(n,s,r):s.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:u}=c;s.modified_&&u&&u.generatePatches_(s,[],c)}),i}function Wl(t){return rd(t)||Ul(10,t),OY(t)}function OY(t){if(!Zl(t)||aM(t))return t;const e=t[Ds];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=oD(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=oD(t,!0);return rv(n,(i,s)=>{F1(n,i,OY(s))},r),e&&(e.finalized_=!1),n}var gEe=new pEe,FY=gEe.produce;function IY(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var bEe=IY(),xEe=IY,yEe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?R1:R1.apply(null,arguments)};function yl(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Eo(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=>CY(r)&&r.type===t,n}var zY=class yy extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,yy.prototype)}static get[Symbol.species](){return yy}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new yy(...e[0].concat(this)):new yy(...e.concat(this))}};function RH(t){return Zl(t)?FY(t,()=>{}):t}function tS(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function vEe(t){return typeof t=="boolean"}var wEe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let o=new zY;return n&&(vEe(n)?o.push(bEe):o.push(xEe(n.extraArgument))),o},UY="RTK_autoBatch",li=()=>t=>({payload:t,meta:{[UY]:!0}}),LH=t=>e=>{setTimeout(e,t)},BY=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,s=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:LH(10):t.type==="callback"?t.queueNotification:LH(t.timeout),u=()=>{o=!1,s&&(s=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const h=()=>i&&d(),p=r.subscribe(h);return l.add(d),()=>{p(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[UY],s=!i,s&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},_Ee=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new zY(t);return r&&i.push(BY(typeof r=="object"?r:void 0)),i};function SEe(t){const e=wEe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(rL(n))l=MY(n);else throw new Error(Eo(1));let c;typeof r=="function"?c=r(e):c=e();let u=R1;i&&(u=yEe({trace:!1,...typeof i=="object"&&i}));const d=nEe(...c),h=_Ee(d);let p=typeof o=="function"?o(h):h();const m=u(...p);return kY(l,s,m)}function $Y(t){const e={},n=[];let r;const i={addCase(s,o){const l=typeof s=="string"?s:s.type;if(!l)throw new Error(Eo(28));if(l in e)throw new Error(Eo(29));return e[l]=o,i},addAsyncThunk(s,o){return o.pending&&(e[s.pending.type]=o.pending),o.rejected&&(e[s.rejected.type]=o.rejected),o.fulfilled&&(e[s.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:s.settled,reducer:o.settled}),i},addMatcher(s,o){return n.push({matcher:s,reducer:o}),i},addDefaultCase(s){return r=s,i}};return t(i),[e,n,r]}function NEe(t){return typeof t=="function"}function kEe(t,e){let[n,r,i]=$Y(e),s;if(NEe(t))s=()=>RH(t());else{const l=RH(t);s=()=>l}function o(l=s(),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,h)=>{if(h)if(rd(d)){const m=h(d,c);return m===void 0?d:m}else{if(Zl(d))return FY(d,p=>h(p,c));{const p=h(d,c);if(p===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return d},l)}return o.getInitialState=s,o}var MEe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",CEe=(t=21)=>{let e="",n=t;for(;n--;)e+=MEe[Math.random()*64|0];return e},EEe=Symbol.for("rtk-slice-createasyncthunk");function AEe(t,e){return`${t}/${e}`}function TEe({creators:t}={}){const e=t?.asyncThunk?.[EEe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(Eo(11));const o=(typeof r.reducers=="function"?r.reducers(PEe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(k,E){const N=typeof k=="string"?k:k.type;if(!N)throw new Error(Eo(12));if(N in c.sliceCaseReducersByType)throw new Error(Eo(13));return c.sliceCaseReducersByType[N]=E,u},addMatcher(k,E){return c.sliceMatchers.push({matcher:k,reducer:E}),u},exposeAction(k,E){return c.actionCreators[k]=E,u},exposeCaseReducer(k,E){return c.sliceCaseReducersByName[k]=E,u}};l.forEach(k=>{const E=o[k],N={reducerName:k,type:AEe(i,k),createNotation:typeof r.reducers=="function"};REe(E)?OEe(N,E,u,e):DEe(N,E,u)});function d(){const[k={},E=[],N=void 0]=typeof r.extraReducers=="function"?$Y(r.extraReducers):[r.extraReducers],A={...k,...c.sliceCaseReducersByType};return kEe(r.initialState,M=>{for(let P in A)M.addCase(P,A[P]);for(let P of c.sliceMatchers)M.addMatcher(P.matcher,P.reducer);for(let P of E)M.addMatcher(P.matcher,P.reducer);N&&M.addDefaultCase(N)})}const h=k=>k,p=new Map,m=new WeakMap;let x;function y(k,E){return x||(x=d()),x(k,E)}function b(){return x||(x=d()),x.getInitialState()}function v(k,E=!1){function N(M){let P=M[k];return typeof P>"u"&&E&&(P=tS(m,N,b)),P}function A(M=h){const P=tS(p,E,()=>new WeakMap);return tS(P,M,()=>{const T={};for(const[j,z]of Object.entries(r.selectors??{}))T[j]=jEe(z,M,()=>tS(m,M,b),E);return T})}return{reducerPath:k,getSelectors:A,get selectors(){return A(N)},selectSlice:N}}const S={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:b,...v(s),injectInto(k,{reducerPath:E,...N}={}){const A=E??s;return k.inject({reducerPath:A,reducer:y},N),{...S,...v(A,!0)}}};return S}}function jEe(t,e,n,r){function i(s,...o){let l=e(s);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var ro=TEe();function PEe(){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 DEe({type:t,reducerName:e,createNotation:n},r,i){let s,o;if("reducer"in r){if(n&&!LEe(r))throw new Error(Eo(17));s=r.reducer,o=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,o?yl(t,o):yl(t))}function REe(t){return t._reducerDefinitionType==="asyncThunk"}function LEe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function OEe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Eo(18));const{payloadCreator:s,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,h=i(t,s,d);r.exposeAction(e,h),o&&r.addCase(h.fulfilled,o),l&&r.addCase(h.pending,l),c&&r.addCase(h.rejected,c),u&&r.addMatcher(h.settled,u),r.exposeCaseReducer(e,{fulfilled:o||nS,pending:l||nS,rejected:c||nS,settled:u||nS})}function nS(){}var FEe="task",HY="listener",VY="completed",cL="cancelled",IEe=`task-${cL}`,zEe=`task-${VY}`,fD=`${HY}-${cL}`,UEe=`${HY}-${VY}`,oM=class{constructor(t){this.code=t,this.message=`${FEe} ${cL} (reason: ${t})`}name="TaskAbortError";message},uL=(t,e)=>{if(typeof t!="function")throw new TypeError(Eo(32))},z1=()=>{},GY=(t,e=z1)=>(t.catch(e),t),qY=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),cm=(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))},um=t=>{if(t.aborted){const{reason:e}=t;throw new oM(e)}};function WY(t,e){let n=z1;return new Promise((r,i)=>{const s=()=>i(new oM(t.reason));if(t.aborted){s();return}n=qY(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=z1})}var BEe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof oM?"cancelled":"rejected",error:n}}finally{e?.()}},U1=t=>e=>GY(WY(t,e).then(n=>(um(t),n))),KY=t=>{const e=U1(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Hg}=Object,OH={},lM="listenerMiddleware",$Ee=(t,e)=>{const n=r=>qY(t,()=>cm(r,t.reason));return(r,i)=>{uL(r);const s=new AbortController;n(s);const o=BEe(async()=>{um(t),um(s.signal);const l=await r({pause:U1(s.signal),delay:KY(s.signal),signal:s.signal});return um(s.signal),l},()=>cm(s,zEe));return i?.autoJoin&&e.push(o.catch(z1)),{result:U1(t)(o),cancel(){cm(s,IEe)}}}},HEe=(t,e)=>{const n=async(r,i)=>{um(e);let s=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(h,p)=>{p.unsubscribe(),c([h,p.getState(),p.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await WY(e,Promise.race(l));return um(e),c}finally{s()}};return(r,i)=>GY(n(r,i))},XY=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=yl(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Eo(21));return uL(s),{predicate:i,type:e,effect:s}},YY=Hg(t=>{const{type:e,predicate:n,effect:r}=XY(t);return{id:CEe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Eo(22))}}},{withTypes:()=>YY}),FH=(t,e)=>{const{type:n,effect:r,predicate:i}=XY(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},mD=t=>{t.pending.forEach(e=>{cm(e,fD)})},VEe=(t,e)=>()=>{for(const n of e.keys())mD(n);t.clear()},IH=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},QY=Hg(yl(`${lM}/add`),{withTypes:()=>QY}),GEe=yl(`${lM}/removeAll`),ZY=Hg(yl(`${lM}/remove`),{withTypes:()=>ZY}),qEe=(...t)=>{console.error(`${lM}/error`,...t)},av=(t={})=>{const e=new Map,n=new Map,r=m=>{const x=n.get(m)??0;n.set(m,x+1)},i=m=>{const x=n.get(m)??1;x===1?n.delete(m):n.set(m,x-1)},{extra:s,onError:o=qEe}=t;uL(o);const l=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&mD(m)}),c=m=>{const x=FH(e,m)??YY(m);return l(x)};Hg(c,{withTypes:()=>c});const u=m=>{const x=FH(e,m);return x&&(x.unsubscribe(),m.cancelActive&&mD(x)),!!x};Hg(u,{withTypes:()=>u});const d=async(m,x,y,b)=>{const v=new AbortController,S=HEe(c,v.signal),k=[];try{m.pending.add(v),r(m),await Promise.resolve(m.effect(x,Hg({},y,{getOriginalState:b,condition:(E,N)=>S(E,N).then(Boolean),take:S,delay:KY(v.signal),pause:U1(v.signal),extra:s,signal:v.signal,fork:$Ee(v.signal,k),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((E,N,A)=>{E!==v&&(cm(E,fD),A.delete(E))})},cancel:()=>{cm(v,fD),m.pending.delete(v)},throwIfCancelled:()=>{um(v.signal)}})))}catch(E){E instanceof oM||IH(o,E,{raisedBy:"effect"})}finally{await Promise.all(k),cm(v,UEe),i(m),m.pending.delete(v)}},h=VEe(e,n);return{middleware:m=>x=>y=>{if(!CY(y))return x(y);if(QY.match(y))return c(y.payload);if(GEe.match(y)){h();return}if(ZY.match(y))return u(y.payload);let b=m.getState();const v=()=>{if(b===OH)throw new Error(Eo(23));return b};let S;try{if(S=x(y),e.size>0){const k=m.getState(),E=Array.from(e.values());for(const N of E){let A=!1;try{A=N.predicate(y,k,b)}catch(M){A=!1,IH(o,M,{raisedBy:"predicate"})}A&&d(N,y,m,v)}}}finally{b=OH}return S},startListening:c,stopListening:u,clearListeners:h}};function Eo(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 WEe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},JY=ro({name:"chartLayout",initialState:WEe,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,s;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=(s=e.payload.left)!==null&&s!==void 0?s:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:KEe,setLayout:XEe,setChartSize:YEe,setScale:QEe}=JY.actions,ZEe=JY.reducer;function eQ(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function zH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ag(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zH(Object(n),!0).forEach(function(r){JEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JEe(t,e,n){return(e=eAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eAe(t){var e=tAe(t,"string");return typeof e=="symbol"?e:e+""}function tAe(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 _r(t,e,n){return ii(t)||ii(e)?n:xl(e)?Dm(t,e,n):typeof e=="function"?e(t):n}var nAe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:s,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&s!=="center"&&Ht(t[s]))return Ag(Ag({},t),{},{[s]:t[s]+(r||0)});if((l==="horizontal"||l==="vertical"&&s==="center")&&o!=="middle"&&Ht(t[o]))return Ag(Ag({},t),{},{[o]:t[o]+(i||0)})}return t},Bc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",tQ=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,s,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(s=!0),l.coordinate));return i||o.push(e),s||o.push(n),o},nQ=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:h,niceTicks:p,axisType:m}=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=m==="angleAxis"&&s&&s.length>=2?Pa(s[0]-s[1])*2*y:y,h||p){var b=(h||p||[]).map((v,S)=>{var k=r?r.indexOf(v):v;return{coordinate:o(k)+y,value:v,offset:y,index:S}});return b.filter(v=>!no(v.coordinate))}return c&&u?u.map((v,S)=>({coordinate:o(v)+y,value:v,index:S,offset:y})):o.ticks&&d!=null?o.ticks(d).map((v,S)=>({coordinate:o(v)+y,value:v,offset:y,index:S})):o.domain().map((v,S)=>({coordinate:o(v)+y,value:r?r[v]:v,index:S,offset:y}))},UH=1e-4,rAe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-UH,s=Math.max(r[0],r[1])+UH,o=t(e[0]),l=t(e[n-1]);(o<i||o>s||l<i||l>s)&&t.domain([e[0],e[n-1]])}},iAe=(t,e)=>{if(!e||e.length!==2||!Ht(e[0])||!Ht(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(!Ht(t[0])||t[0]<n)&&(i[0]=n),(!Ht(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},aAe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0,o=0;o<e;++o){var l=no(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]=s,t[o][n][1]=s+l,s=t[o][n][1])}},sAe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0;s<e;++s){var o=no(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},oAe={sign:aAe,expand:TCe,none:db,silhouette:jCe,wiggle:PCe,positive:sAe},lAe=(t,e,n)=>{var r=oAe[n],i=ACe().keys(e).value((s,o)=>Number(_r(s,o,0))).order(rD).offset(r);return i(t)};function rQ(t){return t==null?void 0:String(t)}function B1(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!ii(i[e.dataKey])){var l=sY(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var c=_r(i,ii(o)?e.dataKey:o);return ii(c)?null:e.scale(c)}var BH=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:s,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=_r(s,e.dataKey,e.scale.domain()[o]);return ii(l)?null:e.scale(l)-i/2+r},cAe=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]},uAe=t=>{var e=t.flat(2).filter(Ht);return[Math.min(...e),Math.max(...e)]},dAe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],hAe=(t,e,n)=>{if(t!=null)return dAe(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:o}=s,l=o.reduce((c,u)=>{var d=eQ(u,e,n),h=uAe(d);return[Math.min(c[0],h[0]),Math.max(c[1],h[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},$H=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,HH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Hh=(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=eM(e,d=>d.coordinate),s=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];s=Math.min((c.coordinate||0)-(u.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function VH(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return Ag(Ag({},e),{},{dataKey:n,payload:r,value:i,name:s})}function Yh(t,e){if(t)return String(t);if(typeof e=="string")return e}var fAe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},mAe=(t,e)=>e==="centric"?t.angle:t.radius,ud=t=>t.layout.width,dd=t=>t.layout.height,pAe=t=>t.layout.scale,iQ=t=>t.layout.margin,cM=lt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),uM=lt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),aQ="data-recharts-item-index",sQ="data-recharts-item-data-key",sv=60;function GH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function rS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GH(Object(n),!0).forEach(function(r){gAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gAe(t,e,n){return(e=bAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bAe(t){var e=xAe(t,"string");return typeof e=="symbol"?e:e+""}function xAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var yAe=t=>t.brush.height;function vAe(t){var e=uM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:sv;return n+i}return n},0)}function wAe(t){var e=uM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:sv;return n+i}return n},0)}function _Ae(t){var e=cM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function SAe(t){var e=cM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var pa=lt([ud,dd,iQ,yAe,vAe,wAe,_Ae,SAe,SY,X2e],(t,e,n,r,i,s,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+s},h={top:(n.top||0)+o,bottom:(n.bottom||0)+l},p=rS(rS({},h),d),m=p.bottom;p.bottom+=r,p=nAe(p,c,u);var x=t-p.left-p.right,y=e-p.top-p.bottom;return rS(rS({brushBottom:m},p),{},{width:Math.max(x,0),height:Math.max(y,0)})}),NAe=lt(pa,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),dL=lt(ud,dd,(t,e)=>({x:0,y:0,width:t,height:e})),kAe=w.createContext(null),ga=()=>w.useContext(kAe)!=null,dM=t=>t.brush,hM=lt([dM,pa,iQ],(t,e,n)=>({height:t.height,x:Ht(t.x)?t.x:e.left,y:Ht(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ht(t.width)?t.width:e.width})),$T={},HT={},VT={},qH;function MAe(){return qH||(qH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:s}={}){let o,l=null;const c=s!=null&&s.includes("leading"),u=s==null||s.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},h=()=>{u&&d(),y()};let p=null;const m=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,h()},r)},x=()=>{p!==null&&(clearTimeout(p),p=null)},y=()=>{x(),o=void 0,l=null},b=()=>{d()},v=function(...S){if(i?.aborted)return;o=this,l=S;const k=p==null;m(),c&&k&&d()};return v.schedule=m,v.cancel=y,v.flush=b,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(VT)),VT}var WH;function CAe(){return WH||(WH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=MAe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:o=!1,trailing:l=!0,maxWait:c}=s,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,h=null;const p=e.debounce(function(...y){d=r.apply(this,y),h=null},i,{edges:u}),m=function(...y){return c!=null&&(h===null&&(h=Date.now()),Date.now()-h>=c)?(d=r.apply(this,y),h=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,y),d)},x=()=>(p.flush(),d);return m.cancel=p.cancel,m.flush=x,m}t.debounce=n})(HT)),HT}var KH;function EAe(){return KH||(KH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CAe();function n(r,i=0,s={}){const{leading:o=!0,trailing:l=!0}=s;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})($T)),$T}var GT,XH;function AAe(){return XH||(XH=1,GT=EAe().throttle),GT}var TAe=AAe();const jAe=wl(TAe);var $1=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];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++]))}},oQ=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:o}=n,l=nd(r)?t:Number(r),c=nd(i)?e:Number(i);return s&&s>0&&(l?c=l/s:c&&(l=c*s),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},PAe={width:0,height:0,overflow:"visible"},DAe={width:0,overflowX:"visible"},RAe={height:0,overflowY:"visible"},LAe={},OAe=t=>{var{width:e,height:n}=t,r=nd(e),i=nd(n);return r&&i?PAe:r?DAe:i?RAe:LAe};function FAe(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i="100%",s="100%"):i===void 0?i=r&&r>0?void 0:"100%":s===void 0&&(s=r&&r>0?void 0:"100%"),{width:i,height:s}}function Sr(t){return Number.isFinite(t)}function Pc(t){return typeof t=="number"&&t>0&&Number.isFinite(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 YH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function QH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YH(Object(n),!0).forEach(function(r){IAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function IAe(t,e,n){return(e=zAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zAe(t){var e=UAe(t,"string");return typeof e=="symbol"?e:e+""}function UAe(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 lQ=w.createContext({width:-1,height:-1});function BAe(t){return Pc(t.width)&&Pc(t.height)}function cQ(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return BAe(i)?w.createElement(lQ.Provider,{value:i},e):null}var hL=()=>w.useContext(lQ),$Ae=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:h,className:p,onResize:m,style:x={}}=t,y=w.useRef(null),b=w.useRef();b.current=m,w.useImperativeHandle(e,()=>y.current);var[v,S]=w.useState({containerWidth:r.width,containerHeight:r.height}),k=w.useCallback((P,T)=>{S(j=>{var z=Math.round(P),F=Math.round(T);return j.containerWidth===z&&j.containerHeight===F?j:{containerWidth:z,containerHeight:F}})},[]);w.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return tv;var P=F=>{var $,{width:D,height:H}=F[0].contentRect;k(D,H),($=b.current)===null||$===void 0||$.call(b,D,H)};d>0&&(P=jAe(P,d,{trailing:!0,leading:!1}));var T=new ResizeObserver(P),{width:j,height:z}=y.current.getBoundingClientRect();return k(j,z),T.observe(y.current),()=>{T.disconnect()}},[k,d]);var{containerWidth:E,containerHeight:N}=v;$1(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:A,calculatedHeight:M}=oQ(E,N,{width:i,height:s,aspect:n,maxHeight:c});return $1(A!=null&&A>0||M!=null&&M>0,`The width(%s) and height(%s) of chart should be greater than 0,
  8071. please check the style of container, or the props width(%s) and height(%s),
  8072. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  8073. height and width.`,A,M,i,s,o,l,n),w.createElement("div",{id:h?"".concat(h):void 0,className:ir("recharts-responsive-container",p),style:QH(QH({},x),{},{width:i,height:s,minWidth:o,minHeight:l,maxHeight:c}),ref:y},w.createElement("div",{style:OAe({width:i,height:s})},w.createElement(cQ,{width:A,height:M},u)))}),WS=w.forwardRef((t,e)=>{var n=hL();if(Pc(n.width)&&Pc(n.height))return t.children;var{width:r,height:i}=FAe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:o}=oQ(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ht(s)&&Ht(o)?w.createElement(cQ,{width:s,height:o},t.children):w.createElement($Ae,pD({},t,{width:r,height:i,ref:e}))});function uQ(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 ov=()=>{var t,e=ga(),n=zt(NAe),r=zt(hM),i=(t=zt(dM))===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}},HAe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},dQ=()=>{var t;return(t=zt(pa))!==null&&t!==void 0?t:HAe},fL=()=>zt(ud),mL=()=>zt(dd),VAe=()=>zt(t=>t.layout.margin),Wn=t=>t.layout.layoutType,Km=()=>zt(Wn),GAe=()=>{var t=Km();if(t==="horizontal"||t==="vertical")return t},qAe=()=>{var t=Km();return t!==void 0},fM=t=>{var e=$r(),n=ga(),{width:r,height:i}=t,s=hL(),o=r,l=i;return s&&(o=s.width>0?s.width:r,l=s.height>0?s.height:i),w.useEffect(()=>{!n&&Pc(o)&&Pc(l)&&e(YEe({width:o,height:l}))},[e,n,o,l]),null},hQ=Symbol.for("immer-nothing"),ZH=Symbol.for("immer-draftable"),Ro=Symbol.for("immer-state");function Bl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var y0=Object.getPrototypeOf;function mb(t){return!!t&&!!t[Ro]}function Rm(t){return t?fQ(t)||Array.isArray(t)||!!t[ZH]||!!t.constructor?.[ZH]||lv(t)||pM(t):!1}var WAe=Object.prototype.constructor.toString(),JH=new WeakMap;function fQ(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=JH.get(n);return r===void 0&&(r=Function.toString.call(n),JH.set(n,r)),r===WAe}function H1(t,e,n=!0){mM(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 mM(t){const e=t[Ro];return e?e.type_:Array.isArray(t)?1:lv(t)?2:pM(t)?3:0}function gD(t,e){return mM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function mQ(t,e,n){const r=mM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function KAe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function lv(t){return t instanceof Map}function pM(t){return t instanceof Set}function Uf(t){return t.copy_||t.base_}function bD(t,e){if(lv(t))return new Map(t);if(pM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=fQ(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Ro];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],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(y0(t),r)}else{const r=y0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function pL(t,e=!1){return gM(t)||mb(t)||!Rm(t)||(mM(t)>1&&Object.defineProperties(t,{set:iS,add:iS,clear:iS,delete:iS}),Object.freeze(t),e&&Object.values(t).forEach(n=>pL(n,!0))),t}function XAe(){Bl(2)}var iS={value:XAe};function gM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var YAe={};function Lm(t){const e=YAe[t];return e||Bl(0,t),e}var v0;function pQ(){return v0}function QAe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function eV(t,e){e&&(Lm("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function xD(t){yD(t),t.drafts_.forEach(ZAe),t.drafts_=null}function yD(t){t===v0&&(v0=t.parent_)}function tV(t){return v0=QAe(v0,t)}function ZAe(t){const e=t[Ro];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function nV(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Ro].modified_&&(xD(e),Bl(4)),Rm(t)&&(t=V1(e,t),e.parent_||G1(e,t)),e.patches_&&Lm("Patches").generateReplacementPatches_(n[Ro].base_,t,e.patches_,e.inversePatches_)):t=V1(e,n,[]),xD(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==hQ?t:void 0}function V1(t,e,n){if(gM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Ro];if(!i)return H1(e,(s,o)=>rV(t,i,e,s,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return G1(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let o=s,l=!1;i.type_===3&&(o=new Set(s),s.clear(),l=!0),H1(o,(c,u)=>rV(t,i,s,c,u,n,l),r),G1(t,s,!1),n&&t.patches_&&Lm("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function rV(t,e,n,r,i,s,o){if(i==null||typeof i!="object"&&!o)return;const l=gM(i);if(!(l&&!o)){if(mb(i)){const c=s&&e&&e.type_!==3&&!gD(e.assigned_,r)?s.concat(r):void 0,u=V1(t,i,c);if(mQ(n,r,u),mb(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Rm(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;V1(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(lv(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&G1(t,i)}}}function G1(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&pL(e,n)}function JAe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:pQ(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=gL;n&&(i=[r],s=w0);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,l}var gL={get(t,e){if(e===Ro)return t;const n=Uf(t);if(!gD(n,e))return eTe(t,n,e);const r=n[e];return t.finalized_||!Rm(r)?r:r===qT(t.base_,e)?(WT(t),t.copy_[e]=wD(r,t)):r},has(t,e){return e in Uf(t)},ownKeys(t){return Reflect.ownKeys(Uf(t))},set(t,e,n){const r=gQ(Uf(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=qT(Uf(t),e),s=i?.[Ro];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(KAe(n,i)&&(n!==void 0||gD(t.base_,e)))return!0;WT(t),vD(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 qT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,WT(t),vD(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Uf(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Bl(11)},getPrototypeOf(t){return y0(t.base_)},setPrototypeOf(){Bl(12)}},w0={};H1(gL,(t,e)=>{w0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});w0.deleteProperty=function(t,e){return w0.set.call(this,t,e,void 0)};w0.set=function(t,e,n){return gL.set.call(this,t[0],e,n,t[0])};function qT(t,e){const n=t[Ro];return(n?Uf(n):t)[e]}function eTe(t,e,n){const r=gQ(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function gQ(t,e){if(!(e in t))return;let n=y0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=y0(n)}}function vD(t){t.modified_||(t.modified_=!0,t.parent_&&vD(t.parent_))}function WT(t){t.copy_||(t.copy_=bD(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var tTe=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 s=n;n=e;const o=this;return function(c=s,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Bl(6),r!==void 0&&typeof r!="function"&&Bl(7);let i;if(Rm(e)){const s=tV(this),o=wD(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?xD(s):yD(s)}return eV(s,r),nV(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===hQ&&(i=void 0),this.autoFreeze_&&pL(i,!0),r){const s=[],o=[];Lm("Patches").generateReplacementPatches_(e,i,s,o),r(s,o)}return i}else Bl(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){Rm(t)||Bl(8),mb(t)&&(t=nTe(t));const e=tV(this),n=wD(t,void 0);return n[Ro].isManual_=!0,yD(e),n}finishDraft(t,e){const n=t&&t[Ro];(!n||!n.isManual_)&&Bl(9);const{scope_:r}=n;return eV(r,e),nV(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=Lm("Patches").applyPatches_;return mb(t)?r(t,e):this.produce(t,i=>r(i,e))}};function wD(t,e){const n=lv(t)?Lm("MapSet").proxyMap_(t,e):pM(t)?Lm("MapSet").proxySet_(t,e):JAe(t,e);return(e?e.scope_:pQ()).drafts_.push(n),n}function nTe(t){return mb(t)||Bl(10,t),bQ(t)}function bQ(t){if(!Rm(t)||gM(t))return t;const e=t[Ro];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=bD(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=bD(t,!0);return H1(n,(i,s)=>{mQ(n,i,bQ(s))},r),e&&(e.finalized_=!1),n}var rTe=new tTe;rTe.produce;var iTe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},xQ=ro({name:"legend",initialState:iTe,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:li()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Wl(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:li()},removeLegendPayload:{reducer(t,e){var n=Wl(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:li()}}}),{setLegendSize:iV,setLegendSettings:aTe,addLegendPayload:yQ,replaceLegendPayload:vQ,removeLegendPayload:wQ}=xQ.actions,sTe=xQ.reducer,oTe=["contextPayload"];function _D(){return _D=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_D.apply(null,arguments)}function aV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aV(Object(n),!0).forEach(function(r){lTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lTe(t,e,n){return(e=cTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cTe(t){var e=uTe(t,"string");return typeof e=="symbol"?e:e+""}function uTe(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 dTe(t,e){if(t==null)return{};var n,r,i=hTe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function hTe(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 fTe(t){return t.value}function mTe(t){var{contextPayload:e}=t,n=dTe(t,oTe),r=xY(e,t.payloadUniqBy,fTe),i=pb(pb({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(o2e,i)}function pTe(t,e,n,r,i,s){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)-s.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)-s.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),pb(pb({},u),d)}function gTe(t){var e=$r();return w.useEffect(()=>{e(aTe(t))},[e,t]),null}function bTe(t){var e=$r();return w.useEffect(()=>(e(iV(t)),()=>{e(iV({width:0,height:0}))}),[e,t]),null}function xTe(t,e,n,r){return t==="vertical"&&Ht(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var yTe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function bL(t){var e=bi(t,yTe),n=Z2e(),r=JMe(),i=VAe(),{width:s,height:o,wrapperStyle:l,portal:c}=e,[u,d]=NY([n]),h=fL(),p=mL();if(h==null||p==null)return null;var m=h-(i?.left||0)-(i?.right||0),x=xTe(e.layout,o,s,m),y=c?l:pb(pb({position:"absolute",width:x?.width||s||"auto",height:x?.height||o||"auto"},pTe(l,e,i,h,p,u)),l),b=c??r;if(b==null||n==null)return null;var v=w.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},w.createElement(gTe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(bTe,{width:u.width,height:u.height}),w.createElement(mTe,_D({},e,x,{margin:i,chartWidth:h,chartHeight:p,contextPayload:n})));return Pu.createPortal(v,b)}bL.displayName="Legend";function SD(){return SD=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},SD.apply(null,arguments)}function sV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function KT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sV(Object(n),!0).forEach(function(r){vTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vTe(t,e,n){return(e=wTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wTe(t){var e=_Te(t,"string");return typeof e=="symbol"?e:e+""}function _Te(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 STe(t){return Array.isArray(t)&&xl(t[0])&&xl(t[1])?t.join(" ~ "):t}var NTe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:h,accessibilityLayer:p=!1}=t,m=()=>{if(s&&s.length){var N={padding:0,margin:0},A=(l?eM(s,l):s).map((M,P)=>{if(M.type==="none")return null;var T=M.formatter||o||STe,{value:j,name:z}=M,F=j,$=z;if(T){var D=T(j,z,M,P,s);if(Array.isArray(D))[F,$]=D;else if(D!=null)F=D;else return null}var H=KT({display:"block",paddingTop:4,paddingBottom:4,color:M.color||"#000"},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(P),style:H},xl($)?w.createElement("span",{className:"recharts-tooltip-item-name"},$):null,xl($)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},F),w.createElement("span",{className:"recharts-tooltip-item-unit"},M.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:N},A)}return null},x=KT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=KT({margin:0},i),b=!ii(d),v=b?d:"",S=ir("recharts-default-tooltip",c),k=ir("recharts-tooltip-label",u);b&&h&&s!==void 0&&s!==null&&(v=h(d,s));var E=p?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",SD({className:S,style:x},E),w.createElement("p",{className:k,style:y},w.isValidElement(v)?v:"".concat(v)),m())},ry="recharts-tooltip-wrapper",kTe={visibility:"hidden"};function MTe(t){var{coordinate:e,translateX:n,translateY:r}=t;return ir(ry,{["".concat(ry,"-right")]:Ht(n)&&e&&Ht(e.x)&&n>=e.x,["".concat(ry,"-left")]:Ht(n)&&e&&Ht(e.x)&&n<e.x,["".concat(ry,"-bottom")]:Ht(r)&&e&&Ht(e.y)&&r>=e.y,["".concat(ry,"-top")]:Ht(r)&&e&&Ht(e.y)&&r<e.y})}function oV(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(s&&Ht(s[r]))return s[r];var d=n[r]-l-(i>0?i:0),h=n[r]+i;if(e[r])return o[r]?d:h;var p=c[r];if(p==null)return 0;if(o[r]){var m=d,x=p;return m<x?Math.max(h,p):Math.max(d,p)}if(u==null)return 0;var y=h+l,b=p+u;return y>b?Math.max(d,p):Math.max(h,p)}function CTe(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 ETe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,h;return o.height>0&&o.width>0&&n?(d=oV({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),h=oV({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=CTe({translateX:d,translateY:h,useTranslate3d:l})):u=kTe,{cssProperties:u,cssClasses:MTe({translateX:d,translateY:h,coordinate:n})}}function lV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function aS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lV(Object(n),!0).forEach(function(r){ND(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ND(t,e,n){return(e=ATe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ATe(t){var e=TTe(t,"string");return typeof e=="symbol"?e:e+""}function TTe(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 jTe extends w.PureComponent{constructor(){super(...arguments),ND(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),ND(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,s;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=(s=this.props.coordinate)===null||s===void 0?void 0:s.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:s,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:h,useTranslate3d:p,viewBox:m,wrapperStyle:x,lastBoundingBox:y,innerRef:b,hasPortalFromProps:v}=this.props,{cssClasses:S,cssProperties:k}=ETe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:h,tooltipBox:{height:y.height,width:y.width},useTranslate3d:p,viewBox:m}),E=v?{}:aS(aS({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},k),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),N=aS(aS({},E),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:S,style:N,ref:b},s)}}var _Q=()=>{var t;return(t=zt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function kD(){return kD=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},kD.apply(null,arguments)}function cV(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 uV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cV(Object(n),!0).forEach(function(r){PTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PTe(t,e,n){return(e=DTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DTe(t){var e=RTe(t,"string");return typeof e=="symbol"?e:e+""}function RTe(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 dV={curveBasisClosed:xCe,curveBasisOpen:yCe,curveBasis:bCe,curveBumpX:rCe,curveBumpY:iCe,curveLinearClosed:vCe,curveLinear:Zk,curveMonotoneX:wCe,curveMonotoneY:_Ce,curveNatural:SCe,curveStep:NCe,curveStepAfter:MCe,curveStepBefore:kCe},q1=t=>Sr(t.x)&&Sr(t.y),hV=t=>t.base!=null&&q1(t.base)&&q1(t),iy=t=>t.x,ay=t=>t.y,LTe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(ev(t));return(n==="curveMonotone"||n==="curveBump")&&e?dV["".concat(n).concat(e==="vertical"?"Y":"X")]:dV[n]||Zk},OTe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,o=LTe(e,i),l=s?n.filter(q1):n,c;if(Array.isArray(r)){var u=n.map((m,x)=>uV(uV({},m),{},{base:r[x]}));i==="vertical"?c=Q_().y(ay).x1(iy).x0(m=>m.base.x):c=Q_().x(iy).y1(ay).y0(m=>m.base.y);var d=c.defined(hV).curve(o),h=s?u.filter(hV):u;return d(h)}i==="vertical"&&Ht(r)?c=Q_().y(ay).x1(iy).x0(r):Ht(r)?c=Q_().x(iy).y1(ay).y0(r):c=WX().x(iy).y(ay);var p=c.defined(q1).curve(o);return p(l)},Vg=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?OTe(t):r;return w.createElement("path",kD({},Ps(t),eL(t),{className:ir("recharts-curve",e),d:s===null?void 0:s,ref:i}))},FTe=["x","y","top","left","width","height","className"];function MD(){return MD=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},MD.apply(null,arguments)}function fV(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 ITe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fV(Object(n),!0).forEach(function(r){zTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zTe(t,e,n){return(e=UTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UTe(t){var e=BTe(t,"string");return typeof e=="symbol"?e:e+""}function BTe(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 $Te(t,e){if(t==null)return{};var n,r,i=HTe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function HTe(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 VTe=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),GTe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:o=0,className:l}=t,c=$Te(t,FTe),u=ITe({x:e,y:n,top:r,left:i,width:s,height:o},c);return!Ht(e)||!Ht(n)||!Ht(s)||!Ht(o)||!Ht(r)||!Ht(i)?null:w.createElement("path",MD({},es(u),{className:ir("recharts-cross",l),d:VTe(e,n,s,o,r,i)}))};function qTe(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 mV(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 pV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mV(Object(n),!0).forEach(function(r){WTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function WTe(t,e,n){return(e=KTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KTe(t){var e=XTe(t,"string");return typeof e=="symbol"?e:e+""}function XTe(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 YTe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),SQ=(t,e,n)=>t.map(r=>"".concat(YTe(r)," ").concat(e,"ms ").concat(n)).join(","),QTe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),_0=(t,e)=>Object.keys(e).reduce((n,r)=>pV(pV({},n),{},{[r]:t(r,e[r])}),{});function gV(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?gV(Object(n),!0).forEach(function(r){ZTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZTe(t,e,n){return(e=JTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JTe(t){var e=eje(t,"string");return typeof e=="symbol"?e:e+""}function eje(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 W1=(t,e,n)=>t+(e-t)*n,CD=t=>{var{from:e,to:n}=t;return e!==n},NQ=(t,e,n)=>{var r=_0((i,s)=>{if(CD(s)){var[o,l]=t(s.from,s.to,s.velocity);return la(la({},s),{},{from:o,velocity:l})}return s},e);return n<1?_0((i,s)=>CD(s)?la(la({},s),{},{velocity:W1(s.velocity,r[i].velocity,n),from:W1(s.from,r[i].from,n)}):s,e):NQ(t,r,n-1)};function tje(t,e,n,r,i,s){var o,l=r.reduce((p,m)=>la(la({},p),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>_0((p,m)=>m.from,l),u=()=>!Object.values(l).filter(CD).length,d=null,h=p=>{o||(o=p);var m=p-o,x=m/n.dt;l=NQ(n,l,x),i(la(la(la({},t),e),c())),o=p,u()||(d=s.setTimeout(h))};return()=>(d=s.setTimeout(h),()=>{var p;(p=d)===null||p===void 0||p()})}function nje(t,e,n,r,i,s,o){var l=null,c=i.reduce((h,p)=>la(la({},h),{},{[p]:[t[p],e[p]]}),{}),u,d=h=>{u||(u=h);var p=(h-u)/r,m=_0((y,b)=>W1(...b,n(p)),c);if(s(la(la(la({},t),e),m)),p<1)l=o.setTimeout(d);else{var x=_0((y,b)=>W1(...b,n(1)),c);s(la(la(la({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var h;(h=l)===null||h===void 0||h()})}const rje=(t,e,n,r,i,s)=>{var o=QTe(t,e);return n==null?()=>(i(la(la({},t),e)),()=>{}):n.isStepper===!0?tje(t,e,n,o,i,s):nje(t,e,n,r,o,i,s)};var K1=1e-4,kQ=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],MQ=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),bV=(t,e)=>n=>{var r=kQ(t,e);return MQ(r,n)},ije=(t,e)=>n=>{var r=kQ(t,e),i=[...r.map((s,o)=>s*o).slice(1),0];return MQ(i,n)},aje=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,s=n[0].split("(");if(s[0]==="cubic-bezier"&&((i=s[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=s[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]},sje=(t,e,n,r)=>{var i=bV(t,n),s=bV(e,r),o=ije(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,h=d,p=0;p<8;++p){var m=i(h)-d,x=o(h);if(Math.abs(m-d)<K1||x<K1)return s(h);h=l(h-m/x)}return s(h)};return c.isStepper=!1,c},xV=function(){return sje(...aje(...arguments))},oje=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,s=(o,l,c)=>{var u=-(o-l)*n,d=c*r,h=c+(u-d)*i/1e3,p=c*i/1e3+o;return Math.abs(p-l)<K1&&Math.abs(h)<K1?[l,0]:[p,h]};return s.isStepper=!0,s.dt=i,s},lje=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return xV(t);case"spring":return oje();default:if(t.split("(")[0]==="cubic-bezier")return xV(t)}return typeof t=="function"?t:null};function cje(t){var e,n=()=>null,r=!1,i=null,s=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(s.bind(null,u),c);return}s(c),i=t.setTimeout(s.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),s(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class uje{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,s=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>{i!=null&&cancelAnimationFrame(i)}}}function dje(){return cje(new uje)}var hje=w.createContext(dje);function fje(t,e){var n=w.useContext(hje);return w.useMemo(()=>e??n(t),[t,e,n])}var mje=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),zb={devToolsEnabled:!1,isSsr:mje()},pje={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},yV={t:0},XT={t:1};function Ub(t){var e=bi(t,pje),{isActive:n,canBegin:r,duration:i,easing:s,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!zb.isSsr:n,h=fje(e.animationId,e.animationManager),[p,m]=w.useState(d?yV:XT),x=w.useRef(null);return w.useEffect(()=>{d||m(XT)},[d]),w.useEffect(()=>{if(!d||!r)return tv;var y=rje(yV,XT,lje(s),i,m,h.getTimeoutController()),b=()=>{x.current=y()};return h.start([c,o,b,i,l]),()=>{h.stop(),x.current&&x.current(),l()}},[d,r,i,s,o,c,l,h]),u(p.t)}function Bb(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(p0(e)),r=w.useRef(t);return r.current!==t&&(n.current=p0(e),r.current=t),n.current}var gje=["radius"],bje=["radius"];function vV(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 wV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vV(Object(n),!0).forEach(function(r){xje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xje(t,e,n){return(e=yje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yje(t){var e=vje(t,"string");return typeof e=="symbol"?e:e+""}function vje(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function X1(){return X1=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},X1.apply(null,arguments)}function _V(t,e){if(t==null)return{};var n,r,i=wje(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function wje(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 SV=(t,e,n,r,i)=>{var s=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(s>0&&i instanceof Array){for(var d=[0,0,0,0],h=0,p=4;h<p;h++)d[h]=i[h]>s?s:i[h];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,`,
  8074. `).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,`,
  8075. `).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,`,
  8076. `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(s>0&&i===+i&&i>0){var m=Math.min(s,i);u="M ".concat(t,",").concat(e+o*m,`
  8077. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+l*m,",").concat(e,`
  8078. L `).concat(t+n-l*m,",").concat(e,`
  8079. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*m,`
  8080. L `).concat(t+n,",").concat(e+r-o*m,`
  8081. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n-l*m,",").concat(e+r,`
  8082. L `).concat(t+l*m,",").concat(e+r,`
  8083. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*m," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},NV={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},CQ=t=>{var e=bi(t,NV),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var I=n.current.getTotalLength();I&&i(I)}catch{}},[]);var{x:s,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:h,animationDuration:p,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:y}=e,b=w.useRef(l),v=w.useRef(c),S=w.useRef(s),k=w.useRef(o),E=w.useMemo(()=>({x:s,y:o,width:l,height:c,radius:u}),[s,o,l,c,u]),N=Bb(E,"rectangle-");if(s!==+s||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var A=ir("recharts-rectangle",d);if(!y){var M=es(e),{radius:P}=M,T=_V(M,gje);return w.createElement("path",X1({},T,{radius:typeof u=="number"?u:void 0,className:A,d:SV(s,o,l,c,u)}))}var j=b.current,z=v.current,F=S.current,$=k.current,D="0px ".concat(r===-1?1:r,"px"),H="".concat(r,"px 0px"),q=SQ(["strokeDasharray"],p,typeof h=="string"?h:NV.animationEasing);return w.createElement(Ub,{animationId:N,key:N,canBegin:r>0,duration:p,easing:h,isActive:y,begin:m},I=>{var K=pr(j,l,I),Z=pr(z,c,I),se=pr(F,s,I),V=pr($,o,I);n.current&&(b.current=K,v.current=Z,S.current=se,k.current=V);var W;x?I>0?W={transition:q,strokeDasharray:H}:W={strokeDasharray:D}:W={strokeDasharray:H};var ie=es(e),{radius:J}=ie,pe=_V(ie,bje);return w.createElement("path",X1({},pe,{radius:typeof u=="number"?u:void 0,className:A,d:SV(se,V,K,Z,u),ref:n,style:wV(wV({},W),e.style)}))})};function kV(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 MV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kV(Object(n),!0).forEach(function(r){_je(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _je(t,e,n){return(e=Sje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sje(t){var e=Nje(t,"string");return typeof e=="symbol"?e:e+""}function Nje(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 Y1=Math.PI/180,kje=t=>t*180/Math.PI,Ji=(t,e,n,r)=>({x:t+Math.cos(-Y1*r)*n,y:e+Math.sin(-Y1*r)*n}),EQ=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},Mje=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},Cje=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,o=Mje({x:n,y:r},{x:i,y:s});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>s&&(c=2*Math.PI-c),{radius:o,angle:kje(c),angleInRadian:c}},Eje=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),s=Math.min(r,i);return{startAngle:e-s*360,endAngle:n-s*360}},Aje=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),s=Math.floor(r/360),o=Math.min(i,s);return t+o*360},Tje=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=Cje({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=Eje(e),d=s,h;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;h=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;h=d>=u&&d<=c}return h?MV(MV({},e),{},{radius:i,angle:Aje(d,e)}):null};function AQ(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,o=Ji(e,n,r,i),l=Ji(e,n,r,s);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function ED(){return ED=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},ED.apply(null,arguments)}var jje=(t,e)=>{var n=Pa(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},sS=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/Y1,h=c?i:i+s*d,p=Ji(e,n,u,h),m=Ji(e,n,r,h),x=c?i-s*d:i,y=Ji(e,n,u*Math.cos(d*Y1),x);return{center:p,circleTangency:m,lineTangency:y,theta:d}},TQ=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:o}=t,l=jje(s,o),c=s+l,u=Ji(e,n,i,s),d=Ji(e,n,i,c),h="M ".concat(u.x,",").concat(u.y,`
  8084. A `).concat(i,",").concat(i,`,0,
  8085. `).concat(+(Math.abs(l)>180),",").concat(+(s>c),`,
  8086. `).concat(d.x,",").concat(d.y,`
  8087. `);if(r>0){var p=Ji(e,n,r,s),m=Ji(e,n,r,c);h+="L ".concat(m.x,",").concat(m.y,`
  8088. A `).concat(r,",").concat(r,`,0,
  8089. `).concat(+(Math.abs(l)>180),",").concat(+(s<=c),`,
  8090. `).concat(p.x,",").concat(p.y," Z")}else h+="L ".concat(e,",").concat(n," Z");return h},Pje=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Pa(u-c),{circleTangency:h,lineTangency:p,theta:m}=sS({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:s,cornerIsExternal:l}),{circleTangency:x,lineTangency:y,theta:b}=sS({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-m-b;if(v<0)return o?"M ".concat(p.x,",").concat(p.y,`
  8091. a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0
  8092. a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0
  8093. `):TQ({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S="M ".concat(p.x,",").concat(p.y,`
  8094. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(h.x,",").concat(h.y,`
  8095. A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
  8096. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
  8097. `);if(r>0){var{circleTangency:k,lineTangency:E,theta:N}=sS({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),{circleTangency:A,lineTangency:M,theta:P}=sS({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),T=l?Math.abs(c-u):Math.abs(c-u)-N-P;if(T<0&&s===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+="L".concat(M.x,",").concat(M.y,`
  8098. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,`
  8099. A`).concat(r,",").concat(r,",0,").concat(+(T>180),",").concat(+(d>0),",").concat(k.x,",").concat(k.y,`
  8100. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(E.x,",").concat(E.y,"Z")}else S+="L".concat(e,",").concat(n,"Z");return S},Dje={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},jQ=t=>{var e=bi(t,Dje),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:h}=e;if(s<i||u===d)return null;var p=ir("recharts-sector",h),m=s-i,x=gs(o,m,0,!0),y;return x>0&&Math.abs(u-d)<360?y=Pje({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,m/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=TQ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),w.createElement("path",ED({},es(e),{className:p,d:y}))};function Rje(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(lY(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:o,angle:l}=e,c=Ji(r,i,s,l),u=Ji(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return AQ(e)}}var YT={},QT={},ZT={},CV;function Lje(){return CV||(CV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wY();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(ZT)),ZT}var EV;function Oje(){return EV||(EV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Lje();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})(QT)),QT}var AV;function Fje(){return AV||(AV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=_Y(),n=Oje();function r(i,s,o){o&&typeof o!="number"&&e.isIterateeCall(i,s,o)&&(s=o=void 0),i=n.toFinite(i),s===void 0?(s=i,i=0):s=n.toFinite(s),o=o===void 0?i<s?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((s-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})(YT)),YT}var JT,TV;function Ije(){return TV||(TV=1,JT=Fje().range),JT}var zje=Ije();const PQ=wl(zje);function Ph(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Uje(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function xL(t){let e,n,r;t.length!==2?(e=Ph,n=(l,c)=>Ph(t(l),c),r=(l,c)=>t(l)-c):(e=t===Ph||t===Uje?t:Bje,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 h=u+d>>>1;n(l[h],c)<0?u=h+1:d=h}while(u<d)}return u}function s(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const h=u+d>>>1;n(l[h],c)<=0?u=h+1:d=h}while(u<d)}return u}function o(l,c,u=0,d=l.length){const h=i(l,c,u,d-1);return h>u&&r(l[h-1],c)>-r(l[h],c)?h-1:h}return{left:i,center:o,right:s}}function Bje(){return 0}function DQ(t){return t===null?NaN:+t}function*$je(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const Hje=xL(Ph),cv=Hje.right;xL(DQ).center;class jV extends Map{constructor(e,n=qje){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(PV(this,e))}has(e){return super.has(PV(this,e))}set(e,n){return super.set(Vje(this,e),n)}delete(e){return super.delete(Gje(this,e))}}function PV({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Vje({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Gje({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function qje(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Wje(t=Ph){if(t===Ph)return RQ;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 RQ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const Kje=Math.sqrt(50),Xje=Math.sqrt(10),Yje=Math.sqrt(2);function Q1(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),o=s>=Kje?10:s>=Xje?5:s>=Yje?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?Q1(t,e,n*2):[l,c,u]}function AD(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,s,o]=r?Q1(e,t,n):Q1(t,e,n);if(!(s>=i))return[];const l=s-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(s-u)/-o;else for(let u=0;u<l;++u)c[u]=(s-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 TD(t,e,n){return e=+e,t=+t,n=+n,Q1(t,e,n)[2]}function jD(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?TD(e,t,n):TD(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function DV(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function RV(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function LQ(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?RQ:Wje(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),h=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*h*(c-h)/c)*(u-c/2<0?-1:1),m=Math.max(n,Math.floor(e-u*h/c+p)),x=Math.min(r,Math.floor(e+(c-u)*h/c+p));LQ(t,e,m,x,i)}const s=t[e];let o=n,l=r;for(sy(t,n,e),i(t[r],s)>0&&sy(t,n,r);o<l;){for(sy(t,o,l),++o,--l;i(t[o],s)<0;)++o;for(;i(t[l],s)>0;)--l}i(t[n],s)===0?sy(t,n,l):(++l,sy(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function sy(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function Qje(t,e,n){if(t=Float64Array.from($je(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return RV(t);if(e>=1)return DV(t);var r,i=(r-1)*e,s=Math.floor(i),o=DV(LQ(t,s).subarray(0,s+1)),l=RV(t.subarray(s+1));return o+(l-o)*(i-s)}}function Zje(t,e,n=DQ){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,s=Math.floor(i),o=+n(t[s],s,t),l=+n(t[s+1],s+1,t);return o+(l-o)*(i-s)}}function Jje(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,s=new Array(i);++r<i;)s[r]=t+r*n;return s}function Sl(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function hd(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 PD=Symbol("implicit");function yL(){var t=new jV,e=[],n=[],r=PD;function i(s){let o=t.get(s);if(o===void 0){if(r!==PD)return r;t.set(s,o=e.push(s)-1)}return n[o%n.length]}return i.domain=function(s){if(!arguments.length)return e.slice();e=[],t=new jV;for(const o of s)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return yL(e,n).unknown(r)},Sl.apply(i,arguments),i}function vL(){var t=yL().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function h(){var p=e().length,m=i<r,x=m?i:r,y=m?r:i;s=(y-x)/Math.max(1,p-c+u*2),l&&(s=Math.floor(s)),x+=(y-x-s*(p-c))*d,o=s*(1-c),l&&(x=Math.round(x),o=Math.round(o));var b=Jje(p).map(function(v){return x+s*v});return n(m?b.reverse():b)}return t.domain=function(p){return arguments.length?(e(p),h()):e()},t.range=function(p){return arguments.length?([r,i]=p,r=+r,i=+i,h()):[r,i]},t.rangeRound=function(p){return[r,i]=p,r=+r,i=+i,l=!0,h()},t.bandwidth=function(){return o},t.step=function(){return s},t.round=function(p){return arguments.length?(l=!!p,h()):l},t.padding=function(p){return arguments.length?(c=Math.min(1,u=+p),h()):c},t.paddingInner=function(p){return arguments.length?(c=Math.min(1,p),h()):c},t.paddingOuter=function(p){return arguments.length?(u=+p,h()):u},t.align=function(p){return arguments.length?(d=Math.max(0,Math.min(1,p)),h()):d},t.copy=function(){return vL(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},Sl.apply(h(),arguments)}function OQ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return OQ(e())},t}function ePe(){return OQ(vL.apply(null,arguments).paddingInner(1))}function wL(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function FQ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function uv(){}var S0=.7,Z1=1/S0,Gg="\\s*([+-]?\\d+)\\s*",N0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ec="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",tPe=/^#([0-9a-f]{3,8})$/,nPe=new RegExp(`^rgb\\(${Gg},${Gg},${Gg}\\)$`),rPe=new RegExp(`^rgb\\(${Ec},${Ec},${Ec}\\)$`),iPe=new RegExp(`^rgba\\(${Gg},${Gg},${Gg},${N0}\\)$`),aPe=new RegExp(`^rgba\\(${Ec},${Ec},${Ec},${N0}\\)$`),sPe=new RegExp(`^hsl\\(${N0},${Ec},${Ec}\\)$`),oPe=new RegExp(`^hsla\\(${N0},${Ec},${Ec},${N0}\\)$`),LV={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};wL(uv,k0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:OV,formatHex:OV,formatHex8:lPe,formatHsl:cPe,formatRgb:FV,toString:FV});function OV(){return this.rgb().formatHex()}function lPe(){return this.rgb().formatHex8()}function cPe(){return IQ(this).formatHsl()}function FV(){return this.rgb().formatRgb()}function k0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=tPe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?IV(e):n===3?new Ys(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?oS(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?oS(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=nPe.exec(t))?new Ys(e[1],e[2],e[3],1):(e=rPe.exec(t))?new Ys(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=iPe.exec(t))?oS(e[1],e[2],e[3],e[4]):(e=aPe.exec(t))?oS(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=sPe.exec(t))?BV(e[1],e[2]/100,e[3]/100,1):(e=oPe.exec(t))?BV(e[1],e[2]/100,e[3]/100,e[4]):LV.hasOwnProperty(t)?IV(LV[t]):t==="transparent"?new Ys(NaN,NaN,NaN,0):null}function IV(t){return new Ys(t>>16&255,t>>8&255,t&255,1)}function oS(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ys(t,e,n,r)}function uPe(t){return t instanceof uv||(t=k0(t)),t?(t=t.rgb(),new Ys(t.r,t.g,t.b,t.opacity)):new Ys}function DD(t,e,n,r){return arguments.length===1?uPe(t):new Ys(t,e,n,r??1)}function Ys(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}wL(Ys,DD,FQ(uv,{brighter(t){return t=t==null?Z1:Math.pow(Z1,t),new Ys(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?S0:Math.pow(S0,t),new Ys(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ys(dm(this.r),dm(this.g),dm(this.b),J1(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:zV,formatHex:zV,formatHex8:dPe,formatRgb:UV,toString:UV}));function zV(){return`#${Zf(this.r)}${Zf(this.g)}${Zf(this.b)}`}function dPe(){return`#${Zf(this.r)}${Zf(this.g)}${Zf(this.b)}${Zf((isNaN(this.opacity)?1:this.opacity)*255)}`}function UV(){const t=J1(this.opacity);return`${t===1?"rgb(":"rgba("}${dm(this.r)}, ${dm(this.g)}, ${dm(this.b)}${t===1?")":`, ${t})`}`}function J1(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function dm(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Zf(t){return t=dm(t),(t<16?"0":"")+t.toString(16)}function BV(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new $l(t,e,n,r)}function IQ(t){if(t instanceof $l)return new $l(t.h,t.s,t.l,t.opacity);if(t instanceof uv||(t=k0(t)),!t)return new $l;if(t instanceof $l)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,l=s-i,c=(s+i)/2;return l?(e===s?o=(n-r)/l+(n<r)*6:n===s?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?s+i:2-s-i,o*=60):l=c>0&&c<1?0:o,new $l(o,l,c,t.opacity)}function hPe(t,e,n,r){return arguments.length===1?IQ(t):new $l(t,e,n,r??1)}function $l(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}wL($l,hPe,FQ(uv,{brighter(t){return t=t==null?Z1:Math.pow(Z1,t),new $l(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?S0:Math.pow(S0,t),new $l(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 Ys(ej(t>=240?t-240:t+120,i,r),ej(t,i,r),ej(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new $l($V(this.h),lS(this.s),lS(this.l),J1(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=J1(this.opacity);return`${t===1?"hsl(":"hsla("}${$V(this.h)}, ${lS(this.s)*100}%, ${lS(this.l)*100}%${t===1?")":`, ${t})`}`}}));function $V(t){return t=(t||0)%360,t<0?t+360:t}function lS(t){return Math.max(0,Math.min(1,t||0))}function ej(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 _L=t=>()=>t;function fPe(t,e){return function(n){return t+n*e}}function mPe(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 pPe(t){return(t=+t)==1?zQ:function(e,n){return n-e?mPe(e,n,t):_L(isNaN(e)?n:e)}}function zQ(t,e){var n=e-t;return n?fPe(t,n):_L(isNaN(t)?e:t)}const HV=(function t(e){var n=pPe(e);function r(i,s){var o=n((i=DD(i)).r,(s=DD(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),u=zQ(i.opacity,s.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 gPe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function bPe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function xPe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),o;for(o=0;o<r;++o)i[o]=$b(t[o],e[o]);for(;o<n;++o)s[o]=e[o];return function(l){for(o=0;o<r;++o)s[o]=i[o](l);return s}}function yPe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function eN(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function vPe(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]=$b(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var RD=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,tj=new RegExp(RD.source,"g");function wPe(t){return function(){return t}}function _Pe(t){return function(e){return t(e)+""}}function SPe(t,e){var n=RD.lastIndex=tj.lastIndex=0,r,i,s,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=RD.exec(t))&&(i=tj.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),l[o]?l[o]+=s:l[++o]=s),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:eN(r,i)})),n=tj.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?c[0]?_Pe(c[0].x):wPe(e):(e=c.length,function(u){for(var d=0,h;d<e;++d)l[(h=c[d]).i]=h.x(u);return l.join("")})}function $b(t,e){var n=typeof e,r;return e==null||n==="boolean"?_L(e):(n==="number"?eN:n==="string"?(r=k0(e))?(e=r,HV):SPe:e instanceof k0?HV:e instanceof Date?yPe:bPe(e)?gPe:Array.isArray(e)?xPe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?vPe:eN)(t,e)}function SL(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function NPe(t,e){e===void 0&&(e=t,t=$b);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return s[l](o-l)}}function kPe(t){return function(){return t}}function tN(t){return+t}var VV=[0,1];function Cs(t){return t}function LD(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:kPe(isNaN(e)?NaN:.5)}function MPe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function CPe(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=LD(i,r),s=n(o,s)):(r=LD(r,i),s=n(s,o)),function(l){return s(r(l))}}function EPe(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=LD(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(l){var c=cv(t,l,1,r)-1;return s[c](i[c](l))}}function dv(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function bM(){var t=VV,e=VV,n=$b,r,i,s,o=Cs,l,c,u;function d(){var p=Math.min(t.length,e.length);return o!==Cs&&(o=MPe(t[0],t[p-1])),l=p>2?EPe:CPe,c=u=null,h}function h(p){return p==null||isNaN(p=+p)?s:(c||(c=l(t.map(r),e,n)))(r(o(p)))}return h.invert=function(p){return o(i((u||(u=l(e,t.map(r),eN)))(p)))},h.domain=function(p){return arguments.length?(t=Array.from(p,tN),d()):t.slice()},h.range=function(p){return arguments.length?(e=Array.from(p),d()):e.slice()},h.rangeRound=function(p){return e=Array.from(p),n=SL,d()},h.clamp=function(p){return arguments.length?(o=p?!0:Cs,d()):o!==Cs},h.interpolate=function(p){return arguments.length?(n=p,d()):n},h.unknown=function(p){return arguments.length?(s=p,h):s},function(p,m){return r=p,i=m,d()}}function NL(){return bM()(Cs,Cs)}function APe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function nN(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 gb(t){return t=nN(Math.abs(t)),t?t[1]:NaN}function TPe(t,e){return function(n,r){for(var i=n.length,s=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),s.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return s.reverse().join(e)}}function jPe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var PPe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function M0(t){if(!(e=PPe.exec(t)))throw new Error("invalid format: "+t);var e;return new kL({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]})}M0.prototype=kL.prototype;function kL(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+""}kL.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 DPe(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 UQ;function RPe(t,e){var n=nN(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(UQ=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return s===o?r:s>o?r+new Array(s-o+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+nN(t,Math.max(0,e+s-1))[0]}function GV(t,e){var n=nN(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 qV={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:APe,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)=>GV(t*100,e),r:GV,s:RPe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function WV(t){return t}var KV=Array.prototype.map,XV=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function LPe(t){var e=t.grouping===void 0||t.thousands===void 0?WV:TPe(KV.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+"",s=t.numerals===void 0?WV:jPe(KV.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(h){h=M0(h);var p=h.fill,m=h.align,x=h.sign,y=h.symbol,b=h.zero,v=h.width,S=h.comma,k=h.precision,E=h.trim,N=h.type;N==="n"?(S=!0,N="g"):qV[N]||(k===void 0&&(k=12),E=!0,N="g"),(b||p==="0"&&m==="=")&&(b=!0,p="0",m="=");var A=y==="$"?n:y==="#"&&/[boxX]/.test(N)?"0"+N.toLowerCase():"",M=y==="$"?r:/[%p]/.test(N)?o:"",P=qV[N],T=/[defgprs%]/.test(N);k=k===void 0?6:/[gprs]/.test(N)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function j(z){var F=A,$=M,D,H,q;if(N==="c")$=P(z)+$,z="";else{z=+z;var I=z<0||1/z<0;if(z=isNaN(z)?c:P(Math.abs(z),k),E&&(z=DPe(z)),I&&+z==0&&x!=="+"&&(I=!1),F=(I?x==="("?x:l:x==="-"||x==="("?"":x)+F,$=(N==="s"?XV[8+UQ/3]:"")+$+(I&&x==="("?")":""),T){for(D=-1,H=z.length;++D<H;)if(q=z.charCodeAt(D),48>q||q>57){$=(q===46?i+z.slice(D+1):z.slice(D))+$,z=z.slice(0,D);break}}}S&&!b&&(z=e(z,1/0));var K=F.length+z.length+$.length,Z=K<v?new Array(v-K+1).join(p):"";switch(S&&b&&(z=e(Z+z,Z.length?v-$.length:1/0),Z=""),m){case"<":z=F+z+$+Z;break;case"=":z=F+Z+z+$;break;case"^":z=Z.slice(0,K=Z.length>>1)+F+z+$+Z.slice(K);break;default:z=Z+F+z+$;break}return s(z)}return j.toString=function(){return h+""},j}function d(h,p){var m=u((h=M0(h),h.type="f",h)),x=Math.max(-8,Math.min(8,Math.floor(gb(p)/3)))*3,y=Math.pow(10,-x),b=XV[8+x/3];return function(v){return m(y*v)+b}}return{format:u,formatPrefix:d}}var cS,ML,BQ;OPe({thousands:",",grouping:[3],currency:["$",""]});function OPe(t){return cS=LPe(t),ML=cS.format,BQ=cS.formatPrefix,cS}function FPe(t){return Math.max(0,-gb(Math.abs(t)))}function IPe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(gb(e)/3)))*3-gb(Math.abs(t)))}function zPe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,gb(e)-gb(t))+1}function $Q(t,e,n,r){var i=jD(t,e,n),s;switch(r=M0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=IPe(i,o))&&(r.precision=s),BQ(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=zPe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=FPe(i))&&(r.precision=s-(r.type==="%")*2);break}}return ML(r)}function Qh(t){var e=t.domain;return t.ticks=function(n){var r=e();return AD(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return $Q(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,s=r.length-1,o=r[i],l=r[s],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=s,s=u);d-- >0;){if(u=TD(o,l,n),u===c)return r[i]=o,r[s]=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 HQ(){var t=NL();return t.copy=function(){return dv(t,HQ())},Sl.apply(t,arguments),Qh(t)}function VQ(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,tN),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return VQ(t).unknown(e)},t=arguments.length?Array.from(t,tN):[0,1],Qh(n)}function GQ(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],o;return s<i&&(o=n,n=r,r=o,o=i,i=s,s=o),t[n]=e.floor(i),t[r]=e.ceil(s),t}function YV(t){return Math.log(t)}function QV(t){return Math.exp(t)}function UPe(t){return-Math.log(-t)}function BPe(t){return-Math.exp(-t)}function $Pe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function HPe(t){return t===10?$Pe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function VPe(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 ZV(t){return(e,n)=>-t(-e,n)}function CL(t){const e=t(YV,QV),n=e.domain;let r=10,i,s;function o(){return i=VPe(r),s=HPe(r),n()[0]<0?(i=ZV(i),s=ZV(s),t(UPe,BPe)):t(YV,QV),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 h=d<u;h&&([u,d]=[d,u]);let p=i(u),m=i(d),x,y;const b=l==null?10:+l;let v=[];if(!(r%1)&&m-p<b){if(p=Math.floor(p),m=Math.ceil(m),u>0){for(;p<=m;++p)for(x=1;x<r;++x)if(y=p<0?x/s(-p):x*s(p),!(y<u)){if(y>d)break;v.push(y)}}else for(;p<=m;++p)for(x=r-1;x>=1;--x)if(y=p>0?x/s(-p):x*s(p),!(y<u)){if(y>d)break;v.push(y)}v.length*2<b&&(v=AD(u,d,b))}else v=AD(p,m,Math.min(m-p,b)).map(s);return h?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=M0(c)).precision==null&&(c.trim=!0),c=ML(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let h=d/s(Math.round(i(d)));return h*r<r-.5&&(h*=r),h<=u?c(d):""}},e.nice=()=>n(GQ(n(),{floor:l=>s(Math.floor(i(l))),ceil:l=>s(Math.ceil(i(l)))})),e}function qQ(){const t=CL(bM()).domain([1,10]);return t.copy=()=>dv(t,qQ()).base(t.base()),Sl.apply(t,arguments),t}function JV(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function eG(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function EL(t){var e=1,n=t(JV(e),eG(e));return n.constant=function(r){return arguments.length?t(JV(e=+r),eG(e)):e},Qh(n)}function WQ(){var t=EL(bM());return t.copy=function(){return dv(t,WQ()).constant(t.constant())},Sl.apply(t,arguments)}function tG(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function GPe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function qPe(t){return t<0?-t*t:t*t}function AL(t){var e=t(Cs,Cs),n=1;function r(){return n===1?t(Cs,Cs):n===.5?t(GPe,qPe):t(tG(n),tG(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Qh(e)}function TL(){var t=AL(bM());return t.copy=function(){return dv(t,TL()).exponent(t.exponent())},Sl.apply(t,arguments),t}function WPe(){return TL.apply(null,arguments).exponent(.5)}function nG(t){return Math.sign(t)*t*t}function KPe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function KQ(){var t=NL(),e=[0,1],n=!1,r;function i(s){var o=KPe(t(s));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(s){return t.invert(nG(s))},i.domain=function(s){return arguments.length?(t.domain(s),i):t.domain()},i.range=function(s){return arguments.length?(t.range((e=Array.from(s,tN)).map(nG)),i):e.slice()},i.rangeRound=function(s){return i.range(s).round(!0)},i.round=function(s){return arguments.length?(n=!!s,i):n},i.clamp=function(s){return arguments.length?(t.clamp(s),i):t.clamp()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return KQ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},Sl.apply(i,arguments),Qh(i)}function XQ(){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]=Zje(t,o/l);return s}function s(o){return o==null||isNaN(o=+o)?r:e[cv(n,o)]}return s.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]]},s.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(Ph),i()},s.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},s.unknown=function(o){return arguments.length?(r=o,s):r},s.quantiles=function(){return n.slice()},s.copy=function(){return XQ().domain(t).range(e).unknown(r)},Sl.apply(s,arguments)}function YQ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function o(c){return c!=null&&c<=c?i[cv(r,c,0,n)]:s}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&&(s=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return YQ().domain([t,e]).range(i).unknown(s)},Sl.apply(Qh(o),arguments)}function QQ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[cv(t,s,0,r)]:n}return i.domain=function(s){return arguments.length?(t=Array.from(s),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(s){return arguments.length?(e=Array.from(s),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(s){var o=e.indexOf(s);return[t[o-1],t[o]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return QQ().domain(t).range(e).unknown(n)},Sl.apply(i,arguments)}const nj=new Date,rj=new Date;function ba(t,e,n,r){function i(s){return t(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(t(s=new Date(+s)),s),i.ceil=s=>(t(s=new Date(s-1)),e(s,1),t(s),s),i.round=s=>{const o=i(s),l=i.ceil(s);return s-o<l-s?o:l},i.offset=(s,o)=>(e(s=new Date(+s),o==null?1:Math.floor(o)),s),i.range=(s,o,l)=>{const c=[];if(s=i.ceil(s),l=l==null?1:Math.floor(l),!(s<o)||!(l>0))return c;let u;do c.push(u=new Date(+s)),e(s,l),t(s);while(u<s&&s<o);return c},i.filter=s=>ba(o=>{if(o>=o)for(;t(o),!s(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!s(o););else for(;--l>=0;)for(;e(o,1),!s(o););}),n&&(i.count=(s,o)=>(nj.setTime(+s),rj.setTime(+o),t(nj),t(rj),Math.floor(n(nj,rj))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?o=>r(o)%s===0:o=>i.count(0,o)%s===0):i)),i}const rN=ba(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);rN.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ba(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):rN);rN.range;const Fu=1e3,ul=Fu*60,Iu=ul*60,id=Iu*24,jL=id*7,rG=id*30,ij=id*365,Jf=ba(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Fu)},(t,e)=>(e-t)/Fu,t=>t.getUTCSeconds());Jf.range;const PL=ba(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Fu)},(t,e)=>{t.setTime(+t+e*ul)},(t,e)=>(e-t)/ul,t=>t.getMinutes());PL.range;const DL=ba(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*ul)},(t,e)=>(e-t)/ul,t=>t.getUTCMinutes());DL.range;const RL=ba(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Fu-t.getMinutes()*ul)},(t,e)=>{t.setTime(+t+e*Iu)},(t,e)=>(e-t)/Iu,t=>t.getHours());RL.range;const LL=ba(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Iu)},(t,e)=>(e-t)/Iu,t=>t.getUTCHours());LL.range;const hv=ba(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ul)/id,t=>t.getDate()-1);hv.range;const xM=ba(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/id,t=>t.getUTCDate()-1);xM.range;const ZQ=ba(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/id,t=>Math.floor(t/id));ZQ.range;function Xm(t){return ba(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())*ul)/jL)}const yM=Xm(0),iN=Xm(1),XPe=Xm(2),YPe=Xm(3),bb=Xm(4),QPe=Xm(5),ZPe=Xm(6);yM.range;iN.range;XPe.range;YPe.range;bb.range;QPe.range;ZPe.range;function Ym(t){return ba(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)/jL)}const vM=Ym(0),aN=Ym(1),JPe=Ym(2),e3e=Ym(3),xb=Ym(4),t3e=Ym(5),n3e=Ym(6);vM.range;aN.range;JPe.range;e3e.range;xb.range;t3e.range;n3e.range;const OL=ba(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());OL.range;const FL=ba(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());FL.range;const ad=ba(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());ad.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ba(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)});ad.range;const sd=ba(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());sd.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ba(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)});sd.range;function JQ(t,e,n,r,i,s){const o=[[Jf,1,Fu],[Jf,5,5*Fu],[Jf,15,15*Fu],[Jf,30,30*Fu],[s,1,ul],[s,5,5*ul],[s,15,15*ul],[s,30,30*ul],[i,1,Iu],[i,3,3*Iu],[i,6,6*Iu],[i,12,12*Iu],[r,1,id],[r,2,2*id],[n,1,jL],[e,1,rG],[e,3,3*rG],[t,1,ij]];function l(u,d,h){const p=d<u;p&&([u,d]=[d,u]);const m=h&&typeof h.range=="function"?h:c(u,d,h),x=m?m.range(u,+d+1):[];return p?x.reverse():x}function c(u,d,h){const p=Math.abs(d-u)/h,m=xL(([,,b])=>b).right(o,p);if(m===o.length)return t.every(jD(u/ij,d/ij,h));if(m===0)return rN.every(Math.max(jD(u,d,h),1));const[x,y]=o[p/o[m-1][2]<o[m][2]/p?m-1:m];return x.every(y)}return[l,c]}const[r3e,i3e]=JQ(sd,FL,vM,ZQ,LL,DL),[a3e,s3e]=JQ(ad,OL,yM,hv,RL,PL);function aj(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 sj(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 oy(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function o3e(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=ly(i),d=cy(i),h=ly(s),p=cy(s),m=ly(o),x=cy(o),y=ly(l),b=cy(l),v=ly(c),S=cy(c),k={a:I,A:K,b:Z,B:se,c:null,d:cG,e:cG,f:T3e,g:U3e,G:$3e,H:C3e,I:E3e,j:A3e,L:eZ,m:j3e,M:P3e,p:V,q:W,Q:hG,s:fG,S:D3e,u:R3e,U:L3e,V:O3e,w:F3e,W:I3e,x:null,X:null,y:z3e,Y:B3e,Z:H3e,"%":dG},E={a:ie,A:J,b:pe,B:fe,c:null,d:uG,e:uG,f:W3e,g:rDe,G:aDe,H:V3e,I:G3e,j:q3e,L:nZ,m:K3e,M:X3e,p:ve,q:Le,Q:hG,s:fG,S:Y3e,u:Q3e,U:Z3e,V:J3e,w:eDe,W:tDe,x:null,X:null,y:nDe,Y:iDe,Z:sDe,"%":dG},N={a:j,A:z,b:F,B:$,c:D,d:oG,e:oG,f:S3e,g:sG,G:aG,H:lG,I:lG,j:y3e,L:_3e,m:x3e,M:v3e,p:T,q:b3e,Q:k3e,s:M3e,S:w3e,u:h3e,U:f3e,V:m3e,w:d3e,W:p3e,x:H,X:q,y:sG,Y:aG,Z:g3e,"%":N3e};k.x=A(n,k),k.X=A(r,k),k.c=A(e,k),E.x=A(n,E),E.X=A(r,E),E.c=A(e,E);function A(de,ce){return function(Ae){var re=[],Ie=-1,G=0,Y=de.length,ue,B,ee;for(Ae instanceof Date||(Ae=new Date(+Ae));++Ie<Y;)de.charCodeAt(Ie)===37&&(re.push(de.slice(G,Ie)),(B=iG[ue=de.charAt(++Ie)])!=null?ue=de.charAt(++Ie):B=ue==="e"?" ":"0",(ee=ce[ue])&&(ue=ee(Ae,B)),re.push(ue),G=Ie+1);return re.push(de.slice(G,Ie)),re.join("")}}function M(de,ce){return function(Ae){var re=oy(1900,void 0,1),Ie=P(re,de,Ae+="",0),G,Y;if(Ie!=Ae.length)return null;if("Q"in re)return new Date(re.Q);if("s"in re)return new Date(re.s*1e3+("L"in re?re.L:0));if(ce&&!("Z"in re)&&(re.Z=0),"p"in re&&(re.H=re.H%12+re.p*12),re.m===void 0&&(re.m="q"in re?re.q:0),"V"in re){if(re.V<1||re.V>53)return null;"w"in re||(re.w=1),"Z"in re?(G=sj(oy(re.y,0,1)),Y=G.getUTCDay(),G=Y>4||Y===0?aN.ceil(G):aN(G),G=xM.offset(G,(re.V-1)*7),re.y=G.getUTCFullYear(),re.m=G.getUTCMonth(),re.d=G.getUTCDate()+(re.w+6)%7):(G=aj(oy(re.y,0,1)),Y=G.getDay(),G=Y>4||Y===0?iN.ceil(G):iN(G),G=hv.offset(G,(re.V-1)*7),re.y=G.getFullYear(),re.m=G.getMonth(),re.d=G.getDate()+(re.w+6)%7)}else("W"in re||"U"in re)&&("w"in re||(re.w="u"in re?re.u%7:"W"in re?1:0),Y="Z"in re?sj(oy(re.y,0,1)).getUTCDay():aj(oy(re.y,0,1)).getDay(),re.m=0,re.d="W"in re?(re.w+6)%7+re.W*7-(Y+5)%7:re.w+re.U*7-(Y+6)%7);return"Z"in re?(re.H+=re.Z/100|0,re.M+=re.Z%100,sj(re)):aj(re)}}function P(de,ce,Ae,re){for(var Ie=0,G=ce.length,Y=Ae.length,ue,B;Ie<G;){if(re>=Y)return-1;if(ue=ce.charCodeAt(Ie++),ue===37){if(ue=ce.charAt(Ie++),B=N[ue in iG?ce.charAt(Ie++):ue],!B||(re=B(de,Ae,re))<0)return-1}else if(ue!=Ae.charCodeAt(re++))return-1}return re}function T(de,ce,Ae){var re=u.exec(ce.slice(Ae));return re?(de.p=d.get(re[0].toLowerCase()),Ae+re[0].length):-1}function j(de,ce,Ae){var re=m.exec(ce.slice(Ae));return re?(de.w=x.get(re[0].toLowerCase()),Ae+re[0].length):-1}function z(de,ce,Ae){var re=h.exec(ce.slice(Ae));return re?(de.w=p.get(re[0].toLowerCase()),Ae+re[0].length):-1}function F(de,ce,Ae){var re=v.exec(ce.slice(Ae));return re?(de.m=S.get(re[0].toLowerCase()),Ae+re[0].length):-1}function $(de,ce,Ae){var re=y.exec(ce.slice(Ae));return re?(de.m=b.get(re[0].toLowerCase()),Ae+re[0].length):-1}function D(de,ce,Ae){return P(de,e,ce,Ae)}function H(de,ce,Ae){return P(de,n,ce,Ae)}function q(de,ce,Ae){return P(de,r,ce,Ae)}function I(de){return o[de.getDay()]}function K(de){return s[de.getDay()]}function Z(de){return c[de.getMonth()]}function se(de){return l[de.getMonth()]}function V(de){return i[+(de.getHours()>=12)]}function W(de){return 1+~~(de.getMonth()/3)}function ie(de){return o[de.getUTCDay()]}function J(de){return s[de.getUTCDay()]}function pe(de){return c[de.getUTCMonth()]}function fe(de){return l[de.getUTCMonth()]}function ve(de){return i[+(de.getUTCHours()>=12)]}function Le(de){return 1+~~(de.getUTCMonth()/3)}return{format:function(de){var ce=A(de+="",k);return ce.toString=function(){return de},ce},parse:function(de){var ce=M(de+="",!1);return ce.toString=function(){return de},ce},utcFormat:function(de){var ce=A(de+="",E);return ce.toString=function(){return de},ce},utcParse:function(de){var ce=M(de+="",!0);return ce.toString=function(){return de},ce}}}var iG={"-":"",_:" ",0:"0"},Oa=/^\s*\d+/,l3e=/^%/,c3e=/[\\^$*+?|[\]().{}]/g;function ur(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function u3e(t){return t.replace(c3e,"\\$&")}function ly(t){return new RegExp("^(?:"+t.map(u3e).join("|")+")","i")}function cy(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function d3e(t,e,n){var r=Oa.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function h3e(t,e,n){var r=Oa.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function f3e(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function m3e(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function p3e(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function aG(t,e,n){var r=Oa.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function sG(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function g3e(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 b3e(t,e,n){var r=Oa.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function x3e(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function oG(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function y3e(t,e,n){var r=Oa.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function lG(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function v3e(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function w3e(t,e,n){var r=Oa.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function _3e(t,e,n){var r=Oa.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function S3e(t,e,n){var r=Oa.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function N3e(t,e,n){var r=l3e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function k3e(t,e,n){var r=Oa.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function M3e(t,e,n){var r=Oa.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function cG(t,e){return ur(t.getDate(),e,2)}function C3e(t,e){return ur(t.getHours(),e,2)}function E3e(t,e){return ur(t.getHours()%12||12,e,2)}function A3e(t,e){return ur(1+hv.count(ad(t),t),e,3)}function eZ(t,e){return ur(t.getMilliseconds(),e,3)}function T3e(t,e){return eZ(t,e)+"000"}function j3e(t,e){return ur(t.getMonth()+1,e,2)}function P3e(t,e){return ur(t.getMinutes(),e,2)}function D3e(t,e){return ur(t.getSeconds(),e,2)}function R3e(t){var e=t.getDay();return e===0?7:e}function L3e(t,e){return ur(yM.count(ad(t)-1,t),e,2)}function tZ(t){var e=t.getDay();return e>=4||e===0?bb(t):bb.ceil(t)}function O3e(t,e){return t=tZ(t),ur(bb.count(ad(t),t)+(ad(t).getDay()===4),e,2)}function F3e(t){return t.getDay()}function I3e(t,e){return ur(iN.count(ad(t)-1,t),e,2)}function z3e(t,e){return ur(t.getFullYear()%100,e,2)}function U3e(t,e){return t=tZ(t),ur(t.getFullYear()%100,e,2)}function B3e(t,e){return ur(t.getFullYear()%1e4,e,4)}function $3e(t,e){var n=t.getDay();return t=n>=4||n===0?bb(t):bb.ceil(t),ur(t.getFullYear()%1e4,e,4)}function H3e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+ur(e/60|0,"0",2)+ur(e%60,"0",2)}function uG(t,e){return ur(t.getUTCDate(),e,2)}function V3e(t,e){return ur(t.getUTCHours(),e,2)}function G3e(t,e){return ur(t.getUTCHours()%12||12,e,2)}function q3e(t,e){return ur(1+xM.count(sd(t),t),e,3)}function nZ(t,e){return ur(t.getUTCMilliseconds(),e,3)}function W3e(t,e){return nZ(t,e)+"000"}function K3e(t,e){return ur(t.getUTCMonth()+1,e,2)}function X3e(t,e){return ur(t.getUTCMinutes(),e,2)}function Y3e(t,e){return ur(t.getUTCSeconds(),e,2)}function Q3e(t){var e=t.getUTCDay();return e===0?7:e}function Z3e(t,e){return ur(vM.count(sd(t)-1,t),e,2)}function rZ(t){var e=t.getUTCDay();return e>=4||e===0?xb(t):xb.ceil(t)}function J3e(t,e){return t=rZ(t),ur(xb.count(sd(t),t)+(sd(t).getUTCDay()===4),e,2)}function eDe(t){return t.getUTCDay()}function tDe(t,e){return ur(aN.count(sd(t)-1,t),e,2)}function nDe(t,e){return ur(t.getUTCFullYear()%100,e,2)}function rDe(t,e){return t=rZ(t),ur(t.getUTCFullYear()%100,e,2)}function iDe(t,e){return ur(t.getUTCFullYear()%1e4,e,4)}function aDe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?xb(t):xb.ceil(t),ur(t.getUTCFullYear()%1e4,e,4)}function sDe(){return"+0000"}function dG(){return"%"}function hG(t){return+t}function fG(t){return Math.floor(+t/1e3)}var cg,iZ,aZ;oDe({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 oDe(t){return cg=o3e(t),iZ=cg.format,cg.parse,aZ=cg.utcFormat,cg.utcParse,cg}function lDe(t){return new Date(t)}function cDe(t){return t instanceof Date?+t:+new Date(+t)}function IL(t,e,n,r,i,s,o,l,c,u){var d=NL(),h=d.invert,p=d.domain,m=u(".%L"),x=u(":%S"),y=u("%I:%M"),b=u("%I %p"),v=u("%a %d"),S=u("%b %d"),k=u("%B"),E=u("%Y");function N(A){return(c(A)<A?m:l(A)<A?x:o(A)<A?y:s(A)<A?b:r(A)<A?i(A)<A?v:S:n(A)<A?k:E)(A)}return d.invert=function(A){return new Date(h(A))},d.domain=function(A){return arguments.length?p(Array.from(A,cDe)):p().map(lDe)},d.ticks=function(A){var M=p();return t(M[0],M[M.length-1],A??10)},d.tickFormat=function(A,M){return M==null?N:u(M)},d.nice=function(A){var M=p();return(!A||typeof A.range!="function")&&(A=e(M[0],M[M.length-1],A??10)),A?p(GQ(M,A)):d},d.copy=function(){return dv(d,IL(t,e,n,r,i,s,o,l,c,u))},d}function uDe(){return Sl.apply(IL(a3e,s3e,ad,OL,yM,hv,RL,PL,Jf,iZ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function dDe(){return Sl.apply(IL(r3e,i3e,sd,FL,vM,xM,LL,DL,Jf,aZ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function wM(){var t=0,e=1,n,r,i,s,o=Cs,l=!1,c;function u(h){return h==null||isNaN(h=+h)?c:o(i===0?.5:(h=(s(h)-n)*i,l?Math.max(0,Math.min(1,h)):h))}u.domain=function(h){return arguments.length?([t,e]=h,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(h){return arguments.length?(l=!!h,u):l},u.interpolator=function(h){return arguments.length?(o=h,u):o};function d(h){return function(p){var m,x;return arguments.length?([m,x]=p,o=h(m,x),u):[o(0),o(1)]}}return u.range=d($b),u.rangeRound=d(SL),u.unknown=function(h){return arguments.length?(c=h,u):c},function(h){return s=h,n=h(t),r=h(e),i=n===r?0:1/(r-n),u}}function Zh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function sZ(){var t=Qh(wM()(Cs));return t.copy=function(){return Zh(t,sZ())},hd.apply(t,arguments)}function oZ(){var t=CL(wM()).domain([1,10]);return t.copy=function(){return Zh(t,oZ()).base(t.base())},hd.apply(t,arguments)}function lZ(){var t=EL(wM());return t.copy=function(){return Zh(t,lZ()).constant(t.constant())},hd.apply(t,arguments)}function zL(){var t=AL(wM());return t.copy=function(){return Zh(t,zL()).exponent(t.exponent())},hd.apply(t,arguments)}function hDe(){return zL.apply(null,arguments).exponent(.5)}function cZ(){var t=[],e=Cs;function n(r){if(r!=null&&!isNaN(r=+r))return e((cv(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(Ph),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,s)=>Qje(t,s/r))},n.copy=function(){return cZ(e).domain(t)},hd.apply(n,arguments)}function _M(){var t=0,e=.5,n=1,r=1,i,s,o,l,c,u=Cs,d,h=!1,p;function m(y){return isNaN(y=+y)?p:(y=.5+((y=+d(y))-s)*(r*y<r*s?l:c),u(h?Math.max(0,Math.min(1,y)):y))}m.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),s=d(e=+e),o=d(n=+n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,m):[t,e,n]},m.clamp=function(y){return arguments.length?(h=!!y,m):h},m.interpolator=function(y){return arguments.length?(u=y,m):u};function x(y){return function(b){var v,S,k;return arguments.length?([v,S,k]=b,u=NPe(y,[v,S,k]),m):[u(0),u(.5),u(1)]}}return m.range=x($b),m.rangeRound=x(SL),m.unknown=function(y){return arguments.length?(p=y,m):p},function(y){return d=y,i=y(t),s=y(e),o=y(n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,m}}function uZ(){var t=Qh(_M()(Cs));return t.copy=function(){return Zh(t,uZ())},hd.apply(t,arguments)}function dZ(){var t=CL(_M()).domain([.1,1,10]);return t.copy=function(){return Zh(t,dZ()).base(t.base())},hd.apply(t,arguments)}function hZ(){var t=EL(_M());return t.copy=function(){return Zh(t,hZ()).constant(t.constant())},hd.apply(t,arguments)}function UL(){var t=AL(_M());return t.copy=function(){return Zh(t,UL()).exponent(t.exponent())},hd.apply(t,arguments)}function fDe(){return UL.apply(null,arguments).exponent(.5)}const vy=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:vL,scaleDiverging:uZ,scaleDivergingLog:dZ,scaleDivergingPow:UL,scaleDivergingSqrt:fDe,scaleDivergingSymlog:hZ,scaleIdentity:VQ,scaleImplicit:PD,scaleLinear:HQ,scaleLog:qQ,scaleOrdinal:yL,scalePoint:ePe,scalePow:TL,scaleQuantile:XQ,scaleQuantize:YQ,scaleRadial:KQ,scaleSequential:sZ,scaleSequentialLog:oZ,scaleSequentialPow:zL,scaleSequentialQuantile:cZ,scaleSequentialSqrt:hDe,scaleSequentialSymlog:lZ,scaleSqrt:WPe,scaleSymlog:WQ,scaleThreshold:QQ,scaleTime:uDe,scaleUtc:dDe,tickFormat:$Q},Symbol.toStringTag,{value:"Module"}));var Jh=t=>t.chartData,BL=lt([Jh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),fv=(t,e,n,r)=>r?BL(t):Jh(t);function Vh(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Sr(e)&&Sr(n))return!0}return!1}function mG(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function fZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(Sr(n))i=n;else if(typeof n=="function")return;if(Sr(r))s=r;else if(typeof r=="function")return;var o=[i,s];if(Vh(o))return o}}function mDe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Vh(r))return mG(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,s]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(Ht(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&$H.test(i)){var c=$H.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(s==="auto")e!=null&&(l=Math.max(...e));else if(Ht(s))l=s;else if(typeof s=="function")try{e!=null&&(l=s(e?.[1]))}catch{}else if(typeof s=="string"&&HH.test(s)){var d=HH.exec(s);if(d==null||e==null)l=void 0;else{var h=+d[1];l=e[1]+h}}else l=e?.[1];var p=[o,l];if(Vh(p))return e==null?p:mG(p,e,n)}}}var Hb=1e9,pDe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},HL,ui=!0,vl="[DecimalError] ",hm=vl+"Invalid argument: ",$L=vl+"Exponent out of range: ",Vb=Math.floor,Bf=Math.pow,gDe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,_o,Aa=1e7,ni=7,mZ=9007199254740991,sN=Vb(mZ/ni),qt={};qt.absoluteValue=qt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};qt.comparedTo=qt.cmp=function(t){var e,n,r,i,s=this;if(t=new s.constructor(t),s.s!==t.s)return s.s||-t.s;if(s.e!==t.e)return s.e>t.e^s.s<0?1:-1;for(r=s.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(s.d[e]!==t.d[e])return s.d[e]>t.d[e]^s.s<0?1:-1;return r===i?0:r>i^s.s<0?1:-1};qt.decimalPlaces=qt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*ni;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};qt.dividedBy=qt.div=function(t){return Vu(this,new this.constructor(t))};qt.dividedToIntegerBy=qt.idiv=function(t){var e=this,n=e.constructor;return Br(Vu(e,new n(t),0,1),n.precision)};qt.equals=qt.eq=function(t){return!this.cmp(t)};qt.exponent=function(){return ra(this)};qt.greaterThan=qt.gt=function(t){return this.cmp(t)>0};qt.greaterThanOrEqualTo=qt.gte=function(t){return this.cmp(t)>=0};qt.isInteger=qt.isint=function(){return this.e>this.d.length-2};qt.isNegative=qt.isneg=function(){return this.s<0};qt.isPositive=qt.ispos=function(){return this.s>0};qt.isZero=function(){return this.s===0};qt.lessThan=qt.lt=function(t){return this.cmp(t)<0};qt.lessThanOrEqualTo=qt.lte=function(t){return this.cmp(t)<1};qt.logarithm=qt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,s=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(_o))throw Error(vl+"NaN");if(n.s<1)throw Error(vl+(n.s?"NaN":"-Infinity"));return n.eq(_o)?new r(0):(ui=!1,e=Vu(C0(n,s),C0(t,s),s),ui=!0,Br(e,i))};qt.minus=qt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?bZ(e,t):pZ(e,(t.s=-t.s,t))};qt.modulo=qt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(vl+"NaN");return n.s?(ui=!1,e=Vu(n,t,0,1).times(t),ui=!0,n.minus(e)):Br(new r(n),i)};qt.naturalExponential=qt.exp=function(){return gZ(this)};qt.naturalLogarithm=qt.ln=function(){return C0(this)};qt.negated=qt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};qt.plus=qt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?pZ(e,t):bZ(e,(t.s=-t.s,t))};qt.precision=qt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(hm+t);if(e=ra(i)+1,r=i.d.length-1,n=r*ni+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};qt.squareRoot=qt.sqrt=function(){var t,e,n,r,i,s,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(vl+"NaN")}for(t=ra(l),ui=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=Nc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Vb((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(s=r,r=s.plus(Vu(l,s,o+2)).times(.5),Nc(s.d).slice(0,o)===(e=Nc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Br(s,n+1,0),s.times(s).eq(l)){r=s;break}}else if(e!="9999")break;o+=4}return ui=!0,Br(r,n)};qt.times=qt.mul=function(t){var e,n,r,i,s,o,l,c,u,d=this,h=d.constructor,p=d.d,m=(t=new h(t)).d;if(!d.s||!t.s)return new h(0);for(t.s*=d.s,n=d.e+t.e,c=p.length,u=m.length,c<u&&(s=p,p=m,m=s,o=c,c=u,u=o),s=[],o=c+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=s[i]+m[r]*p[i-r-1]+e,s[i--]=l%Aa|0,e=l/Aa|0;s[i]=(s[i]+e)%Aa|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,ui?Br(t,h.precision):t};qt.toDecimalPlaces=qt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Dc(t,0,Hb),e===void 0?e=r.rounding:Dc(e,0,8),Br(n,t+ra(n)+1,e))};qt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Om(r,!0):(Dc(t,0,Hb),e===void 0?e=i.rounding:Dc(e,0,8),r=Br(new i(r),t+1,e),n=Om(r,!0,t+1)),n};qt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Om(i):(Dc(t,0,Hb),e===void 0?e=s.rounding:Dc(e,0,8),r=Br(new s(i),t+ra(i)+1,e),n=Om(r.abs(),!1,t+ra(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};qt.toInteger=qt.toint=function(){var t=this,e=t.constructor;return Br(new e(t),ra(t)+1,e.rounding)};qt.toNumber=function(){return+this};qt.toPower=qt.pow=function(t){var e,n,r,i,s,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(_o);if(l=new c(l),!l.s){if(t.s<1)throw Error(vl+"Infinity");return l}if(l.eq(_o))return l;if(r=c.precision,t.eq(_o))return Br(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,s=l.s,o){if((n=d<0?-d:d)<=mZ){for(i=new c(_o),e=Math.ceil(r/ni+4),ui=!1;n%2&&(i=i.times(l),gG(i.d,e)),n=Vb(n/2),n!==0;)l=l.times(l),gG(l.d,e);return ui=!0,t.s<0?new c(_o).div(i):Br(i,r)}}else if(s<0)throw Error(vl+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,ui=!1,i=t.times(C0(l,r+u)),ui=!0,i=gZ(i),i.s=s,i};qt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=ra(i),r=Om(i,n<=s.toExpNeg||n>=s.toExpPos)):(Dc(t,1,Hb),e===void 0?e=s.rounding:Dc(e,0,8),i=Br(new s(i),t,e),n=ra(i),r=Om(i,t<=n||n<=s.toExpNeg,t)),r};qt.toSignificantDigits=qt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Dc(t,1,Hb),e===void 0?e=r.rounding:Dc(e,0,8)),Br(new r(n),t,e)};qt.toString=qt.valueOf=qt.val=qt.toJSON=qt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=ra(t),n=t.constructor;return Om(t,e<=n.toExpNeg||e>=n.toExpPos)};function pZ(t,e){var n,r,i,s,o,l,c,u,d=t.constructor,h=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),ui?Br(e,h):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),s=o-i,s){for(s<0?(r=c,s=-s,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(h/ni),l=o>l?o+1:l+1,s>l&&(s=l,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(l=c.length,s=u.length,l-s<0&&(s=l,r=u,u=c,c=r),n=0;s;)n=(c[--s]=c[s]+u[s]+n)/Aa|0,c[s]%=Aa;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,ui?Br(e,h):e}function Dc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(hm+t)}function Nc(t){var e,n,r,i=t.length-1,s="",o=t[0];if(i>0){for(s+=o,e=1;e<i;e++)r=t[e]+"",n=ni-r.length,n&&(s+=ih(n)),s+=r;o=t[e],r=o+"",n=ni-r.length,n&&(s+=ih(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}var Vu=(function(){function t(r,i){var s,o=0,l=r.length;for(r=r.slice();l--;)s=r[l]*i+o,r[l]=s%Aa|0,o=s/Aa|0;return o&&r.unshift(o),r}function e(r,i,s,o){var l,c;if(s!=o)c=s>o?1:-1;else for(l=c=0;l<s;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,s){for(var o=0;s--;)r[s]-=o,o=r[s]<i[s]?1:0,r[s]=o*Aa+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o){var l,c,u,d,h,p,m,x,y,b,v,S,k,E,N,A,M,P,T=r.constructor,j=r.s==i.s?1:-1,z=r.d,F=i.d;if(!r.s)return new T(r);if(!i.s)throw Error(vl+"Division by zero");for(c=r.e-i.e,M=F.length,N=z.length,m=new T(j),x=m.d=[],u=0;F[u]==(z[u]||0);)++u;if(F[u]>(z[u]||0)&&--c,s==null?S=s=T.precision:o?S=s+(ra(r)-ra(i))+1:S=s,S<0)return new T(0);if(S=S/ni+2|0,u=0,M==1)for(d=0,F=F[0],S++;(u<N||d)&&S--;u++)k=d*Aa+(z[u]||0),x[u]=k/F|0,d=k%F|0;else{for(d=Aa/(F[0]+1)|0,d>1&&(F=t(F,d),z=t(z,d),M=F.length,N=z.length),E=M,y=z.slice(0,M),b=y.length;b<M;)y[b++]=0;P=F.slice(),P.unshift(0),A=F[0],F[1]>=Aa/2&&++A;do d=0,l=e(F,y,M,b),l<0?(v=y[0],M!=b&&(v=v*Aa+(y[1]||0)),d=v/A|0,d>1?(d>=Aa&&(d=Aa-1),h=t(F,d),p=h.length,b=y.length,l=e(h,y,p,b),l==1&&(d--,n(h,M<p?P:F,p))):(d==0&&(l=d=1),h=F.slice()),p=h.length,p<b&&h.unshift(0),n(y,h,b),l==-1&&(b=y.length,l=e(F,y,M,b),l<1&&(d++,n(y,M<b?P:F,b))),b=y.length):l===0&&(d++,y=[0]),x[u++]=d,l&&y[0]?y[b++]=z[E]||0:(y=[z[E]],b=1);while((E++<N||y[0]!==void 0)&&S--)}return x[0]||x.shift(),m.e=c,Br(m,o?s+ra(m)+1:s)}})();function gZ(t,e){var n,r,i,s,o,l,c=0,u=0,d=t.constructor,h=d.precision;if(ra(t)>16)throw Error($L+ra(t));if(!t.s)return new d(_o);for(ui=!1,l=h,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Bf(2,u))/Math.LN10*2+5|0,l+=r,n=i=s=new d(_o),d.precision=l;;){if(i=Br(i.times(t),l),n=n.times(++c),o=s.plus(Vu(i,n,l)),Nc(o.d).slice(0,l)===Nc(s.d).slice(0,l)){for(;u--;)s=Br(s.times(s),l);return d.precision=h,e==null?(ui=!0,Br(s,h)):s}s=o}}function ra(t){for(var e=t.e*ni,n=t.d[0];n>=10;n/=10)e++;return e}function oj(t,e,n){if(e>t.LN10.sd())throw ui=!0,n&&(t.precision=n),Error(vl+"LN10 precision limit exceeded");return Br(new t(t.LN10),e)}function ih(t){for(var e="";t--;)e+="0";return e}function C0(t,e){var n,r,i,s,o,l,c,u,d,h=1,p=10,m=t,x=m.d,y=m.constructor,b=y.precision;if(m.s<1)throw Error(vl+(m.s?"NaN":"-Infinity"));if(m.eq(_o))return new y(0);if(e==null?(ui=!1,u=b):u=e,m.eq(10))return e==null&&(ui=!0),oj(y,u);if(u+=p,y.precision=u,n=Nc(x),r=n.charAt(0),s=ra(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=Nc(m.d),r=n.charAt(0),h++;s=ra(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return c=oj(y,u+2,b).times(s+""),m=C0(new y(r+"."+n.slice(1)),u-p).plus(c),y.precision=b,e==null?(ui=!0,Br(m,b)):m;for(l=o=m=Vu(m.minus(_o),m.plus(_o),u),d=Br(m.times(m),u),i=3;;){if(o=Br(o.times(d),u),c=l.plus(Vu(o,new y(i),u)),Nc(c.d).slice(0,u)===Nc(l.d).slice(0,u))return l=l.times(2),s!==0&&(l=l.plus(oj(y,u+2,b).times(s+""))),l=Vu(l,new y(h),u),y.precision=b,e==null?(ui=!0,Br(l,b)):l;l=c,i+=2}}function pG(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=Vb(n/ni),t.d=[],r=(n+1)%ni,n<0&&(r+=ni),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=ni;r<i;)t.d.push(+e.slice(r,r+=ni));e=e.slice(r),r=ni-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),ui&&(t.e>sN||t.e<-sN))throw Error($L+n)}else t.s=0,t.e=0,t.d=[0];return t}function Br(t,e,n){var r,i,s,o,l,c,u,d,h=t.d;for(o=1,s=h[0];s>=10;s/=10)o++;if(r=e-o,r<0)r+=ni,i=e,u=h[d=0];else{if(d=Math.ceil((r+1)/ni),s=h.length,d>=s)return t;for(u=s=h[d],o=1;s>=10;s/=10)o++;r%=ni,i=r-ni+o}if(n!==void 0&&(s=Bf(10,o-i-1),l=u/s%10|0,c=e<0||h[d+1]!==void 0||u%s,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/Bf(10,o-i):0:h[d-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return c?(s=ra(t),h.length=1,e=e-s-1,h[0]=Bf(10,(ni-e%ni)%ni),t.e=Vb(-e/ni)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(r==0?(h.length=d,s=1,d--):(h.length=d+1,s=Bf(10,ni-r),h[d]=i>0?(u/Bf(10,o-i)%Bf(10,i)|0)*s:0),c)for(;;)if(d==0){(h[0]+=s)==Aa&&(h[0]=1,++t.e);break}else{if(h[d]+=s,h[d]!=Aa)break;h[d--]=0,s=1}for(r=h.length;h[--r]===0;)h.pop();if(ui&&(t.e>sN||t.e<-sN))throw Error($L+ra(t));return t}function bZ(t,e){var n,r,i,s,o,l,c,u,d,h,p=t.constructor,m=p.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new p(t),ui?Br(e,m):e;if(c=t.d,h=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=h.length):(n=h,r=u,l=c.length),i=Math.max(Math.ceil(m/ni),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=h.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=h[i]){d=c[i]<h[i];break}o=0}for(d&&(n=c,c=h,h=n,e.s=-e.s),l=c.length,i=h.length-l;i>0;--i)c[l++]=0;for(i=h.length;i>o;){if(c[--i]<h[i]){for(s=i;s&&c[--s]===0;)c[s]=Aa-1;--c[s],c[i]+=Aa}c[i]-=h[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,ui?Br(e,m):e):new p(0)}function Om(t,e,n){var r,i=ra(t),s=Nc(t.d),o=s.length;return e?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+ih(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+ih(-i-1)+s,n&&(r=n-o)>0&&(s+=ih(r))):i>=o?(s+=ih(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+ih(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=ih(r))),t.s<0?"-"+s:s}function gG(t,e){if(t.length>e)return t.length=e,!0}function xZ(t){var e,n,r;function i(s){var o=this;if(!(o instanceof i))return new i(s);if(o.constructor=i,s instanceof i){o.s=s.s,o.e=s.e,o.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(hm+s);if(s>0)o.s=1;else if(s<0)s=-s,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(s===~~s&&s<1e7){o.e=0,o.d=[s];return}return pG(o,s.toString())}else if(typeof s!="string")throw Error(hm+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,gDe.test(s))pG(o,s);else throw Error(hm+s)}if(i.prototype=qt,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=xZ,i.config=i.set=bDe,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 bDe(t){if(!t||typeof t!="object")throw Error(vl+"Object expected");var e,n,r,i=["precision",1,Hb,"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(Vb(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(hm+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(hm+n+": "+r);return this}var HL=xZ(pDe);_o=new HL(1);const wr=HL;var xDe=t=>t,yZ={},vZ=t=>t===yZ,bG=t=>function e(){return arguments.length===0||arguments.length===1&&vZ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},wZ=(t,e)=>t===1?e:bG(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=r.filter(o=>o!==yZ).length;return s>=t?e(...r):wZ(t-s,bG(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>vZ(d)?l.shift():d);return e(...u,...l)}))}),yDe=t=>wZ(t.length,t),OD=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},vDe=yDe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),wDe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return xDe;var i=n.reverse(),s=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),s(...arguments))}},FD=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function _Z(t){var e;return t===0?e=1:e=Math.floor(new wr(t).abs().log(10).toNumber())+1,e}function SZ(t,e,n){for(var r=new wr(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var NZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},kZ=(t,e,n)=>{if(t.lte(0))return new wr(0);var r=_Z(t.toNumber()),i=new wr(10).pow(r),s=t.div(i),o=r!==1?.05:.1,l=new wr(Math.ceil(s.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new wr(c.toNumber()):new wr(Math.ceil(c.toNumber()))},_De=(t,e,n)=>{var r=new wr(1),i=new wr(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new wr(10).pow(_Z(t)-1),i=new wr(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new wr(Math.floor(t)))}else t===0?i=new wr(Math.floor((e-1)/2)):n||(i=new wr(Math.floor(t)));var o=Math.floor((e-1)/2),l=wDe(vDe(c=>i.add(new wr(c-o).mul(r)).toNumber()),OD);return l(0,e)},MZ=function(e,n,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new wr(0),tickMin:new wr(0),tickMax:new wr(0)};var o=kZ(new wr(n).sub(e).div(r-1),i,s),l;e<=0&&n>=0?l=new wr(0):(l=new wr(e).add(n).div(2),l=l.sub(new wr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new wr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?MZ(e,n,r,i,s+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new wr(c).mul(o)),tickMax:l.add(new wr(u).mul(o))})},SDe=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),[l,c]=NZ([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...OD(0,i-1).map(()=>1/0)]:[...OD(0,i-1).map(()=>-1/0),c];return n>r?FD(u):u}if(l===c)return _De(l,i,s);var{step:d,tickMin:h,tickMax:p}=MZ(l,c,o,s,0),m=SZ(h,p.add(new wr(.1).mul(d)),d);return n>r?FD(m):m},NDe=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=NZ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=kZ(new wr(l).sub(o).div(c-1),s,0),d=[...SZ(new wr(o),new wr(l),u),l];return s===!1&&(d=d.map(h=>Math.round(h))),r>i?FD(d):d},CZ=t=>t.rootProps.maxBarSize,kDe=t=>t.rootProps.barGap,EZ=t=>t.rootProps.barCategoryGap,MDe=t=>t.rootProps.barSize,mv=t=>t.rootProps.stackOffset,AZ=t=>t.rootProps.reverseStackOrder,VL=t=>t.options.chartName,GL=t=>t.rootProps.syncId,TZ=t=>t.rootProps.syncMethod,qL=t=>t.options.eventEmitter,CDe=t=>t.rootProps.baseValue,Di={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Au={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},vo={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},SM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},EDe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Au.angleAxisId,includeHidden:!1,name:void 0,reversed:Au.reversed,scale:Au.scale,tick:Au.tick,tickCount:void 0,ticks:void 0,type:Au.type,unit:void 0},ADe={allowDataOverflow:vo.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:vo.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:vo.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:vo.scale,tick:vo.tick,tickCount:vo.tickCount,ticks:void 0,type:vo.type,unit:void 0},TDe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Au.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Au.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Au.scale,tick:Au.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},jDe={allowDataOverflow:vo.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:vo.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:vo.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:vo.scale,tick:vo.tick,tickCount:vo.tickCount,ticks:void 0,type:"category",unit:void 0},WL=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?TDe:EDe,KL=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?jDe:ADe,NM=t=>t.polarOptions,XL=lt([ud,dd,pa],EQ),jZ=lt([NM,XL],(t,e)=>{if(t!=null)return gs(t.innerRadius,e,0)}),PZ=lt([NM,XL],(t,e)=>{if(t!=null)return gs(t.outerRadius,e,e*.8)}),PDe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},DZ=lt([NM],PDe);lt([WL,DZ],SM);var RZ=lt([XL,jZ,PZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});lt([KL,RZ],SM);var LZ=lt([Wn,NM,jZ,PZ,ud,dd],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:gs(o,i,i/2),cy:gs(l,s,s/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),fi=(t,e)=>e,pv=(t,e,n)=>n;function kM(t){return t?.id}function OZ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=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=kM(l);u.forEach((h,p)=>{var m=s==null||i?p:String(_r(h,s,null)),x=_r(h,l.dataKey,0),y;o.has(m)?y=o.get(m):y={},Object.assign(y,{[d]:x}),o.set(m,y)})}}),Array.from(o.values())}function MM(t){return t.stackId!=null&&t.dataKey!=null}var CM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function EM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function DDe(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 xa=t=>{var e=Wn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Gb=t=>t.tooltip.settings.axisId;function xG(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 oN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xG(Object(n),!0).forEach(function(r){RDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RDe(t,e,n){return(e=LDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LDe(t){var e=ODe(t,"string");return typeof e=="symbol"?e:e+""}function ODe(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 ID=[0,"auto"],Ca={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},FZ=(t,e)=>t.cartesianAxis.xAxis[e],$c=(t,e)=>{var n=FZ(t,e);return n??Ca},Ea={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:ID,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:sv},IZ=(t,e)=>t.cartesianAxis.yAxis[e],Hc=(t,e)=>{var n=IZ(t,e);return n??Ea},FDe={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:""},YL=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??FDe},xi=(t,e,n)=>{switch(e){case"xAxis":return $c(t,n);case"yAxis":return Hc(t,n);case"zAxis":return YL(t,n);case"angleAxis":return WL(t,n);case"radiusAxis":return KL(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},IDe=(t,e,n)=>{switch(e){case"xAxis":return $c(t,n);case"yAxis":return Hc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},gv=(t,e,n)=>{switch(e){case"xAxis":return $c(t,n);case"yAxis":return Hc(t,n);case"angleAxis":return WL(t,n);case"radiusAxis":return KL(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},zZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function QL(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 bv=t=>t.graphicalItems.cartesianItems,zDe=lt([fi,pv],QL),ZL=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),xv=lt([bv,xi,zDe],ZL,{memoizeOptions:{resultEqualityCheck:EM}}),UZ=lt([xv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(MM)),BZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),UDe=lt([xv],BZ),JL=t=>t.map(e=>e.data).filter(Boolean).flat(1),BDe=lt([xv],JL,{memoizeOptions:{resultEqualityCheck:EM}}),eO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},tO=lt([BDe,fv],eO),nO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:_r(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:_r(i,r)}))):t.map(r=>({value:r})),AM=lt([tO,xi,xv],nO);function $Z(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function KS(t){if(xl(t)||t instanceof Date){var e=Number(t);if(Sr(e))return e}}function yG(t){if(Array.isArray(t)){var e=[KS(t[0]),KS(t[1])];return Vh(e)?e:void 0}var n=KS(t);if(n!=null)return[n,n]}function od(t){return t.map(KS).filter(ICe)}function $De(t,e,n){return!n||typeof e!="number"||no(e)?[]:n.length?od(n.flatMap(r=>{var i=_r(t,r.dataKey),s,o;if(Array.isArray(i)?[s,o]=i:s=o=i,!(!Sr(s)||!Sr(o)))return[e-s,e+o]})):[]}var ya=t=>{var e=xa(t),n=Gb(t);return gv(t,e,n)},yv=lt([ya],t=>t?.dataKey),HDe=lt([UZ,fv,ya],OZ),HZ=(t,e,n,r)=>{var i={},s=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(s).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(kM);return[l,{stackedData:lAe(t,d,n),graphicalItems:u}]}))},E0=lt([HDe,UZ,mv,AZ],HZ),VZ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var o=hAe(t,i,s);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},VDe=lt([xi],t=>t.allowDataOverflow),rO=t=>{var e;if(t==null||!("domain"in t))return ID;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=od(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:ID},iO=lt([xi],rO),aO=lt([iO,VDe],fZ),GDe=lt([E0,Jh,fi,aO],VZ,{memoizeOptions:{resultEqualityCheck:CM}}),TM=t=>t.errorBars,qDe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>$Z(n,r)),lN=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 s=i.flat(),o=Math.min(...s),l=Math.max(...s);return[o,l]}},sO=(t,e,n,r,i)=>{var s,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,h=(u=r[c.id])===null||u===void 0?void 0:u.filter(v=>$Z(i,v)),p=_r(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=$De(l,p,h);if(m.length>=2){var x=Math.min(...m),y=Math.max(...m);(s==null||x<s)&&(s=x),(o==null||y>o)&&(o=y)}var b=yG(p);b!=null&&(s=s==null?b[0]:Math.min(s,b[0]),o=o==null?b[1]:Math.max(o,b[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=yG(_r(l,e.dataKey));c!=null&&(s=s==null?c[0]:Math.min(s,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),Sr(s)&&Sr(o))return[s,o]},WDe=lt([tO,xi,UDe,TM,fi],sO,{memoizeOptions:{resultEqualityCheck:CM}});function KDe(t){var{value:e}=t;if(xl(e)||e instanceof Date)return e}var XDe=(t,e,n)=>{var r=t.map(KDe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&aY(r))?PQ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},GZ=t=>t.referenceElements.dots,qb=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),YDe=lt([GZ,fi,pv],qb),qZ=t=>t.referenceElements.areas,QDe=lt([qZ,fi,pv],qb),WZ=t=>t.referenceElements.lines,ZDe=lt([WZ,fi,pv],qb),KZ=(t,e)=>{var n=od(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},JDe=lt(YDe,fi,KZ),XZ=(t,e)=>{var n=od(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)]},eRe=lt([QDe,fi],XZ);function tRe(t){var e;if(t.x!=null)return od([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:od(n)}function nRe(t){var e;if(t.y!=null)return od([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:od(n)}var YZ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?tRe(r):nRe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},rRe=lt([ZDe,fi],YZ),iRe=lt(JDe,rRe,eRe,(t,e,n)=>lN(t,n,e)),oO=(t,e,n,r,i,s,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?lN(r,s,i):lN(s,i);return mDe(e,u,t.allowDataOverflow)},aRe=lt([xi,iO,aO,GDe,WDe,iRe,Wn,fi],oO,{memoizeOptions:{resultEqualityCheck:CM}}),sRe=[0,1],lO=(t,e,n,r,i,s,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Bc(e,s);if(u&&l==null){var d;return PQ(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?XDe(r,t,u):i==="expand"?sRe:o}},cO=lt([xi,Wn,tO,AM,mv,fi,aRe],lO),QZ=(t,e,n,r,i)=>{if(t!=null){var{scale:s,type:o}=t;if(s==="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 s=="string"){var l="scale".concat(ev(s));return l in vy?l:"point"}}},Wb=lt([xi,Wn,zZ,VL,fi],QZ);function oRe(t){if(t!=null){if(t in vy)return vy[t]();var e="scale".concat(ev(t));if(e in vy)return vy[e]()}}function uO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=oRe(e);if(i!=null){var s=i.domain(n).range(r);return rAe(s),s}}}var dO=(t,e,n)=>{var r=rO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Vh(t))return SDe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Vh(t))return NDe(t,e.tickCount,e.allowDecimals)}},hO=lt([cO,gv,Wb],dO),fO=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Vh(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,s),Math.max(o,l)]}return e},lRe=lt([xi,cO,hO,fi],fO),cRe=lt(AM,xi,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(od(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 s=0;s<r.length-1;s++){var o=r[s+1]-r[s];n=Math.min(n,o)}return n/i}}),ZZ=lt(cRe,Wn,EZ,pa,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!Sr(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var o=gs(n,t*s),l=t*s/2;return l-o-(l-o)/s*o}return 0}),uRe=(t,e)=>{var n=$c(t,e);return n==null||typeof n.padding!="string"?0:ZZ(t,"xAxis",e,n.padding)},dRe=(t,e)=>{var n=Hc(t,e);return n==null||typeof n.padding!="string"?0:ZZ(t,"yAxis",e,n.padding)},hRe=lt($c,uRe,(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}}),fRe=lt(Hc,dRe,(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}}),mRe=lt([pa,hRe,hM,dM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:s}=r;return i?[s.left,n.width-s.right]:[t.left+e.left,t.left+t.width-e.right]}),pRe=lt([pa,Wn,fRe,hM,dM,(t,e,n)=>n],(t,e,n,r,i,s)=>{var{padding:o}=i;return s?[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]}),vv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return mRe(t,n,r);case"yAxis":return pRe(t,n,r);case"zAxis":return(i=YL(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return DZ(t);case"radiusAxis":return RZ(t,n);default:return}},JZ=lt([xi,vv],SM),Gh=lt([xi,Wb,lRe,JZ],uO);lt([xv,TM,fi],qDe);function eJ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var jM=(t,e)=>e,PM=(t,e,n)=>n,gRe=lt(cM,jM,PM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(eJ)),bRe=lt(uM,jM,PM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(eJ)),tJ=(t,e)=>({width:t.width,height:e.height}),xRe=(t,e)=>{var n=typeof e.width=="number"?e.width:sv;return{width:n,height:t.height}},nJ=lt(pa,$c,tJ),yRe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},vRe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},wRe=lt(dd,pa,gRe,jM,PM,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=tJ(e,l);o==null&&(o=yRe(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;s[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),s}),_Re=lt(ud,pa,bRe,jM,PM,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=xRe(e,l);o==null&&(o=vRe(e,r,t));var u=r==="left"&&!i||r==="right"&&i;s[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),s}),SRe=(t,e)=>{var n=$c(t,e);if(n!=null)return wRe(t,n.orientation,n.mirror)},NRe=lt([pa,$c,SRe,(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}}}),kRe=(t,e)=>{var n=Hc(t,e);if(n!=null)return _Re(t,n.orientation,n.mirror)},MRe=lt([pa,Hc,kRe,(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}}}),rJ=lt(pa,Hc,(t,e)=>{var n=typeof e.width=="number"?e.width:sv;return{width:n,height:t.height}}),vG=(t,e,n)=>{switch(e){case"xAxis":return nJ(t,n).width;case"yAxis":return rJ(t,n).height;default:return}},iJ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:o}=n,l=Bc(t,r),c=e.map(u=>u.value);if(o&&l&&s==="category"&&i&&aY(c))return c}},mO=lt([Wn,AM,xi,fi],iJ),aJ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,o=Bc(t,r);if(o&&(i==="number"||s!=="auto"))return e.map(l=>l.value)}},pO=lt([Wn,AM,gv,fi],aJ),wG=lt([Wn,IDe,Wb,Gh,mO,pO,vv,hO,fi],(t,e,n,r,i,s,o,l,c)=>{if(e!=null){var u=Bc(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:s,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),CRe=(t,e,n,r,i,s,o,l,c)=>{if(!(e==null||r==null)){var u=Bc(t,c),{type:d,ticks:h,tickCount:p}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/m:0;x=c==="angleAxis"&&s!=null&&s.length>=2?Pa(s[0]-s[1])*2*x:x;var y=h||i;if(y){var b=y.map((v,S)=>{var k=o?o.indexOf(v):v;return{index:S,coordinate:r(k)+x,value:v,offset:x}});return b.filter(v=>Sr(v.coordinate))}return u&&l?l.map((v,S)=>({coordinate:r(v)+x,value:v,index:S,offset:x})).filter(v=>Sr(v.coordinate)):r.ticks?r.ticks(p).map(v=>({coordinate:r(v)+x,value:v,offset:x})):r.domain().map((v,S)=>({coordinate:r(v)+x,value:o?o[v]:v,index:S,offset:x}))}},sJ=lt([Wn,gv,Wb,Gh,hO,vv,mO,pO,fi],CRe),ERe=(t,e,n,r,i,s,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Bc(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Pa(r[0]-r[1])*2*u:u,l&&s?s.map((d,h)=>({coordinate:n(d)+u,value:d,index:h,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,h)=>({coordinate:n(d)+u,value:i?i[d]:d,index:h,offset:u}))}},Rc=lt([Wn,gv,Gh,vv,mO,pO,fi],ERe),Lc=lt(xi,Gh,(t,e)=>{if(!(t==null||e==null))return oN(oN({},t),{},{scale:e})}),ARe=lt([xi,Wb,cO,JZ],uO);lt((t,e,n)=>YL(t,n),ARe,(t,e)=>{if(!(t==null||e==null))return oN(oN({},t),{},{scale:e})});var TRe=lt([Wn,cM,uM],(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}}),oJ=t=>t.options.defaultTooltipEventType,lJ=t=>t.options.validateTooltipEventTypes;function cJ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function gO(t,e){var n=oJ(t),r=lJ(t);return cJ(e,n,r)}function jRe(t){return zt(e=>gO(e,t))}var uJ=(t,e)=>{var n,r=Number(e);if(!(no(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},PRe=t=>t.tooltip.settings,hh={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},DRe={itemInteraction:{click:hh,hover:hh},axisInteraction:{click:hh,hover:hh},keyboardInteraction:hh,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}},dJ=ro({name:"tooltip",initialState:DRe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:li()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Wl(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:li()},removeTooltipEntrySettings:{reducer(t,e){var n=Wl(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:li()},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:RRe,replaceTooltipEntrySettings:LRe,removeTooltipEntrySettings:ORe,setTooltipSettingsState:FRe,setActiveMouseOverItemIndex:hJ,mouseLeaveItem:IRe,mouseLeaveChart:fJ,setActiveClickItemIndex:zRe,setMouseOverAxisIndex:mJ,setMouseClickAxisIndex:URe,setSyncInteraction:zD,setKeyboardInteraction:UD}=dJ.actions,BRe=dJ.reducer;function _G(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function uS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_G(Object(n),!0).forEach(function(r){$Re(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_G(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Re(t,e,n){return(e=HRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HRe(t){var e=VRe(t,"string");return typeof e=="symbol"?e:e+""}function VRe(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 GRe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function qRe(t){return t.index!=null}var pJ=(t,e,n,r)=>{if(e==null)return hh;var i=GRe(t,e,n);if(i==null)return hh;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var s=t.settings.active===!0;if(qRe(i)){if(s)return uS(uS({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return uS(uS({},hh),{},{coordinate:i.coordinate})};function WRe(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 KRe(t,e){var n=WRe(t),r=e[0],i=e[1];if(n===void 0)return!1;var s=Math.min(r,i),o=Math.max(r,i);return n>=s&&n<=o}function XRe(t,e,n){if(n==null||e==null)return!0;var r=_r(t,e);return r==null||!Vh(n)?!0:KRe(r,n)}var bO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!Sr(s))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(s,l)),u=e[c];return u==null||XRe(u,n,r)?String(c):null},gJ=(t,e,n,r,i,s,o,l)=>{if(!(s==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,s);if(u!=null)return u;var d=i?.[Number(s)];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}}}},bJ=(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(s=>{var o;return((o=s.settings)===null||o===void 0?void 0:o.dataKey)===i})},wv=t=>t.options.tooltipPayloadSearcher,Kb=t=>t.tooltip;function SG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function NG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SG(Object(n),!0).forEach(function(r){YRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YRe(t,e,n){return(e=QRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QRe(t){var e=ZRe(t,"string");return typeof e=="symbol"?e:e+""}function ZRe(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 JRe(t,e){return t??e}var xJ=(t,e,n,r,i,s,o)=>{if(!(e==null||s==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,h=[];return t.reduce((p,m)=>{var x,{dataDefinedOnItem:y,settings:b}=m,v=JRe(y,l),S=Array.isArray(v)?eQ(v,u,d):v,k=(x=b?.dataKey)!==null&&x!==void 0?x:r,E=b?.nameKey,N;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?N=sY(S,r,i):N=s(S,e,c,E),Array.isArray(N))N.forEach(M=>{var P=NG(NG({},b),{},{name:M.name,unit:M.unit,color:void 0,fill:void 0});p.push(VH({tooltipEntrySettings:P,dataKey:M.dataKey,payload:M.payload,value:_r(M.payload,M.dataKey),name:M.name}))});else{var A;p.push(VH({tooltipEntrySettings:b,dataKey:k,payload:N,value:_r(N,k),name:(A=_r(N,E))!==null&&A!==void 0?A:b?.name}))}return p},h)}},xO=lt([ya,Wn,zZ,VL,xa],QZ),e4e=lt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),t4e=lt([xa,Gb],QL),_v=lt([e4e,ya,t4e],ZL,{memoizeOptions:{resultEqualityCheck:EM}}),n4e=lt([_v],t=>t.filter(MM)),r4e=lt([_v],JL,{memoizeOptions:{resultEqualityCheck:EM}}),Xb=lt([r4e,Jh],eO),i4e=lt([n4e,Jh,ya],OZ),yO=lt([Xb,ya,_v],nO),yJ=lt([ya],rO),a4e=lt([ya],t=>t.allowDataOverflow),vJ=lt([yJ,a4e],fZ),s4e=lt([_v],t=>t.filter(MM)),o4e=lt([i4e,s4e,mv,AZ],HZ),l4e=lt([o4e,Jh,xa,vJ],VZ),c4e=lt([_v],BZ),u4e=lt([Xb,ya,c4e,TM,xa],sO,{memoizeOptions:{resultEqualityCheck:CM}}),d4e=lt([GZ,xa,Gb],qb),h4e=lt([d4e,xa],KZ),f4e=lt([qZ,xa,Gb],qb),m4e=lt([f4e,xa],XZ),p4e=lt([WZ,xa,Gb],qb),g4e=lt([p4e,xa],YZ),b4e=lt([h4e,g4e,m4e],lN),x4e=lt([ya,yJ,vJ,l4e,u4e,b4e,Wn,xa],oO),Sv=lt([ya,Wn,Xb,yO,mv,xa,x4e],lO),y4e=lt([Sv,ya,xO],dO),v4e=lt([ya,Sv,y4e,xa],fO),wJ=t=>{var e=xa(t),n=Gb(t),r=!1;return vv(t,e,n,r)},_J=lt([ya,wJ],SM),SJ=lt([ya,xO,v4e,_J],uO),w4e=lt([Wn,yO,ya,xa],iJ),_4e=lt([Wn,yO,ya,xa],aJ),S4e=(t,e,n,r,i,s,o,l)=>{if(e){var{type:c}=e,u=Bc(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,h=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return h=l==="angleAxis"&&i!=null&&i?.length>=2?Pa(i[0]-i[1])*2*h:h,u&&o?o.map((p,m)=>({coordinate:r(p)+h,value:p,index:m,offset:h})):r.domain().map((p,m)=>({coordinate:r(p)+h,value:s?s[p]:p,index:m,offset:h}))}}},fd=lt([Wn,ya,xO,SJ,wJ,w4e,_4e,xa],S4e),vO=lt([oJ,lJ,PRe],(t,e,n)=>cJ(n.shared,t,e)),NJ=t=>t.tooltip.settings.trigger,wO=t=>t.tooltip.settings.defaultIndex,Nv=lt([Kb,vO,NJ,wO],pJ),qh=lt([Nv,Xb,yv,Sv],bO),kJ=lt([fd,qh],uJ),_O=lt([Nv],t=>{if(t)return t.dataKey}),N4e=lt([Nv],t=>{if(t)return t.graphicalItemId}),MJ=lt([Kb,vO,NJ,wO],bJ),k4e=lt([ud,dd,Wn,pa,fd,wO,MJ,wv],gJ),M4e=lt([Nv,k4e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),C4e=lt([Nv],t=>t.active),E4e=lt([MJ,qh,Jh,yv,kJ,wv,vO],xJ),A4e=lt([E4e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function kG(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 MG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kG(Object(n),!0).forEach(function(r){T4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function T4e(t,e,n){return(e=j4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j4e(t){var e=P4e(t,"string");return typeof e=="symbol"?e:e+""}function P4e(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 D4e=()=>zt(ya),R4e=()=>{var t=D4e(),e=zt(fd),n=zt(SJ);return Hh(!t||!n?void 0:MG(MG({},t),{},{scale:n}),e)};function CG(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 ug(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CG(Object(n),!0).forEach(function(r){L4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function L4e(t,e,n){return(e=O4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O4e(t){var e=F4e(t,"string");return typeof e=="symbol"?e:e+""}function F4e(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 I4e=(t,e,n,r)=>{var i=e.find(s=>s&&s.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}},z4e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:o}=r;return ug(ug(ug({},r),Ji(r.cx,r.cy,o,s)),{},{angle:s,radius:o})}var l=i.coordinate,{angle:c}=r;return ug(ug(ug({},r),Ji(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 U4e(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 CJ=(t,e,n,r,i)=>{var s,o=-1,l=(s=e?.length)!==null&&s!==void 0?s: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,h=c>=l-1?n[0].coordinate:n[c+1].coordinate,p=void 0;if(Pa(d-u)!==Pa(h-d)){var m=[];if(Pa(h-d)===Pa(i[1]-i[0])){p=h;var x=d+i[1]-i[0];m[0]=Math.min(x,(x+u)/2),m[1]=Math.max(x,(x+u)/2)}else{p=u;var y=h+i[1]-i[0];m[0]=Math.min(d,(y+d)/2),m[1]=Math.max(d,(y+d)/2)}var b=[Math.min(d,(p+d)/2),Math.max(d,(p+d)/2)];if(t>b[0]&&t<=b[1]||t>=m[0]&&t<=m[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,h),S=Math.max(u,h);if(t>(v+d)/2&&t<=(S+d)/2){({index:o}=n[c]);break}}}else if(e){for(var k=0;k<l;k++)if(k===0&&t<=(e[k].coordinate+e[k+1].coordinate)/2||k>0&&k<l-1&&t>(e[k].coordinate+e[k-1].coordinate)/2&&t<=(e[k].coordinate+e[k+1].coordinate)/2||k===l-1&&t>(e[k].coordinate+e[k-1].coordinate)/2){({index:o}=e[k]);break}}return o},EJ=()=>zt(VL),SO=(t,e)=>e,AJ=(t,e,n)=>n,NO=(t,e,n,r)=>r,B4e=lt(fd,t=>eM(t,e=>e.coordinate)),kO=lt([Kb,SO,AJ,NO],pJ),MO=lt([kO,Xb,yv,Sv],bO),$4e=(t,e,n)=>{if(e!=null){var r=Kb(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},TJ=lt([Kb,SO,AJ,NO],bJ),cN=lt([ud,dd,Wn,pa,fd,NO,TJ,wv],gJ),H4e=lt([kO,cN],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),jJ=lt([fd,MO],uJ),V4e=lt([TJ,MO,Jh,yv,jJ,wv,SO],xJ),G4e=lt([kO,MO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),q4e=(t,e,n,r,i,s,o)=>{if(!(!t||!n||!r||!i)&&U4e(t,o)){var l=fAe(t,e),c=CJ(l,s,i,n,r),u=I4e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},W4e=(t,e,n,r,i,s,o)=>{if(!(!t||!r||!i||!s||!n)){var l=Tje(t,n);if(l){var c=mAe(l,e),u=CJ(c,o,s,r,i),d=z4e(e,s,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},K4e=(t,e,n,r,i,s,o,l)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?q4e(t,e,r,i,s,o,l):W4e(t,e,n,r,i,s,o)},X4e=lt(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}}),Y4e=lt(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Di)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:DDe}});function EG(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 AG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EG(Object(n),!0).forEach(function(r){Q4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):EG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q4e(t,e,n){return(e=Z4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z4e(t){var e=J4e(t,"string");return typeof e=="symbol"?e:e+""}function J4e(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 eLe={},tLe={zIndexMap:Object.values(Di).reduce((t,e)=>AG(AG({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),eLe)},nLe=new Set(Object.values(Di));function rLe(t){return nLe.has(t)}var PJ=ro({name:"zIndex",initialState:tLe,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:li()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!rLe(n)&&delete t.zIndexMap[n])},prepare:li()},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:li()},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:li()}}}),{registerZIndexPortal:iLe,unregisterZIndexPortal:aLe,registerZIndexPortalId:sLe,unregisterZIndexPortalId:oLe}=PJ.actions,lLe=PJ.reducer;function xs(t){var{zIndex:e,children:n}=t,r=qAe(),i=r&&e!==void 0&&e!==0,s=ga(),o=$r();w.useLayoutEffect(()=>i?(o(iLe({zIndex:e})),()=>{o(aLe({zIndex:e}))}):tv,[o,e,i]);var l=zt(u=>X4e(u,e,s));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Pu.createPortal(n,c):null}function BD(){return BD=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},BD.apply(null,arguments)}function TG(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 dS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TG(Object(n),!0).forEach(function(r){cLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cLe(t,e,n){return(e=uLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uLe(t){var e=dLe(t,"string");return typeof e=="symbol"?e:e+""}function dLe(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 hLe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function fLe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,h=n,p=r,m=i;if(!c||!h||d!=="ScatterChart"&&u!=="axis")return null;var x,y,b;if(d==="ScatterChart")x=h,y=GTe,b=Di.cursorLine;else if(d==="BarChart")x=qTe(l,h,s,o),y=CQ,b=Di.cursorRectangle;else if(l==="radial"&&lY(h)){var{cx:v,cy:S,radius:k,startAngle:E,endAngle:N}=AQ(h);x={cx:v,cy:S,startAngle:E,endAngle:N,innerRadius:k,outerRadius:k},y=jQ,b=Di.cursorLine}else x={points:Rje(l,h,s)},y=Vg,b=Di.cursorLine;var A=typeof c=="object"&&"className"in c?c.className:void 0,M=dS(dS(dS(dS({stroke:"#ccc",pointerEvents:"none"},s),x),Pm(c)),{},{payload:p,payloadIndex:m,className:ir("recharts-tooltip-cursor",A)});return w.createElement(xs,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},w.createElement(hLe,{cursor:c,cursorComp:y,cursorProps:M}))}function mLe(t){var e=R4e(),n=dQ(),r=Km(),i=EJ();return e==null||n==null||r==null||i==null?null:w.createElement(fLe,BD({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var DJ=w.createContext(null),pLe=()=>w.useContext(DJ),lj={exports:{}},jG;function gLe(){return jG||(jG=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 s(c,u,d,h,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,h||c,p),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],m]:c._events[x].push(m):(c._events[x]=m,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,h;if(this._eventsCount===0)return u;for(h in d=this._events)e.call(d,h)&&u.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,m=h.length,x=new Array(m);p<m;p++)x[p]=h[p].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,h=this._events[d];return h?h.fn?1:h.length:0},l.prototype.emit=function(u,d,h,p,m,x){var y=n?n+u:u;if(!this._events[y])return!1;var b=this._events[y],v=arguments.length,S,k;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,h),!0;case 4:return b.fn.call(b.context,d,h,p),!0;case 5:return b.fn.call(b.context,d,h,p,m),!0;case 6:return b.fn.call(b.context,d,h,p,m,x),!0}for(k=1,S=new Array(v-1);k<v;k++)S[k-1]=arguments[k];b.fn.apply(b.context,S)}else{var E=b.length,N;for(k=0;k<E;k++)switch(b[k].once&&this.removeListener(u,b[k].fn,void 0,!0),v){case 1:b[k].fn.call(b[k].context);break;case 2:b[k].fn.call(b[k].context,d);break;case 3:b[k].fn.call(b[k].context,d,h);break;case 4:b[k].fn.call(b[k].context,d,h,p);break;default:if(!S)for(N=1,S=new Array(v-1);N<v;N++)S[N-1]=arguments[N];b[k].fn.apply(b[k].context,S)}}return!0},l.prototype.on=function(u,d,h){return s(this,u,d,h,!1)},l.prototype.once=function(u,d,h){return s(this,u,d,h,!0)},l.prototype.removeListener=function(u,d,h,p){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return o(this,m),this;var x=this._events[m];if(x.fn)x.fn===d&&(!p||x.once)&&(!h||x.context===h)&&o(this,m);else{for(var y=0,b=[],v=x.length;y<v;y++)(x[y].fn!==d||p&&!x[y].once||h&&x[y].context!==h)&&b.push(x[y]);b.length?this._events[m]=b.length===1?b[0]:b:o(this,m)}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})(lj)),lj.exports}var bLe=gLe();const xLe=wl(bLe);var A0=new xLe,$D="recharts.syncEvent.tooltip",PG="recharts.syncEvent.brush";function DM(t,e){if(e){var n=Number.parseInt(e,10);if(!no(n))return t?.[n]}}var yLe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},RJ=ro({name:"options",initialState:yLe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),vLe=RJ.reducer,{createEventEmitter:wLe}=RJ.actions;function _Le(t){return t.tooltip.syncInteraction}var SLe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},LJ=ro({name:"chartData",initialState:SLe,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:DG,setDataStartEndIndexes:NLe,setComputedData:EZe}=LJ.actions,kLe=LJ.reducer,MLe=["x","y"];function RG(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 dg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RG(Object(n),!0).forEach(function(r){CLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function CLe(t,e,n){return(e=ELe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ELe(t){var e=ALe(t,"string");return typeof e=="symbol"?e:e+""}function ALe(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 TLe(t,e){if(t==null)return{};var n,r,i=jLe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jLe(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 PLe(){var t=zt(GL),e=zt(qL),n=$r(),r=zt(TZ),i=zt(fd),s=Km(),o=ov(),l=zt(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return tv;var c=(u,d,h)=>{if(e!==h&&t===u){if(r==="index"){var p;if(o&&d!==null&&d!==void 0&&(p=d.payload)!==null&&p!==void 0&&p.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x,y}=m,b=TLe(m,MLe),{x:v,y:S,width:k,height:E}=d.payload.sourceViewBox,N=dg(dg({},b),{},{x:o.x+(k?(x-v)/k:0)*o.width,y:o.y+(E?(y-S)/E:0)*o.height});n(dg(dg({},d),{},{payload:dg(dg({},d.payload),{},{coordinate:N})}))}else n(d);return}if(i!=null){var A;if(typeof r=="function"){var M={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},P=r(i,M);A=i[P]}else r==="value"&&(A=i.find(q=>String(q.value)===d.payload.label));var{coordinate:T}=d.payload;if(A==null||d.payload.active===!1||T==null||o==null){n(zD({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:j,y:z}=T,F=Math.min(j,o.x+o.width),$=Math.min(z,o.y+o.height),D={x:s==="horizontal"?A.coordinate:F,y:s==="horizontal"?$:A.coordinate},H=zD({active:d.payload.active,coordinate:D,dataKey:d.payload.dataKey,index:String(A.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(H)}}};return A0.on($D,c),()=>{A0.off($D,c)}},[l,n,e,t,r,i,s,o])}function DLe(){var t=zt(GL),e=zt(qL),n=$r();w.useEffect(()=>{if(t==null)return tv;var r=(i,s,o)=>{e!==o&&t===i&&n(NLe(s))};return A0.on(PG,r),()=>{A0.off(PG,r)}},[n,e,t])}function RLe(){var t=$r();w.useEffect(()=>{t(wLe())},[t]),PLe(),DLe()}function LLe(t,e,n,r,i,s){var o=zt(m=>$4e(m,t,e)),l=zt(qL),c=zt(GL),u=zt(TZ),d=zt(_Le),h=d?.active,p=ov();w.useEffect(()=>{if(!h&&c!=null&&l!=null){var m=zD({active:s,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:p,graphicalItemId:void 0});A0.emit($D,c,m,l)}},[h,n,o,i,r,l,c,u,s,p])}function LG(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 OG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LG(Object(n),!0).forEach(function(r){OLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OLe(t,e,n){return(e=FLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FLe(t){var e=ILe(t,"string");return typeof e=="symbol"?e:e+""}function ILe(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 zLe(t){return t.dataKey}function ULe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(NTe,e)}var FG=[],BLe={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 XS(t){var e,n,r=bi(t,BLe),{active:i,allowEscapeViewBox:s,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:h,payloadUniqBy:p,position:m,reverseDirection:x,useTranslate3d:y,wrapperStyle:b,cursor:v,shared:S,trigger:k,defaultIndex:E,portal:N,axisId:A}=r,M=$r(),P=typeof E=="number"?String(E):E;w.useEffect(()=>{M(FRe({shared:S,trigger:k,axisId:A,active:i,defaultIndex:P}))},[M,S,k,A,i,P]);var T=ov(),j=_Q(),z=jRe(S),{activeIndex:F,isActive:$}=(e=zt(ve=>G4e(ve,z,k,P)))!==null&&e!==void 0?e:{},D=zt(ve=>V4e(ve,z,k,P)),H=zt(ve=>jJ(ve,z,k,P)),q=zt(ve=>H4e(ve,z,k,P)),I=D,K=pLe(),Z=(n=i??$)!==null&&n!==void 0?n:!1,[se,V]=NY([I,Z]),W=z==="axis"?H:void 0;LLe(z,k,q,W,F,Z);var ie=N??K;if(ie==null||T==null||z==null)return null;var J=I??FG;Z||(J=FG),u&&J.length&&(J=xY(J.filter(ve=>ve.value!=null&&(ve.hide!==!0||r.includeHidden)),p,zLe));var pe=J.length>0,fe=w.createElement(jTe,{allowEscapeViewBox:s,animationDuration:o,animationEasing:l,isAnimationActive:d,active:Z,coordinate:q,hasPayload:pe,offset:h,position:m,reverseDirection:x,useTranslate3d:y,viewBox:T,wrapperStyle:b,lastBoundingBox:se,innerRef:V,hasPortalFromProps:!!N},ULe(c,OG(OG({},r),{},{payload:J,label:W,active:Z,activeIndex:F,coordinate:q,accessibilityLayer:j})));return w.createElement(w.Fragment,null,Pu.createPortal(fe,ie),Z&&w.createElement(mLe,{cursor:v,tooltipEventType:z,coordinate:q,payload:J,index:F}))}var kv=t=>null;kv.displayName="Cell";function $Le(t,e,n){return(e=HLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HLe(t){var e=VLe(t,"string");return typeof e=="symbol"?e:e+""}function VLe(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 GLe{constructor(e){$Le(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 IG(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 qLe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?IG(Object(n),!0).forEach(function(r){WLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):IG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function WLe(t,e,n){return(e=KLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KLe(t){var e=XLe(t,"string");return typeof e=="symbol"?e:e+""}function XLe(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 YLe={cacheSize:2e3,enableCache:!0},OJ=qLe({},YLe),zG=new GLe(OJ.cacheSize),QLe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},UG="recharts_measurement_span";function ZLe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",s=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(s,"|").concat(o,"|").concat(l)}var BG=(t,e)=>{try{var n=document.getElementById(UG);n||(n=document.createElement("span"),n.setAttribute("id",UG),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,QLe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Oy=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||zb.isSsr)return{width:0,height:0};if(!OJ.enableCache)return BG(e,n);var r=ZLe(e,n),i=zG.get(r);if(i)return i;var s=BG(e,n);return zG.set(r,s),s},$G=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,HG=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,JLe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,eOe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,FJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},tOe=Object.keys(FJ),Tg="NaN";function nOe(t,e){return t*FJ[e]}class Gs{static parse(e){var n,[,r,i]=(n=eOe.exec(e))!==null&&n!==void 0?n:[];return new Gs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,no(e)&&(this.unit=""),n!==""&&!JLe.test(n)&&(this.num=NaN,this.unit=""),tOe.includes(n)&&(this.num=nOe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Gs(NaN,""):new Gs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Gs(NaN,""):new Gs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Gs(NaN,""):new Gs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Gs(NaN,""):new Gs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return no(this.num)}}function IJ(t){if(t.includes(Tg))return Tg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=$G.exec(e))!==null&&n!==void 0?n:[],o=Gs.parse(r??""),l=Gs.parse(s??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Tg;e=e.replace($G,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,h,p]=(u=HG.exec(e))!==null&&u!==void 0?u:[],m=Gs.parse(d??""),x=Gs.parse(p??""),y=h==="+"?m.add(x):m.subtract(x);if(y.isNaN())return Tg;e=e.replace(HG,y.toString())}return e}var VG=/\(([^()]*)\)/;function rOe(t){for(var e=t,n;(n=VG.exec(e))!=null;){var[,r]=n;e=e.replace(VG,IJ(r))}return e}function iOe(t){var e=t.replace(/\s+/g,"");return e=rOe(e),e=IJ(e),e}function aOe(t){try{return iOe(t)}catch{return Tg}}function cj(t){var e=aOe(t.slice(5,-1));return e===Tg?"":e}var sOe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],oOe=["dx","dy","angle","className","breakAll"];function HD(){return HD=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},HD.apply(null,arguments)}function GG(t,e){if(t==null)return{};var n,r,i=lOe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lOe(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 zJ=/[ \f\n\r\t\v\u2028\u2029]+/,UJ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];ii(e)||(n?i=e.toString().split(""):i=e.toString().split(zJ));var s=i.map(l=>({word:l,width:Oy(l,r).width})),o=n?0:Oy(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:o}}catch{return null}};function cOe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var BJ=(t,e,n,r)=>t.reduce((i,s)=>{var{word:o,width:l}=s,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},[]),$J=t=>t.reduce((e,n)=>e.width>n.width?e:n),uOe="…",qG=(t,e,n,r,i,s,o,l)=>{var c=t.slice(0,e),u=UJ({breakAll:n,style:r,children:c+uOe});if(!u)return[!1,[]];var d=BJ(u.wordsWithComputedWidth,s,o,l),h=d.length>i||$J(d).width>Number(s);return[h,d]},dOe=(t,e,n,r,i)=>{var{maxLines:s,children:o,style:l,breakAll:c}=t,u=Ht(s),d=String(o),h=BJ(e,r,n,i);if(!u||i)return h;var p=h.length>s||$J(h).width>Number(r);if(!p)return h;for(var m=0,x=d.length-1,y=0,b;m<=x&&y<=d.length-1;){var v=Math.floor((m+x)/2),S=v-1,[k,E]=qG(d,S,c,l,s,r,n,i),[N]=qG(d,v,c,l,s,r,n,i);if(!k&&!N&&(m=v+1),k&&N&&(x=v-1),!k&&N){b=E;break}y++}return b||h},WG=t=>{var e=ii(t)?[]:t.toString().split(zJ);return[{words:e,width:void 0}]},hOe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:o}=t;if((e||n)&&!zb.isSsr){var l,c,u=UJ({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:h}=u;l=d,c=h}else return WG(r);return dOe({breakAll:s,children:r,maxLines:o,style:i},l,c,e,!!n)}return WG(r)},HJ="#808080",fOe={angle:0,breakAll:!1,capHeight:"0.71em",fill:HJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},RM=w.forwardRef((t,e)=>{var n=bi(t,fOe),{x:r,y:i,lineHeight:s,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,h=GG(n,sOe),p=w.useMemo(()=>hOe({breakAll:h.breakAll,children:h.children,maxLines:h.maxLines,scaleToFit:c,style:h.style,width:h.width}),[h.breakAll,h.children,h.maxLines,c,h.style,h.width]),{dx:m,dy:x,angle:y,className:b,breakAll:v}=h,S=GG(h,oOe);if(!xl(r)||!xl(i)||p.length===0)return null;var k=Number(r)+(Ht(m)?m:0),E=Number(i)+(Ht(x)?x:0);if(!Sr(k)||!Sr(E))return null;var N;switch(d){case"start":N=cj("calc(".concat(o,")"));break;case"middle":N=cj("calc(".concat((p.length-1)/2," * -").concat(s," + (").concat(o," / 2))"));break;default:N=cj("calc(".concat(p.length-1," * -").concat(s,")"));break}var A=[];if(c){var M=p[0].width,{width:P}=h;A.push("scale(".concat(Ht(P)&&Ht(M)?P/M:1,")"))}return y&&A.push("rotate(".concat(y,", ").concat(k,", ").concat(E,")")),A.length&&(S.transform=A.join(" ")),w.createElement("text",HD({},es(S),{ref:e,x:k,y:E,className:ir("recharts-text",b),textAnchor:u,fill:l.includes("url")?HJ:l}),p.map((T,j)=>{var z=T.words.join(v?"":" ");return w.createElement("tspan",{x:k,dy:j===0?N:s,key:"".concat(z,"-").concat(j)},z)}))});RM.displayName="Text";var mOe=["labelRef"];function pOe(t,e){if(t==null)return{};var n,r,i=gOe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function gOe(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 KG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ii(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KG(Object(n),!0).forEach(function(r){bOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bOe(t,e,n){return(e=xOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xOe(t){var e=yOe(t,"string");return typeof e=="symbol"?e:e+""}function yOe(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 Tu(){return Tu=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},Tu.apply(null,arguments)}var VJ=w.createContext(null),GJ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o,children:l}=t,c=w.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o}),[e,n,r,i,s,o]);return w.createElement(VJ.Provider,{value:c},l)},qJ=()=>{var t=w.useContext(VJ),e=ov();return t||uQ(e)},vOe=w.createContext(null),wOe=()=>{var t=w.useContext(vOe),e=zt(LZ);return t||e},_Oe=t=>{var{value:e,formatter:n}=t,r=ii(t.children)?e:t.children;return typeof n=="function"?n(r):r},CO=t=>t!=null&&typeof t=="function",SOe=(t,e)=>{var n=Pa(e-t),r=Math.min(Math.abs(e-t),360);return n*r},NOe=(t,e,n,r,i)=>{var{offset:s,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:h,endAngle:p,clockWise:m}=i,x=(u+d)/2,y=SOe(h,p),b=y>=0?1:-1,v,S;switch(e){case"insideStart":v=h+b*s,S=m;break;case"insideEnd":v=p-b*s,S=!m;break;case"end":v=p+b*s,S=m;break;default:throw new Error("Unsupported position ".concat(e))}S=y<=0?S:!S;var k=Ji(l,c,x,v),E=Ji(l,c,x,v+(S?1:-1)*359),N="M".concat(k.x,",").concat(k.y,`
  8101. A`).concat(x,",").concat(x,",0,1,").concat(S?0:1,`,
  8102. `).concat(E.x,",").concat(E.y),A=ii(t.id)?p0("recharts-radial-line-"):t.id;return w.createElement("text",Tu({},r,{dominantBaseline:"central",className:ir("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:A,d:N})),w.createElement("textPath",{xlinkHref:"#".concat(A)},n))},kOe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:h}=Ji(r,i,o+e,u);return{x:d,y:h,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 p=(s+o)/2,{x:m,y:x}=Ji(r,i,p,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},VD=t=>"cx"in t&&Ht(t.cx),MOe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!VD(n)&&(s=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,h=o,p=o+(c-u)/2,m=(h+p)/2,x=(c+u)/2,y=h+c/2,b=d>=0?1:-1,v=b*r,S=b>0?"end":"start",k=b>0?"start":"end",E=c>=0?1:-1,N=E*r,A=E>0?"end":"start",M=E>0?"start":"end";if(i==="top"){var P={x:h+c/2,y:l-v,textAnchor:"middle",verticalAnchor:S};return Ii(Ii({},P),s?{height:Math.max(l-s.y,0),width:c}:{})}if(i==="bottom"){var T={x:p+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:k};return Ii(Ii({},T),s?{height:Math.max(s.y+s.height-(l+d),0),width:u}:{})}if(i==="left"){var j={x:m-N,y:l+d/2,textAnchor:A,verticalAnchor:"middle"};return Ii(Ii({},j),s?{width:Math.max(j.x-s.x,0),height:d}:{})}if(i==="right"){var z={x:m+x+N,y:l+d/2,textAnchor:M,verticalAnchor:"middle"};return Ii(Ii({},z),s?{width:Math.max(s.x+s.width-z.x,0),height:d}:{})}var F=s?{width:x,height:d}:{};return i==="insideLeft"?Ii({x:m+N,y:l+d/2,textAnchor:M,verticalAnchor:"middle"},F):i==="insideRight"?Ii({x:m+x-N,y:l+d/2,textAnchor:A,verticalAnchor:"middle"},F):i==="insideTop"?Ii({x:h+c/2,y:l+v,textAnchor:"middle",verticalAnchor:k},F):i==="insideBottom"?Ii({x:p+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:S},F):i==="insideTopLeft"?Ii({x:h+N,y:l+v,textAnchor:M,verticalAnchor:k},F):i==="insideTopRight"?Ii({x:h+c-N,y:l+v,textAnchor:A,verticalAnchor:k},F):i==="insideBottomLeft"?Ii({x:p+N,y:l+d-v,textAnchor:M,verticalAnchor:S},F):i==="insideBottomRight"?Ii({x:p+u-N,y:l+d-v,textAnchor:A,verticalAnchor:S},F):i&&typeof i=="object"&&(Ht(i.x)||nd(i.x))&&(Ht(i.y)||nd(i.y))?Ii({x:o+gs(i.x,x),y:l+gs(i.y,d),textAnchor:"end",verticalAnchor:"end"},F):Ii({x:y,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},F)},COe={angle:0,offset:5,zIndex:Di.label,position:"middle",textBreakAll:!1};function ah(t){var e=bi(t,COe),{viewBox:n,position:r,value:i,children:s,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=wOe(),h=qJ(),p=r==="center"?h:d??h,m,x,y;if(n==null?m=p:VD(n)?m=n:m=uQ(n),!m||ii(i)&&ii(s)&&!w.isValidElement(o)&&typeof o!="function")return null;var b=Ii(Ii({},e),{},{viewBox:m});if(w.isValidElement(o)){var{labelRef:v}=b,S=pOe(b,mOe);return w.cloneElement(o,S)}if(typeof o=="function"){if(x=w.createElement(o,b),w.isValidElement(x))return x}else x=_Oe(e);var k=es(e);if(VD(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return NOe(e,r,x,k,m);y=kOe(m,e.offset,e.position)}else y=MOe(e,m);return w.createElement(xs,{zIndex:e.zIndex},w.createElement(RM,Tu({ref:u,className:ir("recharts-label",l)},k,y,{textAnchor:cOe(k.textAnchor)?k.textAnchor:y.textAnchor,breakAll:c}),x))}ah.displayName="Label";var EOe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(ah,Tu({key:"label-implicit"},r)):xl(t)?w.createElement(ah,Tu({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===ah?w.cloneElement(t,Ii({key:"label-implicit"},r)):w.createElement(ah,Tu({key:"label-implicit",content:t},r)):CO(t)?w.createElement(ah,Tu({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(ah,Tu({},t,{key:"label-implicit"},r)):null};function WJ(t){var{label:e,labelRef:n}=t,r=qJ();return EOe(e,r,n)||null}var uj={},dj={},XG;function AOe(){return XG||(XG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(dj)),dj}var hj={},YG;function TOe(){return YG||(YG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(hj)),hj}var QG;function jOe(){return QG||(QG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=AOe(),n=TOe(),r=tL();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(uj)),uj}var fj,ZG;function POe(){return ZG||(ZG=1,fj=jOe().last),fj}var DOe=POe();const ROe=wl(DOe);var LOe=["valueAccessor"],OOe=["dataKey","clockWise","id","textBreakAll","zIndex"];function uN(){return uN=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},uN.apply(null,arguments)}function JG(t,e){if(t==null)return{};var n,r,i=FOe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function FOe(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 IOe=t=>Array.isArray(t.value)?ROe(t.value):t.value,KJ=w.createContext(void 0),EO=KJ.Provider,XJ=w.createContext(void 0),zOe=XJ.Provider;function UOe(){return w.useContext(KJ)}function BOe(){return w.useContext(XJ)}function YS(t){var{valueAccessor:e=IOe}=t,n=JG(t,LOe),{dataKey:r,clockWise:i,id:s,textBreakAll:o,zIndex:l}=n,c=JG(n,OOe),u=UOe(),d=BOe(),h=u||d;return!h||!h.length?null:w.createElement(xs,{zIndex:l??Di.label},w.createElement(gi,{className:"recharts-label-list"},h.map((p,m)=>{var x,y=ii(r)?e(p,m):_r(p&&p.payload,r),b=ii(s)?{}:{id:"".concat(s,"-").concat(m)};return w.createElement(ah,uN({key:"label-".concat(m)},es(p),c,b,{fill:(x=n.fill)!==null&&x!==void 0?x:p.fill,parentViewBox:p.parentViewBox,value:y,textBreakAll:o,viewBox:p.viewBox,index:m,zIndex:0}))})))}YS.displayName="LabelList";function LM(t){var{label:e}=t;return e?e===!0?w.createElement(YS,{key:"labelList-implicit"}):w.isValidElement(e)||CO(e)?w.createElement(YS,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(YS,uN({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function GD(){return GD=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},GD.apply(null,arguments)}var YJ=t=>{var{cx:e,cy:n,r,className:i}=t,s=ir("recharts-dot",i);return Ht(e)&&Ht(n)&&Ht(r)?w.createElement("circle",GD({},Ps(t),eL(t),{className:s,cx:e,cy:n,r})):null},QJ=t=>t.graphicalItems.polarItems,$Oe=lt([fi,pv],QL),OM=lt([QJ,xi,$Oe],ZL),HOe=lt([OM],JL),FM=lt([HOe,BL],eO),VOe=lt([FM,xi,OM],nO);lt([FM,xi,OM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,o=_r(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:_r(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var eq=()=>{},GOe=lt([FM,xi,OM,TM,fi],sO),qOe=lt([xi,iO,aO,eq,GOe,eq,Wn,fi],oO),ZJ=lt([xi,Wn,FM,VOe,mv,fi,qOe],lO),WOe=lt([ZJ,xi,Wb],dO);lt([xi,ZJ,WOe,fi],fO);var KOe={radiusAxis:{},angleAxis:{}},JJ=ro({name:"polarAxis",initialState:KOe,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:AZe,removeRadiusAxis:TZe,addAngleAxis:jZe,removeAngleAxis:PZe}=JJ.actions,XOe=JJ.reducer;function tq(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 nq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tq(Object(n),!0).forEach(function(r){YOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YOe(t,e,n){return(e=QOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QOe(t){var e=ZOe(t,"string");return typeof e=="symbol"?e:e+""}function ZOe(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 JOe=(t,e)=>e,AO=lt([QJ,JOe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),eFe=[],TO=(t,e,n)=>n?.length===0?eFe:n,eee=lt([BL,AO,TO],(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(s=>nq(nq({},e.presentationProps),s.props))),i!=null)return i}}),tFe=lt([eee,AO,TO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,o=_r(r,e.nameKey,e.name),l;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Yh(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),nFe=lt([eee,AO,TO,pa],(t,e,n,r)=>{if(!(e==null||t==null))return rIe({offset:r,pieSettings:e,displayedData:t,cells:n})}),mj={exports:{}},Er={};var rq;function rFe(){if(rq)return Er;rq=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"),s=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"),h=Symbol.for("react.lazy"),p=Symbol.for("react.view_transition"),m=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 p:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case h:case d:return y;case s:return y;default:return b}}case e:return b}}}return Er.ContextConsumer=s,Er.ContextProvider=o,Er.Element=t,Er.ForwardRef=l,Er.Fragment=n,Er.Lazy=h,Er.Memo=d,Er.Portal=e,Er.Profiler=i,Er.StrictMode=r,Er.Suspense=c,Er.SuspenseList=u,Er.isContextConsumer=function(y){return x(y)===s},Er.isContextProvider=function(y){return x(y)===o},Er.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Er.isForwardRef=function(y){return x(y)===l},Er.isFragment=function(y){return x(y)===n},Er.isLazy=function(y){return x(y)===h},Er.isMemo=function(y){return x(y)===d},Er.isPortal=function(y){return x(y)===e},Er.isProfiler=function(y){return x(y)===i},Er.isStrictMode=function(y){return x(y)===r},Er.isSuspense=function(y){return x(y)===c},Er.isSuspenseList=function(y){return x(y)===u},Er.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===h||y.$$typeof===d||y.$$typeof===o||y.$$typeof===s||y.$$typeof===l||y.$$typeof===m||y.getModuleId!==void 0)},Er.typeOf=x,Er}var iq;function iFe(){return iq||(iq=1,mj.exports=rFe()),mj.exports}var aFe=iFe(),aq=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",sq=null,pj=null,tee=t=>{if(t===sq&&Array.isArray(pj))return pj;var e=[];return w.Children.forEach(t,n=>{ii(n)||(aFe.isFragment(n)?e=e.concat(tee(n.props.children)):e.push(n))}),pj=e,sq=t,e};function jO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>aq(i)):r=[aq(e)],tee(t).forEach(i=>{var s=Dm(i,"type.displayName")||Dm(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var PO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,gj={},oq;function sFe(){return oq||(oq=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})(gj)),gj}var bj,lq;function oFe(){return lq||(lq=1,bj=sFe().isPlainObject),bj}var lFe=oFe();const cFe=wl(lFe);function cq(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 uq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cq(Object(n),!0).forEach(function(r){uFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uFe(t,e,n){return(e=dFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dFe(t){var e=hFe(t,"string");return typeof e=="symbol"?e:e+""}function hFe(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 dN(){return dN=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},dN.apply(null,arguments)}var dq=(t,e,n,r,i)=>{var s=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-s/2,",").concat(e+i),o+="L ".concat(t+n-s/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},fFe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},mFe=t=>{var e=bi(t,fFe),{x:n,y:r,upperWidth:i,lowerWidth:s,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:h}=e,p=w.useRef(null),[m,x]=w.useState(-1),y=w.useRef(i),b=w.useRef(s),v=w.useRef(o),S=w.useRef(n),k=w.useRef(r),E=Bb(t,"trapezoid-");if(w.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var D=p.current.getTotalLength();D&&x(D)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||o!==+o||i===0&&s===0||o===0)return null;var N=ir("recharts-trapezoid",l);if(!h)return w.createElement("g",null,w.createElement("path",dN({},es(e),{className:N,d:dq(n,r,i,s,o)})));var A=y.current,M=b.current,P=v.current,T=S.current,j=k.current,z="0px ".concat(m===-1?1:m,"px"),F="".concat(m,"px 0px"),$=SQ(["strokeDasharray"],u,c);return w.createElement(Ub,{animationId:E,key:E,canBegin:m>0,duration:u,easing:c,isActive:h,begin:d},D=>{var H=pr(A,i,D),q=pr(M,s,D),I=pr(P,o,D),K=pr(T,n,D),Z=pr(j,r,D);p.current&&(y.current=H,b.current=q,v.current=I,S.current=K,k.current=Z);var se=D>0?{transition:$,strokeDasharray:F}:{strokeDasharray:z};return w.createElement("path",dN({},es(e),{className:N,d:dq(K,Z,H,q,I),ref:p,style:uq(uq({},se),e.style)}))})},pFe=["option","shapeType","propTransformer","activeClassName"];function gFe(t,e){if(t==null)return{};var n,r,i=bFe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function bFe(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 hq(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 hN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hq(Object(n),!0).forEach(function(r){xFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xFe(t,e,n){return(e=yFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yFe(t){var e=vFe(t,"string");return typeof e=="symbol"?e:e+""}function vFe(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 wFe(t,e){return hN(hN({},e),t)}function _Fe(t,e){return t==="symbols"}function fq(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(CQ,n);case"trapezoid":return w.createElement(mFe,n);case"sector":return w.createElement(jQ,n);case"symbols":if(_Fe(e))return w.createElement(J4,n);break;case"curve":return w.createElement(Vg,n);default:return null}}function SFe(t){return w.isValidElement(t)?t.props:t}function DO(t){var{option:e,shapeType:n,propTransformer:r=wFe,activeClassName:i="recharts-active-shape"}=t,s=gFe(t,pFe),o;if(w.isValidElement(e))o=w.cloneElement(e,hN(hN({},s),SFe(e)));else if(typeof e=="function")o=e(s,s.index);else if(cFe(e)&&typeof e!="boolean"){var l=r(e,s);o=w.createElement(fq,{shapeType:n,elementProps:l})}else{var c=s;o=w.createElement(fq,{shapeType:n,elementProps:c})}return s.isActive?w.createElement(gi,{className:i},o):o}var RO=(t,e,n)=>{var r=$r();return(i,s)=>o=>{t?.(i,s,o),r(hJ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},LO=t=>{var e=$r();return(n,r)=>i=>{t?.(n,r,i),e(IRe())}},OO=(t,e,n)=>{var r=$r();return(i,s)=>o=>{t?.(i,s,o),r(zRe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function IM(t){var{tooltipEntrySettings:e}=t,n=$r(),r=ga(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(RRe(e)):i.current!==e&&n(LRe({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(ORe(i.current)),i.current=null)},[n]),null}function FO(t){var{legendPayload:e}=t,n=$r(),r=ga(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(yQ(e)):i.current!==e&&n(vQ({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(wQ(i.current)),i.current=null)},[n]),null}function NFe(t){var{legendPayload:e}=t,n=$r(),r=zt(Wn),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(yQ(e)):i.current!==e&&n(vQ({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(wQ(i.current)),i.current=null)},[n]),null}var xj,kFe=()=>{var[t]=w.useState(()=>p0("uid-"));return t},MFe=(xj=xse.useId)!==null&&xj!==void 0?xj:kFe;function nee(t,e){var n=MFe();return e||(t?"".concat(t,"-").concat(n):n)}var CFe=w.createContext(void 0),zM=t=>{var{id:e,type:n,children:r}=t,i=nee("recharts-".concat(n),e);return w.createElement(CFe.Provider,{value:i},r(i))},EFe={cartesianItems:[],polarItems:[]},ree=ro({name:"graphicalItems",initialState:EFe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:li()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Wl(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:li()},removeCartesianGraphicalItem:{reducer(t,e){var n=Wl(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:li()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:li()},removePolarGraphicalItem:{reducer(t,e){var n=Wl(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:li()}}}),{addCartesianGraphicalItem:AFe,replaceCartesianGraphicalItem:TFe,removeCartesianGraphicalItem:jFe,addPolarGraphicalItem:PFe,removePolarGraphicalItem:DFe}=ree.actions,RFe=ree.reducer,LFe=t=>{var e=$r(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(AFe(t)):n.current!==t&&e(TFe({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(jFe(n.current)),n.current=null)},[e]),null},IO=w.memo(LFe);function OFe(t){var e=$r();return w.useLayoutEffect(()=>(e(PFe(t)),()=>{e(DFe(t))}),[e,t]),null}var FFe=["key"],IFe=["onMouseEnter","onClick","onMouseLeave"],zFe=["id"],UFe=["id"];function mq(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 Ai(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mq(Object(n),!0).forEach(function(r){BFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function BFe(t,e,n){return(e=$Fe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Fe(t){var e=HFe(t,"string");return typeof e=="symbol"?e:e+""}function HFe(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 Wh(){return Wh=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},Wh.apply(null,arguments)}function UM(t,e){if(t==null)return{};var n,r,i=VFe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function VFe(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 GFe(t){var e=w.useMemo(()=>jO(t.children,kv),[t.children]),n=zt(r=>tFe(r,t.id,e));return n==null?null:w.createElement(NFe,{legendPayload:n})}var qFe=w.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:o,dataKey:e,nameKey:n,name:Yh(l,e),hide:c,type:u,color:o,unit:""}};return w.createElement(IM,{tooltipEntrySettings:d})}),WFe=(t,e)=>t>e?"start":t<e?"end":"middle",KFe=(t,e,n)=>gs(typeof e=="function"?e(t):e,n,n*.8),XFe=(t,e,n)=>{var{top:r,left:i,width:s,height:o}=e,l=EQ(s,o),c=i+gs(t.cx,s,s/2),u=r+gs(t.cy,o,o/2),d=gs(t.innerRadius,l,0),h=KFe(n,t.outerRadius,l),p=t.maxRadius||Math.sqrt(s*s+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:h,maxRadius:p}},YFe=(t,e)=>{var n=Pa(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function QFe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var ZFe=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=ir("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=UM(e,FFe);return w.createElement(Vg,Wh({},i,{type:"linear",className:n}))},JFe=(t,e,n)=>{if(w.isValidElement(t))return w.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),w.isValidElement(r)))return r;var i=ir("recharts-pie-label-text",QFe(t));return w.createElement(RM,Wh({},e,{alignmentBaseline:"middle",className:i}),r)};function eIe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:o}=n;if(!r||!i||!e)return null;var l=Ps(n),c=Pm(i),u=Pm(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((p,m)=>{var x=(p.startAngle+p.endAngle)/2,y=Ji(p.cx,p.cy,p.outerRadius+d,x),b=Ai(Ai(Ai(Ai({},l),p),{},{stroke:"none"},c),{},{index:m,textAnchor:WFe(y.x,p.cx)},y),v=Ai(Ai(Ai(Ai({},l),p),{},{fill:"none",stroke:p.fill},u),{},{index:m,points:[Ji(p.cx,p.cy,p.outerRadius,x),y],key:"line"});return w.createElement(xs,{zIndex:Di.label,key:"label-".concat(p.startAngle,"-").concat(p.endAngle,"-").concat(p.midAngle,"-").concat(m)},w.createElement(gi,null,s&&ZFe(s,v),JFe(i,b,_r(p,o))))});return w.createElement(gi,{className:"recharts-pie-labels"},h)}function tIe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(LM,{label:i}):w.createElement(eIe,{sectors:e,props:n,showLabels:r})}function nIe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:o}=t,l=zt(qh),c=zt(_O),u=zt(N4e),{onMouseEnter:d,onClick:h,onMouseLeave:p}=i,m=UM(i,IFe),x=RO(d,i.dataKey,o),y=LO(p),b=OO(h,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((v,S)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var k=u==null||u===o,E=String(S)===l&&(c==null||i.dataKey===c)&&k,N=l?r:null,A=n&&E?n:N,M=Ai(Ai({},v),{},{stroke:v.stroke,tabIndex:-1,[aQ]:S,[sQ]:i.dataKey});return w.createElement(gi,Wh({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},nv(m,v,S),{onMouseEnter:x(v,S),onMouseLeave:y(v,S),onClick:b(v,S)}),w.createElement(DO,Wh({option:s??A,index:S,shapeType:"sector",isActive:E},M)))}))}function rIe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:h}=n,p=Math.abs(n.minAngle),m=YFe(l,c),x=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(A=>_r(A,u,0)!==0).length,v=(x>=360?b:b-1)*y,S=x-b*p-v,k=r.reduce((A,M)=>{var P=_r(M,u,0);return A+(Ht(P)?P:0)},0),E;if(k>0){var N;E=r.map((A,M)=>{var P=_r(A,u,0),T=_r(A,d,M),j=XFe(n,s,A),z=(Ht(P)?P:0)/k,F,$=Ai(Ai({},A),i&&i[M]&&i[M].props);M?F=N.endAngle+Pa(m)*y*(P!==0?1:0):F=l;var D=F+Pa(m)*((P!==0?p:0)+z*S),H=(F+D)/2,q=(j.innerRadius+j.outerRadius)/2,I=[{name:T,value:P,payload:$,dataKey:u,type:h}],K=Ji(j.cx,j.cy,q,H);return N=Ai(Ai(Ai(Ai({},n.presentationProps),{},{percent:z,cornerRadius:typeof o=="string"?parseFloat(o):o,name:T,tooltipPayload:I,midAngle:H,middleRadius:q,tooltipPosition:K},$),j),{},{value:P,dataKey:u,startAngle:F,endAngle:D,payload:$,paddingAngle:Pa(m)*y}),N})}return E}function iIe(t){var{showLabels:e,sectors:n,children:r}=t,i=w.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return w.createElement(zOe,{value:e?i:void 0},r)}function aIe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:h,onAnimationEnd:p}=e,m=Bb(e,"recharts-pie-"),x=n.current,[y,b]=w.useState(!1),v=w.useCallback(()=>{typeof p=="function"&&p(),b(!1)},[p]),S=w.useCallback(()=>{typeof h=="function"&&h(),b(!0)},[h]);return w.createElement(iIe,{showLabels:!y,sectors:i},w.createElement(Ub,{animationId:m,begin:o,duration:l,isActive:s,easing:c,onAnimationStart:S,onAnimationEnd:v,key:m},k=>{var E=[],N=i&&i[0],A=N?.startAngle;return i?.forEach((M,P)=>{var T=x&&x[P],j=P>0?Dm(M,"paddingAngle",0):0;if(T){var z=pr(T.endAngle-T.startAngle,M.endAngle-M.startAngle,k),F=Ai(Ai({},M),{},{startAngle:A+j,endAngle:A+z+j});E.push(F),A=F.endAngle}else{var{endAngle:$,startAngle:D}=M,H=pr(0,$-D,k),q=Ai(Ai({},M),{},{startAngle:A+j,endAngle:A+H+j});E.push(q),A=q.endAngle}}),n.current=E,w.createElement(gi,null,w.createElement(nIe,{sectors:E,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(tIe,{showLabels:!y,sectors:i,props:e}),e.children)}var sIe={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:Di.area};function oIe(t){var{id:e}=t,n=UM(t,zFe),{hide:r,className:i,rootTabIndex:s}=t,o=w.useMemo(()=>jO(t.children,kv),[t.children]),l=zt(d=>nFe(d,e,o)),c=w.useRef(null),u=ir("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(gi,{tabIndex:s,className:u})):w.createElement(xs,{zIndex:t.zIndex},w.createElement(qFe,{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}),w.createElement(gi,{tabIndex:s,className:u},w.createElement(aIe,{props:Ai(Ai({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function iee(t){var e=bi(t,sIe),{id:n}=e,r=UM(e,UFe),i=Ps(r);return w.createElement(zM,{id:n,type:"pie"},s=>w.createElement(w.Fragment,null,w.createElement(OFe,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),w.createElement(GFe,Wh({},r,{id:s})),w.createElement(oIe,Wh({},r,{id:s}))))}iee.displayName="Pie";var lIe=["points"];function pq(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 yj(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pq(Object(n),!0).forEach(function(r){cIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cIe(t,e,n){return(e=uIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uIe(t){var e=dIe(t,"string");return typeof e=="symbol"?e:e+""}function dIe(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 fN(){return fN=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},fN.apply(null,arguments)}function hIe(t,e){if(t==null)return{};var n,r,i=fIe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function fIe(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 mIe(t){var{option:e,dotProps:n,className:r}=t;if(w.isValidElement(e))return w.cloneElement(e,n);if(typeof e=="function")return e(n);var i=ir(r,typeof e!="boolean"?e.className:""),s=n??{},{points:o}=s,l=hIe(s,lIe);return w.createElement(YJ,fN({},l,{className:i}))}function pIe(t,e){return t==null?!1:e?!0:t.length===1}function aee(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:o,needClip:l,clipPathId:c,zIndex:u=Di.scatter}=t;if(!pIe(e,n))return null;var d=PO(n),h=qMe(n),p=e.map((x,y)=>{var b,v,S=yj(yj(yj({r:3},o),h),{},{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:s,value:x.value,payload:x.payload,points:e});return w.createElement(mIe,{key:"dot-".concat(y),option:n,dotProps:S,className:i})}),m={};return l&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement(xs,{zIndex:u},w.createElement(gi,fN({className:r},m),p))}function gq(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 bq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gq(Object(n),!0).forEach(function(r){gIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gIe(t,e,n){return(e=bIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bIe(t){var e=xIe(t,"string");return typeof e=="symbol"?e:e+""}function xIe(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 yIe={xAxis:{},yAxis:{},zAxis:{}},see=ro({name:"cartesianAxis",initialState:yIe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:li()},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:li()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:li()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:li()},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:li()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:li()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:li()},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:li()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:li()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var s=i.widthHistory||[];if(s.length===3&&s[0]===s[2]&&r===s[1]&&r!==i.width&&Math.abs(r-s[0])<=1)return;var o=[...s,r].slice(-3);t.yAxis[n]=bq(bq({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:vIe,replaceXAxis:wIe,removeXAxis:_Ie,addYAxis:SIe,replaceYAxis:NIe,removeYAxis:kIe,addZAxis:DZe,replaceZAxis:RZe,removeZAxis:LZe,updateYAxisWidth:MIe}=see.actions,CIe=see.reducer,EIe=lt([pa],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),AIe=lt([EIe,ud,dd],(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)}}),BM=()=>zt(AIe),TIe=()=>zt(A4e);function xq(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 vj(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xq(Object(n),!0).forEach(function(r){jIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jIe(t,e,n){return(e=PIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PIe(t){var e=DIe(t,"string");return typeof e=="symbol"?e:e+""}function DIe(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 RIe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=vj(vj(vj({},l),Pm(i)),eL(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(YJ,c),w.createElement(gi,{className:"recharts-active-dot",clipPath:o},u)};function qD(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:o=Di.activeDot}=t,l=zt(qh),c=TIe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return ii(u)?null:w.createElement(xs,{zIndex:o},w.createElement(RIe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var LIe="Invariant failed";function OIe(t,e){throw new Error(LIe)}var FIe=["x","y"];function WD(){return WD=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},WD.apply(null,arguments)}function yq(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 uy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yq(Object(n),!0).forEach(function(r){IIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function IIe(t,e,n){return(e=zIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zIe(t){var e=UIe(t,"string");return typeof e=="symbol"?e:e+""}function UIe(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 BIe(t,e){if(t==null)return{};var n,r,i=$Ie(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function $Ie(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 HIe(t,e){var{x:n,y:r}=t,i=BIe(t,FIe),s="".concat(n),o=parseInt(s,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),h="".concat(e.width||i.width),p=parseInt(h,10);return uy(uy(uy(uy(uy({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:p,name:e.name,radius:e.radius})}function mN(t){return w.createElement(DO,WD({shapeType:"rectangle",propTransformer:HIe,activeClassName:"recharts-active-bar"},t))}var VIe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ht(e))return e;var s=Ht(r)||ii(r);return s?e(r,i):(s||OIe(),n)}},GIe={},oee=ro({name:"errorBars",initialState:GIe,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(s=>s.dataKey===r.dataKey&&s.direction===r.direction?i:s))},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:OZe,replaceErrorBar:FZe,removeErrorBar:IZe}=oee.actions,qIe=oee.reducer,WIe=["children"];function KIe(t,e){if(t==null)return{};var n,r,i=XIe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function XIe(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 YIe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},QIe=w.createContext(YIe);function lee(t){var{children:e}=t,n=KIe(t,WIe);return w.createElement(QIe.Provider,{value:n},e)}function $M(t,e){var n,r,i=zt(u=>$c(u,t)),s=zt(u=>Hc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ca.allowDataOverflow,l=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Ea.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function zO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=BM(),{needClipX:s,needClipY:o,needClip:l}=$M(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:h}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:s?c:c-d/2,y:o?u:u-h/2,width:s?d:d*2,height:o?h:h*2}))}function ZIe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Sr(t.zIndex)?t.zIndex:e}var wj={exports:{}},_j={};var vq;function JIe(){if(vq)return _j;vq=1;var t=Cb();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,s=t.useEffect,o=t.useMemo,l=t.useDebugValue;return _j.useSyncExternalStoreWithSelector=function(c,u,d,h,p){var m=i(null);if(m.current===null){var x={hasValue:!1,value:null};m.current=x}else x=m.current;m=o(function(){function b(N){if(!v){if(v=!0,S=N,N=h(N),p!==void 0&&x.hasValue){var A=x.value;if(p(A,N))return k=A}return k=N}if(A=k,n(S,N))return A;var M=h(N);return p!==void 0&&p(A,M)?(S=N,A):(S=N,k=M)}var v=!1,S,k,E=d===void 0?null:d;return[function(){return b(u())},E===null?void 0:function(){return b(E())}]},[u,d,h,p]);var y=r(c,m[0],m[1]);return s(function(){x.hasValue=!0,x.value=y},[y]),l(y),y},_j}var wq;function e5e(){return wq||(wq=1,wj.exports=JIe()),wj.exports}e5e();function t5e(t){t()}function n5e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){t5e(()=>{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 _q={notify(){},get:()=>[]};function r5e(t,e){let n,r=_q,i=0,s=!1;function o(y){d();const b=r.subscribe(y);let v=!1;return()=>{v||(v=!0,b(),h())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(c),r=n5e())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=_q)}function p(){s||(s=!0,d())}function m(){s&&(s=!1,h())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:p,tryUnsubscribe:m,getListeners:()=>r};return x}var i5e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",a5e=i5e(),s5e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",o5e=s5e(),l5e=()=>a5e||o5e?w.useLayoutEffect:w.useEffect,c5e=l5e();function Sq(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function u5e(t,e){if(Sq(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])||!Sq(t[n[i]],e[n[i]]))return!1;return!0}var d5e=Symbol.for("react-redux-context"),h5e=typeof globalThis<"u"?globalThis:{};function f5e(){if(!w.createContext)return{};const t=h5e[d5e]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var m5e=f5e();function p5e(t){const{children:e,context:n,serverState:r,store:i}=t,s=w.useMemo(()=>{const c=r5e(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);c5e(()=>{const{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,o]);const l=n||m5e;return w.createElement(l.Provider,{value:s},e)}var g5e=p5e,b5e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function x5e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Mv(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(b5e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!u5e(t[r],e[r]))return!1}else if(!x5e(t[r],e[r]))return!1;return!0}var y5e=["onMouseEnter","onMouseLeave","onClick"],v5e=["value","background","tooltipPosition"],w5e=["id"],_5e=["onMouseEnter","onClick","onMouseLeave"];function ld(){return ld=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},ld.apply(null,arguments)}function Nq(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 ks(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Nq(Object(n),!0).forEach(function(r){S5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Nq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function S5e(t,e,n){return(e=N5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function N5e(t){var e=k5e(t,"string");return typeof e=="symbol"?e:e+""}function k5e(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 pN(t,e){if(t==null)return{};var n,r,i=M5e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function M5e(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 C5e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Yh(n,e),payload:t}]},E5e=w.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,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:Yh(s,e),hide:o,type:c,color:i,unit:l}};return w.createElement(IM,{tooltipEntrySettings:u})});function A5e(t){var e=zt(qh),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=s,u=pN(s,y5e),d=RO(o,r),h=LO(l),p=OO(c,r);if(!i||n==null)return null;var m=Pm(i);return w.createElement(xs,{zIndex:ZIe(i,Di.barBackground)},n.map((x,y)=>{var{value:b,background:v,tooltipPosition:S}=x,k=pN(x,v5e);if(!v)return null;var E=d(x,y),N=h(x,y),A=p(x,y),M=ks(ks(ks(ks(ks({option:i,isActive:String(y)===e},k),{},{fill:"#eee"},v),m),nv(u,x,y)),{},{onMouseEnter:E,onMouseLeave:N,onClick:A,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return w.createElement(mN,ld({key:"background-bar-".concat(y)},M))}))}function T5e(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var o={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return ks(ks({},o),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:o,fill:s.fill})});return w.createElement(EO,{value:e?i:void 0},n)}function j5e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:o}=t,l=zt(qh),c=zt(_O),u=n&&String(s)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(xs,{zIndex:Di.activeBar},w.createElement(mN,ld({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))):w.createElement(mN,ld({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))}function P5e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return w.createElement(mN,ld({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function D5e(t){var e,{data:n,props:r}=t,i=(e=Ps(r))!==null&&e!==void 0?e:{},{id:s}=i,o=pN(i,w5e),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:h,onMouseLeave:p}=r,m=pN(r,_5e),x=RO(d,c),y=LO(p),b=OO(h,c);return n?w.createElement(w.Fragment,null,n.map((v,S)=>w.createElement(gi,ld({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},nv(m,v,S),{onMouseEnter:x(v,S),onMouseLeave:y(v,S),onClick:b(v,S)}),u?w.createElement(j5e,{shape:l,activeBar:u,baseProps:o,entry:v,index:S,dataKey:c}):w.createElement(P5e,{shape:l,baseProps:o,entry:v,index:S,dataKey:c})))):null}function R5e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,h=n.current,p=Bb(e,"recharts-bar-"),[m,x]=w.useState(!1),y=!m,b=w.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=w.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return w.createElement(T5e,{showLabels:y,rects:r},w.createElement(Ub,{animationId:p,begin:o,duration:l,isActive:s,easing:c,onAnimationEnd:b,onAnimationStart:v,key:p},S=>{var k=S===1?r:r?.map((E,N)=>{var A=h&&h[N];if(A)return ks(ks({},E),{},{x:pr(A.x,E.x,S),y:pr(A.y,E.y,S),width:pr(A.width,E.width,S),height:pr(A.height,E.height,S)});if(i==="horizontal"){var M=pr(0,E.height,S),P=pr(E.stackedBarStart,E.y,S);return ks(ks({},E),{},{y:P,height:M})}var T=pr(0,E.width,S),j=pr(E.stackedBarStart,E.x,S);return ks(ks({},E),{},{width:T,x:j})});return S>0&&(n.current=k??null),k==null?null:w.createElement(gi,null,w.createElement(D5e,{props:e,data:k}))}),w.createElement(LM,{label:e.label}),e.children)}function L5e(t){var e=w.useRef(null);return w.createElement(R5e,{previousRectanglesRef:e,props:t})}var cee=0,O5e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:_r(t,e)}};class F5e extends w.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=ir("recharts-bar",i),h=u;return w.createElement(gi,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(zO,{clipPathId:h,xAxisId:s,yAxisId:o})),w.createElement(gi,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(h,")"):void 0},w.createElement(A5e,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(L5e,this.props)))}}var I5e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:cee,xAxisId:0,yAxisId:0,zIndex:Di.bar};function z5e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:h}=$M(e,n),p=Km(),m=ga(),x=jO(t.children,kv),y=zt(S=>fze(S,e,n,m,t.id,x));if(p!=="vertical"&&p!=="horizontal")return null;var b,v=y?.[0];return v==null||v.height==null||v.width==null?b=0:b=p==="vertical"?v.height/2:v.width/2,w.createElement(lee,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:O5e,errorBarOffset:b},w.createElement(F5e,ld({},t,{layout:p,needClip:h,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function U5e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:h,offset:p,cells:m,parentViewBox:x,dataStartIndex:y}=t,b=e==="horizontal"?l:o,v=d?b.scale.domain():null,S=cAe({numericAxis:b}),k=b.scale(S);return h.map((E,N)=>{var A,M,P,T,j,z;d?A=iAe(d[N+y],v):(A=_r(E,n),Array.isArray(A)||(A=[S,A]));var F=VIe(r,cee)(A[1],N);if(e==="horizontal"){var $,[D,H]=[l.scale(A[0]),l.scale(A[1])];M=BH({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:E,index:N}),P=($=H??D)!==null&&$!==void 0?$:void 0,T=i.size;var q=D-H;if(j=no(q)?0:q,z={x:M,y:p.top,width:T,height:p.height},Math.abs(F)>0&&Math.abs(j)<Math.abs(F)){var I=Pa(j||F)*(Math.abs(F)-Math.abs(j));P-=I,j+=I}}else{var[K,Z]=[o.scale(A[0]),o.scale(A[1])];if(M=K,P=BH({axis:l,ticks:u,bandSize:s,offset:i.offset,entry:E,index:N}),T=Z-K,j=i.size,z={x:p.left,y:P,width:p.width,height:j},Math.abs(F)>0&&Math.abs(T)<Math.abs(F)){var se=Pa(T||F)*(Math.abs(F)-Math.abs(T));T+=se}}if(M==null||P==null||T==null||j==null)return null;var V=ks(ks({},E),{},{stackedBarStart:k,x:M,y:P,width:T,height:j,value:d?A:A[1],payload:E,background:z,tooltipPosition:{x:M+T/2,y:P+j/2},parentViewBox:x},m&&m[N]&&m[N].props);return V}).filter(Boolean)}function B5e(t){var e=bi(t,I5e),n=ga();return w.createElement(zM,{id:e.id,type:"bar"},r=>w.createElement(w.Fragment,null,w.createElement(FO,{legendPayload:C5e(e)}),w.createElement(E5e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),w.createElement(IO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:rQ(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),w.createElement(xs,{zIndex:e.zIndex},w.createElement(z5e,ld({},e,{id:r})))))}var uee=w.memo(B5e,Mv);uee.displayName="Bar";function kq(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 hS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kq(Object(n),!0).forEach(function(r){$5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $5e(t,e,n){return(e=H5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H5e(t){var e=V5e(t,"string");return typeof e=="symbol"?e:e+""}function V5e(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 G5e=(t,e)=>e,q5e=(t,e,n)=>n,W5e=(t,e,n,r)=>r,K5e=(t,e,n,r,i)=>i,Cv=lt([bv,K5e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),X5e=lt([Cv],t=>t?.maxBarSize),Y5e=(t,e,n,r,i,s)=>s,Mq=(t,e,n)=>{var r=n??t;if(!ii(r))return gs(r,e,0)},Q5e=lt([Wn,bv,G5e,q5e,W5e],(t,e,n,r,i)=>e.filter(s=>t==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===i).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),Z5e=(t,e,n,r)=>{var i=Wn(t);return i==="horizontal"?E0(t,"yAxis",n,r):E0(t,"xAxis",e,r)},J5e=(t,e,n)=>{var r=Wn(t);return r==="horizontal"?vG(t,"xAxis",e):vG(t,"yAxis",n)},eze=(t,e,n)=>{var r={},i=t.filter(MM),s=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,h]=u,p=h.map(x=>x.dataKey),m=Mq(e,n,h[0].barSize);return{stackId:d,dataKeys:p,barSize:m}}),c=s.map(u=>{var d=[u.dataKey].filter(p=>p!=null),h=Mq(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:h}});return[...l,...c]},tze=lt([Q5e,MDe,J5e],eze),nze=(t,e,n,r,i)=>{var s,o,l=Cv(t,e,n,r,i);if(l!=null){var c=Wn(t),u=CZ(t),{maxBarSize:d}=l,h=ii(d)?u:d,p,m;return c==="horizontal"?(p=Lc(t,"xAxis",e,r),m=Rc(t,"xAxis",e,r)):(p=Lc(t,"yAxis",n,r),m=Rc(t,"yAxis",n,r)),(s=(o=Hh(p,m,!0))!==null&&o!==void 0?o:h)!==null&&s!==void 0?s:0}},dee=(t,e,n,r)=>{var i=Wn(t),s,o;return i==="horizontal"?(s=Lc(t,"xAxis",e,r),o=Rc(t,"xAxis",e,r)):(s=Lc(t,"yAxis",n,r),o=Rc(t,"yAxis",n,r)),Hh(s,o)};function rze(t,e,n,r,i){var s=r.length;if(!(s<1)){var o=gs(t,n,0,!0),l,c=[];if(Sr(r[0].barSize)){var u=!1,d=n/s,h=r.reduce((v,S)=>v+(S.barSize||0),0);h+=(s-1)*o,h>=n&&(h-=(s-1)*o,o=0),h>=n&&d>0&&(u=!0,d*=.9,h=s*d);var p=(n-h)/2>>0,m={offset:p-o,size:0};l=r.reduce((v,S)=>{var k,E={stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:m.offset+m.size+o,size:u?d:(k=S.barSize)!==null&&k!==void 0?k:0}},N=[...v,E];return m=N[N.length-1].position,N},c)}else{var x=gs(e,n,0,!0);n-2*x-(s-1)*o<=0&&(o=0);var y=(n-2*x-(s-1)*o)/s;y>1&&(y>>=0);var b=Sr(i)?Math.min(y,i):y;l=r.reduce((v,S,k)=>[...v,{stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:x+(y+o)*k+(y-b)/2,size:b}}],c)}return l}}var ize=(t,e,n,r,i,s,o)=>{var l=ii(o)?e:o,c=rze(n,r,i!==s?i:s,t,l);return i!==s&&c!=null&&(c=c.map(u=>hS(hS({},u),{},{position:hS(hS({},u.position),{},{offset:u.position.offset-i/2})}))),c},aze=lt([tze,CZ,kDe,EZ,nze,dee,X5e],ize),sze=(t,e,n,r)=>Lc(t,"xAxis",e,r),oze=(t,e,n,r)=>Lc(t,"yAxis",n,r),lze=(t,e,n,r)=>Rc(t,"xAxis",e,r),cze=(t,e,n,r)=>Rc(t,"yAxis",n,r),uze=lt([aze,Cv],(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}}),dze=(t,e)=>{var n=kM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(o=>o.key===n)}}}},hze=lt([Z5e,Cv],dze),fze=lt([pa,dL,sze,oze,lze,cze,uze,Wn,fv,dee,hze,Cv,Y5e],(t,e,n,r,i,s,o,l,c,u,d,h,p)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:y}=c;if(!(h==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||s==null||u==null)){var{data:b}=h,v;if(b!=null&&b.length>0?v=b:v=m?.slice(x,y+1),v!=null)return U5e({layout:l,barSettings:h,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:v,offset:t,cells:p,dataStartIndex:x})}}),hee=t=>{var{chartData:e}=t,n=$r(),r=ga();return w.useEffect(()=>r?()=>{}:(n(DG(e)),()=>{n(DG(void 0))}),[e,n,r]),null},Cq={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},fee=ro({name:"brush",initialState:Cq,reducers:{setBrushSettings(t,e){return e.payload==null?Cq:e.payload}}}),{setBrushSettings:zZe}=fee.actions,mze=fee.reducer;function Eq(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 fS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Eq(Object(n),!0).forEach(function(r){mee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Eq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mee(t,e,n){return(e=pze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pze(t){var e=gze(t,"string");return typeof e=="symbol"?e:e+""}function gze(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 bze=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return{x:Math.min(n,i),y:Math.min(r,s),width:Math.abs(i-n),height:Math.abs(s-r)}},xze=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return bze({x:e,y:n},{x:r,y:i})};class HM{static create(e){return new HM(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 s=this.bandwidth?this.bandwidth():0;return this.scale(e)+s}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}}mee(HM,"EPS",1e-4);var yze=t=>{var e=Object.keys(t).reduce((n,r)=>fS(fS({},n),{},{[r]:HM.create(t[r])}),{});return fS(fS({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(s=>{var[o,l]=s;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function vze(t){return(t%180+180)%180}var wze=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=vze(i),o=s*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)},_ze={dots:[],areas:[],lines:[]},pee=ro({name:"referenceElements",initialState:_ze,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Wl(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=Wl(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=Wl(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:UZe,removeDot:BZe,addArea:$Ze,removeArea:HZe,addLine:Sze,removeLine:Nze}=pee.actions,kze=pee.reducer,gee=w.createContext(void 0),Mze=t=>{var{children:e}=t,[n]=w.useState("".concat(p0("recharts"),"-clip")),r=BM();if(r==null)return null;var{x:i,y:s,width:o,height:l}=r;return w.createElement(gee.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:s,height:l,width:o}))),e)},Cze=()=>w.useContext(gee);function Aq(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 Tq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Aq(Object(n),!0).forEach(function(r){Eze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Aq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Eze(t,e,n){return(e=Aze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Aze(t){var e=Tze(t,"string");return typeof e=="symbol"?e:e+""}function Tze(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 gN(){return gN=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},gN.apply(null,arguments)}var jze=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Sr(e.x1)||!Sr(e.y1)||!Sr(e.x2)||!Sr(e.y2))return null;n=w.createElement("line",gN({},e,{className:"recharts-reference-line-line"}))}return n},Pze=(t,e,n,r,i,s)=>{var{x:o,width:l}=s,c=i.y.apply(t,{position:n});if(no(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},Dze=(t,e,n,r,i,s)=>{var{y:o,height:l}=s,c=i.x.apply(t,{position:n});if(no(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},Rze=(t,e,n,r)=>{var i=t.map(s=>r.apply(s,{position:n}));return e==="discard"&&i.some(s=>!r.isInRange(s))?null:i},Lze=(t,e,n,r,i,s)=>{var{x:o,y:l,segment:c,ifOverflow:u}=s,d=xl(o),h=xl(l);return h?Pze(l,u,n,i,t,e):d?Dze(o,u,n,r,t,e):c!=null&&c.length===2?Rze(c,u,n,t):null};function Oze(t){var e=$r();return w.useEffect(()=>(e(Sze(t)),()=>{e(Nze(t))})),null}function Fze(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,o=ga(),l=Cze(),c=zt(A=>$c(A,e)),u=zt(A=>Hc(A,n)),d=zt(A=>Gh(A,"xAxis",e,o)),h=zt(A=>Gh(A,"yAxis",n,o)),p=ov();if(!l||!p||c==null||u==null||d==null||h==null)return null;var m=yze({x:d,y:h}),x=Lze(m,p,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:b},{x:v,y:S}]=x,k=s==="hidden"?"url(#".concat(l,")"):void 0,E=Tq(Tq({clipPath:k},es(t)),{},{x1:y,y1:b,x2:v,y2:S}),N=xze({x1:y,y1:b,x2:v,y2:S});return w.createElement(xs,{zIndex:t.zIndex},w.createElement(gi,{className:ir("recharts-reference-line",i)},jze(r,E),w.createElement(GJ,gN({},N,{lowerWidth:N.width,upperWidth:N.width}),w.createElement(WJ,{label:t.label}),t.children)))}var Ize={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Di.line};function wy(t){var e=bi(t,Ize);return w.createElement(w.Fragment,null,w.createElement(Oze,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(Fze,e))}wy.displayName="ReferenceLine";function bee(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 zze(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return wze(r,n)}function Uze(t,e,n){var r=n==="width",{x:i,y:s,width:o,height:l}=t;return e===1?{start:r?i:s,end:r?i+o:s+l}:{start:r?i+o:s+l,end:r?i:s}}function bN(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var s=n();return t*(e-t*s/2-r)>=0&&t*(e+t*s/2-i)<=0}function Bze(t,e){return bee(t,e+1)}function $ze(t,e,n,r,i){for(var s=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,h=function(){var x=r?.[c];if(x===void 0)return{v:bee(r,u)};var y=c,b,v=()=>(b===void 0&&(b=n(x,y)),b),S=x.coordinate,k=c===0||bN(t,S,v,d,l);k||(c=0,d=o,u+=1),k&&(d=S+t*(v()/2+i),c+=u)},p;u<=s.length;)if(p=h(),p)return p.v;return[]}function jq(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function cs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jq(Object(n),!0).forEach(function(r){Hze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Hze(t,e,n){return(e=Vze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vze(t){var e=Gze(t,"string");return typeof e=="symbol"?e:e+""}function Gze(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 qze(t,e,n,r,i){for(var s=(r||[]).slice(),o=s.length,{start:l}=e,{end:c}=e,u=function(p){var m=s[p],x,y=()=>(x===void 0&&(x=n(m,p)),x);if(p===o-1){var b=t*(m.coordinate+t*y()/2-c);s[p]=m=cs(cs({},m),{},{tickCoord:b>0?m.coordinate-b*t:m.coordinate})}else s[p]=m=cs(cs({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var v=bN(t,m.tickCoord,y,l,c);v&&(c=m.tickCoord-t*(y()/2+i),s[p]=cs(cs({},m),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return s}function Wze(t,e,n,r,i,s){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(s){var d=r[l-1],h=n(d,l-1),p=t*(d.coordinate+t*h/2-u);if(o[l-1]=d=cs(cs({},d),{},{tickCoord:p>0?d.coordinate-p*t:d.coordinate}),d.tickCoord!=null){var m=bN(t,d.tickCoord,()=>h,c,u);m&&(u=d.tickCoord-t*(h/2+i),o[l-1]=cs(cs({},d),{},{isShow:!0}))}}for(var x=s?l-1:l,y=function(S){var k=o[S],E,N=()=>(E===void 0&&(E=n(k,S)),E);if(S===0){var A=t*(k.coordinate-t*N()/2-c);o[S]=k=cs(cs({},k),{},{tickCoord:A<0?k.coordinate-A*t:k.coordinate})}else o[S]=k=cs(cs({},k),{},{tickCoord:k.coordinate});if(k.tickCoord!=null){var M=bN(t,k.tickCoord,N,c,u);M&&(c=k.tickCoord+t*(N()/2+i),o[S]=cs(cs({},k),{},{isShow:!0}))}},b=0;b<x;b++)y(b);return o}function UO(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:h}=t;if(!i||!i.length||!r)return[];if(Ht(c)||zb.isSsr){var p;return(p=Bze(i,Ht(c)?c:0))!==null&&p!==void 0?p:[]}var m=[],x=l==="top"||l==="bottom"?"width":"height",y=d&&x==="width"?Oy(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(k,E)=>{var N=typeof u=="function"?u(k.value,E):k.value;return x==="width"?zze(Oy(N,{fontSize:e,letterSpacing:n}),y,h):Oy(N,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?Pa(i[1].coordinate-i[0].coordinate):1,S=Uze(s,v,x);return c==="equidistantPreserveStart"?$ze(v,S,b,i,o):(c==="preserveStart"||c==="preserveStartEnd"?m=Wze(v,S,b,i,o,c==="preserveStartEnd"):m=qze(v,S,b,i,o),m.filter(k=>k.isShow))}var Kze=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var h=d.getBoundingClientRect();h.width>o&&(o=h.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+s,u=o+c+l+(n?r:0);return Math.round(u)}return 0},Xze=["axisLine","width","height","className","hide","ticks","axisType"];function Yze(t,e){if(t==null)return{};var n,r,i=Qze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Qze(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 Fm(){return Fm=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},Fm.apply(null,arguments)}function Pq(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 Xi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Pq(Object(n),!0).forEach(function(r){Zze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Pq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zze(t,e,n){return(e=Jze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jze(t){var e=eUe(t,"string");return typeof e=="symbol"?e:e+""}function eUe(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 Gu={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:Di.axis};function tUe(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=Xi(Xi(Xi({},c),Ps(l)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!o||s==="bottom"&&o);u=Xi(Xi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var h=+(s==="left"&&!o||s==="right"&&o);u=Xi(Xi({},u),{},{x1:e+h*r,y1:n,x2:e+h*r,y2:n+i})}return w.createElement("line",Fm({},u,{className:ir("recharts-cartesian-axis-line",Dm(l,"className"))}))}function nUe(t,e,n,r,i,s,o,l,c){var u,d,h,p,m,x,y=l?-1:1,b=t.tickSize||o,v=Ht(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,p=n+ +!l*i,h=p-y*b,x=h-y*c,m=v;break;case"left":h=p=t.coordinate,d=e+ +!l*r,u=d-y*b,m=u-y*c,x=v;break;case"right":h=p=t.coordinate,d=e+ +l*r,u=d+y*b,m=u+y*c,x=v;break;default:u=d=t.coordinate,p=n+ +l*i,h=p+y*b,x=h+y*c,m=v;break}return{line:{x1:u,y1:h,x2:d,y2:p},tick:{x:m,y:x}}}function rUe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function iUe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function aUe(t){var{option:e,tickProps:n,value:r}=t,i,s=ir(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,Xi(Xi({},n),{},{className:s}));else if(typeof e=="function")i=e(Xi(Xi({},n),{},{className:s}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=ir(o,e?.className)),i=w.createElement(RM,Fm({},n,{className:o}),r)}return i}var sUe=w.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:h,x:p,y:m,width:x,height:y,tickSize:b,tickMargin:v,fontSize:S,letterSpacing:k,getTicksConfig:E,events:N,axisType:A}=t,M=UO(Xi(Xi({},E),{},{ticks:n}),S,k),P=rUe(d,h),T=iUe(d,h),j=Ps(E),z=Pm(r),F={};typeof i=="object"&&(F=i);var $=Xi(Xi({},j),{},{fill:"none"},F),D=M.map(I=>Xi({entry:I},nUe(I,p,m,x,y,d,b,h,v))),H=D.map(I=>{var{entry:K,line:Z}=I;return w.createElement(gi,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(K.value,"-").concat(K.coordinate,"-").concat(K.tickCoord)},i&&w.createElement("line",Fm({},$,Z,{className:ir("recharts-cartesian-axis-tick-line",Dm(i,"className"))})))}),q=D.map((I,K)=>{var{entry:Z,tick:se}=I,V=Xi(Xi(Xi(Xi({textAnchor:P,verticalAnchor:T},j),{},{stroke:"none",fill:s},z),se),{},{index:K,payload:Z,visibleTicksCount:M.length,tickFormatter:o,padding:c},u);return w.createElement(gi,Fm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},nv(N,Z,K)),r&&w.createElement(aUe,{option:r,tickProps:V,value:"".concat(typeof o=="function"?o(Z.value,K):Z.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(A,"-ticks")},q.length>0&&w.createElement(xs,{zIndex:Di.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(A,"-tick-labels"),ref:e},q)),H.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(A,"-tick-lines")},H))}),oUe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:o,ticks:l,axisType:c}=t,u=Yze(t,Xze),[d,h]=w.useState(""),[p,m]=w.useState(""),x=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return Kze({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=w.useCallback(b=>{if(b){var v=b.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=v;var S=v[0];if(S){var k=window.getComputedStyle(S),E=k.fontSize,N=k.letterSpacing;(E!==d||N!==p)&&(h(E),m(N))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(xs,{zIndex:t.zIndex},w.createElement(gi,{className:ir("recharts-cartesian-axis",s)},w.createElement(tUe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ps(t)}),w.createElement(sUe,{ref:y,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:p,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),w.createElement(GJ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(WJ,{label:t.label,labelRef:t.labelRef}),t.children)))}),BO=w.forwardRef((t,e)=>{var n=bi(t,Gu);return w.createElement(oUe,Fm({},n,{ref:e}))});BO.displayName="CartesianAxis";var lUe=["x1","y1","x2","y2","key"],cUe=["offset"],uUe=["xAxisId","yAxisId"],dUe=["xAxisId","yAxisId"];function Dq(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 hs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Dq(Object(n),!0).forEach(function(r){hUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Dq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hUe(t,e,n){return(e=fUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fUe(t){var e=mUe(t,"string");return typeof e=="symbol"?e:e+""}function mUe(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 em(){return em=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},em.apply(null,arguments)}function xN(t,e){if(t==null)return{};var n,r,i=pUe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function pUe(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 gUe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:o,ry:l}=t;return w.createElement("rect",{x:r,y:i,ry:l,width:s,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function xee(t){var{option:e,lineItemProps:n}=t,r;if(w.isValidElement(e))r=w.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:o,x2:l,y2:c,key:u}=n,d=xN(n,lUe),h=(i=Ps(d))!==null&&i!==void 0?i:{},{offset:p}=h,m=xN(h,cUe);r=w.createElement("line",em({},m,{x1:s,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function bUe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=t,l=xN(t,uUe),c=i.map((u,d)=>{var h=hs(hs({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(xee,{key:"line-".concat(d),option:r,lineItemProps:h})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function xUe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=t,l=xN(t,dUe),c=i.map((u,d)=>{var h=hs(hs({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(xee,{option:r,lineItemProps:h,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function yUe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(h=>Math.round(h+i-i)).sort((h,p)=>h-p);i!==u[0]&&u.unshift(0);var d=u.map((h,p)=>{var m=!u[p+1],x=m?i+o-h:u[p+1]-h;if(x<=0)return null;var y=p%e.length;return w.createElement("rect",{key:"react-".concat(p),y:h,x:r,height:x,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function vUe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(h=>Math.round(h+i-i)).sort((h,p)=>h-p);i!==u[0]&&u.unshift(0);var d=u.map((h,p)=>{var m=!u[p+1],x=m?i+o-h:u[p+1]-h;if(x<=0)return null;var y=p%n.length;return w.createElement("rect",{key:"react-".concat(p),x:h,y:s,width:x,height:l,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var wUe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return tQ(UO(hs(hs(hs({},Gu),n),{},{ticks:nQ(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},_Ue=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return tQ(UO(hs(hs(hs({},Gu),n),{},{ticks:nQ(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},SUe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Di.grid};function yN(t){var e=fL(),n=mL(),r=dQ(),i=hs(hs({},bi(t,SUe)),{},{x:Ht(t.x)?t.x:r.left,y:Ht(t.y)?t.y:r.top,width:Ht(t.width)?t.width:r.width,height:Ht(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:h,horizontalValues:p,verticalValues:m}=i,x=ga(),y=zt(T=>wG(T,"xAxis",s,x)),b=zt(T=>wG(T,"yAxis",o,x));if(!Pc(u)||!Pc(d)||!Ht(l)||!Ht(c))return null;var v=i.verticalCoordinatesGenerator||wUe,S=i.horizontalCoordinatesGenerator||_Ue,{horizontalPoints:k,verticalPoints:E}=i;if((!k||!k.length)&&typeof S=="function"){var N=p&&p.length,A=S({yAxis:b?hs(hs({},b),{},{ticks:N?p:b.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:h);$1(Array.isArray(A),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof A,"]")),Array.isArray(A)&&(k=A)}if((!E||!E.length)&&typeof v=="function"){var M=m&&m.length,P=v({xAxis:y?hs(hs({},y),{},{ticks:M?m:y.ticks}):void 0,width:e??u,height:n??d,offset:r},M?!0:h);$1(Array.isArray(P),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(E=P)}return w.createElement(xs,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(gUe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(yUe,em({},i,{horizontalPoints:k})),w.createElement(vUe,em({},i,{verticalPoints:E})),w.createElement(bUe,em({},i,{offset:r,horizontalPoints:k,xAxis:y,yAxis:b})),w.createElement(xUe,em({},i,{offset:r,verticalPoints:E,xAxis:y,yAxis:b}))))}yN.displayName="CartesianGrid";var yee=(t,e,n,r)=>Lc(t,"xAxis",e,r),vee=(t,e,n,r)=>Rc(t,"xAxis",e,r),wee=(t,e,n,r)=>Lc(t,"yAxis",n,r),_ee=(t,e,n,r)=>Rc(t,"yAxis",n,r),NUe=lt([Wn,yee,wee,vee,_ee],(t,e,n,r,i)=>Bc(t,"xAxis")?Hh(e,r,!1):Hh(n,i,!1)),kUe=(t,e,n,r,i)=>i;function MUe(t){return t.type==="line"}var CUe=lt([bv,kUe],(t,e)=>t.filter(MUe).find(n=>n.id===e)),EUe=lt([Wn,yee,wee,vee,_ee,CUe,NUe,fv],(t,e,n,r,i,s,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(s==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:h,data:p}=s,m;if(p!=null&&p.length>0?m=p:m=c?.slice(u,d+1),m!=null)return KUe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:h,bandSize:o,displayedData:m})}});function See(t){var e=Pm(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,o=Number(i),l=Number(s);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 AUe=["id"],TUe=["type","layout","connectNulls","needClip","shape"],jUe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function T0(){return T0=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},T0.apply(null,arguments)}function Rq(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 bc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Rq(Object(n),!0).forEach(function(r){PUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Rq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PUe(t,e,n){return(e=DUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DUe(t){var e=RUe(t,"string");return typeof e=="symbol"?e:e+""}function RUe(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 $O(t,e){if(t==null)return{};var n,r,i=LUe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function LUe(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 OUe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Yh(n,e),payload:t}]},FUe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:Yh(o,e),hide:l,type:u,color:r,unit:c}};return w.createElement(IM,{tooltipEntrySettings:d})}),Nee=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function IUe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var zUe=(t,e,n)=>{var r=n.reduce((h,p)=>h+p);if(!r)return Nee(e,t);for(var i=Math.floor(t/r),s=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>s){l=[...n.slice(0,c),s-u];break}var d=l.length%2===0?[0,o]:[o];return[...IUe(n,i),...l,...d].map(h=>"".concat(h,"px")).join(", ")};function UUe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:o}=r,{id:l}=r,c=$O(r,AUe),u=Ps(c);return w.createElement(aee,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:u,needClip:o,clipPathId:e})}function BUe(t){var{showLabels:e,children:n,points:r}=t,i=w.useMemo(()=>r?.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return bc(bc({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(EO,{value:e?i:void 0},n)}function Lq(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:s}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=s,h=$O(s,TUe),p=bc(bc({},es(h)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??s.strokeDasharray});return w.createElement(w.Fragment,null,r?.length>1&&w.createElement(DO,T0({shapeType:"curve",option:d},p,{pathRef:n})),w.createElement(UUe,{points:r,clipPathId:e,props:s}))}function $Ue(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function HUe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:s}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:h,animateNewValues:p,width:m,height:x,onAnimationEnd:y,onAnimationStart:b}=n,v=i.current,S=Bb(o,"recharts-line-"),k=w.useRef(S),[E,N]=w.useState(!1),A=!E,M=w.useCallback(()=>{typeof y=="function"&&y(),N(!1)},[y]),P=w.useCallback(()=>{typeof b=="function"&&b(),N(!0)},[b]),T=$Ue(r.current),j=w.useRef(0);k.current!==S&&(j.current=s.current,k.current=S);var z=j.current;return w.createElement(BUe,{points:o,showLabels:A},n.children,w.createElement(Ub,{animationId:S,begin:u,duration:d,isActive:c,easing:h,onAnimationEnd:M,onAnimationStart:P,key:S},F=>{var $=pr(z,T+z,F),D=Math.min($,T),H;if(c)if(l){var q="".concat(l).split(/[,\s]+/gim).map(Z=>parseFloat(Z));H=zUe(D,T,q)}else H=Nee(T,D);else H=l==null?void 0:String(l);if(F>0&&T>0&&(i.current=o,s.current=Math.max(s.current,D)),v){var I=v.length/o.length,K=F===1?o:o.map((Z,se)=>{var V=Math.floor(se*I);if(v[V]){var W=v[V];return bc(bc({},Z),{},{x:pr(W.x,Z.x,F),y:pr(W.y,Z.y,F)})}return p?bc(bc({},Z),{},{x:pr(m*2,Z.x,F),y:pr(x/2,Z.y,F)}):bc(bc({},Z),{},{x:Z.x,y:Z.y})});return i.current=K,w.createElement(Lq,{props:n,points:K,clipPathId:e,pathRef:r,strokeDasharray:H})}return w.createElement(Lq,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:H})}),w.createElement(LM,{label:n.label}))}function VUe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),s=w.useRef(null);return w.createElement(HUe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var GUe=(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:_r(t.payload,e)}};class qUe extends w.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:o,top:l,left:c,width:u,height:d,id:h,needClip:p,zIndex:m}=this.props;if(e)return null;var x=ir("recharts-line",i),y=h,{r:b,strokeWidth:v}=See(n),S=PO(n),k=b*2+v,E=p?"url(#clipPath-".concat(S?"":"dots-").concat(y,")"):void 0;return w.createElement(xs,{zIndex:m},w.createElement(gi,{className:x},p&&w.createElement("defs",null,w.createElement(zO,{clipPathId:y,xAxisId:s,yAxisId:o}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(y)},w.createElement("rect",{x:c-k/2,y:l-k/2,width:u+k,height:d+k}))),w.createElement(lee,{xAxisId:s,yAxisId:o,data:r,dataPointFormatter:GUe,errorBarOffset:0},w.createElement(VUe,{props:this.props,clipPathId:y}))),w.createElement(qD,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:E}))}}var kee={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:Di.line,type:"linear"};function WUe(t){var e=bi(t,kee),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:h,legendType:p,xAxisId:m,yAxisId:x,id:y}=e,b=$O(e,jUe),{needClip:v}=$M(m,x),S=BM(),k=Km(),E=ga(),N=zt(j=>EUe(j,m,x,E,y));if(k!=="horizontal"&&k!=="vertical"||N==null||S==null)return null;var{height:A,width:M,x:P,y:T}=S;return w.createElement(qUe,T0({},b,{id:y,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,isAnimationActive:d,hide:u,label:h,legendType:p,xAxisId:m,yAxisId:x,points:N,layout:k,height:A,width:M,left:P,top:T,needClip:v}))}function KUe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var h=_r(u,o);if(e==="horizontal"){var p=B1({axis:n,ticks:i,bandSize:l,entry:u,index:d}),m=ii(h)?null:r.scale(h);return{x:p,y:m,value:h,payload:u}}var x=ii(h)?null:n.scale(h),y=B1({axis:r,ticks:s,bandSize:l,entry:u,index:d});return x==null||y==null?null:{x,y,value:h,payload:u}}).filter(Boolean)}function XUe(t){var e=bi(t,kee),n=ga();return w.createElement(zM,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(FO,{legendPayload:OUe(e)}),w.createElement(FUe,{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}),w.createElement(IO,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),w.createElement(WUe,T0({},e,{id:r}))))}var Mee=w.memo(XUe,Mv);Mee.displayName="Line";var Cee=(t,e,n,r)=>Lc(t,"xAxis",e,r),Eee=(t,e,n,r)=>Rc(t,"xAxis",e,r),Aee=(t,e,n,r)=>Lc(t,"yAxis",n,r),Tee=(t,e,n,r)=>Rc(t,"yAxis",n,r),YUe=lt([Wn,Cee,Aee,Eee,Tee],(t,e,n,r,i)=>Bc(t,"xAxis")?Hh(e,r,!1):Hh(n,i,!1)),QUe=(t,e,n,r,i)=>i,jee=lt([bv,QUe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),ZUe=(t,e,n,r,i)=>{var s,o=jee(t,e,n,r,i);if(o!=null){var l=Wn(t),c=Bc(l,"xAxis"),u;if(c?u=E0(t,"yAxis",n,r):u=E0(t,"xAxis",e,r),u!=null){var{stackId:d}=o,h=kM(o);if(!(d==null||h==null)){var p=(s=u[d])===null||s===void 0?void 0:s.stackedData;return p?.find(m=>m.key===h)}}}},JUe=lt([Wn,Cee,Aee,Eee,Tee,ZUe,fv,YUe,jee,CDe],(t,e,n,r,i,s,o,l,c,u)=>{var{chartData:d,dataStartIndex:h,dataEndIndex:p}=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:m}=c,x;if(m&&m.length>0?x=m:x=d?.slice(h,p+1),x!=null)return xBe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:l})}}),eBe=["id"],tBe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function fm(){return fm=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},fm.apply(null,arguments)}function Pee(t,e){if(t==null)return{};var n,r,i=nBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nBe(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 Oq(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 jg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Oq(Object(n),!0).forEach(function(r){rBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Oq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rBe(t,e,n){return(e=iBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iBe(t){var e=aBe(t,"string");return typeof e=="symbol"?e:e+""}function aBe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function vN(t,e){return t&&t!=="none"?t:e}var sBe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:o}=t;return[{inactive:o,dataKey:e,type:s,color:vN(r,i),value:Yh(n,e),payload:t}]},oBe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:Yh(o,e),hide:l,type:u,color:vN(r,s),unit:c}};return w.createElement(IM,{tooltipEntrySettings:d})});function lBe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:o}=r,l=Ps(r);return w.createElement(aee,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function cBe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return jg(jg({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(EO,{value:e?i:void 0},n)}function Fq(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=s,{id:h}=s,p=Pee(s,eBe),m=Ps(p),x=es(p);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(gi,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(Vg,fm({},x,{id:h,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(Vg,fm({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(Vg,fm({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(lBe,{points:e,props:p,clipPathId:i}))}function uBe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,o=r[r.length-1].y;if(!Sr(s)||!Sr(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.x||0));return Ht(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Ht(c)?w.createElement("rect",{x:0,y:s<o?s:s-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function dBe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,o=r[r.length-1].x;if(!Sr(s)||!Sr(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.y||0));return Ht(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Ht(c)?w.createElement("rect",{x:s<o?s:s-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function hBe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?w.createElement(uBe,{alpha:e,points:r,baseLine:i,strokeWidth:s}):w.createElement(dBe,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function fBe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:h,onAnimationStart:p,onAnimationEnd:m}=r,x=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=Bb(x,"recharts-area-"),b=GAe(),[v,S]=w.useState(!1),k=!v,E=w.useCallback(()=>{typeof m=="function"&&m(),S(!1)},[m]),N=w.useCallback(()=>{typeof p=="function"&&p(),S(!0)},[p]);if(b==null)return null;var A=i.current,M=s.current;return w.createElement(cBe,{showLabels:k,points:o},r.children,w.createElement(Ub,{animationId:y,begin:u,duration:d,isActive:c,easing:h,onAnimationEnd:E,onAnimationStart:N,key:y},P=>{if(A){var T=A.length/o.length,j=P===1?o:o.map((F,$)=>{var D=Math.floor($*T);if(A[D]){var H=A[D];return jg(jg({},F),{},{x:pr(H.x,F.x,P),y:pr(H.y,F.y,P)})}return F}),z;return Ht(l)?z=pr(M,l,P):ii(l)||no(l)?z=pr(M,0,P):z=l.map((F,$)=>{var D=Math.floor($*T);if(Array.isArray(M)&&M[D]){var H=M[D];return jg(jg({},F),{},{x:pr(H.x,F.x,P),y:pr(H.y,F.y,P)})}return F}),P>0&&(i.current=j,s.current=z),w.createElement(Fq,{points:j,baseLine:z,needClip:e,clipPathId:n,props:r})}return P>0&&(i.current=o,s.current=l),w.createElement(gi,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(hBe,{alpha:P,points:o,baseLine:l,layout:b,strokeWidth:r.strokeWidth}))),w.createElement(gi,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(Fq,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(LM,{label:r.label}))}function mBe(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),s=w.useRef();return w.createElement(fBe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class pBe extends w.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:h,id:p,baseLine:m,zIndex:x}=this.props;if(e)return null;var y=ir("recharts-area",i),b=p,{r:v,strokeWidth:S}=See(n),k=PO(n),E=v*2+S,N=l?"url(#clipPath-".concat(k?"":"dots-").concat(b,")"):void 0;return w.createElement(xs,{zIndex:x},w.createElement(gi,{className:y},l&&w.createElement("defs",null,w.createElement(zO,{clipPathId:b,xAxisId:c,yAxisId:u}),!k&&w.createElement("clipPath",{id:"clipPath-dots-".concat(b)},w.createElement("rect",{x:o-E/2,y:s-E/2,width:d+E,height:h+E}))),w.createElement(mBe,{needClip:l,clipPathId:b,props:this.props})),w.createElement(qD,{points:r,mainColor:vN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:N}),this.props.isRange&&Array.isArray(m)&&w.createElement(qD,{points:m,mainColor:vN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:N}))}}var Dee={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:Di.area};function gBe(t){var e,n=bi(t,Dee),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:h,isAnimationActive:p,legendType:m,stroke:x,xAxisId:y,yAxisId:b}=n,v=Pee(n,tBe),S=Km(),k=EJ(),{needClip:E}=$M(y,b),N=ga(),{points:A,isRange:M,baseLine:P}=(e=zt(D=>JUe(D,y,b,N,t.id)))!==null&&e!==void 0?e:{},T=BM();if(S!=="horizontal"&&S!=="vertical"||T==null||k!=="AreaChart"&&k!=="ComposedChart")return null;var{height:j,width:z,x:F,y:$}=T;return!A||!A.length?null:w.createElement(pBe,fm({},v,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,baseLine:P,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:j,hide:h,layout:S,isAnimationActive:p==="auto"?!zb.isSsr:p,isRange:M,legendType:m,needClip:E,points:A,stroke:x,width:z,left:F,top:$,xAxisId:y,yAxisId:b}))}var bBe=(t,e,n,r,i)=>{var s=n??e;if(Ht(s))return s;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 s==="dataMin"?u:s==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]};function xBe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:h,yAxisTicks:p,bandSize:m}=t,x=i&&i.length,y=bBe(s,o,n,l,c),b=s==="horizontal",v=!1,S=u.map((E,N)=>{var A;x?A=i[d+N]:(A=_r(E,r),Array.isArray(A)?v=!0:A=[y,A]);var M=A[1]==null||x&&!e&&_r(E,r)==null;return b?{x:B1({axis:l,ticks:h,bandSize:m,entry:E,index:N}),y:M?null:c.scale(A[1]),value:A,payload:E}:{x:M?null:l.scale(A[1]),y:B1({axis:c,ticks:p,bandSize:m,entry:E,index:N}),value:A,payload:E}}),k;return x||v?k=S.map(E=>{var N=Array.isArray(E.value)?E.value[0]:null;return b?{x:E.x,y:N!=null&&E.y!=null?c.scale(N):null,payload:E.payload}:{x:N!=null?l.scale(N):null,y:E.y,payload:E.payload}}):k=b?c.scale(y):l.scale(y),{points:S,baseLine:k,isRange:v}}function yBe(t){var e=bi(t,Dee),n=ga();return w.createElement(zM,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(FO,{legendPayload:sBe(e)}),w.createElement(oBe,{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}),w.createElement(IO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:rQ(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(gBe,fm({},e,{id:r}))))}var Ree=w.memo(yBe,Mv);Ree.displayName="Area";var vBe=["domain","range"],wBe=["domain","range"];function Iq(t,e){if(t==null)return{};var n,r,i=_Be(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _Be(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 zq(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 Lee(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=Iq(t,vBe),{domain:s,range:o}=e,l=Iq(e,wBe);return!zq(n,s)||!zq(r,o)?!1:Mv(i,l)}var SBe=["dangerouslySetInnerHTML","ticks"],NBe=["id"];function KD(){return KD=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},KD.apply(null,arguments)}function Uq(t,e){if(t==null)return{};var n,r,i=kBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function kBe(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 MBe(t){var e=$r(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(vIe(t)):n.current!==t&&e(wIe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(_Ie(n.current)),n.current=null)},[e]),null}var CBe=t=>{var{xAxisId:e,className:n}=t,r=zt(dL),i=ga(),s="xAxis",o=zt(b=>Gh(b,s,e,i)),l=zt(b=>sJ(b,s,e,i)),c=zt(b=>nJ(b,e)),u=zt(b=>NRe(b,e)),d=zt(b=>FZ(b,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:h,ticks:p}=t,m=Uq(t,SBe),{id:x}=d,y=Uq(d,NBe);return w.createElement(BO,KD({},m,y,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:ir("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:l,axisType:s}))},EBe={allowDataOverflow:Ca.allowDataOverflow,allowDecimals:Ca.allowDecimals,allowDuplicatedCategory:Ca.allowDuplicatedCategory,angle:Ca.angle,axisLine:Gu.axisLine,height:Ca.height,hide:!1,includeHidden:Ca.includeHidden,interval:Ca.interval,minTickGap:Ca.minTickGap,mirror:Ca.mirror,orientation:Ca.orientation,padding:Ca.padding,reversed:Ca.reversed,scale:Ca.scale,tick:Ca.tick,tickCount:Ca.tickCount,tickLine:Gu.tickLine,tickSize:Gu.tickSize,type:Ca.type,xAxisId:0},ABe=t=>{var e=bi(t,EBe);return w.createElement(w.Fragment,null,w.createElement(MBe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),w.createElement(CBe,e))},wN=w.memo(ABe,Lee);wN.displayName="XAxis";var TBe=["dangerouslySetInnerHTML","ticks"],jBe=["id"];function XD(){return XD=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},XD.apply(null,arguments)}function Bq(t,e){if(t==null)return{};var n,r,i=PBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PBe(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 DBe(t){var e=$r(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(SIe(t)):n.current!==t&&e(NIe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(kIe(n.current)),n.current=null)},[e]),null}var RBe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=w.useRef(null),o=w.useRef(null),l=zt(dL),c=ga(),u=$r(),d="yAxis",h=zt(N=>Gh(N,d,e,c)),p=zt(N=>rJ(N,e)),m=zt(N=>MRe(N,e)),x=zt(N=>sJ(N,d,e,c)),y=zt(N=>IZ(N,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!p||CO(i)||w.isValidElement(i)||y==null)){var N=s.current;if(N){var A=N.getCalculatedWidth();Math.round(p.width)!==Math.round(A)&&u(MIe({id:e,width:A}))}}},[x,p,u,i,e,r,y]),p==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:v}=t,S=Bq(t,TBe),{id:k}=y,E=Bq(y,jBe);return w.createElement(BO,XD({},S,E,{ref:s,labelRef:o,scale:h,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:p.width,height:p.height,className:ir("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},LBe={allowDataOverflow:Ea.allowDataOverflow,allowDecimals:Ea.allowDecimals,allowDuplicatedCategory:Ea.allowDuplicatedCategory,angle:Ea.angle,axisLine:Gu.axisLine,hide:!1,includeHidden:Ea.includeHidden,interval:Ea.interval,minTickGap:Ea.minTickGap,mirror:Ea.mirror,orientation:Ea.orientation,padding:Ea.padding,reversed:Ea.reversed,scale:Ea.scale,tick:Ea.tick,tickCount:Ea.tickCount,tickLine:Gu.tickLine,tickSize:Gu.tickSize,type:Ea.type,width:Ea.width,yAxisId:0},OBe=t=>{var e=bi(t,LBe);return w.createElement(w.Fragment,null,w.createElement(DBe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),w.createElement(RBe,e))},_N=w.memo(OBe,Lee);_N.displayName="YAxis";var FBe=(t,e)=>e,HO=lt([FBe,Wn,LZ,xa,_J,fd,B4e,pa],K4e),VO=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)}},Oee=yl("mouseClick"),Fee=av();Fee.startListening({actionCreator:Oee,effect:(t,e)=>{var n=t.payload,r=HO(e.getState(),VO(n));r?.activeIndex!=null&&e.dispatch(URe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var YD=yl("mouseMove"),Iee=av(),mS=null;Iee.startListening({actionCreator:YD,effect:(t,e)=>{var n=t.payload;mS!==null&&cancelAnimationFrame(mS);var r=VO(n);mS=requestAnimationFrame(()=>{var i=e.getState(),s=gO(i,i.tooltip.settings.shared);if(s==="axis"){var o=HO(i,r);o?.activeIndex!=null?e.dispatch(mJ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(fJ())}mS=null})}});var $q={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},zee=ro({name:"rootProps",initialState:$q,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:$q.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}}}),IBe=zee.reducer,{updateOptions:zBe}=zee.actions,Uee=ro({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:UBe}=Uee.actions,BBe=Uee.reducer,Bee=yl("keyDown"),$ee=yl("focus"),GO=av();GO.startListening({actionCreator:Bee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,s=t.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var o=bO(i,Xb(n),yv(n),Sv(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=fd(n);if(s==="Enter"){var u=cN(n,"axis","hover",String(i.index));e.dispatch(UD({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=TRe(n),h=d==="left-to-right"?1:-1,p=s==="ArrowRight"?1:-1,m=l+p*h;if(!(c==null||m>=c.length||m<0)){var x=cN(n,"axis","hover",String(m));e.dispatch(UD({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});GO.startListening({actionCreator:$ee,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 s="0",o=cN(n,"axis","hover",String(s));e.dispatch(UD({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:o}))}}}});var Qo=yl("externalEvent"),Hee=av(),Sj=new Map;Hee.startListening({actionCreator:Qo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=Sj.get(i);s!==void 0&&cancelAnimationFrame(s);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:M4e(l),activeDataKey:_O(l),activeIndex:qh(l),activeLabel:kJ(l),activeTooltipIndex:qh(l),isTooltipActive:C4e(l)};n(c,r)}finally{Sj.delete(i)}});Sj.set(i,o)}}});var $Be=lt([Kb],t=>t.tooltipItemPayloads),HBe=lt([$Be,wv,(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:s}=i;if(s!=null){var o=e(s,n);return o}}}),Vee=yl("touchMove"),Gee=av();Gee.startListening({actionCreator:Vee,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=gO(r,r.tooltip.settings.shared);if(i==="axis"){var s=HO(r,VO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(mJ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.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(aQ),d=(o=c.getAttribute(sQ))!==null&&o!==void 0?o:void 0,h=HBe(e.getState(),u,d);e.dispatch(hJ({activeDataKey:d,activeIndex:u,activeCoordinate:h}))}}}});var VBe=MY({brush:mze,cartesianAxis:CIe,chartData:kLe,errorBars:qIe,graphicalItems:RFe,layout:ZEe,legend:sTe,options:vLe,polarAxis:XOe,polarOptions:BBe,referenceElements:kze,rootProps:IBe,tooltip:BRe,zIndex:lLe}),GBe=function(e){return SEe({reducer:VBe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([Fee.middleware,Iee.middleware,GO.middleware,Hee.middleware,Gee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(BY({type:"raf"}))},devTools:zb.devToolsEnabled})};function qee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ga(),s=w.useRef(null);if(i)return n;s.current==null&&(s.current=GBe(e));var o=nL;return w.createElement(g5e,{context:o,store:s.current},n)}function qBe(t){var{layout:e,margin:n}=t,r=$r(),i=ga();return w.useEffect(()=>{i||(r(XEe(e)),r(KEe(n)))},[r,i,e,n]),null}var Wee=w.memo(qBe,Mv);function Kee(t){var e=$r();return w.useEffect(()=>{e(zBe(t))},[e,t]),null}function Hq(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=nee("".concat(r).concat(e)),s=$r();return w.useLayoutEffect(()=>(s(sLe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(oLe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),w.createElement("g",{tabIndex:-1,id:i})}function Vq(t){var{children:e,isPanorama:n}=t,r=zt(Y4e);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),s=r.filter(o=>o>0);return w.createElement(w.Fragment,null,i.map(o=>w.createElement(Hq,{key:o,zIndex:o,isPanorama:n})),e,s.map(o=>w.createElement(Hq,{key:o,zIndex:o,isPanorama:n})))}var WBe=["children"];function KBe(t,e){if(t==null)return{};var n,r,i=XBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function XBe(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 SN(){return SN=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},SN.apply(null,arguments)}var YBe={width:"100%",height:"100%",display:"block"},QBe=w.forwardRef((t,e)=>{var n=fL(),r=mL(),i=_Q();if(!Pc(n)||!Pc(r))return null;var{children:s,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),w.createElement(q4,SN({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:YBe,ref:e}),s)}),ZBe=t=>{var{children:e}=t,n=zt(hM);if(!n)return null;var{width:r,height:i,y:s,x:o}=n;return w.createElement(q4,{width:r,height:i,x:o,y:s},e)},Gq=w.forwardRef((t,e)=>{var{children:n}=t,r=KBe(t,WBe),i=ga();return i?w.createElement(ZBe,null,w.createElement(Vq,{isPanorama:!0},n)):w.createElement(QBe,SN({ref:e},r),w.createElement(Vq,{isPanorama:!1},n))});function JBe(){var t=$r(),[e,n]=w.useState(null),r=zt(pAe);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;Sr(s)&&s!==r&&t(QEe(s))}},[e,t,r]),n}function qq(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 e8e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qq(Object(n),!0).forEach(function(r){t8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t8e(t,e,n){return(e=n8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n8e(t){var e=r8e(t,"string");return typeof e=="symbol"?e:e+""}function r8e(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 Im(){return Im=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},Im.apply(null,arguments)}var i8e=()=>(RLe(),null);function NN(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var a8e=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[s,o]=w.useState({containerWidth:NN((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:NN((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((u,d)=>{o(h=>{var p=Math.round(u),m=Math.round(d);return h.containerWidth===p&&h.containerHeight===m?h:{containerWidth:p,containerHeight:m}})},[]),c=w.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:h}=u.getBoundingClientRect();l(d,h);var p=x=>{var{width:y,height:b}=x[0].contentRect;l(y,b)},m=new ResizeObserver(p);m.observe(u),i.current=m}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(fM,{width:s.containerWidth,height:s.containerHeight}),w.createElement("div",Im({ref:c},t)))}),s8e=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=w.useState({containerWidth:NN(n),containerHeight:NN(r)}),o=w.useCallback((c,u)=>{s(d=>{var h=Math.round(c),p=Math.round(u);return d.containerWidth===h&&d.containerHeight===p?d:{containerWidth:h,containerHeight:p}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(fM,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",Im({ref:l},t)))}),o8e=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(fM,{width:n,height:r}),w.createElement("div",Im({ref:e},t)))}),l8e=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return nd(n)||nd(r)?w.createElement(s8e,Im({},t,{ref:e})):w.createElement(o8e,Im({},t,{ref:e}))});function c8e(t){return t===!0?a8e:l8e}var u8e=w.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:h,onMouseUp:p,onTouchEnd:m,onTouchMove:x,onTouchStart:y,style:b,width:v,responsive:S,dispatchTouchEvents:k=!0}=t,E=w.useRef(null),N=$r(),[A,M]=w.useState(null),[P,T]=w.useState(null),j=JBe(),z=hL(),F=z?.width>0?z.width:v,$=z?.height>0?z.height:i,D=w.useCallback(de=>{j(de),typeof e=="function"&&e(de),M(de),T(de),de!=null&&(E.current=de)},[j,e,M,T]),H=w.useCallback(de=>{N(Oee(de)),N(Qo({handler:s,reactEvent:de}))},[N,s]),q=w.useCallback(de=>{N(YD(de)),N(Qo({handler:u,reactEvent:de}))},[N,u]),I=w.useCallback(de=>{N(fJ()),N(Qo({handler:d,reactEvent:de}))},[N,d]),K=w.useCallback(de=>{N(YD(de)),N(Qo({handler:h,reactEvent:de}))},[N,h]),Z=w.useCallback(()=>{N($ee())},[N]),se=w.useCallback(de=>{N(Bee(de.key))},[N]),V=w.useCallback(de=>{N(Qo({handler:o,reactEvent:de}))},[N,o]),W=w.useCallback(de=>{N(Qo({handler:l,reactEvent:de}))},[N,l]),ie=w.useCallback(de=>{N(Qo({handler:c,reactEvent:de}))},[N,c]),J=w.useCallback(de=>{N(Qo({handler:p,reactEvent:de}))},[N,p]),pe=w.useCallback(de=>{N(Qo({handler:y,reactEvent:de}))},[N,y]),fe=w.useCallback(de=>{k&&N(Vee(de)),N(Qo({handler:x,reactEvent:de}))},[N,k,x]),ve=w.useCallback(de=>{N(Qo({handler:m,reactEvent:de}))},[N,m]),Le=c8e(S);return w.createElement(DJ.Provider,{value:A},w.createElement(BX.Provider,{value:P},w.createElement(Le,{width:F??b?.width,height:$??b?.height,className:ir("recharts-wrapper",r),style:e8e({position:"relative",cursor:"default",width:F,height:$},b),onClick:H,onContextMenu:V,onDoubleClick:W,onFocus:Z,onKeyDown:se,onMouseDown:ie,onMouseEnter:q,onMouseLeave:I,onMouseMove:K,onMouseUp:J,onTouchEnd:ve,onTouchMove:fe,onTouchStart:pe,ref:D},w.createElement(i8e,null),n)))}),d8e=["width","height","responsive","children","className","style","compact","title","desc"];function h8e(t,e){if(t==null)return{};var n,r,i=f8e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function f8e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Xee=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:o,style:l,compact:c,title:u,desc:d}=t,h=h8e(t,d8e),p=Ps(h);return c?w.createElement(w.Fragment,null,w.createElement(fM,{width:n,height:r}),w.createElement(Gq,{otherAttributes:p,title:u,desc:d},s)):w.createElement(u8e,{className:o,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},w.createElement(Gq,{otherAttributes:p,title:u,desc:d,ref:e},w.createElement(Mze,null,s)))});function QD(){return QD=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},QD.apply(null,arguments)}var m8e={top:5,right:5,bottom:5,left:5},p8e={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:m8e,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},qO=w.forwardRef(function(e,n){var r,i=bi(e.categoricalChartProps,p8e),{chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(qee,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},w.createElement(hee,{chartData:u.data}),w.createElement(Wee,{layout:i.layout,margin:i.margin}),w.createElement(Kee,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),w.createElement(Xee,QD({},i,{ref:n})))}),g8e=["axis"],b8e=w.forwardRef((t,e)=>w.createElement(qO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:g8e,tooltipPayloadSearcher:DM,categoricalChartProps:t,ref:e})),x8e=["axis","item"],y8e=w.forwardRef((t,e)=>w.createElement(qO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:x8e,tooltipPayloadSearcher:DM,categoricalChartProps:t,ref:e}));function v8e(t){var e=$r();return w.useEffect(()=>{e(UBe(t))},[e,t]),null}var w8e=["layout"];function ZD(){return ZD=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ZD.apply(null,arguments)}function _8e(t,e){if(t==null)return{};var n,r,i=S8e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function S8e(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 N8e={top:5,right:5,bottom:5,left:5},Yee={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:N8e,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},k8e=w.forwardRef(function(e,n){var r,i=bi(e.categoricalChartProps,Yee),{layout:s}=i,o=_8e(i,w8e),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,h={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(qee,{preloadedState:{options:h},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(hee,{chartData:i.data}),w.createElement(Wee,{layout:s,margin:i.margin}),w.createElement(Kee,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),w.createElement(v8e,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(Xee,ZD({},o,{ref:n})))});function Wq(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 Kq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Wq(Object(n),!0).forEach(function(r){M8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Wq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function M8e(t,e,n){return(e=C8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C8e(t){var e=E8e(t,"string");return typeof e=="symbol"?e:e+""}function E8e(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 A8e=["item"],T8e=Kq(Kq({},Yee),{},{layout:"centric",startAngle:0,endAngle:360}),j8e=w.forwardRef((t,e)=>{var n=bi(t,T8e);return w.createElement(k8e,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:A8e,tooltipPayloadSearcher:DM,categoricalChartProps:n,ref:e})}),P8e=["axis"],D8e=w.forwardRef((t,e)=>w.createElement(qO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:P8e,tooltipPayloadSearcher:DM,categoricalChartProps:t,ref:e}));const Xq=[{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 R8e({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:o="humidity",thresholds:l}){const{t:c}=Ut(),{mode:u}=Gm(),[d,h]=w.useState("24h"),[p,m]=w.useState(o),x=u==="dark",{data:y}=et({queryKey:["settings"],queryFn:ae.getSettings}),b=y?.time_format||"system";w.useEffect(()=>{if(!t)return;const J=pe=>{pe.key==="Escape"&&e()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[t,e]);const v=Xq.find(J=>J.value===d)?.hours||24,{data:S,isLoading:k,error:E}=et({queryKey:["ams-history",n,i,v],queryFn:()=>ae.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const N=S?.data.map(J=>{const pe=Qi(J.recorded_at)||new Date,fe={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:pe.getTime(),humidity:J.humidity,temperature:J.temperature,timeLabel:pe.toLocaleTimeString([],Ty(fe,b))}})||[],A=l?.humidityGood||40,M=l?.humidityFair||60,P=l?.tempGood||30,T=l?.tempFair||35,j=N[N.length-1],z=j?.humidity,F=j?.temperature,$=J=>{const pe=J.filter(Ae=>Ae!=null);if(pe.length<4)return"stable";const fe=pe.slice(0,Math.floor(pe.length/4)),ve=pe.slice(-Math.floor(pe.length/4)),Le=fe.reduce((Ae,re)=>Ae+re,0)/fe.length,ce=ve.reduce((Ae,re)=>Ae+re,0)/ve.length-Le;return Math.abs(ce)<2?"stable":ce>0?"up":"down"},D=$(N.map(J=>J.humidity)),H=$(N.map(J=>J.temperature)),q=({trend:J})=>J==="up"?a.jsx(GP,{className:"w-4 h-4 text-red-400"}):J==="down"?a.jsx(u4,{className:"w-4 h-4 text-green-400"}):a.jsx(HP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),I=J=>J==null?"#9ca3af":J<=A?"#22a352":J<=M?"#d4a017":"#c62828",K=J=>J==null?"#9ca3af":J<=P?"#22a352":J<=T?"#d4a017":"#c62828",Z=x?"#2d2d2d":"#ffffff",se=x?"#1d1d1d":"#f3f4f6",V=x?"#3d3d3d":"#e5e7eb",W=x?"#ffffff":"#111827",ie=x?"#9ca3af":"#4b5563";return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:Z},onClick:J=>J.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:V},children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold",style:{color:W},children:[s," ",c("common.history","History")]}),a.jsx("p",{className:"text-sm",style:{color:ie},children:r})]}),a.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ie},children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:se},children:[a.jsxs("button",{onClick:()=>m("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="humidity"?"bg-blue-600 text-white":""}`,style:p!=="humidity"?{color:ie}:void 0,children:[a.jsx(a4,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),a.jsxs("button",{onClick:()=>m("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="temperature"?"bg-orange-600 text-white":""}`,style:p!=="temperature"?{color:ie}:void 0,children:[a.jsx(Fk,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),a.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:se},children:Xq.map(J=>a.jsx("button",{onClick:()=>h(J.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===J.value?"bg-bambu-green text-white":""}`,style:d!==J.value?{color:ie}:void 0,children:J.label},J.value))})]}),a.jsx("div",{className:"grid grid-cols-4 gap-4",children:p==="humidity"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:ie},children:c("common.current","Current")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-2xl font-bold",style:{color:I(z)},children:z!=null?`${z}%`:"—"}),a.jsx(q,{trend:D})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:ie},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:ie},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:ie},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:ie},children:c("common.current","Current")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-2xl font-bold",style:{color:K(F)},children:F!=null?`${F}°C`:"—"}),a.jsx(q,{trend:H})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:ie},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:ie},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:ie},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),a.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:k?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ie},children:c("common.loading","Loading...")}):E?a.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):N.length===0?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ie},children:c("common.noData","No data available for this time range")}):a.jsx(WS,{width:"100%",height:300,children:a.jsxs(b8e,{data:N,children:[a.jsx(yN,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),a.jsx(wN,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:J=>{const pe=new Date(J);return v>24?pe.toLocaleDateString([],{day:"numeric",month:"short"}):pe.toLocaleTimeString([],Ty({hour:"2-digit",minute:"2-digit"},b))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),a.jsx(_N,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:p==="humidity"?[0,100]:["auto","auto"],tickFormatter:J=>p==="humidity"?`${J}%`:`${J}°C`}),a.jsx(XS,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:J=>new Date(J).toLocaleString(void 0,Ty({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},b)),formatter:J=>[p==="humidity"?`${J??0}%`:`${J??0}°C`,p==="humidity"?"Humidity":"Temperature"]}),a.jsx(bL,{}),p==="humidity"?a.jsxs(a.Fragment,{children:[a.jsx(wy,{y:A,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(wy,{y:M,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):a.jsxs(a.Fragment,{children:[a.jsx(wy,{y:P,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(wy,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),a.jsx(Mee,{type:"monotone",dataKey:p,name:p==="humidity"?"Humidity":"Temperature",stroke:p==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),a.jsx("div",{className:"text-xs text-center",style:{color:ie},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function Nj({data:t,children:e,disabled:n,className:r="",spoolman:i,inventory:s,configureSlot:o}){const{t:l}=Ut(),[c,u]=w.useState(!1),[d,h]=w.useState("top"),[p,m]=w.useState(!1),x=w.useRef(null),y=w.useRef(null),b=w.useRef(null),v=()=>{const P=t.trayUuid;P&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(P).then(()=>{m(!0),setTimeout(()=>m(!1),2e3)}).catch(()=>{S(P)}):S(P))},S=P=>{const T=document.createElement("textarea");T.value=P,T.style.position="fixed",T.style.opacity="0",document.body.appendChild(T),T.select();try{document.execCommand("copy"),m(!0),setTimeout(()=>m(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(T)};w.useEffect(()=>{if(c&&x.current&&y.current){const P=x.current.getBoundingClientRect(),T=y.current.offsetHeight,z=P.top-56,F=window.innerHeight-P.bottom;z<T+12&&F>z?h("bottom"):h("top")}},[c]);const k=()=>{n||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>u(!0),80))},E=()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>u(!1),100)};w.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const N=P=>P<=15?"#ef4444":P<=30?"#f97316":P<=50?"#eab308":"#22c55e",A=P=>{if(!P)return!1;const T=P.replace("#",""),j=parseInt(T.slice(0,2),16),z=parseInt(T.slice(2,4),16),F=parseInt(T.slice(4,6),16);return(.299*j+.587*z+.114*F)/255>.6},M=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return a.jsxs("div",{ref:x,className:`relative ${r}`,onMouseEnter:k,onMouseLeave:E,children:[e,c&&a.jsxs("div",{ref:y,className:`
  8103. absolute left-1/2 -translate-x-1/2 z-50
  8104. ${d==="top"?"bottom-full mb-2":"top-full mt-2"}
  8105. animate-in fade-in-0 zoom-in-95 duration-150
  8106. `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:`
  8107. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  8108. rounded-lg shadow-xl overflow-hidden
  8109. backdrop-blur-sm
  8110. `,children:[a.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:M||"#3d3d3d"},children:[a.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),a.jsx("div",{className:`
  8111. absolute inset-0 flex items-center justify-center
  8112. font-semibold text-sm tracking-wide
  8113. ${A(M)?"text-black/80":"text-white/90"}
  8114. `,children:t.colorName}),a.jsx("div",{className:`
  8115. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  8116. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  8117. `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),a.jsxs("div",{className:"p-3 space-y-2.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:l("ams.profile")}),a.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:l("ams.kFactor")}),a.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[a.jsx(a4,{className:"w-3 h-3"}),l("ams.fill")]}),a.jsxs("span",{className:"text-xs text-white font-semibold flex items-center gap-1",children:[t.fillLevel!==null?`${t.fillLevel}%`:"—",t.fillSource==="spoolman"&&t.fillLevel!==null&&a.jsx("span",{className:"text-[9px] text-bambu-gray font-normal",children:l("spoolman.fillSourceLabel")}),t.fillSource==="inventory"&&t.fillLevel!==null&&a.jsx("span",{className:"text-[9px] text-bambu-gray font-normal",children:l("inventory.fillSourceLabel")})]})]}),a.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?a.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:N(t.fillLevel)}}):a.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:l("spoolman.spoolId")}),a.jsxs("button",{onClick:P=>{P.stopPropagation(),v()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[a.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),p?a.jsx(Kr,{className:"w-3 h-3 text-bambu-green"}):a.jsx(Xl,{className:"w-3 h-3"})]})]}),i.linkedSpoolId&&i.spoolmanUrl&&a.jsxs("a",{href:`${i.spoolmanUrl.replace(/\/$/,"")}/spool/show/${i.linkedSpoolId}`,target:"_blank",rel:"noopener noreferrer",onClick:P=>P.stopPropagation(),className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green",title:l("spoolman.openInSpoolman"),children:[a.jsx(Wr,{className:"w-3.5 h-3.5"}),l("spoolman.openInSpoolman")]}),!i.linkedSpoolId&&i.onLinkSpool&&a.jsxs("button",{onClick:P=>{P.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?l("spoolman.noUnlinkedSpools"):l("spoolman.linkToSpoolman"),children:[a.jsx(Mh,{className:"w-3.5 h-3.5"}),l("spoolman.linkToSpoolman")]})]}),s&&t.vendor!=="Bambu Lab"&&a.jsx("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:s.assignedSpool?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(ta,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:l("inventory.assigned")})]}),a.jsxs("p",{className:"text-xs text-white truncate",children:[s.assignedSpool.brand?`${s.assignedSpool.brand} `:"",s.assignedSpool.material,s.assignedSpool.color_name?` - ${s.assignedSpool.color_name}`:""]}),s.onUnassignSpool&&a.jsxs("button",{onClick:P=>{P.stopPropagation(),s.onUnassignSpool?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-red-500/20 hover:bg-red-500/30 text-red-400",children:[a.jsx(Ik,{className:"w-3.5 h-3.5"}),l("inventory.unassignSpool")]})]}):s.onAssignSpool?a.jsxs("button",{onClick:P=>{P.stopPropagation(),s.onAssignSpool?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",children:[a.jsx(ta,{className:"w-3.5 h-3.5"}),l("inventory.assignSpool")]}):null}),o?.enabled&&a.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("button",{onClick:P=>{P.stopPropagation(),o.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:l("ams.configureSlot"),children:[a.jsx(Qu,{className:"w-3.5 h-3.5"}),l("ams.configure")]})})]})]}),a.jsx("div",{className:`
  8118. absolute left-1/2 -translate-x-1/2 w-0 h-0
  8119. border-l-[6px] border-l-transparent
  8120. border-r-[6px] border-r-transparent
  8121. ${d==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  8122. `})]})]})}function Yq({children:t,className:e="",configureSlot:n}){const{t:r}=Ut(),[i,s]=w.useState(!1),o=w.useRef(null),l=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!0),80)},c=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),100)};return w.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),a.jsxs("div",{className:`relative ${e}`,onMouseEnter:l,onMouseLeave:c,children:[t,i&&a.jsxs("div",{className:`
  8123. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  8124. animate-in fade-in-0 zoom-in-95 duration-150
  8125. `,children:[a.jsxs("div",{className:`
  8126. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  8127. rounded-md shadow-lg overflow-hidden
  8128. `,children:[a.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:r("ams.emptySlot")}),n?.enabled&&a.jsx("div",{className:"px-2 pb-2",children:a.jsxs("button",{onClick:u=>{u.stopPropagation(),n.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:r("ams.configureSlot"),children:[a.jsx(Qu,{className:"w-3.5 h-3.5"}),r("ams.configure")]})})]}),a.jsx("div",{className:`
  8129. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  8130. border-l-[5px] border-l-transparent
  8131. border-r-[5px] border-r-transparent
  8132. border-t-[5px] border-t-bambu-dark-tertiary
  8133. `})]})]})}function L8e({isOpen:t,onClose:e,tagUid:n,trayUuid:r,printerId:i,amsId:s,trayId:o}){const{t:l}=Ut(),c=Zt(),{showToast:u}=hn(),[d,h]=w.useState(""),{data:p,isLoading:m}=et({queryKey:["inventory-spools"],queryFn:()=>ae.getSpools(!1),enabled:t}),x=w.useMemo(()=>p?p.filter(b=>{if(b.tag_uid||b.tray_uuid)return!1;if(!d)return!0;const v=d.toLowerCase();return b.material.toLowerCase().includes(v)||b.brand&&b.brand.toLowerCase().includes(v)||b.color_name&&b.color_name.toLowerCase().includes(v)}):[],[p,d]),y=st({mutationFn:b=>ae.linkTagToSpool(b,{tag_uid:n||void 0,tray_uuid:r||void 0,tag_type:r?"bambulab":"generic",data_origin:"nfc_link"}),onSuccess:()=>{c.invalidateQueries({queryKey:["inventory-spools"]}),c.invalidateQueries({queryKey:["inventory-assignments"]}),u(l("inventory.tagLinked"),"success"),e()},onError:b=>{u(b.message||l("inventory.tagLinkFailed"),"error")}});return t?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl shadow-xl w-full max-w-md mx-4 max-h-[80vh] flex flex-col border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[a.jsxs("div",{children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Db,{className:"w-5 h-5 text-bambu-green"}),l("inventory.linkToSpool")]}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["AMS ",s," T",o," · Printer #",i]})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 border-b border-white/10",children:[a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:d,onChange:b=>h(b.target.value),placeholder:l("inventory.searchSpools"),className:"w-full pl-9 pr-3 py-2 bg-bambu-dark rounded-lg border border-white/10 text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green"})]}),(n||r)&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 font-mono truncate",title:n||r,children:["Tag: ",n||r]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:m?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):x.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8 text-sm",children:l("inventory.noSpoolsMatch")}):x.map(b=>a.jsxs("button",{onClick:()=>y.mutate(b.id),disabled:y.isPending,className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-white/5 transition-colors text-left",children:[a.jsx("span",{className:"w-6 h-6 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:b.rgba?`#${b.rgba.substring(0,6)}`:"#808080"}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"text-sm text-white font-medium truncate",children:[b.brand?`${b.brand} `:"",b.material,b.subtype?` ${b.subtype}`:""]}),a.jsxs("div",{className:"text-xs text-bambu-gray truncate",children:[b.color_name||"No color"," · #",b.id]})]}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(b.label_weight-b.weight_used),"g"]})]},b.id))}),a.jsx("div",{className:"p-4 border-t border-white/10 flex justify-end",children:a.jsx(Me,{variant:"ghost",onClick:e,children:l("inventory.cancel")||"Cancel"})})]})]}):null}function O8e({isOpen:t,onClose:e,printerId:n,amsId:r,trayId:i,trayInfo:s}){const{t:o}=Ut(),l=Zt(),{showToast:c}=hn(),[u,d]=w.useState(null),[h,p]=w.useState(""),{data:m,isLoading:x}=et({queryKey:["inventory-spools"],queryFn:()=>ae.getSpools(),enabled:t}),{data:y}=et({queryKey:["spool-assignments"],queryFn:()=>ae.getAssignments(),enabled:t}),b=st({mutationFn:N=>ae.assignSpool({spool_id:N,printer_id:n,ams_id:r,tray_id:i}),onSuccess:N=>{l.setQueryData(["spool-assignments"],A=>{const M=(A||[]).filter(P=>!(P.printer_id===n&&P.ams_id===r&&P.tray_id===i));return M.push(N),M}),l.invalidateQueries({queryKey:["spool-assignments"]}),c(o("inventory.assignSuccess"),"success"),e()},onError:N=>{c(`${o("inventory.assignFailed")}: ${N.message}`,"error")}});if(!t)return null;const v=new Set((y||[]).filter(N=>!(N.printer_id===n&&N.ams_id===r&&N.tray_id===i)).map(N=>N.spool_id)),S=m?.filter(N=>!N.tag_uid&&!N.tray_uuid&&!v.has(N.id)),k=S?.filter(N=>{if(!h)return!0;const A=h.toLowerCase();return N.material.toLowerCase().includes(A)||(N.brand?.toLowerCase().includes(A)??!1)||(N.color_name?.toLowerCase().includes(A)??!1)||(N.subtype?.toLowerCase().includes(A)??!1)}),E=()=>{u&&b.mutate(u)};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:o("inventory.assignSpool")})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[s&&a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-xs text-bambu-gray mb-1",children:[o("inventory.selectSpool"),":"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[s.color&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${s.color}`}}),a.jsx("span",{className:"text-white font-medium",children:s.type||o("ams.emptySlot")}),a.jsxs("span",{className:"text-bambu-gray",children:["(",s.location,")"]})]})]}),a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:h,onChange:N=>p(N.target.value),placeholder:o("inventory.searchSpools"),className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsx("div",{children:x?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):k&&k.length>0?a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:k.map(N=>a.jsx("button",{onClick:()=>d(N.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${u===N.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[N.rgba&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${N.rgba.substring(0,6)}`}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("p",{className:"text-white font-medium truncate",children:[N.brand?`${N.brand} `:"",N.material,N.subtype?` ${N.subtype}`:""]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[N.color_name||"",N.label_weight?` - ${N.label_weight}g`:"",N.weight_used>0?` (${Math.round(N.weight_used)}g used)`:""]})]}),u===N.id&&a.jsx(Kr,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},N.id))}):S&&S.length===0?a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:a.jsx("p",{children:o("inventory.noManualSpools")})}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:a.jsx("p",{children:o("inventory.noSpoolsMatch")})})})]}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:o("common.cancel")}),a.jsx(Me,{onClick:E,disabled:!u||b.isPending,children:b.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),o("inventory.assigning")]}):a.jsxs(a.Fragment,{children:[a.jsx(ta,{className:"w-4 h-4"}),o("inventory.assignSpool")]})})]}),b.isError&&a.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:b.error.message})]})]})}function F8e(t,e){if(t===255)return"External";let n,r=!1;t>=128&&t<=135?(n=t-128,r=!0):t>=0&&t<=3?(n=t,r=e===1):n=0,n=Math.max(0,Math.min(n,7));const i=String.fromCharCode(65+n);return r?`HT-${i}`:`AMS-${i}`}function Qq(t){const e=t.includes("_")?t.split("_")[0]:t;return e.startsWith("GFS")?"GF"+e.slice(3):(e.startsWith("PFUS")||e.startsWith("PFSP"),e)}const I8e=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function Zq(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of I8e){const s=new RegExp(`\\b${i}\\b`,"i");if(s.test(n)){const o=e.split(s),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function z8e(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const U8e={white:"FFFFFF",black:"000000",red:"FF0000",green:"00FF00",blue:"0000FF",yellow:"FFFF00",cyan:"00FFFF",magenta:"FF00FF",orange:"FFA500",purple:"800080",pink:"FFC0CB",brown:"8B4513",gray:"808080",grey:"808080","jade white":"FFFEF2",ivory:"FFFFF0",beige:"F5F5DC",cream:"FFFDD0",silver:"C0C0C0",gold:"FFD700",bronze:"CD7F32",copper:"B87333",navy:"000080",teal:"008080",olive:"808000",maroon:"800000",coral:"FF7F50",salmon:"FA8072",lime:"32CD32",mint:"98FF98","forest green":"228B22","sky blue":"87CEEB","royal blue":"4169E1",turquoise:"40E0D0",lavender:"E6E6FA",violet:"EE82EE",plum:"DDA0DD",tan:"D2B48C",chocolate:"D2691E",charcoal:"36454F",slate:"708090",transparent:"000000",natural:"F5F5DC",wood:"DEB887"},B8e=[{name:"White",hex:"FFFFFF"},{name:"Black",hex:"000000"},{name:"Red",hex:"FF0000"},{name:"Blue",hex:"0000FF"},{name:"Green",hex:"00AA00"},{name:"Yellow",hex:"FFFF00"},{name:"Orange",hex:"FFA500"},{name:"Gray",hex:"808080"}],$8e=[{name:"Cyan",hex:"00FFFF"},{name:"Magenta",hex:"FF00FF"},{name:"Purple",hex:"800080"},{name:"Pink",hex:"FFC0CB"},{name:"Brown",hex:"8B4513"},{name:"Beige",hex:"F5F5DC"},{name:"Navy",hex:"000080"},{name:"Teal",hex:"008080"},{name:"Lime",hex:"32CD32"},{name:"Gold",hex:"FFD700"},{name:"Silver",hex:"C0C0C0"},{name:"Maroon",hex:"800000"},{name:"Olive",hex:"808000"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Indigo",hex:"4B0082"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Slate",hex:"708090"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Cream",hex:"FFFDD0"}];function H8e(t){const e=t.toLowerCase().trim();return U8e[e]||null}function V8e({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:s}){const{t:o}=Ut(),[l,c]=w.useState(""),[u,d]=w.useState(null),[h,p]=w.useState(""),[m,x]=w.useState(""),[y,b]=w.useState(""),[v,S]=w.useState(!1),[k,E]=w.useState(!1),{data:N,isLoading:A,isError:M}=et({queryKey:["cloudSettings"],queryFn:()=>ae.getCloudSettings(),enabled:t,retry:!1}),{data:P,isLoading:T}=et({queryKey:["localPresets"],queryFn:()=>ae.getLocalPresets(),enabled:t}),{data:j,isLoading:z}=et({queryKey:["builtinFilaments"],queryFn:()=>ae.getBuiltinFilaments(),enabled:t,staleTime:1/0}),{data:F,isLoading:$}=et({queryKey:["kprofiles",n,i],queryFn:()=>ae.getKProfiles(n,i),enabled:t&&!!n}),D=st({mutationFn:async()=>{if(!l)throw new Error("No filament preset selected");const J=l.startsWith("local_"),pe=l.startsWith("builtin_"),fe=J?parseInt(l.replace("local_",""),10):null,ve=pe?l.replace("builtin_",""):null,Le=J?P?.filament.find(X=>X.id===fe):null,de=pe?j?.find(X=>X.filament_id===ve):null,ce=!J&&!pe?N?.filament.find(X=>X.setting_id===l):null;if(!J&&!pe&&!ce)throw new Error("Selected preset not found");if(J&&!Le)throw new Error("Selected local preset not found");if(pe&&!de)throw new Error("Selected builtin preset not found");const Ae=J?Le.name:pe?de.name:ce.name,re=Zq(Ae),Ie=u?.slot_id??-1,G=h||r.trayColor?.slice(0,6)||"FFFFFF",Y=Ae.replace(/@.+$/,"").trim();let ue,B;if(J)ue="",B="";else if(pe)ue=ve,B="";else if(ue=Qq(l),B=l,!l.startsWith("GFS"))try{const X=await ae.getCloudSettingDetail(l);X.filament_id?ue=X.filament_id:X.base_id&&(ue=Qq(X.base_id),console.log(`Derived tray_info_idx from base_id: ${X.base_id} -> ${ue}`))}catch(X){console.warn("Failed to fetch preset detail for filament_id:",X)}let ee=J&&Le?.nozzle_temp_min?Le.nozzle_temp_min:190,Q=J&&Le?.nozzle_temp_max?Le.nozzle_temp_max:230;if(!J||pe||!Le?.nozzle_temp_min&&!Le?.nozzle_temp_max){const X=(J&&Le?.filament_type||re.material).toUpperCase();X.includes("PLA")?(ee=190,Q=230):X.includes("PETG")?(ee=220,Q=260):X.includes("ABS")||X.includes("ASA")?(ee=240,Q=280):X.includes("TPU")?(ee=200,Q=240):X.includes("PC")?(ee=260,Q=300):(X.includes("PA")||X.includes("NYLON"))&&(ee=250,Q=290)}const le=u?.k_value?parseFloat(u.k_value):0,he=J?Le?.filament_type||re.material||"PLA":re.material||"PLA",te=await ae.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ue,tray_type:he,tray_sub_brands:Y,tray_color:G+"FF",nozzle_temp_min:ee,nozzle_temp_max:Q,cali_idx:Ie,nozzle_diameter:i,setting_id:B,kprofile_filament_id:u?.filament_id,kprofile_setting_id:u?.setting_id||void 0,k_value:le}),U=J?`local_${fe}`:pe?`builtin_${ve}`:l,L=J?"local":pe?"builtin":"cloud";try{await ae.saveSlotPreset(n,r.amsId,r.trayId,U,Y,L)}catch(X){console.warn("Failed to save slot preset mapping:",X)}return te},onSuccess:()=>{S(!0),s?.(),setTimeout(()=>{S(!1),e()},1500)}}),H=st({mutationFn:async()=>ae.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{S(!0),s?.(),setTimeout(()=>{S(!1),e()},1500)}}),q=w.useMemo(()=>{const J=y.toLowerCase(),pe=[],fe=new Set;if(N?.filament)for(const ve of N.filament)fe.add(ve.setting_id),(!J||ve.name.toLowerCase().includes(J))&&pe.push({id:ve.setting_id,name:ve.name,source:"cloud",isUser:z8e(ve.setting_id)});if(P?.filament)for(const ve of P.filament)(!J||ve.name.toLowerCase().includes(J))&&pe.push({id:`local_${ve.id}`,name:ve.name,source:"local",isUser:!1});if(j)for(const ve of j){if(fe.has(ve.filament_id))continue;const Le=ve.filament_id.startsWith("GF")?"GFS"+ve.filament_id.slice(2):ve.filament_id;fe.has(Le)||(!J||ve.name.toLowerCase().includes(J))&&pe.push({id:`builtin_${ve.filament_id}`,name:ve.name,source:"builtin",isUser:!1})}return pe.sort((ve,Le)=>{const de={cloud:0,local:1,builtin:2};return ve.source!==Le.source?de[ve.source]-de[Le.source]:ve.isUser&&!Le.isUser?-1:!ve.isUser&&Le.isUser?1:ve.name.localeCompare(Le.name)})},[N?.filament,P?.filament,j,y]),I=w.useMemo(()=>{if(!l)return null;let J=null;if(l.startsWith("local_")){const ve=parseInt(l.replace("local_",""),10);J=P?.filament.find(de=>de.id===ve)?.name||null}else if(l.startsWith("builtin_")){const ve=l.replace("builtin_","");J=j?.find(de=>de.filament_id===ve)?.name||null}else N?.filament&&(J=N.filament.find(Le=>Le.setting_id===l)?.name||null);if(!J)return null;let pe=J.replace(/@.+$/,"").trim();pe.startsWith("# ")&&(pe=pe.slice(2).trim());const fe=Zq(pe);return{fullName:pe,material:fe.material,brand:fe.brand}},[l,N?.filament,P?.filament,j]),K=I?.fullName||"",Z=w.useMemo(()=>{if(!F?.profiles||!I)return[];const{fullName:J,material:pe,brand:fe}=I,ve=J.toUpperCase(),Le=pe.toUpperCase(),de=fe.toUpperCase();if(!Le||Le.length<2)return[];const ce=F.profiles.filter(re=>{const Ie=re.name.toUpperCase();if(de)return!(!Ie.includes(de)||!Ie.includes(Le));if(Ie.includes(ve)||Ie.includes(Le))return!0;const Y={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[Le]||[];for(const ue of Y)if(Ie.includes(ue))return!0;return!1}),Ae=new Map;for(const re of ce){const Ie=`${re.name}|${re.k_value}`,G=Ae.get(Ie);G?re.extruder_id===1&&G.extruder_id===0&&Ae.set(Ie,re):Ae.set(Ie,re)}return Array.from(Ae.values())},[F?.profiles,I]);w.useEffect(()=>{if(t&&N?.filament){if(r.trayInfoIdx){const J=N.filament.find(pe=>pe.setting_id===r.trayInfoIdx);J&&c(J.setting_id)}}else t||(c(""),d(null),p(""),x(""),b(""),S(!1))},[t,N?.filament,r.trayInfoIdx]),w.useEffect(()=>{Z.length>0?d(Z[0]):d(null)},[l,Z]);const se=w.useCallback(J=>{J.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[t,se]),!t)return null;const V=A&&!M||T||z||$,W=l&&!D.isPending,ie=h||r.trayColor?.slice(0,6)||"FFFFFF";return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qu,{className:"w-5 h-5 text-bambu-blue"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[v&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:a.jsxs("div",{className:"text-center space-y-3",children:[a.jsx(Zg,{className:"w-16 h-16 text-bambu-green mx-auto"}),a.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:o("configureAmsSlot.settingsSentToPrinter")})]})}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),a.jsxs("span",{className:"text-white font-medium",children:[F8e(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&a.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),V?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:o("configureAmsSlot.searchPresets"),value:y,onChange:J=>b(J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:q.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:N?.filament?.length===0&&!P?.filament?.length?"No presets available. Login to Bambu Cloud or import local profiles.":"No matching presets found."}):q.map(J=>a.jsx("button",{onClick:()=>c(J.id),className:`w-full p-2 rounded-lg border text-left transition-colors ${l===J.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-white text-sm truncate",children:J.name}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[J.source==="local"&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/20 text-green-400",children:o("profiles.localProfiles.badge")}),J.source==="builtin"&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400",children:o("configureAmsSlot.builtin")}),J.isUser&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:o("configureAmsSlot.custom")})]})]})},J.id))})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",K&&a.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",K]})]}),Z.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:u?.name||"",onChange:J=>{const pe=Z.find(fe=>fe.name===J.target.value);d(pe||null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10",children:[a.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),Z.map(J=>a.jsxs("option",{value:J.name,children:[J.name," (K=",J.k_value,")"]},`${J.name}-${J.extruder_id}`))]}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):l?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):a.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),u&&a.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",u.k_value," from printer calibration"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[B8e.map(J=>a.jsx("button",{onClick:()=>{p(J.hex),x(J.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${h===J.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${J.hex}`},title:J.name},J.hex)),a.jsx("button",{onClick:()=>E(!k),className:"w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs",title:k?"Show less colors":"Show more colors",children:k?"−":"+"})]}),k&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:$8e.map(J=>a.jsx("button",{onClick:()=>{p(J.hex),x(J.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${h===J.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${J.hex}`},title:J.name},J.hex))}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${ie}`}}),a.jsx("input",{type:"text",placeholder:o("configureAmsSlot.colorPlaceholder"),value:m,onChange:J=>{const pe=J.target.value;x(pe);const fe=H8e(pe);if(fe)p(fe);else{const ve=pe.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();ve.length===6?p(ve):ve.length===3&&p(ve.split("").map(Le=>Le+Le).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),h&&a.jsx("button",{onClick:()=>{p(""),x("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:o("configureAmsSlot.clearCustomColor"),children:"Clear"})]}),h&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",h]})]})]})]}),a.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:()=>H.mutate(),disabled:H.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:H.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Po,{className:"w-4 h-4"}),"Reset Slot"]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Me,{onClick:()=>D.mutate(),disabled:!W,children:D.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Qu,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||H.isError)&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:D.error?.message||H.error?.message})]})]})}const Jq={"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"},G8e={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 kj(t){if(!t)return null;if(Jq[t])return Jq[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return G8e[n]||null}function Mj(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,s=Math.min(e,n,r)/255,o=(i+s)/2;let l=0,c=0;if(i!==s){const u=i-s;c=o>.5?u/(2-i-s):u/(i+s);const d=e/255,h=n/255,p=r/255;i===d?l=((h-p)/u+(h<p?6:0))/6:i===h?l=((p-d)/u+2)/6:l=((d-h)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":"Pink"}function Cj(t){return(t??.02).toFixed(3)}function e7({side:t}){const{mode:e}=Gm(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return a.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 Qee(t){if(!t||t==="00000000"||t.length<6)return null;const e=t.slice(0,2),n=t.slice(2,4),r=t.slice(4,6),i=t.length>=8?parseInt(t.slice(6,8),16)/255:1;return i===0?null:`rgba(${parseInt(e,16)}, ${parseInt(n,16)}, ${parseInt(r,16)}, ${i})`}function q8e(t){if(!t||t.length<6)return!1;const e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return(.299*e+.587*n+.114*r)/255>.6}function Zee(t,e){if(!t)return"";if(t.includes("hardened"))return e("printers.nozzleHardenedSteel");if(t.includes("stainless"))return e("printers.nozzleStainlessSteel");if(t.includes("tungsten"))return e("printers.nozzleTungstenCarbide");if(t.length>=4){const n=t.slice(2,4);if(n==="00")return e("printers.nozzleStainlessSteel");if(n==="01")return e("printers.nozzleHardenedSteel");if(n==="05")return e("printers.nozzleTungstenCarbide")}return t==="00"?e("printers.nozzleStainlessSteel"):t==="01"?e("printers.nozzleHardenedSteel"):t==="05"?e("printers.nozzleTungstenCarbide"):t.startsWith("H")?e("printers.nozzleHardenedSteel"):t}function Jee(t,e){return t?t.startsWith("HH")?e("printers.nozzleHighFlow"):t.startsWith("HS")?e("printers.nozzleStandardFlow"):"":""}function ete({slot:t,index:e,activeStatus:n,filamentName:r,children:i}){const{t:s}=Ut(),[o,l]=w.useState(!1),[c,u]=w.useState("top"),d=w.useRef(null),h=w.useRef(null),p=w.useRef(null),m=!t.nozzle_diameter&&!t.nozzle_type,x=t.stat===1;w.useEffect(()=>{if(o&&d.current&&h.current){const E=d.current.getBoundingClientRect(),N=h.current.offsetHeight,M=E.top-56,P=window.innerHeight-E.bottom;M<N+12&&P>M?u("bottom"):u("top")}},[o]);const y=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>l(!0),80)},b=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const v=Qee(t.filament_color),S=Zee(t.nozzle_type,s),k=Jee(t.nozzle_type,s);return a.jsxs("div",{ref:d,className:"relative",onMouseEnter:y,onMouseLeave:b,children:[i,o&&a.jsxs("div",{ref:h,className:`
  8134. absolute left-1/2 -translate-x-1/2 z-50
  8135. ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
  8136. animate-in fade-in-0 zoom-in-95 duration-150
  8137. `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsx("div",{className:"w-44 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm",children:m?a.jsxs("div",{className:"px-3 py-2 text-xs text-bambu-gray text-center whitespace-nowrap",children:["Slot ",e+1," — Empty"]}):a.jsxs("div",{className:"p-2.5 space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleDiameter")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[t.nozzle_diameter," mm"]})]}),S&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleType")}),a.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[100px]",children:S})]}),k&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleFlow")}),a.jsx("span",{className:"text-xs text-white font-semibold",children:k})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleStatus")}),a.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${n||x?"bg-green-900/50 text-green-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s(n?"printers.nozzleActive":x?"printers.nozzleMounted":"printers.nozzleDocked")})]}),t.wear!=null&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleWear")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[t.wear,"%"]})]}),t.max_temp>0&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleMaxTemp")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[t.max_temp,"°C"]})]}),t.serial_number&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleSerial")}),a.jsx("span",{className:"text-[10px] text-white font-mono truncate max-w-[80px]",children:t.serial_number})]}),(v||t.filament_type)&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleFilament")}),a.jsxs("div",{className:"flex items-center gap-1",children:[v&&a.jsx("div",{className:"w-3 h-3 rounded-sm border border-white/20",style:{backgroundColor:v}}),a.jsx("span",{className:"text-[10px] text-white font-semibold truncate max-w-[100px]",children:r||t.filament_type||t.filament_id||""})]})]})]})}),a.jsx("div",{className:`
  8138. absolute left-1/2 -translate-x-1/2 w-0 h-0
  8139. border-l-[6px] border-l-transparent
  8140. border-r-[6px] border-r-transparent
  8141. ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  8142. `})]})]})}function W8e({leftSlot:t,rightSlot:e,activeNozzle:n,children:r}){const{t:i}=Ut(),[s,o]=w.useState(!1),[l,c]=w.useState("top"),u=w.useRef(null),d=w.useRef(null),h=w.useRef(null);w.useEffect(()=>{if(s&&u.current&&d.current){const y=u.current.getBoundingClientRect(),b=d.current.offsetHeight,S=y.top-56,k=window.innerHeight-y.bottom;S<b+12&&k>S?c("bottom"):c("top")}},[s]);const p=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>o(!0),80)},m=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>o(!1),100)};if(w.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),!t&&!e)return a.jsx(a.Fragment,{children:r});const x=(y,b)=>{const v=n===b,S=Zee(y.nozzle_type,i),k=Jee(y.nozzle_type,i);return a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:`text-[10px] font-bold pb-1 border-b border-bambu-dark-tertiary/50 ${v?"text-amber-400":"text-bambu-gray"}`,children:i(b==="L"?"common.left":"common.right")}),y.nozzle_diameter&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleDiameter")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[y.nozzle_diameter," mm"]})]}),S&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleType")}),a.jsx("span",{className:"text-[10px] text-white font-semibold",children:S})]}),k&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleFlow")}),a.jsx("span",{className:"text-[10px] text-white font-semibold",children:k})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleStatus")}),a.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${v?"bg-green-900/50 text-green-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:i(v?"printers.nozzleActive":"printers.nozzleIdle")})]}),y.wear!=null&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleWear")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[y.wear,"%"]})]}),b==="R"&&y.max_temp>0&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleMaxTemp")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[y.max_temp,"°C"]})]}),b==="R"&&y.serial_number&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleSerial")}),a.jsx("span",{className:"text-[10px] text-white font-mono",children:y.serial_number})]})]})};return a.jsxs("div",{ref:u,className:"relative flex-1",onMouseEnter:p,onMouseLeave:m,children:[r,s&&a.jsxs("div",{ref:d,className:`
  8143. absolute left-1/2 -translate-x-1/2 z-50
  8144. ${l==="top"?"bottom-full mb-2":"top-full mt-2"}
  8145. animate-in fade-in-0 zoom-in-95 duration-150
  8146. `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsx("div",{className:"w-96 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm",children:a.jsxs("div",{className:"p-2.5 flex gap-3",children:[t&&x(t,"L"),t&&e&&a.jsx("div",{className:"w-px bg-bambu-dark-tertiary/50"}),e&&x(e,"R")]})}),a.jsx("div",{className:`
  8147. absolute left-1/2 -translate-x-1/2 w-0 h-0
  8148. border-l-[6px] border-l-transparent
  8149. border-r-[6px] border-r-transparent
  8150. ${l==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  8151. `})]})]})}function K8e({slots:t,filamentInfo:e}){const{t:n}=Ut(),r=t.filter(l=>l.id>=2),i=6,s=r.length>0?Math.min(...r.map(l=>l.id)):16,o=Array.from({length:i},(l,c)=>r.find(u=>u.id===s+c)??{id:-(c+1),nozzle_type:"",nozzle_diameter:"",wear:null,stat:null,max_temp:0,serial_number:"",filament_color:"",filament_id:"",filament_type:""});return a.jsxs("div",{className:"text-center px-2.5 py-1.5 bg-bambu-dark rounded-lg flex-[2_1_190px] flex flex-col justify-center",children:[a.jsx("p",{className:"text-[9px] text-bambu-gray mb-1",children:n("printers.nozzleRack")}),a.jsx("div",{className:"flex gap-[3px] justify-center",children:o.map((l,c)=>{const u=!l.nozzle_diameter&&!l.nozzle_type,d=u?null:Qee(l.filament_color),h=d?q8e(l.filament_color):!1;return a.jsx(ete,{slot:l,index:c,filamentName:l.filament_id?e?.[l.filament_id]?.name:void 0,children:a.jsx("div",{className:`w-7 h-7 rounded flex items-center justify-center cursor-default transition-colors border-b-2 ${u?"bg-bambu-dark-tertiary/20 border-bambu-dark-tertiary/20":"bg-bambu-dark-tertiary/40 border-bambu-dark-tertiary/40"}`,style:d?{backgroundColor:d}:void 0,children:a.jsx("span",{className:`text-[10px] font-semibold ${u?"text-bambu-gray/30":h?"text-black/80":"text-white"}`,style:d&&!h?{textShadow:"0 1px 3px rgba(0,0,0,0.9)"}:void 0,children:u?"—":l.nozzle_diameter||"?"})})},l.id>=0?l.id:`empty-${c}`)})})]})}function t7({className:t}){return a.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.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 X8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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 Y8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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 Q8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Z8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),a.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 J8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),a.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 Ej({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",s=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?a.jsxs("svg",{className:t,style:s,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),a.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"})]}):a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function n7({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const s=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(s)?(c="#C3C2C1",u="Unknown"):s<=o?(c="#22a352",u="Good"):s<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(s)||s<=o?d=t7:s<=l?d=X8e:d=Y8e,a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${s}% - ${u}${r?" (click for history)":""}`,children:[a.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[s,"%"]})]})}function r7({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const s=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=s?(l="#22a352",c="Good",u=Q8e):t<=o?(l="#d4a017",c="Fair",u=Z8e):(l="#c62828",c="Bad",u=J8e),a.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:[a.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Zd(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,s=r>=128?r-128:r,o=String.fromCharCode(65+s);return i?`HT-${o}`:`AMS-${o}`}function Aj(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function Tj(t){return!t?.remaining_weight||!t?.filament_weight||t.filament_weight<=0?null:Math.min(100,Math.round(t.remaining_weight/t.filament_weight*100))}function e6e(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function t6e(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 s=new Date(r);s.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((s.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function n6e(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")?"/img/printers/h2d.png":e.includes("h2c")?"/img/printers/h2c.png":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 r6e(t){return t>=-50?{labelKey:"printers.wifiSignal.excellent",color:"text-bambu-green",bars:4}:t>=-60?{labelKey:"printers.wifiSignal.good",color:"text-bambu-green",bars:3}:t>=-70?{labelKey:"printers.wifiSignal.fair",color:"text-yellow-400",bars:2}:t>=-80?{labelKey:"printers.wifiSignal.weak",color:"text-orange-400",bars:1}:{labelKey:"printers.wifiSignal.veryWeak",color:"text-red-400",bars:1}}function jj(t){return t?!!(t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function i6e({url:t,printName:e}){const{t:n}=Ut(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(!1),u=w.useMemo(()=>{if(!t)return null;const d=t.includes("?")?"&":"?";return`${t}${d}v=${encodeURIComponent(e||Date.now().toString())}`},[t,e]);return w.useEffect(()=>{i(!1),o(!1)},[u]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${u&&r?"cursor-pointer":""}`,onClick:()=>u&&r&&c(!0),children:u&&!s?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:u,alt:n("printers.printPreview"),className:`w-full h-full object-cover ${r?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>o(!0)}),!r&&a.jsx(Yi,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(Yi,{className:"w-8 h-8 text-bambu-gray"})}),l&&u&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>c(!1),children:a.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[a.jsx("img",{src:u,alt:n("printers.printPreview"),className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&a.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function a6e({printers:t}){const{t:e}=Ut(),n=Zt(),r=w.useMemo(()=>{let s=0,o=0,l=0,c=0;return t?.forEach(u=>{const d=n.getQueryData(["printerStatus",u.id]);d===void 0?c++:d.connected?d.state==="RUNNING"?s++:o++:l++}),{printing:s,idle:o,offline:l,loading:c,total:t?.length||0}},[t,n]),[,i]=w.useState(0);return w.useEffect(()=>{let s=!1;const o=n.getQueryCache().subscribe(()=>{s||(s=!0,requestAnimationFrame(()=>{i(l=>l+1),s=!1}))});return()=>o()},[n]),t?.length?a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.printing>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.printing})," ",e("printers.status.printing").toLowerCase()]})]}),r.idle>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.idle})," ",e("printers.status.idle").toLowerCase()]})]}),r.offline>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.offline})," ",e("printers.status.offline").toLowerCase()]})]})]}):null}function i7(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 a7({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,onGetAssignment:d,onUnassignSpool:h,timeFormat:p="system",cameraViewMode:m="window",onOpenEmbeddedCamera:x,checkPrinterFirmware:y=!0}){const{t:b}=Ut(),v=Zt(),S=Uc(),{showToast:k}=hn(),{hasPermission:E}=Rr(),[N,A]=w.useState(!1),[M,P]=w.useState(!1),[T,j]=w.useState(!0),[z,F]=w.useState(!1),[$,D]=w.useState(!1),[H,q]=w.useState(!1),[I,K]=w.useState(!1),[Z,se]=w.useState(!1),[V,W]=w.useState(!1),[ie,J]=w.useState(!1),[pe,fe]=w.useState(!1),[ve,Le]=w.useState(!1),[de,ce]=w.useState(!1),[Ae,re]=w.useState(null),[Ie,G]=w.useState(null),[Y,ue]=w.useState(null),[B,ee]=w.useState(null),[Q,le]=w.useState(!1),[he,te]=w.useState(null),[U,L]=w.useState(!1),[X,ge]=w.useState(!1),[_e,Ee]=w.useState(null),[$e,Ce]=w.useState(!1),[He,Qe]=w.useState(!1),{data:xe}=et({queryKey:["printerStatus",t.id],queryFn:()=>ae.getPrinterStatus(t.id),refetchInterval:3e4}),{data:ye}=et({queryKey:["firmwareUpdate",t.id],queryFn:()=>RS.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:y&&E("firmware:read")}),we=w.useMemo(()=>{const bt=new Set;if(xe?.ams)for(const Ft of xe.ams)for(const Kn of Ft.tray||[])Kn.tray_info_idx&&bt.add(Kn.tray_info_idx);if(xe?.vt_tray?.tray_info_idx&&bt.add(xe.vt_tray.tray_info_idx),xe?.nozzle_rack)for(const Ft of xe.nozzle_rack)Ft.filament_id&&bt.add(Ft.filament_id);return Array.from(bt)},[xe?.ams,xe?.vt_tray,xe?.nozzle_rack]),{data:Ue}=et({queryKey:["filamentInfo",we],queryFn:()=>ae.getFilamentInfo(we),enabled:we.length>0,staleTime:300*1e3}),{data:Pe}=et({queryKey:["slotPresets",t.id],queryFn:()=>ae.getSlotPresets(t.id),staleTime:120*1e3}),[Ve,ke]=w.useState(null);w.useEffect(()=>{xe?.wifi_signal!=null&&ke(xe.wifi_signal)},[xe?.wifi_signal]);const Ze=xe?.wifi_signal??Ve,je=w.useRef(void 0);w.useEffect(()=>{xe?.connected!==void 0&&(je.current=xe.connected)},[xe?.connected]);const Xe=xe?.connected??je.current,Re=w.useRef({});w.useEffect(()=>{xe?.ams_extruder_map&&Object.keys(xe.ams_extruder_map).length>0&&(Re.current=xe.ams_extruder_map)},[xe?.ams_extruder_map]);const Oe=xe?.ams_extruder_map&&Object.keys(xe.ams_extruder_map).length>0?xe.ams_extruder_map:Re.current,Ne=w.useRef([]);w.useEffect(()=>{xe?.ams&&xe.ams.length>0&&(Ne.current=xe.ams)},[xe?.ams]);const Je=xe?.ams&&xe.ams.length>0?xe.ams:Ne.current,yt=w.useRef(255),Et=xe?.tray_now;Et!==void 0&&Et!==255&&(yt.current=Et);const an=Et===void 0||Et===255?yt.current:Et,{data:jt}=et({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ae.getSmartPlugByPrinter(t.id)}),{data:Fe}=et({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ae.getScriptPlugsByPrinter(t.id)}),{data:gt}=et({queryKey:["smartPlugStatus",jt?.id],queryFn:()=>jt?ae.getSmartPlugStatus(jt.id):null,enabled:!!jt,refetchInterval:1e4}),{data:Qt}=et({queryKey:["queue",t.id,"pending"],queryFn:()=>ae.getQueue(t.id,"pending")}),tn=Qt?.length||0,{data:un}=et({queryKey:["queue",t.id,"printing"],queryFn:()=>ae.getQueue(t.id,"printing"),enabled:xe?.state==="RUNNING"}),{data:dr}=et({queryKey:["currentPrintUser",t.id],queryFn:()=>ae.getCurrentPrintUser(t.id),enabled:xe?.state==="RUNNING"}),gr=un?.[0]?.created_by_username||dr?.username,{data:ar}=et({queryKey:["archives",t.id,"last"],queryFn:()=>ae.getArchives(t.id,1,0),enabled:xe?.connected&&xe?.state!=="RUNNING"}),Xt=ar?.[0],sr=e&&Xe===!1,vi=st({mutationFn:bt=>ae.deletePrinter(t.id,bt.deleteArchives),onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),v.invalidateQueries({queryKey:["archives"]}),v.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:bt=>k(bt.message||b("printers.toast.failedToDelete"),"error")}),Fa=st({mutationFn:()=>ae.connectPrinter(t.id),onSuccess:()=>{v.invalidateQueries({queryKey:["printerStatus",t.id]})}}),De=st({mutationFn:bt=>jt?ae.controlSmartPlug(jt.id,bt):Promise.reject("No plug"),onSuccess:()=>{v.invalidateQueries({queryKey:["smartPlugStatus",jt?.id]})}}),nt=st({mutationFn:bt=>jt?ae.updateSmartPlug(jt.id,{auto_off:bt}):Promise.reject("No plug"),onSuccess:()=>{v.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),v.invalidateQueries({queryKey:["smart-plugs"]})}}),dt=st({mutationFn:bt=>ae.controlSmartPlug(bt,"on"),onSuccess:()=>{k(b("printers.toast.scriptTriggered"))},onError:bt=>k(bt.message||b("printers.toast.failedToRunScript"),"error")}),pt=st({mutationFn:()=>ae.stopPrint(t.id),onSuccess:()=>{k(b("printers.toast.printStopped")),v.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>k(bt.message||b("printers.toast.failedToStopPrint"),"error")}),ot=st({mutationFn:()=>ae.pausePrint(t.id),onSuccess:()=>{k(b("printers.toast.printPaused")),v.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>k(bt.message||b("printers.toast.failedToPausePrint"),"error")}),Lt=st({mutationFn:()=>ae.resumePrint(t.id),onSuccess:()=>{k(b("printers.toast.printResumed")),v.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>k(bt.message||b("printers.toast.failedToResumePrint"),"error")}),me=st({mutationFn:bt=>ae.setChamberLight(t.id,bt),onMutate:async bt=>{await v.cancelQueries({queryKey:["printerStatus",t.id]});const Ft=v.getQueryData(["printerStatus",t.id]);return v.setQueryData(["printerStatus",t.id],Kn=>({...Kn,chamber_light:bt})),{previousStatus:Ft}},onSuccess:(bt,Ft)=>{k(`Chamber light ${Ft?"on":"off"}`)},onError:(bt,Ft,Kn)=>{Kn?.previousStatus&&v.setQueryData(["printerStatus",t.id],Kn.previousStatus),k(bt.message||b("printers.toast.failedToControlChamberLight"),"error")}}),ze=st({mutationFn:bt=>ae.updatePrinter(t.id,{plate_detection_enabled:bt}),onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),k(ze.variables?b("printers.toast.plateCheckEnabled"):b("printers.toast.plateCheckDisabled"))},onError:bt=>k(bt.message||b("printers.toast.failedToUpdateSetting"),"error")}),Ke=(xe?.state==="RUNNING"||xe?.state==="PAUSE"||xe?.state==="PAUSED")&&(xe?.printable_objects_count??0)>=2,{data:Ge}=et({queryKey:["printableObjects",t.id],queryFn:()=>ae.getPrintableObjects(t.id),enabled:de||Ke,refetchInterval:de?5e3:Ke?3e4:!1}),[be,at]=w.useState(null),ht=w.useRef(!1),rt=w.useRef(null),Ct=w.useRef(!1),Vt=st({mutationFn:({amsId:bt,slotId:Ft})=>ae.refreshAmsSlot(t.id,bt,Ft),onMutate:({amsId:bt,slotId:Ft})=>{rt.current&&clearTimeout(rt.current),ht.current=!1,Ct.current=!1,at({amsId:bt,slotId:Ft}),setTimeout(()=>{Ct.current=!0},2e3),rt.current=setTimeout(()=>{at(null)},3e4)},onSuccess:bt=>{k(bt.message||b("printers.toast.rfidRereadInitiated"))},onError:bt=>{k(bt.message||b("printers.toast.failedToRereadRfid"),"error"),rt.current&&clearTimeout(rt.current),at(null)}}),[Dt,Tt]=w.useState(null),[Jt,Kt]=w.useState(null),fn=async()=>{try{const bt=await ae.getPlateReferences(t.id);Tt(bt)}catch{}},Cn=()=>{ze.mutate(!t.plate_detection_enabled)},gn=async()=>{L(!0),te(null);const bt=xe?.chamber_light===!1;Qe(bt),bt&&(await ae.setChamberLight(t.id,!0),await new Promise(Ft=>setTimeout(Ft,2500)));try{const Ft=await ae.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Ft),fn()}catch(Ft){k(Ft instanceof Error?Ft.message:b("printers.toast.failedToCheckPlate"),"error"),bt&&(await ae.setChamberLight(t.id,!1),Qe(!1))}finally{L(!1)}},Gt=w.useCallback(async()=>{te(null),He&&(await ae.setChamberLight(t.id,!1),Qe(!1))},[He,t.id]),mn=async bt=>{ge(!0);try{const Ft=await ae.calibratePlateDetection(t.id,{label:bt});if(Ft.success){k(Ft.message||b("printers.toast.calibrationSaved"),"success"),fn();const Kn=await ae.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Kn)}else k(Ft.message||b("printers.toast.calibrationFailed"),"error")}catch(Ft){k(Ft instanceof Error?Ft.message:b("printers.toast.calibrationFailed"),"error")}finally{ge(!1)}},pn=async(bt,Ft)=>{try{await ae.updatePlateReferenceLabel(t.id,bt,Ft),Kt(null),fn()}catch(Kn){k(Kn instanceof Error?Kn.message:b("printers.toast.failedToUpdateLabel"),"error")}},Hr=async bt=>{try{await ae.deletePlateReference(t.id,bt),k(b("printers.toast.referenceDeleted"),"success"),fn();const Ft=await ae.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Ft)}catch(Ft){k(Ft instanceof Error?Ft.message:b("printers.toast.failedToDeleteReference"),"error")}},Vr=async()=>{if(_e){Ce(!0);try{await ae.updatePrinter(t.id,{plate_detection_roi:_e}),k(b("printers.toast.detectionAreaSaved"),"success"),Ee(null);const bt=await ae.checkPlateEmpty(t.id,{includeDebugImage:!0});te(bt)}catch(bt){k(bt instanceof Error?bt.message:b("printers.toast.failedToSaveDetectionArea"),"error")}finally{Ce(!1)}}};w.useEffect(()=>{const bt=Ft=>{Ft.key==="Escape"&&he&&Gt()};return window.addEventListener("keydown",bt),()=>window.removeEventListener("keydown",bt)},[he,Gt]);const Tn=w.useRef(null);w.useEffect(()=>{if(!be)return;const bt=xe?.ams_status_main??0;return bt!==0&&(ht.current=!0,Tn.current&&(clearTimeout(Tn.current),Tn.current=null)),ht.current&&bt===0&&(Ct.current?(rt.current&&clearTimeout(rt.current),at(null)):Tn.current||(Tn.current=setTimeout(()=>{rt.current&&clearTimeout(rt.current),at(null)},2e3))),()=>{Tn.current&&clearTimeout(Tn.current)}},[xe?.ams_status_main,be]);const[_n,$n]=w.useState(null);if(sr)return null;const mi=()=>{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"}},hr=()=>{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"}},wi=()=>{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 a.jsxs(_t,{className:"relative",children:[a.jsxs(Nt,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:wi(),children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("img",{src:n6e(t.model),alt:t.model||b("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${mi()}`}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-semibold text-white ${hr()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${xe?.connected?"bg-status-ok":"bg-status-error"}`,title:xe?.connected?b("printers.connection.connected"):b("printers.connection.offline")})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&xe?.nozzles&&xe.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:xe.nozzles[0].nozzle_type||"Nozzle",children:["• ",xe.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&a.jsxs("span",{className:"ml-2 text-bambu-gray",children:[a.jsx(qn,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),a.jsxs("div",{className:"relative flex-shrink-0",children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>A(!N),children:a.jsx(_h,{className:"w-4 h-4"})}),N&&a.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-20",children:[a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${E("printers:update")?"hover:bg-bambu-dark-tertiary":"opacity-50 cursor-not-allowed"}`,onClick:()=>{E("printers:update")&&(F(!0),A(!1))},title:E("printers:update")?void 0:b("printers.permission.noEdit"),children:[a.jsx($i,{className:"w-4 h-4"}),b("common.edit")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Fa.mutate(),A(!1)},children:[a.jsx(Ir,{className:"w-4 h-4"}),b("printers.reconnect")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{q(!0),A(!1)},children:[a.jsx(lK,{className:"w-4 h-4"}),b("printers.mqttDebug")]}),a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${E("printers:delete")?"text-red-400 hover:bg-bambu-dark-tertiary":"text-red-400/50 cursor-not-allowed"}`,onClick:()=>{E("printers:delete")&&(P(!0),A(!1))},title:E("printers:delete")?void 0:b("printers.permission.noDelete"),children:[a.jsx(en,{className:"w-4 h-4"}),b("common.delete")]})]})]})]}),r==="expanded"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${xe?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[xe?.connected?a.jsx(Db,{className:"w-3 h-3"}):a.jsx(Ik,{className:"w-3 h-3"}),xe?.connected?b("printers.connection.connected"):b("printers.connection.offline")]}),xe?.connected&&Ze!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Ze>=-50||Ze>=-60?"bg-status-ok/20 text-status-ok":Ze>=-70?"bg-status-warning/20 text-status-warning":Ze>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${Ze} dBm - ${b(r6e(Ze).labelKey)}`,children:[a.jsx(yfe,{className:"w-3 h-3"}),Ze,"dBm"]}),xe?.connected&&(()=>{const bt=xe.hms_errors?IMe(xe.hms_errors):[];return a.jsxs("button",{onClick:()=>W(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${bt.length>0?bt.some(Ft=>Ft.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:b("printers.clickToViewHmsErrors"),children:[a.jsx(kn,{className:"w-3 h-3"}),bt.length>0?bt.length:"OK"]})})(),n&&a.jsxs("button",{onClick:()=>S("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-status-error/20 text-status-error":n.warning_count>0?"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:b("printers.maintenanceUpToDate"),children:[a.jsx(Mm,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),tn>0&&a.jsxs("button",{onClick:()=>S("/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:b("printers.queue.inQueue",{count:tn}),children:[a.jsx(Ja,{className:"w-3 h-3"}),tn]}),ye?.current_version&&ye?.latest_version&&a.jsxs("button",{onClick:()=>le(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${ye.update_available?"bg-orange-500/20 text-orange-400":"bg-status-ok/20 text-status-ok"}`,title:ye.update_available?b("printers.firmwareUpdateAvailable",{current:ye.current_version,latest:ye.latest_version}):b("printers.firmwareUpToDate",{version:ye.current_version}),children:[ye.update_available?a.jsx(hi,{className:"w-3 h-3"}):a.jsx(mr,{className:"w-3 h-3"}),ye.current_version]})]})]}),M&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(_t,{className:"w-full max-w-md mx-4",children:a.jsxs(Nt,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:a.jsx(kn,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:b("printers.confirm.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:b("printers.confirm.deleteMessage",{name:t.name})})]})]}),a.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:T,onChange:bt=>j(bt.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"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:b("printers.deleteArchives")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:b(T?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{P(!1),j(!0)},children:b("common.cancel")}),a.jsx(Me,{variant:"danger",onClick:()=>{vi.mutate({deleteArchives:T}),P(!1),j(!0)},children:"Delete"})]})]})})}),xe?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:xe.state==="RUNNING"?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:a.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${xe.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(xe.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:i7(xe.state,xe.stg_cur_name)})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[a.jsxs("button",{onClick:()=>ce(!0),disabled:!(xe.state==="RUNNING"||xe.state==="PAUSE"||xe.state==="PAUSED")||(xe.printable_objects_count??0)<2||!E("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(xe.state==="RUNNING"||xe.state==="PAUSE"||xe.state==="PAUSED")&&(xe.printable_objects_count??0)>=2&&E("printers:control")?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:E("printers:control")?xe.state==="RUNNING"||xe.state==="PAUSE"||xe.state==="PAUSED"?(xe.printable_objects_count??0)>=2?b("printers.skipObjects.tooltip"):b("printers.skipObjects.requiresMultiple"):b("printers.skipObjects.onlyWhilePrinting"):b("printers.permission.noControl"),children:[a.jsx(Yk,{className:"w-4 h-4"}),Ge&&Ge.skipped_count>0&&a.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:Ge.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(i6e,{url:xe.state==="RUNNING"?xe.cover_url:null,printName:xe.state==="RUNNING"&&(xe.subtask_name||xe.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:xe.current_print&&xe.state==="RUNNING"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:xe.stg_cur_name||"Printing"}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:xe.subtask_name||xe.current_print}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${xe.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(xe.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[xe.remaining_time!=null&&xe.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),e6e(xe.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:b("printers.estimatedCompletion"),children:["ETA ",t6e(xe.remaining_time,p)]})]}),xe.layer_num!=null&&xe.total_layers!=null&&xe.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ja,{className:"w-3 h-3"}),xe.layer_num,"/",xe.total_layers]}),gr&&a.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${gr}`,children:[a.jsx(Zu,{className:"w-3 h-3"}),gr]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:b("printers.sort.status")}),a.jsx("p",{className:"text-white text-sm mb-2",children:i7(xe.state,xe.stg_cur_name)}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),a.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Xt?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Xt.print_name||Xt.filename,children:["Last: ",Xt.print_name||Xt.filename,Xt.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",eb(Xt.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:b("printers.readyToPrint")})]})})]})]}),a.jsx($Me,{printerId:t.id,printerState:xe.state})]}),xe.temperatures&&r==="expanded"&&(()=>{const bt=xe.temperatures.nozzle_heating||xe.temperatures.nozzle_2_heating||!1,Ft=xe.temperatures.bed_heating||!1,Kn=xe.temperatures.chamber_heating||!1,wt=t.nozzle_count===2||xe.temperatures.nozzle_2!==void 0,rr=xe.active_extruder===1?"L":"R",Yr=xe.nozzle_rack?.find(wa=>wa.id===1),ai=xe.nozzle_rack?.find(wa=>wa.id===0),_i=ai||Yr;return a.jsxs("div",{className:"flex items-stretch gap-1.5 flex-wrap",children:[a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center",children:[a.jsx(Ej,{className:"w-3.5 h-3.5 mb-0.5",color:"text-orange-400",isHeating:bt}),xe.temperatures.nozzle_2!==void 0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(xe.temperatures.nozzle||0),"° / ",Math.round(xe.temperatures.nozzle_2||0),"°"]})]}):_i?a.jsx(ete,{slot:_i,index:0,activeStatus:!0,filamentName:_i.filament_id?Ue?.[_i.filament_id]?.name:void 0,children:a.jsxs("div",{className:"cursor-default",children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(xe.temperatures.nozzle||0),"°C"]})]})}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(xe.temperatures.nozzle||0),"°C"]})]})]}),a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center",children:[a.jsx(Ej,{className:"w-3.5 h-3.5 mb-0.5",color:"text-blue-400",isHeating:Ft}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.bed")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(xe.temperatures.bed||0),"°C"]})]}),xe.temperatures.chamber!==void 0&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center",children:[a.jsx(Ej,{className:"w-3.5 h-3.5 mb-0.5",color:"text-green-400",isHeating:Kn}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.chamber")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(xe.temperatures.chamber||0),"°C"]})]}),wt&&a.jsx(W8e,{leftSlot:Yr,rightSlot:ai,activeNozzle:rr,children:a.jsxs("div",{className:"text-center px-3 py-1.5 bg-bambu-dark rounded-lg h-full flex flex-col justify-center items-center cursor-default",title:b("printers.activeNozzle",{nozzle:b(rr==="L"?"common.left":"common.right")}),children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("span",{className:`text-[11px] font-bold ${rr==="L"?"text-amber-400":"text-gray-500"}`,children:["L",Yr?.nozzle_diameter?` ${Yr.nozzle_diameter}`:""]}),a.jsx("span",{className:"text-[9px] text-bambu-gray/40",children:"·"}),a.jsxs("span",{className:`text-[11px] font-bold ${rr==="R"?"text-amber-400":"text-gray-500"}`,children:["R",ai?.nozzle_diameter?` ${ai.nozzle_diameter}`:""]})]}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.nozzle")})]})}),xe.nozzle_rack&&xe.nozzle_rack.some(wa=>wa.id>=2)&&a.jsx(K8e,{slots:xe.nozzle_rack,filamentInfo:Ue})]})})(),r==="expanded"&&(()=>{const bt=xe.state==="RUNNING",Ft=xe.state==="PAUSED"||xe.state==="PAUSE",Kn=bt||Ft,wt=pt.isPending||ot.isPending||Lt.isPending,rr=xe.cooling_fan_speed,Yr=xe.big_fan1_speed,ai=xe.big_fan2_speed;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:b("printers.controls")}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${rr&&rr>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:b("printers.fans.partCooling"),children:[a.jsx(JW,{className:`w-3.5 h-3.5 ${rr&&rr>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${rr&&rr>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[rr??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Yr&&Yr>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:b("printers.fans.auxiliary"),children:[a.jsx(cK,{className:`w-3.5 h-3.5 ${Yr&&Yr>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Yr&&Yr>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Yr??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${ai&&ai>0?"bg-green-500/10":"bg-bambu-dark"}`,title:b("printers.fans.chamber"),children:[a.jsx(Hce,{className:`w-3.5 h-3.5 ${ai&&ai>0?"text-green-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${ai&&ai>0?"text-green-400":"text-bambu-gray/50"}`,children:[ai??0,"%"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>J(!0),disabled:!Kn||wt||!E("printers:control"),className:`
  8152. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  8153. transition-colors
  8154. ${Kn&&E("printers:control")?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  8155. `,title:E("printers:control")?b("printers.stop"):b("printers.permission.noControl"),children:[a.jsx(pl,{className:"w-3 h-3"}),b("printers.stop")]}),a.jsxs("button",{onClick:()=>Ft?Le(!0):fe(!0),disabled:!Kn||wt||!E("printers:control"),className:`
  8156. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  8157. transition-colors
  8158. ${Kn&&E("printers:control")?Ft?"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"}
  8159. `,title:E("printers:control")?b(Ft?"printers.resume":"printers.pause"):b("printers.permission.noControl"),children:[Ft?a.jsx(jo,{className:"w-3 h-3"}):a.jsx(Dk,{className:"w-3 h-3"}),b(Ft?"printers.resume":"printers.pause")]})]})]})]})})(),Je&&Je.length>0&&r==="expanded"&&(()=>{const bt=Je.filter(wt=>wt.tray.length>1),Ft=Je.filter(wt=>wt.tray.length===1),Kn=t.nozzle_count===2||xe?.temperatures?.nozzle_2!==void 0;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:b("printers.filaments")}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"space-y-3",children:[bt.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:bt.map(wt=>{const rr=Oe[String(wt.id)],Yr=wt.id>=128?wt.id-128:wt.id,ai=rr!==void 0?rr:Yr,_i=ai===1,wa=ai===0;return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-[10px] text-white font-medium",children:Zd(wt.id,wt.tray.length)}),Kn&&(_i||wa)&&a.jsx(e7,{side:_i?"L":"R"})]}),(wt.humidity!=null||wt.temp!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[wt.humidity!=null&&a.jsx(n7,{humidity:wt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>re({amsId:wt.id,amsLabel:Zd(wt.id,wt.tray.length),mode:"humidity"}),compact:!0}),wt.temp!=null&&a.jsx(r7,{temp:wt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>re({amsId:wt.id,amsLabel:Zd(wt.id,wt.tray.length),mode:"temperature"}),compact:!0})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map($t=>{const bn=wt.tray[$t]||wt.tray.find(br=>br.id===$t),_a=bn?.tray_type&&bn.remain>=0,si=!bn?.tray_type,Qr=wt.id*4+$t,nc=an===Qr,Or=bn?.tray_info_idx?Ue?.[bn.tray_info_idx]:null,Nl=Pe?.[Qr],Oo=bn?.tray_uuid?.toUpperCase(),Sa=Oo?c?.[Oo]:void 0,kl=Tj(Sa),Ml=d?.(t.id,wt.id,$t),Ia=(()=>{const br=Ml?.spool;return br&&br.label_weight>0&&br.weight_used>0?Math.round(Math.max(0,br.label_weight-br.weight_used)/br.label_weight*100):null})(),Si=_a&&bn.remain>0?bn.remain:kl??Ia??(_a?bn.remain:null),rc=_a&&bn.remain===0&&(kl!==null||Ia!==null)?kl!==null?"spoolman":"inventory":"ams",Gr=bn?.tray_type?{vendor:jj(bn)?"Bambu Lab":"Generic",profile:Or?.name||Nl?.preset_name||bn.tray_sub_brands||bn.tray_type,colorName:kj(bn.tray_id_name)||Mj(bn.tray_color),colorHex:bn.tray_color||null,kFactor:Cj(bn.k),fillLevel:Si,trayUuid:bn.tray_uuid||null,tagUid:bn.tag_uid||null,fillSource:rc}:null,Ni=be?.amsId===wt.id&&be?.slotId===$t,so=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${si?"opacity-50":""} ${nc?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:bn?.tray_color?`#${bn.tray_color}`:bn?.tray_type?"#333":"transparent",borderColor:si?"#666":"rgba(255,255,255,0.1)",borderStyle:si?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:bn?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Si!==null&&Si>=0&&bn?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Si}%`,backgroundColor:Aj(Si)}}):bn?.tray_type?a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return a.jsxs("div",{className:"relative group",children:[Ni&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Ir,{className:"w-4 h-4 text-bambu-green animate-spin"})}),xe?.state!=="RUNNING"&&a.jsx("button",{onClick:br=>{br.stopPropagation(),$n(_n?.amsId===wt.id&&_n?.slotId===$t?null:{amsId:wt.id,slotId:$t})},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:b("printers.slotOptions"),children:a.jsx(_h,{className:"w-2.5 h-2.5 text-bambu-gray"})}),xe?.state!=="RUNNING"&&_n?.amsId===wt.id&&_n?.slotId===$t&&a.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:a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${E("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:br=>{br.stopPropagation(),E("printers:ams_rfid")&&(Vt.mutate({amsId:wt.id,slotId:$t}),$n(null))},disabled:Ni||!E("printers:ams_rfid"),title:E("printers:ams_rfid")?void 0:b("printers.permission.noAmsRfid"),children:[a.jsx(Ir,{className:`w-3 h-3 ${Ni?"animate-spin":""}`}),b("printers.rfid.reread")]})}),Gr?a.jsx(Nj,{data:Gr,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Gr.trayUuid?c?.[Gr.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&Gr.trayUuid?br=>{G({tagUid:Gr.tagUid||"",trayUuid:br,printerId:t.id,amsId:wt.id,trayId:$t})}:void 0},inventory:(()=>{const br=d?.(t.id,wt.id,$t);return{assignedSpool:br?.spool?{id:br.spool.id,material:br.spool.material,brand:br.spool.brand,color_name:br.spool.color_name}:null,onAssignSpool:Gr.vendor!=="Bambu Lab"?()=>ue({printerId:t.id,amsId:wt.id,trayId:$t,trayInfo:{type:Gr.profile,color:Gr.colorHex||"",location:`${Zd(wt.id,wt.tray.length)} Slot ${$t+1}`}}):void 0,onUnassignSpool:br&&Gr.vendor!=="Bambu Lab"?()=>h?.(t.id,wt.id,$t):void 0}})(),configureSlot:{enabled:E("printers:control"),onConfigure:()=>ee({amsId:wt.id,trayId:$t,trayCount:wt.tray.length,trayType:bn?.tray_type||void 0,trayColor:bn?.tray_color||void 0,traySubBrands:bn?.tray_sub_brands||void 0,trayInfoIdx:bn?.tray_info_idx||void 0})},children:so}):a.jsx(Yq,{configureSlot:{enabled:E("printers:control"),onConfigure:()=>ee({amsId:wt.id,trayId:$t,trayCount:wt.tray.length})},children:so})]},$t)})})]},wt.id)})}),(Ft.length>0||xe.vt_tray&&xe.vt_tray.tray_type)&&a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Ft.map(wt=>{const rr=Oe[String(wt.id)],Yr=wt.id>=128?wt.id-128:wt.id,ai=rr!==void 0?rr:Yr,_i=ai===1,wa=ai===0,$t=wt.tray[0],bn=$t?.tray_type&&$t.remain>=0,_a=!$t?.tray_type,si=wt.id*4+($t?.id??0),Qr=an===si,nc=$t?.tray_info_idx?Ue?.[$t.tray_info_idx]:null,Or=Pe?.[si],Nl=$t?.tray_uuid?.toUpperCase(),Oo=Nl?c?.[Nl]:void 0,Sa=Tj(Oo),kl=$t?.id??0,Ml=d?.(t.id,wt.id,kl),Ia=(()=>{const Xn=Ml?.spool;return Xn&&Xn.label_weight>0&&Xn.weight_used>0?Math.round(Math.max(0,Xn.label_weight-Xn.weight_used)/Xn.label_weight*100):null})(),Si=bn&&$t.remain>0?$t.remain:Sa??Ia??(bn?$t.remain:null),rc=bn&&$t.remain===0&&(Sa!==null||Ia!==null)?Sa!==null?"spoolman":"inventory":"ams",Gr=$t?.tray_type?{vendor:jj($t)?"Bambu Lab":"Generic",profile:nc?.name||Or?.preset_name||$t.tray_sub_brands||$t.tray_type,colorName:kj($t.tray_id_name)||Mj($t.tray_color),colorHex:$t.tray_color||null,kFactor:Cj($t.k),fillLevel:Si,trayUuid:$t.tray_uuid||null,tagUid:$t.tag_uid||null,fillSource:rc}:null,Ni=$t?.id??0,so=be?.amsId===wt.id&&be?.slotId===Ni,br=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${_a?"opacity-50":""} ${Qr?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:$t?.tray_color?`#${$t.tray_color}`:$t?.tray_type?"#333":"transparent",borderColor:_a?"#666":"rgba(255,255,255,0.1)",borderStyle:_a?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:$t?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Si!==null&&Si>=0?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Si}%`,backgroundColor:Aj(Si)}}):$t?.tray_type?a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("span",{className:"text-[10px] text-white font-medium",children:Zd(wt.id,wt.tray.length)}),Kn&&(_i||wa)&&a.jsx(e7,{side:_i?"L":"R"})]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsxs("div",{className:"relative group flex-1",children:[so&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Ir,{className:"w-4 h-4 text-bambu-green animate-spin"})}),xe?.state!=="RUNNING"&&a.jsx("button",{onClick:Xn=>{Xn.stopPropagation(),$n(_n?.amsId===wt.id&&_n?.slotId===Ni?null:{amsId:wt.id,slotId:Ni})},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:b("printers.slotOptions"),children:a.jsx(_h,{className:"w-2.5 h-2.5 text-bambu-gray"})}),xe?.state!=="RUNNING"&&_n?.amsId===wt.id&&_n?.slotId===Ni&&a.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:a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${E("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Xn=>{Xn.stopPropagation(),E("printers:ams_rfid")&&(Vt.mutate({amsId:wt.id,slotId:Ni}),$n(null))},disabled:so||!E("printers:ams_rfid"),title:E("printers:ams_rfid")?void 0:b("printers.permission.noAmsRfid"),children:[a.jsx(Ir,{className:`w-3 h-3 ${so?"animate-spin":""}`}),b("printers.rfid.reread")]})}),Gr?a.jsx(Nj,{data:Gr,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Gr.trayUuid?c?.[Gr.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&Gr.trayUuid?Xn=>{G({tagUid:Gr.tagUid||"",trayUuid:Xn,printerId:t.id,amsId:wt.id,trayId:Ni})}:void 0},inventory:(()=>{const Xn=d?.(t.id,wt.id,Ni);return{assignedSpool:Xn?.spool?{id:Xn.spool.id,material:Xn.spool.material,brand:Xn.spool.brand,color_name:Xn.spool.color_name}:null,onAssignSpool:Gr.vendor!=="Bambu Lab"?()=>ue({printerId:t.id,amsId:wt.id,trayId:Ni,trayInfo:{type:Gr.profile,color:Gr.colorHex||"",location:Zd(wt.id,wt.tray.length)}}):void 0,onUnassignSpool:Xn&&Gr.vendor!=="Bambu Lab"?()=>h?.(t.id,wt.id,Ni):void 0}})(),configureSlot:{enabled:E("printers:control"),onConfigure:()=>ee({amsId:wt.id,trayId:Ni,trayCount:wt.tray.length,trayType:$t?.tray_type||void 0,trayColor:$t?.tray_color||void 0,traySubBrands:$t?.tray_sub_brands||void 0,trayInfoIdx:$t?.tray_info_idx||void 0})},children:br}):a.jsx(Yq,{configureSlot:{enabled:E("printers:control"),onConfigure:()=>ee({amsId:wt.id,trayId:Ni,trayCount:wt.tray.length})},children:br})]}),(wt.humidity!=null||wt.temp!=null)&&a.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[wt.temp!=null&&a.jsx(r7,{temp:wt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>re({amsId:wt.id,amsLabel:Zd(wt.id,wt.tray.length),mode:"temperature"}),compact:!0}),wt.humidity!=null&&a.jsx(n7,{humidity:wt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>re({amsId:wt.id,amsLabel:Zd(wt.id,wt.tray.length),mode:"humidity"}),compact:!0})]})]})]},wt.id)}),xe.vt_tray&&xe.vt_tray.tray_type&&(()=>{const wt=xe.vt_tray,rr=an===254,Yr=wt.tray_info_idx?Ue?.[wt.tray_info_idx]:null,ai=Pe?.[1020],_i=wt.tray_uuid?.toUpperCase(),wa=_i?c?.[_i]:void 0,$t=Tj(wa),bn=d?.(t.id,255,0),_a=(()=>{const Or=bn?.spool;return Or&&Or.label_weight>0&&Or.weight_used>0?Math.round(Math.max(0,Or.label_weight-Or.weight_used)/Or.label_weight*100):null})(),si=$t??_a??null,Qr={vendor:jj(wt)?"Bambu Lab":"Generic",profile:Yr?.name||ai?.preset_name||wt.tray_sub_brands||wt.tray_type||"Unknown",colorName:kj(wt.tray_id_name)||Mj(wt.tray_color),colorHex:wt.tray_color||null,kFactor:Cj(wt.k),fillLevel:si,trayUuid:wt.tray_uuid||null,tagUid:wt.tag_uid||null,fillSource:$t!==null?"spoolman":_a!==null?"inventory":void 0},nc=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${rr?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:wt.tray_color?`#${wt.tray_color}`:"#333",borderColor:rr?"var(--accent)":"rgba(255,255,255,0.1)"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:wt.tray_type||"Spool"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:$t!==null?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${$t}%`,backgroundColor:Aj($t)}}):a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.jsx("span",{className:"text-[10px] text-white font-medium",children:b("printers.external")})}),a.jsx(Nj,{data:Qr,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Qr.trayUuid?c?.[Qr.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&Qr.trayUuid?Or=>{G({tagUid:Qr.tagUid||"",trayUuid:Or,printerId:t.id,amsId:255,trayId:0})}:void 0},inventory:(()=>{const Or=d?.(t.id,255,0);return{assignedSpool:Or?.spool?{id:Or.spool.id,material:Or.spool.material,brand:Or.spool.brand,color_name:Or.spool.color_name}:null,onAssignSpool:Qr.vendor!=="Bambu Lab"?()=>ue({printerId:t.id,amsId:255,trayId:0,trayInfo:{type:Qr.profile,color:Qr.colorHex||"",location:"External Spool"}}):void 0,onUnassignSpool:Or&&Qr.vendor!=="Bambu Lab"?()=>h?.(t.id,255,0):void 0}})(),configureSlot:{enabled:E("printers:control"),onConfigure:()=>ee({amsId:255,trayId:0,trayCount:1,trayType:wt.tray_type||void 0,trayColor:wt.tray_color||void 0,traySubBrands:wt.tray_sub_brands||void 0,trayInfoIdx:wt.tray_info_idx||void 0})},children:nc})]})})()]})]})]})})()]}),jt&&r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(Ih,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-sm text-white truncate",children:jt.name}),gt&&a.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${gt.state==="ON"?"bg-bambu-green/20 text-bambu-green":gt.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[gt.state||"?",gt.state==="ON"&&gt.energy?.power!=null&&a.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",gt.energy.power,"W"]})]})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("button",{onClick:()=>K(!0),disabled:De.isPending||gt?.state==="ON"||!E("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${E("smart_plugs:control")?gt?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}`,title:E("smart_plugs:control")?void 0:b("printers.permission.noSmartPlugControl"),children:[a.jsx(cd,{className:"w-3 h-3"}),"On"]}),a.jsxs("button",{onClick:()=>se(!0),disabled:De.isPending||gt?.state==="OFF"||!E("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${E("smart_plugs:control")?gt?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}`,title:E("smart_plugs:control")?void 0:b("printers.permission.noSmartPlugControl"),children:[a.jsx(Rk,{className:"w-3 h-3"}),"Off"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{className:`text-xs hidden sm:inline ${jt.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:jt.auto_off_executed?"Auto-off done":"Auto-off"}),a.jsx("button",{onClick:()=>nt.mutate(!jt.auto_off),disabled:nt.isPending||jt.auto_off_executed||!E("smart_plugs:control"),title:E("smart_plugs:control")?jt.auto_off_executed?b("printers.autoOffExecuted"):b("printers.autoOffAfterPrint"):b("printers.permission.noSmartPlugControl"),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${E("smart_plugs:control")?jt.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":jt.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary":"bg-bambu-dark-tertiary/50 cursor-not-allowed"}`,children:a.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${jt.auto_off||jt.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),Fe&&Fe.length>0&&a.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-bambu-dark-tertiary/50",children:[a.jsx(K0,{className:"w-3.5 h-3.5 text-blue-400 flex-shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"HA:"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Fe.map(bt=>a.jsxs("button",{onClick:()=>dt.mutate(bt.id),disabled:dt.isPending,title:`Run ${bt.ha_entity_id}`,className:"px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1",children:[a.jsx(jo,{className:"w-2.5 h-2.5"}),bt.name]},bt.id))})]})]}),r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[a.jsxs("div",{className:"text-xs text-bambu-gray",children:[a.jsx("p",{children:t.ip_address}),a.jsx("p",{className:"truncate",children:t.serial_number})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>me.mutate(!xe?.chamber_light),disabled:!xe?.connected||me.isPending||!E("printers:control"),title:E("printers:control")?xe?.chamber_light?b("printers.chamberLightOff"):b("printers.chamberLightOn"):b("printers.permission.noControl"),className:xe?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:a.jsx(H4,{on:xe?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{if(m==="embedded"&&x)x(t.id,t.name);else{const bt=localStorage.getItem("cameraWindowState"),Ft=bt?JSON.parse(bt):{width:640,height:400},Kn=[`width=${Ft.width}`,`height=${Ft.height}`,Ft.left!==void 0?`left=${Ft.left}`:"",Ft.top!==void 0?`top=${Ft.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Kn)}},disabled:!xe?.connected,title:b(m==="embedded"?"printers.openCameraOverlay":"printers.openCameraWindow"),children:a.jsx(d4,{className:"w-4 h-4"})}),a.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:Cn,disabled:!xe?.connected||ze.isPending||!E("printers:update"),title:E("printers:update")?t.plate_detection_enabled?b("printers.plateDetection.enabledClick"):b("printers.plateDetection.disabledClick"):b("printers.plateDetection.noPermission"),className:`!rounded-r-none !border-r-0 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:ze.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(f1,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:gn,disabled:!xe?.connected||U||!E("printers:update"),title:E("printers:update")?b("printers.plateDetection.manageCalibration"):b("printers.plateDetection.noPermission"),className:`!rounded-l-none !px-1.5 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:U?a.jsx(it,{className:"w-3 h-3 animate-spin"}):a.jsx(tr,{className:"w-3 h-3"})})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>D(!0),disabled:!E("printers:files"),title:E("printers:files")?b("printers.browseFiles"):b("printers.permission.noFiles"),children:[a.jsx(Pb,{className:"w-4 h-4"}),"Files"]})]})]})]}),$&&a.jsx(TMe,{printerId:t.id,printerName:t.name,onClose:()=>D(!1)}),H&&a.jsx(OMe,{printerId:t.id,printerName:t.name,onClose:()=>q(!1)}),he&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Gt(),children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:bt=>bt.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[he.needs_calibration?a.jsx(f1,{className:"w-5 h-5 text-blue-500"}):he.is_empty?a.jsx(mr,{className:"w-5 h-5 text-green-500"}):a.jsx(ua,{className:"w-5 h-5 text-yellow-500"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),he.reference_count!==void 0&&he.max_references&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[he.reference_count,"/",he.max_references," refs"]})]}),a.jsx("button",{onClick:()=>Gt(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[he.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[a.jsx("p",{className:"font-medium text-blue-400",children:b("printers.plateDetection.calibrationRequired")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",dangerouslySetInnerHTML:{__html:b("printers.plateDetection.calibrationInstructions")}})]}),a.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[a.jsx("p",{children:b("printers.plateDetection.calibrationDescription")}),a.jsx("p",{dangerouslySetInnerHTML:{__html:b("printers.plateDetection.calibrationTip")}})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`p-3 rounded-lg ${he.is_empty?"bg-green-500/20 border border-green-500/50":"bg-yellow-500/20 border border-yellow-500/50"}`,children:[a.jsx("p",{className:`font-medium ${he.is_empty?"text-green-400":"text-yellow-400"}`,children:he.is_empty?b("printers.plateDetection.plateEmpty"):b("printers.plateDetection.objectsDetected")}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:[b("printers.plateDetection.confidence"),": ",Math.round(he.confidence*100),"% | ",b("printers.plateDetection.difference"),": ",he.difference_percent.toFixed(1),"%"]})]}),he.debug_image_url&&a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:b("printers.plateDetection.analysisPreview")}),a.jsx("img",{src:he.debug_image_url,alt:b("printers.plateDetection.analysisPreview"),className:"w-full rounded-lg border border-bambu-dark-tertiary"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:b("printers.plateDetection.analysisLegend")})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:he.message})]}),Dt&&Dt.references.length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:b("printers.plateDetection.savedReferences",{count:Dt.references.length,max:Dt.max_references})}),a.jsx("div",{className:"grid grid-cols-5 gap-2",children:Dt.references.map(bt=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:ae.getPlateReferenceThumbnailUrl(t.id,bt.index),alt:bt.label||`Reference ${bt.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),a.jsx("button",{onClick:()=>Hr(bt.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:b("printers.plateDetection.deleteReference"),children:a.jsx(Rt,{className:"w-3 h-3 text-white"})}),Jt?.index===bt.index?a.jsx("input",{type:"text",value:Jt.label,onChange:Ft=>Kt({...Jt,label:Ft.target.value}),onBlur:()=>pn(bt.index,Jt.label),onKeyDown:Ft=>{Ft.key==="Enter"&&pn(bt.index,Jt.label),Ft.key==="Escape"&&Kt(null)},className:"w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white",autoFocus:!0,placeholder:b("printers.plateDetection.labelPlaceholder")}):a.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Kt({index:bt.index,label:bt.label}),title:bt.label?b("printers.plateDetection.clickToEdit",{label:bt.label}):b("printers.plateDetection.clickToAddLabel"),children:bt.label||a.jsx("span",{className:"italic opacity-50",children:b("printers.noLabel")})}),a.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:bt.timestamp?new Date(bt.timestamp).toLocaleDateString():""})]},bt.index))})]}),!he.needs_calibration&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:b("printers.roi.title")}),_e?a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>Ee(null),disabled:$e,children:b("common.cancel")}),a.jsx(Me,{size:"sm",onClick:Vr,disabled:$e,children:$e?a.jsx(it,{className:"w-3 h-3 animate-spin"}):b("common.save")})]}):a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>Ee(he.roi||{x:.15,y:.35,w:.7,h:.55}),children:[a.jsx($i,{className:"w-3 h-3 mr-1"}),b("common.edit")]})]}),_e?a.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:b("printers.roi.xStart")}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:_e.x,onChange:bt=>Ee({..._e,x:parseFloat(bt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(_e.x*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:b("printers.roi.yStart")}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:_e.y,onChange:bt=>Ee({..._e,y:parseFloat(bt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(_e.y*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:b("printers.width")}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:_e.w,onChange:bt=>Ee({..._e,w:parseFloat(bt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(_e.w*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:b("printers.height")}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:_e.h,onChange:bt=>Ee({..._e,h:parseFloat(bt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(_e.h*100),"%"]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:b("printers.roi.instruction")})]}):a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((he.roi?.x||.15)*100),"%, Y=",Math.round((he.roi?.y||.35)*100),"%, W=",Math.round((he.roi?.w||.7)*100),"%, H=",Math.round((he.roi?.h||.55)*100),"%"]})]})]}),a.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:he.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",onClick:()=>Gt(),children:b("common.cancel")}),a.jsx(Me,{onClick:()=>mn(),disabled:X,children:X?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",onClick:()=>mn(),disabled:X,children:X?"Adding...":`Add Reference (${Dt?.references.length||0}/${Dt?.max_references||5})`}),a.jsx(Me,{onClick:()=>Gt(),children:"Close"})]})})]})}),I&&jt&&a.jsx(On,{title:b("printers.confirm.powerOnTitle"),message:b("printers.confirm.powerOnMessage",{name:t.name}),confirmText:b("printers.confirm.powerOnButton"),variant:"default",onConfirm:()=>{De.mutate("on"),K(!1)},onCancel:()=>K(!1)}),Z&&jt&&a.jsx(On,{title:b("printers.confirm.powerOffTitle"),message:xe?.state==="RUNNING"?b("printers.confirm.powerOffWarning",{name:t.name}):b("printers.confirm.powerOffMessage",{name:t.name}),confirmText:b("printers.confirm.powerOffButton"),variant:"danger",onConfirm:()=>{De.mutate("off"),se(!1)},onCancel:()=>se(!1)}),ie&&a.jsx(On,{title:b("printers.confirm.stopTitle"),message:b("printers.confirm.stopMessage",{name:t.name}),confirmText:b("printers.confirm.stopButton"),variant:"danger",onConfirm:()=>{pt.mutate(),J(!1)},onCancel:()=>J(!1)}),pe&&a.jsx(On,{title:b("printers.confirm.pauseTitle"),message:b("printers.confirm.pauseMessage",{name:t.name}),confirmText:b("printers.confirm.pauseButton"),variant:"default",onConfirm:()=>{ot.mutate(),fe(!1)},onCancel:()=>fe(!1)}),ve&&a.jsx(On,{title:b("printers.confirm.resumeTitle"),message:b("printers.confirm.resumeMessage",{name:t.name}),confirmText:b("printers.confirm.resumeButton"),variant:"default",onConfirm:()=>{Lt.mutate(),Le(!1)},onCancel:()=>Le(!1)}),a.jsx(V4,{printerId:t.id,isOpen:de,onClose:()=>ce(!1)}),V&&a.jsx(UMe,{printerName:t.name,errors:xe?.hms_errors||[],onClose:()=>W(!1)}),Ae&&a.jsx(R8e,{isOpen:!!Ae,onClose:()=>re(null),printerId:t.id,printerName:t.name,amsId:Ae.amsId,amsLabel:Ae.amsLabel,initialMode:Ae.mode,thresholds:s}),Ie&&a.jsx(L8e,{isOpen:!!Ie,onClose:()=>G(null),tagUid:Ie.tagUid,trayUuid:Ie.trayUuid,printerId:Ie.printerId,amsId:Ie.amsId,trayId:Ie.trayId}),Y&&a.jsx(O8e,{isOpen:!!Y,onClose:()=>ue(null),printerId:Y.printerId,amsId:Y.amsId,trayId:Y.trayId,trayInfo:Y.trayInfo}),B&&a.jsx(V8e,{isOpen:!!B,onClose:()=>ee(null),printerId:t.id,slotInfo:B,onSuccess:()=>{v.invalidateQueries({queryKey:["slotPresets",t.id]}),v.invalidateQueries({queryKey:["printerStatus",t.id]})}}),z&&a.jsx(l6e,{printer:t,onClose:()=>F(!1)}),Q&&ye&&a.jsx(o6e,{printer:t,firmwareInfo:ye,onClose:()=>le(!1)}),_n&&a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>$n(null)})]})}function s6e({onClose:t,onAdd:e,existingSerials:n}){const{t:r}=Ut(),[i,s]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",location:"",auto_archive:!0}),[o,l]=w.useState(!1),[c,u]=w.useState([]),[d,h]=w.useState(""),[p,m]=w.useState(!1),[x,y]=w.useState(!1),[b,v]=w.useState([]),[S,k]=w.useState(""),[E,N]=w.useState({scanned:0,total:0});w.useEffect(()=>{cc.getInfo().then(j=>{y(j.is_docker),j.subnets.length>0&&(v(j.subnets),k(j.subnets[0]))}).catch(()=>{})},[]);const A=c.filter(j=>!n.includes(j.serial)),M=async()=>{h(""),u([]),l(!0),m(!1),N({scanned:0,total:0});try{if(x){await cc.startSubnetScan(S);const j=setInterval(async()=>{try{const z=await cc.getScanStatus();N({scanned:z.scanned,total:z.total});const F=await cc.getDiscoveredPrinters();u(F),z.running||(clearInterval(j),l(!1),m(!0))}catch(z){console.error("Failed to get scan status:",z)}},500)}else{await cc.startDiscovery(10);const j=setInterval(async()=>{try{const z=await cc.getDiscoveredPrinters();u(z)}catch(z){console.error("Failed to get discovered printers:",z)}},1e3);setTimeout(async()=>{clearInterval(j);try{await cc.stopDiscovery()}catch{}l(!1),m(!0);try{const z=await cc.getDiscoveredPrinters();u(z)}catch(z){console.error("Failed to get final discovered printers:",z)}},1e4)}}catch(j){console.error("Failed to start discovery:",j),h(j instanceof Error?j.message:r("printers.discovery.failedToStart")),l(!1),m(!0)}},P=j=>j?{O1D:"H2D",O1E:"H2D Pro",O2D:"H2D Pro",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","H2D Pro":"H2D Pro",H2C:"H2C",H2S:"H2S"}[j]||j:"",T=j=>{const z=j.serial.startsWith("unknown-")?"":j.serial;s({...i,name:j.name||"",serial_number:z,ip_address:j.ip_address,model:P(j.model)}),u([])};return w.useEffect(()=>()=>{cc.stopDiscovery().catch(()=>{}),cc.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const j=z=>{z.key==="Escape"&&t()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:a.jsx(_t,{className:"w-full max-w-md",onClick:j=>j.stopPropagation(),children:a.jsxs(Nt,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:r("printers.addPrinter")}),a.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[x&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.discovery.subnetToScan")}),b.length>0?a.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 text-sm",value:S,onChange:j=>k(j.target.value),disabled:o,children:b.map(j=>a.jsx("option",{value:j,children:j},j))}):a.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:S,onChange:j=>k(j.target.value),placeholder:"192.168.1.0/24",disabled:o}),a.jsx("p",{className:"mt-1 text-xs text-bambu-gray",children:r("printers.discovery.dockerNote")})]}),a.jsx(Me,{type:"button",variant:"secondary",onClick:M,disabled:o,className:"w-full",children:o?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),x&&E.total>0?r("printers.discovery.scanProgress",{scanned:E.scanned,total:E.total}):r("printers.discovery.scanning")]}):a.jsxs(a.Fragment,{children:[a.jsx(zr,{className:"w-4 h-4"}),r(x?"printers.discovery.scanSubnet":"printers.discovery.discoverNetwork")]})}),d&&a.jsx("div",{className:"mt-2 text-sm text-red-400",children:d}),A.length>0&&a.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:A.map(j=>a.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:()=>T(j),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-white text-sm truncate",children:j.name||j.serial}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[P(j.model)||r("printers.discovery.unknown")," • ",j.ip_address,j.serial.startsWith("unknown-")&&a.jsxs("span",{className:"text-yellow-500",children:[" • ",r("printers.discovery.serialRequired")]})]})]}),a.jsx(tr,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},j.serial))}),o&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.scanningSubnet":"printers.discovery.scanningNetwork")}),p&&!o&&c.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.noPrintersFoundSubnet":"printers.discovery.noPrintersFoundNetwork")}),p&&!o&&c.length>0&&A.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r("printers.discovery.allConfigured")})]}),a.jsxs("form",{onSubmit:j=>{j.preventDefault(),e(i)},className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.name")}),a.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:i.name,onChange:j=>s({...i,name:j.target.value}),placeholder:r("printers.modal.myPrinter")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.ipAddress")}),a.jsx("input",{type:"text",required:!0,pattern:"(\\d{1,3}(\\.\\d{1,3}){3}|[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*)",className:"w-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.ip_address,onChange:j=>s({...i,ip_address:j.target.value}),placeholder:"192.168.1.100 or printer.local"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.serialNumber")}),a.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:i.serial_number,onChange:j=>s({...i,serial_number:j.target.value}),placeholder:"01P00A000000000"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.accessCode")}),a.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:i.access_code,onChange:j=>s({...i,access_code:j.target.value}),placeholder:r("printers.modal.fromPrinterSettings")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.modelOptional")}),a.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:i.model||"",onChange:j=>s({...i,model:j.target.value}),children:[a.jsx("option",{value:"",children:r("printers.modal.selectModel")}),a.jsxs("optgroup",{label:"H2 Series",children:[a.jsx("option",{value:"H2C",children:"H2C"}),a.jsx("option",{value:"H2D",children:"H2D"}),a.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),a.jsx("option",{value:"H2S",children:"H2S"})]}),a.jsxs("optgroup",{label:"X1 Series",children:[a.jsx("option",{value:"X1E",children:"X1E"}),a.jsx("option",{value:"X1C",children:"X1 Carbon"}),a.jsx("option",{value:"X1",children:"X1"})]}),a.jsxs("optgroup",{label:"P Series",children:[a.jsx("option",{value:"P2S",children:"P2S"}),a.jsx("option",{value:"P1S",children:"P1S"}),a.jsx("option",{value:"P1P",children:"P1P"})]}),a.jsxs("optgroup",{label:"A1 Series",children:[a.jsx("option",{value:"A1",children:"A1"}),a.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.locationGroup")}),a.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:i.location||"",onChange:j=>s({...i,location:j.target.value}),placeholder:r("printers.modal.locationPlaceholder")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("printers.locationHelp")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"auto_archive",checked:i.auto_archive,onChange:j=>s({...i,auto_archive:j.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:r("printers.modal.autoArchiveLabel")})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsx(Me,{type:"submit",className:"flex-1",children:r("printers.addPrinter")})]})]})]})})})}function o6e({printer:t,firmwareInfo:e,onClose:n}){const{t:r}=Ut(),i=Zt(),{showToast:s}=hn(),{hasPermission:o}=Rr(),l=o("firmware:update"),[c,u]=w.useState(null),[d,h]=w.useState(!1),[p,m]=w.useState(null),{data:x,isLoading:y}=et({queryKey:["firmwarePrepare",t.id],queryFn:()=>RS.prepareUpload(t.id),staleTime:3e4,enabled:e.update_available&&l}),b=st({mutationFn:()=>RS.startUpload(t.id),onSuccess:()=>{h(!0);const S=setInterval(async()=>{try{const k=await RS.getUploadStatus(t.id);u(k),(k.status==="complete"||k.status==="error")&&(clearInterval(S),m(null),h(!1),k.status==="complete"&&(s(r("printers.firmwareModal.uploadedToast"),"success"),i.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);m(S)},onError:S=>{s(r("printers.firmwareModal.uploadFailed",{error:S.message}),"error"),h(!1)}});w.useEffect(()=>()=>{p&&clearInterval(p)},[p]);const v=()=>{u(null),b.mutate()};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(_t,{className:"w-full max-w-md mx-4",children:a.jsxs(Nt,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:`p-2 rounded-full ${e.update_available?"bg-orange-500/20":"bg-status-ok/20"}`,children:e.update_available?a.jsx(hi,{className:"w-5 h-5 text-orange-400"}):a.jsx(mr,{className:"w-5 h-5 text-status-ok"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:e.update_available?r("printers.firmwareModal.title"):r("printers.firmwareModal.titleUpToDate")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[a.jsxs("div",{className:"flex justify-between items-center text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.currentVersion")}),a.jsx("span",{className:`font-mono ${e.update_available?"text-white":"text-status-ok"}`,children:e.current_version||r("common.unknown")})]}),e.update_available&&a.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[a.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.latestVersion")}),a.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&a.jsxs("details",{className:"mt-3 text-sm",open:!e.update_available,children:[a.jsx("summary",{className:`cursor-pointer hover:underline ${e.update_available?"text-orange-400":"text-status-ok"}`,children:r("printers.firmwareModal.releaseNotes")}),a.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),e.update_available?y?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),r("printers.firmwareModal.checkingPrereqs")]}):x&&!d&&!c?a.jsx("div",{className:"mb-4",children:x.can_proceed?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[a.jsx(Yi,{className:"w-4 h-4"}),r("printers.firmwareModal.sdCardReady")]}):a.jsx("div",{className:"space-y-1",children:x.errors.map((S,k)=>a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Ui,{className:"w-4 h-4 flex-shrink-0"}),S]},k))})}):null:null,(d||c)&&c&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray capitalize",children:c.status}),a.jsxs("span",{className:"text-white",children:[c.progress,"%"]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:`h-2 rounded-full transition-all ${c.status==="error"?"bg-status-error":c.status==="complete"?"bg-status-ok":"bg-orange-500"} ${c.status==="uploading"?"animate-pulse":""}`,style:{width:`${c.progress}%`}})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:c.message}),c.error&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:c.error})]}),c?.status==="complete"&&a.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:r("printers.firmwareModal.uploadedSuccess")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("printers.firmwareModal.applyInstructions")}),a.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step1")}}),a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step2")}}),a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step3")}}),a.jsx("li",{children:r("printers.firmwareModal.step4")})]})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Me,{variant:"secondary",onClick:n,children:c?.status==="complete"?r("printers.firmwareModal.done"):r("common.cancel")}),x?.can_proceed&&!d&&c?.status!=="complete"&&l&&a.jsx(Me,{onClick:v,disabled:b.isPending,children:b.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}),r("printers.firmwareModal.starting")]}):a.jsxs(a.Fragment,{children:[a.jsx(hi,{className:"w-4 h-4 mr-2"}),r("printers.firmwareModal.uploadFirmware")]})})]})]})})})}function l6e({printer:t,onClose:e}){const{t:n}=Ut(),r=Zt(),{showToast:i}=hn(),[s,o]=w.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),l=st({mutationFn:u=>ae.updatePrinter(t.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["printers"]}),r.invalidateQueries({queryKey:["printerStatus",t.id]}),e()},onError:u=>i(u.message||n("printers.toast.failedToUpdate"),"error")});w.useEffect(()=>{const u=d=>{d.key==="Escape"&&e()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e]);const c=u=>{u.preventDefault();const d={name:s.name,ip_address:s.ip_address,model:s.model||void 0,location:s.location||void 0,auto_archive:s.auto_archive};s.access_code&&(d.access_code=s.access_code),l.mutate(d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsx(_t,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:a.jsxs(Nt,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:n("printers.editPrinter")}),a.jsxs("form",{onSubmit:c,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.name")}),a.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:s.name,onChange:u=>o({...s,name:u.target.value}),placeholder:n("printers.modal.myPrinter")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.ipAddress")}),a.jsx("input",{type:"text",required:!0,pattern:"(\\d{1,3}(\\.\\d{1,3}){3}|[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*)",className:"w-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:s.ip_address,onChange:u=>o({...s,ip_address:u.target.value}),placeholder:"192.168.1.100 or printer.local"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.serialNumber")}),a.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}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.serialCannotBeChanged")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.accessCode")}),a.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:s.access_code,onChange:u=>o({...s,access_code:u.target.value}),placeholder:n("printers.accessCodePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.model")}),a.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:s.model,onChange:u=>o({...s,model:u.target.value}),children:[a.jsx("option",{value:"",children:n("printers.modal.selectModel")}),a.jsxs("optgroup",{label:"H2 Series",children:[a.jsx("option",{value:"H2C",children:"H2C"}),a.jsx("option",{value:"H2D",children:"H2D"}),a.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),a.jsx("option",{value:"H2S",children:"H2S"})]}),a.jsxs("optgroup",{label:"X1 Series",children:[a.jsx("option",{value:"X1E",children:"X1E"}),a.jsx("option",{value:"X1C",children:"X1 Carbon"}),a.jsx("option",{value:"X1",children:"X1"})]}),a.jsxs("optgroup",{label:"P Series",children:[a.jsx("option",{value:"P2S",children:"P2S"}),a.jsx("option",{value:"P1S",children:"P1S"}),a.jsx("option",{value:"P1P",children:"P1P"})]}),a.jsxs("optgroup",{label:"A1 Series",children:[a.jsx("option",{value:"A1",children:"A1"}),a.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),a.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:s.location,onChange:u=>o({...s,location:u.target.value}),placeholder:n("printers.modal.locationPlaceholder")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.locationHelp")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:s.auto_archive,onChange:u=>o({...s,auto_archive:u.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:n("printers.modal.autoArchiveLabel")})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("common.cancel")}),a.jsx(Me,{type:"submit",className:"flex-1",disabled:l.isPending,children:l.isPending?n("common.saving"):n("printers.modal.saveChanges")})]})]})]})})})}function c6e(t){const{data:e}=et({queryKey:["printerStatus",t],queryFn:()=>ae.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function u6e({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=c6e(t.id),{data:s}=et({queryKey:["smartPlugStatus",e.id],queryFn:()=>ae.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${s.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:s.state||"?"})]}),a.jsxs("button",{onClick:()=>n(e.id),disabled:r||s?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${s?.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:[a.jsx(cd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function d6e(){const{t}=Ut(),[e,n]=w.useState(!1),[r,i]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[s,o]=w.useState(!1),[l,c]=w.useState(null),[u,d]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[h,p]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,x]=w.useState(()=>{const ce=localStorage.getItem("printerCardSize");return ce?parseInt(ce,10):2}),y=m===1?"compact":"expanded",b=Zt(),{showToast:v}=hn(),{hasPermission:S}=Rr(),[k,E]=w.useState(()=>{const ce=localStorage.getItem("openEmbeddedCameras");if(ce)try{const Ae=JSON.parse(ce);return new Map(Ae.map(re=>[re.id,re]))}catch{return new Map}return new Map});w.useEffect(()=>{const ce=Array.from(k.values());ce.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(ce)):localStorage.removeItem("openEmbeddedCameras")},[k]);const{data:N,isLoading:A}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:M}=et({queryKey:["settings"],queryFn:ae.getSettings});w.useEffect(()=>{M?.camera_view_mode==="window"&&k.size>0&&E(new Map)},[M?.camera_view_mode,k.size]);const{data:P}=et({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs}),{data:T}=et({queryKey:["maintenanceOverview"],queryFn:ae.getMaintenanceOverview,staleTime:60*1e3}),{data:j}=et({queryKey:["spoolman-status"],queryFn:ae.getSpoolmanStatus,staleTime:60*1e3}),z=j?.enabled&&j?.connected,{data:F}=et({queryKey:["unlinked-spools"],queryFn:ae.getUnlinkedSpools,enabled:!!z,staleTime:30*1e3}),$=F&&F.length>0,{data:D}=et({queryKey:["linked-spools"],queryFn:ae.getLinkedSpools,enabled:!!z,staleTime:30*1e3}),H=D?.linked,{data:q}=et({queryKey:["spool-assignments"],queryFn:()=>ae.getAssignments(),staleTime:30*1e3}),I=st({mutationFn:({printerId:ce,amsId:Ae,trayId:re})=>ae.unassignSpool(ce,Ae,re),onSuccess:()=>{b.invalidateQueries({queryKey:["spool-assignments"]})}}),K=(ce,Ae,re)=>q?.find(Ie=>Ie.printer_id===ce&&Ie.ams_id===Number(Ae)&&Ie.tray_id===Number(re)),Z=T?.reduce((ce,Ae)=>(ce[Ae.printer_id]={due_count:Ae.due_count,warning_count:Ae.warning_count,total_print_hours:Ae.total_print_hours},ce),{})||{},se=P?.reduce((ce,Ae)=>(Ae.printer_id&&(ce[Ae.printer_id]=Ae),ce),{})||{},V=st({mutationFn:ae.createPrinter,onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),b.invalidateQueries({queryKey:["maintenanceOverview"]}),n(!1)},onError:ce=>v(ce.message||t("printers.toast.failedToAdd"),"error")}),W=st({mutationFn:ce=>ae.controlSmartPlug(ce,"on"),onSuccess:()=>{b.invalidateQueries({queryKey:["smart-plugs"]}),c(null)},onError:()=>{c(null)}}),ie=()=>{const ce=!r;i(ce),localStorage.setItem("hideDisconnectedPrinters",String(ce))},J=ce=>{d(ce),localStorage.setItem("printerSortBy",ce)},pe=()=>{const ce=!h;p(ce),localStorage.setItem("printerSortAsc",String(ce))},fe=()=>{switch(m){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},ve=["S","M","L","XL"],Le=w.useMemo(()=>{if(!N)return[];const ce=[...N];switch(u){case"name":ce.sort((Ae,re)=>Ae.name.localeCompare(re.name));break;case"model":ce.sort((Ae,re)=>(Ae.model||"").localeCompare(re.model||""));break;case"location":ce.sort((Ae,re)=>{const Ie=Ae.location||"",G=re.location||"";return!Ie&&G?1:Ie&&!G?-1:Ie.localeCompare(G)||Ae.name.localeCompare(re.name)});break;case"status":ce.sort((Ae,re)=>{const Ie=b.getQueryData(["printerStatus",Ae.id]),G=b.getQueryData(["printerStatus",re.id]),Y=ue=>ue?.connected?ue.state==="RUNNING"?0:1:2;return Y(Ie)-Y(G)});break}return h||ce.reverse(),ce},[N,u,h,b]),de=w.useMemo(()=>{if(u!=="location")return null;const ce={};return Le.forEach(Ae=>{const re=Ae.location||"Ungrouped";ce[re]||(ce[re]=[]),ce[re].push(Ae)}),ce},[u,Le]);return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("printers.title")}),a.jsx(a6e,{printers:N})]}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("select",{value:u,onChange:ce=>J(ce.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:[a.jsx("option",{value:"name",children:t("printers.sort.name")}),a.jsx("option",{value:"status",children:t("printers.sort.status")}),a.jsx("option",{value:"model",children:t("printers.sort.model")}),a.jsx("option",{value:"location",children:t("printers.sort.location")})]}),a.jsx("button",{onClick:pe,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t(h?"printers.sort.descending":"printers.sort.ascending"),children:h?a.jsx(_m,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Yg,{className:"w-4 h-4 text-bambu-gray"})})]}),a.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:ve.map((ce,Ae)=>{const re=Ae+1,Ie=m===re;return a.jsx("button",{onClick:()=>{x(re),localStorage.setItem("printerCardSize",String(re))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${Ae===0?"rounded-l-lg":""} ${Ae===ve.length-1?"rounded-r-lg":""} ${Ie?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:t(ce==="S"?"printers.cardSize.small":ce==="M"?"printers.cardSize.medium":ce==="L"?"printers.cardSize.large":"printers.cardSize.extraLarge"),children:ce},ce)})}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:r,onChange:ie,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),t("printers.hideOffline")]}),r&&Object.keys(se).length>0&&a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>o(!s),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:[a.jsx(cd,{className:"w-4 h-4"}),t("printers.powerOn"),a.jsx(tr,{className:`w-3 h-3 transition-transform ${s?"rotate-180":""}`})]}),s&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>o(!1)}),a.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:[a.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:t("printers.offlinePrintersWithPlugs")}),N?.filter(ce=>se[ce.id]).map(ce=>a.jsx(u6e,{printer:ce,plug:se[ce.id],onPowerOn:Ae=>{c(Ae),W.mutate(Ae)},isPowering:l===se[ce.id]?.id},ce.id)),N?.filter(ce=>se[ce.id]).length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),a.jsxs(Me,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(nr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})]}),A?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):N?.length===0?a.jsx(_t,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("printers.noPrintersConfigured")}),a.jsxs(Me,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(nr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})}):de?a.jsx("div",{className:"space-y-6",children:Object.entries(de).map(([ce,Ae])=>a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),ce,a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Ae.length,")"]})]}),a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${fe()}`,children:Ae.map(re=>a.jsx(a7,{printer:re,hideIfDisconnected:r,maintenanceInfo:Z[re.id],viewMode:y,cardSize:m,amsThresholds:M?{humidityGood:Number(M.ams_humidity_good)||40,humidityFair:Number(M.ams_humidity_fair)||60,tempGood:Number(M.ams_temp_good)||28,tempFair:Number(M.ams_temp_fair)||35}:void 0,spoolmanEnabled:z,hasUnlinkedSpools:$,linkedSpools:H,spoolmanUrl:j?.url,onGetAssignment:K,onUnassignSpool:(Ie,G,Y)=>I.mutate({printerId:Ie,amsId:G,trayId:Y}),timeFormat:M?.time_format||"system",cameraViewMode:M?.camera_view_mode||"window",onOpenEmbeddedCamera:(Ie,G)=>E(Y=>new Map(Y).set(Ie,{id:Ie,name:G})),checkPrinterFirmware:M?.check_printer_firmware!==!1},re.id))})]},ce))}):a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${fe()}`,children:Le.map(ce=>a.jsx(a7,{printer:ce,hideIfDisconnected:r,maintenanceInfo:Z[ce.id],viewMode:y,cardSize:m,spoolmanEnabled:z,hasUnlinkedSpools:$,linkedSpools:H,spoolmanUrl:j?.url,onGetAssignment:K,onUnassignSpool:(Ae,re,Ie)=>I.mutate({printerId:Ae,amsId:re,trayId:Ie}),amsThresholds:M?{humidityGood:Number(M.ams_humidity_good)||40,humidityFair:Number(M.ams_humidity_fair)||60,tempGood:Number(M.ams_temp_good)||28,tempFair:Number(M.ams_temp_fair)||35}:void 0,timeFormat:M?.time_format||"system",cameraViewMode:M?.camera_view_mode||"window",onOpenEmbeddedCamera:(Ae,re)=>E(Ie=>new Map(Ie).set(Ae,{id:Ae,name:re})),checkPrinterFirmware:M?.check_printer_firmware!==!1},ce.id))}),e&&a.jsx(s6e,{onClose:()=>n(!1),onAdd:ce=>V.mutate(ce),existingSerials:N?.map(ce=>ce.serial_number)||[]}),Array.from(k.values()).map((ce,Ae)=>a.jsx(LMe,{printerId:ce.id,printerName:ce.name,viewerIndex:Ae,onClose:()=>E(re=>{const Ie=new Map(re);return Ie.delete(ce.id),Ie})},ce.id))]})}function h6e(){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 vc(t,e="bambu_studio"){let n;e==="orcaslicer"?n=`orcaslicer://open?file=${t}`:n=`${h6e()==="windows"?"bambustudio":"bambustudioopen"}://${encodeURIComponent(t)}`;const r=document.createElement("a");r.href=n,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}function WO({archiveId:t,libraryFileId:e,title:n,fileType:r,onClose:i}){const{t:s}=Ut(),{data:o}=et({queryKey:["settings"],queryFn:ae.getSettings}),l=o?.preferred_slicer||"bambu_studio",c=e!=null,[u,d]=w.useState(null),[h,p]=w.useState(null),[m,x]=w.useState(!0),[y,b]=w.useState(null),[v,S]=w.useState(!1),[k,E]=w.useState(null),[N,A]=w.useState(0),[M,P]=w.useState(!1),[T,j]=w.useState(null),[z,F]=w.useState(!1),[$,D]=w.useState(!1),H=w.useRef(null),q=w.useRef(null),I=10,K=160,Z=240,se=.35;w.useEffect(()=>{const he=te=>{te.key==="Escape"&&i()};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[i]),w.useEffect(()=>{if(x(!0),c){const he=(r||"").toLowerCase(),te=he==="3mf"||he==="stl",U=he==="gcode"||he==="3mf";p({has_model:te,has_gcode:U,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d(te?"3d":U?"gcode":null),x(!1);return}if(!t){p(null),d(null),x(!1);return}ae.getArchiveCapabilities(t).then(he=>{p(he),he.has_model?d("3d"):he.has_gcode&&d("gcode"),x(!1)}).catch(()=>{p({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d("3d"),x(!1)})},[t,r,c]),w.useEffect(()=>{if(S(!0),E(null),A(0),c){const he=(r||"").toLowerCase();if(!e||he!=="3mf"){b(null),S(!1);return}ae.getLibraryFilePlates(e).then(te=>b(te)).catch(()=>b(null)).finally(()=>S(!1));return}if(!t){b(null),S(!1);return}ae.getArchivePlates(t).then(he=>b(he)).catch(()=>b(null)).finally(()=>S(!1))},[t,r,c,e]);const V=w.useMemo(()=>y?.plates??[],[y]),W=(y?.is_multi_plate??!1)&&V.length>1,ie=M&&W,J=k==null?null:V.find(he=>he.index===k)??null,pe=he=>he.object_count??he.objects?.length??0,fe=V.reduce((he,te)=>he+pe(te),0),ve=J?pe(J):fe,Le=J?s("modelViewer.plateNumber",{number:J.index}):s("modelViewer.allPlates"),de=V.length>0,ce=w.useRef(null),Ae=w.useRef(null),[re,Ie]=w.useState(10),[G,Y]=w.useState(3),ue=V.length>re,B=Math.max(1,Math.ceil(V.length/re)),ee=ue?V.slice(N*re,(N+1)*re):V;w.useEffect(()=>{if(!ie){Ie(10),Y(3);return}const he=ce.current,te=Ae.current;if(!he||!te)return;let U=0;const L=()=>{const _e=te.clientWidth,$e=Math.floor(_e/210),Ce=Math.max(3,Math.min(5,$e||3));Y(ke=>ke===Ce?ke:Ce);const He=window.getComputedStyle(he),Qe=Number.parseFloat(He.rowGap||"0"),ye=he.querySelector("button")?.getBoundingClientRect().height??44,we=te.clientHeight,Pe=Math.max(1,Math.floor((we+Qe)/(ye+Qe)))*Ce,Ve=Math.max(1,Pe-1);Ie(ke=>ke===Ve?ke:Ve)},X=()=>{U&&cancelAnimationFrame(U),U=requestAnimationFrame(L)};X();const ge=new ResizeObserver(X);return ge.observe(te),ge.observe(he),()=>{U&&cancelAnimationFrame(U),ge.disconnect()}},[ie,V.length]),w.useEffect(()=>{if(!ue){A(0);return}A(he=>Math.min(he,B-1))},[V.length,ue,B]),w.useEffect(()=>{if(!ue||k==null)return;const he=V.findIndex(U=>U.index===k);if(he<0)return;const te=Math.floor(he/re);A(U=>U===te?U:te)},[V,re,k,ue]),w.useEffect(()=>{if(!ie){j(null),D(!1);return}if($)return;const he=H.current,te=q.current;if(!he||!te)return;const U=he.clientHeight;if(!U)return;const L=Math.max(Z,U*se),X=Math.max(K,U-I-L),ge=Math.min(te.scrollHeight,X);j(Math.max(K,ge))},[ie,$,V.length,N,I,K,Z,se]),w.useEffect(()=>{if(!z)return;const he=U=>{const L=H.current;if(!L)return;const X=L.getBoundingClientRect(),ge=X.height;if(!ge)return;const _e=Math.max(Z,ge*se),Ee=Math.max(K,ge-I-_e),$e=Math.min(Ee,Math.max(K,U.clientY-X.top));j($e)},te=()=>{F(!1),D(!0)};return document.addEventListener("mousemove",he),document.addEventListener("mouseup",te),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",te),document.body.style.cursor="",document.body.style.userSelect=""}},[z,I,K,Z,se]);const Q=c?(r||"").toLowerCase()==="3mf":!0,le=()=>{if(!Q)return;const he=n||"model";if(c){const U=`${window.location.origin}${ae.getLibraryFileDownloadUrl(e)}`;vc(U,l);return}const te=`${window.location.origin}${ae.getArchiveForSlicer(t,he)}`;vc(te,l)};return a.jsx("div",{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 ${M?"p-0":"p-8"}`,onClick:i,children:a.jsxs("div",{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary w-full flex flex-col ${M?"h-full max-w-none rounded-none":"h-[80vh] max-w-4xl rounded-xl"}`,onClick:he=>he.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1 mr-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white truncate",children:n}),de&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary/70 px-2 py-1 rounded whitespace-nowrap",children:[Le,": ",s("modelViewer.objectCount",{count:ve})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:le,disabled:!Q,children:[a.jsx(Wr,{className:"w-4 h-4"}),s("modelViewer.openInSlicer")]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>P(he=>!he),title:M?"Exit fullscreen":"Enter fullscreen",children:M?a.jsx(o4,{className:"w-4 h-4"}):a.jsx(s4,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:i,children:a.jsx(Rt,{className:"w-5 h-5"})})]})]}),h&&a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>h.has_model&&d("3d"),disabled:!h.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${u==="3d"?"text-bambu-green border-b-2 border-bambu-green":h.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Yi,{className:"w-4 h-4"}),s("modelViewer.tabs.model"),!h.has_model&&a.jsxs("span",{className:"text-xs",children:["(",s("modelViewer.notAvailable"),")"]})]}),a.jsxs("button",{onClick:()=>h.has_gcode&&d("gcode"),disabled:!h.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${u==="gcode"?"text-bambu-green border-b-2 border-bambu-green":h.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(que,{className:"w-4 h-4"}),s("modelViewer.tabs.gcode"),!h.has_gcode&&a.jsxs("span",{className:"text-xs",children:["(",s("modelViewer.notSliced"),")"]})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:m?a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"})}):u==="3d"&&h?a.jsxs("div",{ref:H,className:`w-full h-full flex flex-col ${ie?"gap-0 min-h-0":"gap-3"}`,children:[W&&a.jsxs("div",{ref:q,style:ie&&T!=null?{height:T}:void 0,className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3 ${ie?"flex flex-col shrink-0":""}`,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:[a.jsx(Ja,{className:"w-4 h-4"}),s("modelViewer.plates"),v&&a.jsx(it,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:ie?"flex flex-col min-h-0 flex-1":void 0,children:[a.jsx("div",{ref:Ae,className:ie?"min-h-0 overflow-hidden pr-1 flex-1":void 0,children:a.jsxs("div",{ref:ce,className:ie?"grid gap-2":"grid grid-cols-2 md:grid-cols-3 gap-2",style:ie?{gridTemplateColumns:`repeat(${G}, minmax(0, 1fr))`}:void 0,children:[a.jsxs("button",{type:"button",onClick:()=>E(null),className:`flex items-center rounded-lg border text-left transition-colors ${ie?"gap-1.5 p-1.5 w-full":"gap-2 p-2"} ${k==null?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:`rounded bg-bambu-dark-tertiary flex items-center justify-center ${ie?"w-8 h-8":"w-10 h-10"}`,children:a.jsx(Ja,{className:`${ie?"w-4 h-4":"w-5 h-5"} text-bambu-gray`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:`${ie?"text-xs":"text-sm"} text-white font-medium truncate`,children:s("modelViewer.allPlates")}),a.jsx("p",{className:`${ie?"text-[10px]":"text-xs"} text-bambu-gray truncate`,children:s("modelViewer.plateCount",{count:V.length})})]}),k==null&&a.jsx(Kr,{className:`${ie?"w-3.5 h-3.5":"w-4 h-4"} text-bambu-green flex-shrink-0`})]}),ee.map(he=>a.jsxs("button",{type:"button",onClick:()=>E(he.index),className:`flex items-center rounded-lg border text-left transition-colors ${ie?"gap-1.5 p-1.5 w-full":"gap-2 p-2"} ${k===he.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[he.has_thumbnail&&he.thumbnail_url?a.jsx("img",{src:he.thumbnail_url,alt:`Plate ${he.index}`,className:`${ie?"w-8 h-8":"w-10 h-10"} rounded object-cover bg-bambu-dark-tertiary`}):a.jsx("div",{className:`rounded bg-bambu-dark-tertiary flex items-center justify-center ${ie?"w-8 h-8":"w-10 h-10"}`,children:a.jsx(Ja,{className:`${ie?"w-4 h-4":"w-5 h-5"} text-bambu-gray`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:`${ie?"text-xs":"text-sm"} text-white font-medium truncate`,children:he.name||s("modelViewer.plateNumber",{number:he.index})}),a.jsx("p",{className:`${ie?"text-[10px]":"text-xs"} text-bambu-gray truncate`,children:s("modelViewer.objectCount",{count:he.object_count??he.objects?.length??0})})]}),k===he.index&&a.jsx(Kr,{className:`${ie?"w-3.5 h-3.5":"w-4 h-4"} text-bambu-green flex-shrink-0`})]},he.index))]})}),(J||ue)&&a.jsxs("div",{className:"mt-auto pt-3 flex items-center gap-4 text-xs text-bambu-gray overflow-x-auto",children:[J&&a.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[a.jsx("span",{children:s("modelViewer.plateNumber",{number:J.index})}),J.print_time_seconds!=null&&a.jsx("span",{children:s("modelViewer.eta",{minutes:Math.round(J.print_time_seconds/60)})}),J.filament_used_grams!=null&&a.jsxs("span",{children:[J.filament_used_grams.toFixed(1)," g"]}),J.filaments.length>0&&a.jsx("span",{children:s("modelViewer.filamentCount",{count:J.filaments.length})})]}),ue&&a.jsxs("div",{className:`flex items-center gap-2 whitespace-nowrap ${J?"ml-auto":""}`,children:[a.jsx("span",{children:s("modelViewer.pagination.pageOf",{current:N+1,total:B})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>A(he=>Math.max(he-1,0)),disabled:N===0,className:`px-2 py-1 rounded border text-xs ${N===0?"border-bambu-dark-tertiary text-bambu-gray/40 cursor-not-allowed":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:s("modelViewer.pagination.prev")}),(()=>{let te=Math.max(0,N-Math.floor(2.5));const U=Math.min(B,te+5);U-te<5&&(te=Math.max(0,U-5));const L=Array.from({length:U-te},(X,ge)=>te+ge);return a.jsxs(a.Fragment,{children:[te>0&&a.jsx("button",{type:"button",onClick:()=>A(0),className:`px-2 py-1 rounded border text-xs ${N===0?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:"1"}),te>1&&a.jsx("span",{className:"px-1",children:"…"}),L.map(X=>a.jsx("button",{type:"button",onClick:()=>A(X),className:`px-2 py-1 rounded border text-xs ${N===X?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:X+1},X)),U<B-1&&a.jsx("span",{className:"px-1",children:"…"}),U<B&&a.jsx("button",{type:"button",onClick:()=>A(B-1),className:`px-2 py-1 rounded border text-xs ${N===B-1?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:B})]})})(),a.jsx("button",{type:"button",onClick:()=>A(he=>Math.min(he+1,B-1)),disabled:N>=B-1,className:`px-2 py-1 rounded border text-xs ${N>=B-1?"border-bambu-dark-tertiary text-bambu-gray/40 cursor-not-allowed":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:s("modelViewer.pagination.next")})]})]})]})]})]}),ie&&a.jsx("div",{role:"separator","aria-orientation":"horizontal",onMouseDown:he=>{he.preventDefault(),F(!0),D(!0)},className:`h-2 cursor-row-resize flex items-center justify-center ${z?"bg-bambu-dark-tertiary":"bg-bambu-dark-secondary/60 hover:bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:"w-12 h-1 rounded-full bg-bambu-gray/50"})}),a.jsx("div",{className:`flex-1 ${ie?"min-h-0":""}`,children:a.jsx(tX,{url:c?ae.getLibraryFileDownloadUrl(e):h.has_source?ae.getSource3mfDownloadUrl(t):ae.getArchiveDownload(t),fileType:r,buildVolume:h.build_volume,filamentColors:h.filament_colors,selectedPlateId:k,className:"w-full h-full"})})]}):u==="gcode"&&h?a.jsx(FX,{gcodeUrl:c?ae.getLibraryFileGcodeUrl(e):ae.getArchiveGcode(t),filamentColors:h.filament_colors,className:"w-full h-full"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s("modelViewer.noPreview")})})]})})}const kN={"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 f6e(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),s=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(s+o)/2;let c=0,u=0;if(s!==o){const d=s-o;u=l>.5?d/(2-s-o):d/(s+o);const h=n/255,p=r/255,m=i/255;s===h?c=((p-m)/d+(p<m?6:0))/6:s===p?c=((m-h)/d+2)/6:c=((h-p)/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":"Pink"}function MN(t){const e=t.replace("#","").toLowerCase().substring(0,6);return kN[e]?kN[e]:f6e(t)}function tte(t,e){if(t&&!/^[A-Z]\d+-[A-Z]\d+$/.test(t))return t;if(e&&e.length>=6){const n=e.substring(0,6).toLowerCase();if(kN[n])return kN[n]}return null}function s7(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function Pi(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Ac(t,e,n=40){const r=Pi(t),i=Pi(e);if(!r||!i||r.length<6||i.length<6)return!1;const s=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),l=parseInt(r.substring(4,6),16),c=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),d=parseInt(i.substring(4,6),16);return Math.abs(s-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function m6e(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function p6e(t,e,n){return t>=128?t:t*4+e}function g6e(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 o7(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function VM(t){const e=[],n=t?.ams_extruder_map,r=n&&Object.keys(n).length>0;if(t?.ams?.forEach(i=>{const s=i.tray.length===1;i.tray.forEach(o=>{if(o.tray_type){const l=s7(o.tray_color);e.push({type:o.tray_type,color:l,colorName:MN(l),amsId:i.id,trayId:o.id,isHt:s,isExternal:!1,label:m6e(i.id,o.id,s),globalTrayId:p6e(i.id,o.id),trayInfoIdx:o.tray_info_idx||"",extruderId:n?.[String(i.id)]})}})}),t?.vt_tray?.tray_type){const i=s7(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:i,colorName:MN(i),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254,trayInfoIdx:t.vt_tray.tray_info_idx||"",extruderId:r?0:void 0})}return e}function l7(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=VM(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=l.tray_info_idx||"";let u=n.filter(y=>!r.has(y.globalTrayId));if(l.nozzle_id!=null){const y=u.filter(b=>b.extruderId===l.nozzle_id);y.length>0&&(u=y)}let d,h,p,m;if(c){const y=u.filter(b=>b.trayInfoIdx===c);y.length===1?d=y[0]:y.length>1&&(h=y.find(b=>b.type?.toUpperCase()===l.type?.toUpperCase()&&Pi(b.color)===Pi(l.color)),h||(p=y.find(b=>b.type?.toUpperCase()===l.type?.toUpperCase()&&Ac(b.color,l.color))),!h&&!p&&(m=y.find(b=>b.type?.toUpperCase()===l.type?.toUpperCase())))}!d&&!h&&!p&&!m&&(h=u.find(y=>y.type?.toUpperCase()===l.type?.toUpperCase()&&Pi(y.color)===Pi(l.color)),h||(p=u.find(y=>y.type?.toUpperCase()===l.type?.toUpperCase()&&Ac(y.color,l.color))),!h&&!p&&(m=u.find(y=>y.type?.toUpperCase()===l.type?.toUpperCase())));const x=d||h||p||m||void 0;return x&&r.add(x.globalTrayId),{slot_id:l.slot_id,globalTrayId:x?.globalTrayId??-1}}),s=Math.max(...i.map(l=>l.slot_id||0));if(s<=0)return;const o=new Array(s).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function b6e(t){return w.useMemo(()=>VM(t),[t])}function nte(t,e,n){const r=b6e(e),i=w.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(u=>{const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const A=n[d],M=r.find(P=>P.globalTrayId===A);if(M){const P=M.type?.toUpperCase()===u.type?.toUpperCase(),T=Pi(M.color)===Pi(u.color)||Ac(M.color,u.color);let j;return P&&T?j="match":P?j="type_only":j="mismatch",{...u,loaded:M,hasFilament:!0,typeMatch:P,colorMatch:T,status:j,isManual:!0}}}const h=u.tray_info_idx||"";let p=r.filter(A=>!c.has(A.globalTrayId));if(u.nozzle_id!=null){const A=p.filter(M=>M.extruderId===u.nozzle_id);A.length>0&&(p=A)}let m,x,y,b;if(h){const A=p.filter(M=>M.trayInfoIdx===h);A.length===1?m=A[0]:A.length>1&&(x=A.find(M=>M.type?.toUpperCase()===u.type?.toUpperCase()&&Pi(M.color)===Pi(u.color)),x||(y=A.find(M=>M.type?.toUpperCase()===u.type?.toUpperCase()&&Ac(M.color,u.color))),!x&&!y&&(b=A.find(M=>M.type?.toUpperCase()===u.type?.toUpperCase())))}!m&&!x&&!y&&!b&&(x=p.find(A=>A.type?.toUpperCase()===u.type?.toUpperCase()&&Pi(A.color)===Pi(u.color)),x||(y=p.find(A=>A.type?.toUpperCase()===u.type?.toUpperCase()&&Ac(A.color,u.color))),!x&&!y&&(b=p.find(A=>A.type?.toUpperCase()===u.type?.toUpperCase())));const v=m||x||y||b||void 0;v&&c.add(v.globalTrayId);const S=!!v,k=S,E=!!m||!!x||!!y;let N;return m||x||y?N="match":b?N="type_only":N="mismatch",{...u,loaded:v,hasFilament:S,typeMatch:k,colorMatch:E,status:N,isManual:!1}})},[t,r,n]),s=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:s,hasTypeMismatch:o,hasColorMismatch:l}}function x6e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,s=0;const o=new Set(Object.values(n));for(const u of t){const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const b=n[d],v=e.find(S=>S.globalTrayId===b);if(v){const S=v.type?.toUpperCase()===u.type?.toUpperCase(),k=Pi(v.color)===Pi(u.color)||Ac(v.color,u.color);S&&k?r++:S?i++:s++;continue}}let h=e.filter(b=>!o.has(b.globalTrayId));if(u.nozzle_id!=null){const b=h.filter(v=>v.extruderId===u.nozzle_id);b.length>0&&(h=b)}const p=h.find(b=>b.type?.toUpperCase()===u.type?.toUpperCase()&&Pi(b.color)===Pi(u.color)),m=p?void 0:h.find(b=>b.type?.toUpperCase()===u.type?.toUpperCase()&&Ac(b.color,u.color)),x=p||m?void 0:h.find(b=>b.type?.toUpperCase()===u.type?.toUpperCase()),y=p??m??x;y&&o.add(y.globalTrayId),p||m?r++:x?i++:s++}const l=t.length;let c="full";return s>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:s,totalSlots:l,status:c}}function y6e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=VM(e);if(r.length===0)return;const i=new Set(Object.values(n)),s=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){s.push({slot_id:u,globalTrayId:n[u]});continue}let d=r.filter(y=>!i.has(y.globalTrayId));if(c.nozzle_id!=null){const y=d.filter(b=>b.extruderId===c.nozzle_id);y.length>0&&(d=y)}const h=d.find(y=>y.type?.toUpperCase()===c.type?.toUpperCase()&&Pi(y.color)===Pi(c.color)),p=h?void 0:d.find(y=>y.type?.toUpperCase()===c.type?.toUpperCase()&&Ac(y.color,c.color)),m=h||p?void 0:d.find(y=>y.type?.toUpperCase()===c.type?.toUpperCase()),x=h??p??m;x&&i.add(x.globalTrayId),s.push({slot_id:u,globalTrayId:x?.globalTrayId??-1})}const o=Math.max(...s.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return s.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const c7={useDefault:!0,manualMappings:{},autoConfigured:!1};function v6e(t,e,n,r,i,s){const o=r4({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>ae.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((x,y)=>{const b=o[y],v=b?.data,k=e?.find(j=>j.id===x)?.name||`Printer ${x}`,E=VM(v),N=i[x]||c7,A=l7(n,v),M=N.useDefault?r:N.manualMappings,P=y6e(n,v,M),T=x6e(n?.filaments,E,M);return{printerId:x,printerName:k,status:v,isLoading:b?.isLoading??!1,loadedFilaments:E,autoMapping:A,finalMapping:P,matchStatus:T.status,exactMatches:T.exactMatches,typeOnlyMatches:T.typeOnlyMatches,missingTypes:T.missingTypes,totalSlots:T.totalSlots,config:N}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,y)=>{s(b=>({...b,[x]:{...b[x]||c7,...y}}))},d=x=>{const y=l.find(S=>S.printerId===x);if(!y||!y.status||!n?.filaments)return;const b=l7(n,y.status);if(!b)return;const v={};b.forEach((S,k)=>{S!==-1&&(v[k+1]=S)}),u(x,{useDefault:!1,manualMappings:v,autoConfigured:!0})},h=()=>{for(const x of t)d(x)},p=x=>l.find(b=>b.printerId===x)?.finalMapping,m=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:h,autoConfigurePrinter:d,getFinalMapping:p,allPrintersReady:m}}function w6e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=Zt(),[i,s]=w.useState(!1),o=(u,d)=>{if(u<=0)return;const h={...t.config.manualMappings};d===""?delete h[u]:h[u]=parseInt(d,10),n({useDefault:!1,manualMappings:h,autoConfigured:!1})},l=async()=>{s(!0);try{await ae.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{s(!1)}},c=e.map(u=>{const d=u.slot_id||0,h=t.config.manualMappings[d];let p,m=!1;if(h!==void 0)p=t.loadedFilaments.find(y=>y.globalTrayId===h),m=!0;else{const y=new Set(Object.values(t.config.manualMappings)),b=t.loadedFilaments.find(k=>!y.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase()&&Pi(k.color)===Pi(u.color)),v=b?void 0:t.loadedFilaments.find(k=>!y.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase()&&Ac(k.color,u.color)),S=b||v?void 0:t.loadedFilaments.find(k=>!y.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase());p=b??v??S}let x="mismatch";if(p){const y=p.type?.toUpperCase()===u.type?.toUpperCase(),b=Pi(p.color)===Pi(u.color)||Ac(p.color,u.color);y&&b?x="match":y&&(x="type_only")}return{req:u,loaded:p,status:x,isManual:m}});return a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),a.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:i,children:[a.jsx(Ir,{className:`w-3 h-3 ${i?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:h,isManual:p},m)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${u.type} - ${MN(u.color)}`,children:a.jsx(FP,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),a.jsxs("span",{className:"text-white truncate",children:[u.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:d?.globalTrayId??"",onChange:x=>o(u.slot_id||0,x.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${h==="match"?"border-bambu-green/50 text-bambu-green":h==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${p?"ring-1 ring-blue-400/50":""}`,title:p?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(x=>a.jsxs("option",{value:x.globalTrayId,className:"bg-bambu-dark text-white",children:[x.label,": ",x.type," (",x.colorName,")"]},x.globalTrayId))]}),h==="match"?a.jsx(Kr,{className:"w-3 h-3 text-bambu-green"}):h==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(kn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(kn,{className:"w-3 h-3 text-orange-400"})})]},m))]})}function _6e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:s=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u,assignmentMode:d="printer",onAssignmentModeChange:h,targetModel:p,onTargetModelChange:m,targetLocation:x,onTargetLocationChange:y,slicedForModel:b}){const[v,S]=w.useState(!1),k=s?t:t.filter(I=>I.is_active),E=w.useMemo(()=>{if(d!=="printer"||!b||v)return k;const I=k.filter(K=>K.model===b);return I.length>0?I:k},[k,d,b,v]),N=k.length-E.length,A=w.useMemo(()=>{const I=k.map(K=>K.model).filter(K=>!!K);return[...new Set(I)].sort()},[k]),M=w.useMemo(()=>{if(!p)return[];const I=k.filter(K=>K.model===p&&K.location).map(K=>K.location).filter(K=>!!K);return[...new Set(I)].sort()},[k,p]),P=h&&m&&A.length>0,T=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(E.length===0)return a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[a.jsx(Ui,{className:"w-4 h-4"}),"No ",s?"":"active ","printers available"]});const j=I=>{i?e.includes(I)?n(e.filter(K=>K!==I)):n([...e,I]):n([I])},z=()=>{n(E.map(I=>I.id))},F=()=>{n([])},$=(I,K,Z)=>{Z.stopPropagation(),!(!c||!u)&&(K?c(I):u(I,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},D=I=>e.includes(I),H=e.length,q=I=>o?.find(K=>K.printerId===I);return a.jsxs("div",{className:"space-y-2 mb-6",children:[P&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>{h("printer"),m(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="printer"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[a.jsx(Nr,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),a.jsxs("button",{type:"button",onClick:()=>{h("model"),n([]);const I=b&&A.includes(b)?b:A[0];m(I)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="model"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[a.jsx(uh,{className:"w-4 h-4"}),a.jsxs("span",{className:"text-sm",children:["Any ",b||"Model"]})]})]}),d==="model"&&P&&a.jsxs("div",{className:"space-y-3 mb-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Target Model"}),a.jsxs("select",{value:p||"",onChange:I=>{m(I.target.value||null),y&&y(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 text-sm",children:[a.jsx("option",{value:"",children:"Select a model..."}),A.map(I=>a.jsx("option",{value:I,children:I},I))]})]}),p&&M.length>0&&y&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Location Filter (optional)"}),a.jsxs("select",{value:x||"",onChange:I=>y(I.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 text-sm",children:[a.jsx("option",{value:"",children:"Any location"}),M.map(I=>a.jsx("option",{value:I,children:I},I))]})]}),p&&a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Scheduler will assign to first available idle ",p," printer",x?` in ${x}`:""]})]}),d==="printer"&&i&&E.length>1&&a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[a.jsx("span",{children:H===0?"Select printers":`${H} printer${H!==1?"s":""} selected`}),a.jsxs("div",{className:"flex gap-2",children:[H<E.length&&a.jsx("button",{type:"button",onClick:z,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),H>0&&a.jsx("button",{type:"button",onClick:F,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&E.map(I=>{const K=D(I.id),Z=q(I.id),se=Z&&!Z.config.useDefault;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>j(I.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${K?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${I.is_active?"":"opacity-60"}`,children:[a.jsx("div",{className:`p-2 rounded-lg ${K?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:a.jsx(Nr,{className:`w-5 h-5 ${K?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsxs("p",{className:"text-white font-medium",children:[I.name,!I.is_active&&a.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[I.model||"Unknown model"," • ",I.ip_address]})]}),i&&a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${K?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:K&&a.jsx(Kr,{className:"w-3 h-3 text-white"})})]}),K&&T&&Z&&a.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:V=>V.stopPropagation(),children:[a.jsx("input",{type:"checkbox",checked:se,onChange:V=>$(I.id,V.target.checked,V),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),a.jsxs("span",{className:`text-xs ml-2 ${Z.matchStatus==="full"?"text-bambu-green":Z.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",Z.exactMatches,"/",Z.totalSlots," matched)"]}),Z.isLoading&&a.jsx(Ir,{className:"w-3 h-3 text-bambu-gray animate-spin"}),se&&a.jsxs("button",{type:"button",onClick:V=>{V.stopPropagation(),c(I.id)},className:"ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",children:[a.jsx(ome,{className:"w-3 h-3"}),"Auto"]})]}),se&&a.jsx(w6e,{printerResult:Z,filamentReqs:l.filaments,onUpdateConfig:V=>u(I.id,V)})]})]},I.id)}),d==="printer"&&N>0&&!v&&a.jsxs("button",{type:"button",onClick:()=>S(!0),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1",children:[a.jsx(kn,{className:"w-3 h-3 text-yellow-400"}),N," other printer",N>1?"s":""," hidden (different model) —",a.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&v&&b&&a.jsx("button",{type:"button",onClick:()=>S(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:a.jsxs("span",{className:"underline",children:["Show only ",b," printers"]})}),d==="printer"&&H===0&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Ui,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!p&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Ui,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function S6e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Ja,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&a.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[a.jsx(kn,{className:"w-3 h-3"}),"Selection required"]})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>a.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?a.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(Ja,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[i.objects.length>0?i.objects.slice(0,3).join(", ")+(i.objects.length>3?"...":""):`${i.filaments.length} filament${i.filaments.length!==1?"s":""}`,i.print_time_seconds!=null?` • ${g6e(i.print_time_seconds)}`:""]})]}),n===i.index&&a.jsx(Kr,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function N6e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const{t:s}=Ut(),o=Zt(),[l,c]=w.useState(!1),[u,d]=w.useState(i),{data:h}=et({queryKey:["printer-status",t],queryFn:()=>ae.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:p,filamentComparison:m,hasTypeMismatch:x,hasColorMismatch:y}=nte(e,h,n),b=e?.filaments&&e.filaments.length>0,v=e?.filaments?.some(N=>N.nozzle_id!=null)??!1;if(!b||!h)return null;const S=x?"#f97316":y?"#facc15":"#00ae42",k=(N,A)=>{if(N>0)if(A===""){const M={...n};delete M[N],r(M)}else r({...n,[N]:parseInt(A,10)})},E=async()=>{c(!0);try{await ae.refreshPrinterStatus(t),await new Promise(N=>setTimeout(N,500)),await o.refetchQueries({queryKey:["printer-status",t]})}finally{c(!1)}};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>d(!u),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(FP,{className:"w-4 h-4",fill:S,stroke:"none"}),a.jsx("span",{children:"Filament Mapping"}),x?a.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):y?a.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):a.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),u?a.jsx(Kl,{className:"w-4 h-4 ml-auto"}):a.jsx(tr,{className:"w-4 h-4 ml-auto"})]}),u&&a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),a.jsxs("button",{type:"button",onClick:E,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:l,children:[a.jsx(Ir,{className:`w-3 h-3 ${l?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),m.map((N,A)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${N.type} - ${MN(N.color)}`,children:a.jsx(FP,{className:"w-3 h-3",fill:N.color,stroke:N.color})}),a.jsxs("span",{className:"text-white truncate flex items-center gap-1",children:[v&&N.nozzle_id!=null&&a.jsx("span",{className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded text-[9px] font-bold leading-none bg-bambu-gray/20 text-bambu-gray shrink-0",title:N.nozzle_id===1?s("printModal.leftNozzleTooltip"):s("printModal.rightNozzleTooltip"),children:N.nozzle_id===1?s("printModal.leftNozzle"):s("printModal.rightNozzle")}),N.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",N.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:N.loaded?.globalTrayId??"",onChange:M=>k(N.slot_id||0,M.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${N.status==="match"?"border-bambu-green/50 text-bambu-green":N.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${N.isManual?"ring-1 ring-blue-400/50":""}`,title:N.isManual?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),p.map(M=>a.jsxs("option",{value:M.globalTrayId,className:"bg-bambu-dark text-white",children:[M.label,": ",M.type," (",M.colorName,")"]},M.globalTrayId))]}),N.status==="match"?a.jsx(Kr,{className:"w-3 h-3 text-bambu-green"}):N.status==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(kn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(kn,{className:"w-3 h-3 text-orange-400"})})]},A)),x&&a.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const k6e=[{key:"bed_levelling",label:"Bed Levelling",desc:"Auto-level bed before print"},{key:"flow_cali",label:"Flow Calibration",desc:"Calibrate extrusion flow"},{key:"vibration_cali",label:"Vibration Calibration",desc:"Reduce ringing artifacts"},{key:"layer_inspect",label:"First Layer Inspection",desc:"AI inspection of first layer"},{key:"timelapse",label:"Timelapse",desc:"Record timelapse video"}];function M6e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=w.useState(n),s=o=>{e({...t,[o]:!t[o]})};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(Ok,{className:"w-4 h-4"}),a.jsx("span",{children:"Print Options"}),r?a.jsx(Kl,{className:"w-4 h-4 ml-auto"}):a.jsx(tr,{className:"w-4 h-4 ml-auto"})]}),r&&a.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:k6e.map(({key:o,label:l,desc:c})=>a.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:l}),a.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),a.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>s(o),children:a.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${t[o]?"translate-x-5":"translate-x-0.5"}`})})]},o))})]})}function C6e({options:t,onChange:e,dateFormat:n="system",timeFormat:r="system"}){const[i,s]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(!0),[d,h]=w.useState(!0),p=w.useRef(null),m=w.useRef(!1);w.useEffect(()=>{if(t.scheduleType!=="scheduled"){m.current=!1;return}if(!m.current){m.current=!0;let E;t.scheduledTime?(E=new Date(t.scheduledTime),isNaN(E.getTime())&&(E=new Date,E.setHours(E.getHours()+1,0,0,0))):(E=new Date,E.setHours(E.getHours()+1,0,0,0),e({...t,scheduledTime:qP(E)})),s(xB(E,n)),l(yB(E,r)),u(!0),h(!0)}},[t.scheduleType,t.scheduledTime,n,r,e,t]);const x=E=>{e({...t,scheduleType:E})},y=(E,N)=>{const A=jme(E,n),M=Pme(N);u(!!A),h(!!M),A&&M&&(A.setHours(M.hours,M.minutes,0,0),A>new Date&&e({...t,scheduledTime:qP(A)}))},b=E=>{s(E),y(E,o)},v=E=>{l(E),y(i,E)},S=E=>{const N=E.target.value;if(N){const A=new Date(N);isNaN(A.getTime())||(s(xB(A,n)),l(yB(A,r)),u(!0),h(!0),e({...t,scheduledTime:N}))}},k=()=>{p.current?.showPicker()};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>x("asap"),children:[a.jsx(qn,{className:"w-4 h-4"}),"ASAP"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>x("scheduled"),children:[a.jsx(ri,{className:"w-4 h-4"}),"Scheduled"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>x("manual"),children:[a.jsx(tK,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="scheduled"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"flex-1 relative",children:[a.jsx("input",{type:"text",className:`w-full px-3 py-2 pr-10 bg-bambu-dark border rounded-lg text-white focus:outline-none ${c?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:i,onChange:E=>b(E.target.value),placeholder:Ame(n)}),a.jsx("button",{type:"button",onClick:k,className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",title:"Open calendar",children:a.jsx(ri,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"w-32",children:a.jsx("input",{type:"text",className:`w-full px-3 py-2 bg-bambu-dark border rounded-lg text-white focus:outline-none ${d?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:o,onChange:E=>v(E.target.value),placeholder:Tme(r)})})]}),a.jsx("input",{ref:p,type:"datetime-local",className:"sr-only",value:t.scheduledTime,onChange:S,tabIndex:-1}),(!c||!d)&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:"Please enter a valid date and time"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:E=>e({...t,requirePreviousSuccess:E.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:t.autoOffAfter,onChange:E=>e({...t,autoOffAfter:E.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[a.jsx(cd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:t.scheduleType==="asap"?"Print will start as soon as the printer is idle.":t.scheduleType==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."})]})}const hg={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},E6e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function qu({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:s,onSuccess:o}){const{t:l}=Ut(),c=Zt(),{showToast:u}=hn(),d=!!n&&!e,[h,p]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,x]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[y,b]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??hg.bed_levelling,flow_cali:i.flow_cali??hg.flow_cali,vibration_cali:i.vibration_cali??hg.vibration_cali,layer_inspect:i.layer_inspect??hg.layer_inspect,timelapse:i.timelapse??hg.timelapse}:hg),[v,S]=w.useState(()=>{if(t==="edit-queue-item"&&i){let xe="asap";i.manual_start?xe="manual":i.scheduled_time&&!o7(i.scheduled_time)&&(xe="scheduled");let ye="";if(i.scheduled_time&&!o7(i.scheduled_time)){const we=new Date(i.scheduled_time);ye=qP(we)}return{scheduleType:xe,scheduledTime:ye,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return E6e}),[k,E]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const xe={};return i.ams_mapping.forEach((ye,we)=>{ye!==-1&&(xe[we+1]=ye)}),xe}return{}}),[N,A]=w.useState({}),[M,P]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[T,j]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[z,F]=w.useState(()=>t==="edit-queue-item"&&i?.target_location?i.target_location:null),[$]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[D]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[H,q]=w.useState(!1),[I,K]=w.useState({current:0,total:0}),[Z,se]=w.useState(new Set),V=h.length,W=h.length>0?h[0]:null,{data:ie}=et({queryKey:["settings"],queryFn:ae.getSettings}),{data:J,isLoading:pe}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:fe}=et({queryKey:["archive",e],queryFn:()=>ae.getArchive(e),enabled:!!e&&!d}),{data:ve}=et({queryKey:["library-file",n],queryFn:()=>ae.getLibraryFile(n),enabled:d&&!!n}),Le=fe?.sliced_for_model||ve?.sliced_for_model||null,{data:de,isError:ce}=et({queryKey:["archive-plates",e],queryFn:()=>ae.getArchivePlates(e),enabled:!!e&&!d,retry:!1}),{data:Ae}=et({queryKey:["library-file-plates",n],queryFn:()=>ae.getLibraryFilePlates(n),enabled:d&&!!n}),re=d?Ae:de,{data:Ie,isError:G}=et({queryKey:["archive-filaments",e,m],queryFn:()=>ae.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!d&&(m!==null||!re?.is_multi_plate),retry:!1}),{data:Y}=et({queryKey:["library-file-filaments",n,m],queryFn:()=>ae.getLibraryFileFilamentRequirements(n,m??void 0),enabled:d&&!!n&&(m!==null||!re?.is_multi_plate)}),ue=!d&&(ce||G),B=d?Y:Ie,{data:ee}=et({queryKey:["printer-status",W],queryFn:()=>ae.getPrinterStatus(W),enabled:!!W}),{amsMapping:Q}=nte(B,ee,k),le=v6e(h,J,B,k,N,A);w.useEffect(()=>{re?.plates?.length===1&&!m&&x(re.plates[0].index)},[re,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const xe=J?.filter(ye=>ye.is_active)||[];xe.length===1&&h.length===0&&p([xe[0].id])},[t,J,h.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(h.sort())!==JSON.stringify($.sort())||m!==D)&&(E({}),A({}),se(new Set)):(E({}),A({}),se(new Set))},[t,h,m,$,D]),w.useEffect(()=>{if(!ie?.per_printer_mapping_expanded||h.length<=1)return;const xe=h.filter(ye=>{if(Z.has(ye))return!1;const we=le.printerResults.find(Ue=>Ue.printerId===ye);return we&&we.status&&!we.isLoading});xe.length>0&&(se(ye=>{const we=new Set(ye);return xe.forEach(Ue=>we.add(Ue)),we}),xe.forEach(ye=>{le.autoConfigurePrinter(ye)}))},[ie?.per_printer_mapping_expanded,h,Z,le]),w.useEffect(()=>{const xe=ye=>{ye.key==="Escape"&&!H&&s()};return window.addEventListener("keydown",xe),()=>window.removeEventListener("keydown",xe)},[s,H]);const he=re?.is_multi_plate??!1,te=re?.plates??[],U=st({mutationFn:xe=>ae.addToQueue(xe)}),L=st({mutationFn:xe=>ae.updateQueueItem(i.id,xe),onSuccess:()=>{c.invalidateQueries({queryKey:["queue"]}),u("Queue item updated"),o?.(),s()},onError:xe=>{u(xe.message||"Failed to update queue item","error")}}),X=async xe=>{if(xe?.preventDefault(),M==="printer"&&h.length===0){u("Please select at least one printer","error");return}if(M==="model"&&!T){u("Please select a target printer model","error");return}q(!0);const ye=M==="model"?1:h.length;K({current:0,total:ye});const we={success:0,failed:0,errors:[]},Ue=Ve=>{if(h.length>1){const ke=N[Ve];if(ke&&!ke.useDefault)return le.getFinalMapping(Ve)}return Q},Pe=Ve=>({printer_id:M==="printer"?Ve:null,target_model:M==="model"?T:null,target_location:M==="model"?z:null,archive_id:d?void 0:e,library_file_id:d?n:void 0,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:Ve?Ue(Ve):void 0,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():void 0,...y});if(M==="model"){K({current:1,total:1});try{if(t==="reprint"){u("Model-based assignment only works with queue mode","error"),q(!1);return}else if(t==="edit-queue-item"){const Ve={printer_id:null,target_model:T,target_location:z,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:void 0,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():null,...y};await L.mutateAsync(Ve)}else await U.mutateAsync(Pe(null));we.success++}catch(Ve){we.failed++,we.errors.push(Ve.message)}}else for(let Ve=0;Ve<h.length;Ve++){const ke=h[Ve];K({current:Ve+1,total:h.length});try{if(t==="reprint"){const Ze=Ue(ke);d?await ae.printLibraryFile(n,ke,{ams_mapping:Ze,...y}):await ae.reprintArchive(e,ke,{plate_id:m??void 0,ams_mapping:Ze,...y})}else if(t==="edit-queue-item"&&Ve===0){const Ze=Ue(ke),je={printer_id:ke,target_model:null,target_location:null,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:Ze,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():null,...y};await L.mutateAsync(je)}else await U.mutateAsync(Pe(ke));we.success++}catch(Ze){we.failed++;const je=J?.find(Xe=>Xe.id===ke)?.name||`Printer ${ke}`;we.errors.push(`${je}: ${Ze.message}`)}}if(q(!1),we.failed===0){if(M==="model")u(t==="edit-queue-item"?"Queue item updated":`Queued for any ${T}`);else{const Ve=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";we.success===1?u(t==="edit-queue-item"?"Queue item updated":`Print ${Ve} printer`):u(`Print ${Ve} ${we.success} printers`)}c.invalidateQueries({queryKey:["queue"]}),o?.(),s()}else we.success===0?u(`Failed: ${we.errors[0]}`,"error"):(u(`${we.success} succeeded, ${we.failed} failed`,"error"),c.invalidateQueries({queryKey:["queue"]}))},ge=H||L.isPending,_e=w.useMemo(()=>!(ge||M==="printer"&&h.length===0||M==="model"&&!T||M==="model"&&t==="reprint"||!d&&he&&!m),[h.length,M,T,t,he,m,ge,d]),$e=(()=>{const xe=h.length;return t==="reprint"?{title:l(d?"queue.print":"queue.reprint"),icon:Nr,submitText:xe>1?l("queue.printToPrinters",{count:xe}):l("queue.print"),submitIcon:Nr,loadingText:I.total>1?l("queue.sendingProgress",{current:I.current,total:I.total}):l("queue.sending")}:t==="add-to-queue"?{title:l("queue.schedulePrint"),icon:ri,submitText:xe>1?l("queue.queueToPrinters",{count:xe}):l("queue.addToQueue"),submitIcon:ri,loadingText:I.total>1?l("queue.addingProgress",{current:I.current,total:I.total}):l("queue.adding")}:{title:l("queue.editQueueItem"),icon:$i,submitText:l("common.save"),submitIcon:$i,loadingText:I.total>1?l("queue.savingProgress",{current:I.current,total:I.total}):l("common.saving")}})(),Ce=$e.icon,He=$e.submitIcon,Qe=W&&(d||(he?m!==null:!0));return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:H?void 0:s,children:a.jsx(_t,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:xe=>xe.stopPropagation(),children:a.jsxs(Nt,{className:t==="reprint"?"":"p-0",children:[a.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ce,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:$e.title})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:s,disabled:H,children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:X,className:t==="reprint"?"":"p-4 space-y-4",children:[a.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?a.jsxs(a.Fragment,{children:["Send ",a.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),a.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),a.jsx(S6e,{plates:te,isMultiPlate:he,selectedPlate:m,onSelect:x}),a.jsx(_6e,{printers:J||[],selectedPrinterIds:h,onMultiSelect:p,isLoading:pe,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:le.printerResults,filamentReqs:B,onAutoConfigurePrinter:le.autoConfigurePrinter,onUpdatePrinterConfig:le.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":M,onAssignmentModeChange:t!=="reprint"?P:void 0,targetModel:T,onTargetModelChange:t!=="reprint"?j:void 0,targetLocation:z,onTargetLocationChange:t!=="reprint"?F:void 0,slicedForModel:Le}),Le&&M==="printer"&&h.length===1&&(()=>{const xe=J?.find(ye=>ye.id===h[0]);return xe&&xe.model&&Le!==xe.model?a.jsxs("div",{className:"p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2",children:[a.jsx(kn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),a.jsxs("span",{className:"text-sm text-yellow-400",children:["File was sliced for ",Le,", but printing on ",xe.model]})]}):null})(),ue&&a.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[a.jsx(Ui,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),Qe&&!ue&&h.length===1&&a.jsx(N6e,{printerId:W,filamentReqs:B,manualMappings:k,onManualMappingChange:E,defaultExpanded:ie?.per_printer_mapping_expanded??!1}),(t==="reprint"||V>0||M==="model"&&T)&&a.jsx(M6e,{options:y,onChange:b}),t!=="reprint"&&a.jsx(C6e,{options:v,onChange:S,dateFormat:ie?.date_format||"system",timeFormat:ie?.time_format||"system"}),L.isError&&a.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:L.error?.message||"Failed to complete operation"}),a.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:s,className:"flex-1",disabled:H,children:"Cancel"}),a.jsx(Me,{type:"submit",disabled:!_e,className:"flex-1",children:ge?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),$e.loadingText]}):a.jsxs(a.Fragment,{children:[a.jsx(He,{className:"w-4 h-4"}),$e.submitText]})})]})]})]})})})}function A6e({onClose:t,initialFiles:e}){const{t:n}=Ut(),r=Zt(),{showToast:i}=hn(),s=w.useRef(null),[o,l]=w.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[c,u]=w.useState(!1),[d,h]=w.useState(null);w.useEffect(()=>{const N=A=>{A.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]);const p=st({mutationFn:N=>ae.uploadArchivesBulk(N),onSuccess:N=>{h(N),r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["archiveStats"]}),l(A=>A.map(M=>{const P=N.results.find(j=>j.filename===M.file.name),T=N.errors.find(j=>j.filename===M.file.name);return P?{...M,status:"success",archiveId:P.id}:T?{...M,status:"error",error:T.error}:M})),N.failed===0?i(`${N.uploaded} file${N.uploaded!==1?"s":""} uploaded`):N.uploaded===0?i(`Failed to upload ${N.failed} file${N.failed!==1?"s":""}`,"error"):i(`${N.uploaded} uploaded, ${N.failed} failed`,"warning")},onError:()=>{l(N=>N.map(A=>({...A,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),m=w.useCallback(N=>{N.preventDefault(),u(!0)},[]),x=w.useCallback(N=>{N.preventDefault(),u(!1)},[]),y=w.useCallback(N=>{N.preventDefault(),u(!1);const A=Array.from(N.dataTransfer.files).filter(M=>M.name.endsWith(".3mf"));A.length>0&&l(M=>[...M,...A.map(P=>({file:P,status:"pending"}))])},[]),b=w.useCallback(N=>{const A=Array.from(N.target.files||[]).filter(M=>M.name.endsWith(".3mf"));A.length>0&&l(M=>[...M,...A.map(P=>({file:P,status:"pending"}))]),s.current&&(s.current.value="")},[]),v=w.useCallback(N=>{l(A=>A.filter((M,P)=>P!==N))},[]),S=()=>{if(o.length===0)return;const N=o.filter(A=>A.status==="pending");N.length!==0&&(l(A=>A.map(M=>M.status==="pending"?{...M,status:"uploading"}:M)),p.mutate(N.map(A=>A.file)))},k=o.filter(N=>N.status==="pending").length,E=p.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:n("uploadModal.title")}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"p-4",children:a.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:m,onDragLeave:x,onDrop:y,children:[a.jsx(ia,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),a.jsx("p",{className:"text-white mb-2",children:n("uploadModal.dragDrop")}),a.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:n("uploadModal.or")}),a.jsx(Me,{variant:"secondary",onClick:()=>s.current?.click(),disabled:E,children:n("uploadModal.browseFiles")}),a.jsx("input",{ref:s,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:b})]})}),a.jsx("div",{className:"px-4 pb-4",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:n("uploadModal.extractionInfo")})}),o.length>0&&a.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:a.jsx("div",{className:"space-y-2",children:o.map((N,A)=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(Ek,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&a.jsx("button",{onClick:()=>v(A),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:E,children:a.jsx(Rt,{className:"w-4 h-4"})}),N.status==="uploading"&&a.jsx(it,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&a.jsx(mr,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-red-400",children:N.error}),a.jsx(Ui,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${A}`))})}),d&&a.jsx("div",{className:"px-4 pb-4",children:a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"text-bambu-green",children:d.uploaded})," ",n("uploadModal.uploaded"),d.failed>0&&a.jsxs(a.Fragment,{children:[", ",a.jsx("span",{className:"text-red-400",children:d.failed})," ",n("uploadModal.failed")]})]})})}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:n(d?"common.close":"common.cancel")}),!d&&a.jsx(Me,{onClick:S,disabled:k===0||E,className:"flex-1",children:E?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),n("uploadModal.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(ia,{className:"w-4 h-4"}),n("uploadModal.upload")," ",k>0&&`(${k})`]})})]})]})})})}const T6e=["adhesionFailure","spaghettiDetached","layerShift","cloggedNozzle","filamentRunout","warping","stringing","underExtrusion","powerFailure","userCancelled","other"],j6e=["completed","failed","aborted","printing"];function rte({archive:t,onClose:e,existingTags:n=[]}){const{t:r}=Ut();w.useEffect(()=>{const de=ce=>{ce.key==="Escape"&&e()};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[e]);const i=Zt(),[s,o]=w.useState(t.print_name||""),[l,c]=w.useState(t.printer_id),[u,d]=w.useState(t.project_id??null),[h,p]=w.useState(t.notes||""),[m,x]=w.useState(t.tags||""),[y,b]=w.useState(t.failure_reason||""),[v,S]=w.useState(t.status),[k,E]=w.useState(t.quantity??1),[N,A]=w.useState(t.photos||[]),[M,P]=w.useState(t.external_url||""),[T,j]=w.useState(!1),[z,F]=w.useState(!1),$=w.useRef(null),D=w.useRef(null),H=w.useRef(null),{data:q}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:I}=et({queryKey:["projects"],queryFn:()=>ae.getProjects()}),{data:K}=et({queryKey:["tags"],queryFn:ae.getTags,enabled:n.length===0}),Z=n.length>0?n:K?.map(de=>de.name)||[],se=m.split(",").map(de=>de.trim()).filter(Boolean),V=m.includes(",")?m.substring(m.lastIndexOf(",")+1).trim().toLowerCase():m.trim().toLowerCase(),W=Z.filter(de=>!se.includes(de)&&(V===""||de.toLowerCase().includes(V))),ie=de=>{let ce;if(V&&!Z.includes(V)?ce=m.includes(",")?m.substring(0,m.lastIndexOf(",")).split(",").map(Ae=>Ae.trim()).filter(Boolean):[]:ce=se,!ce.includes(de)){const Ae=[...ce,de].join(", ");x(Ae)}H.current!==null&&clearTimeout(H.current),$.current?.focus()},J=de=>{const ce=se.filter(Ae=>Ae!==de).join(", ");x(ce)},pe=st({mutationFn:de=>ae.updateArchive(t.id,de),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),i.invalidateQueries({queryKey:["projects"]}),e()}}),fe=async de=>{const ce=de.target.files?.[0];if(ce){j(!0);try{const Ae=await ae.uploadArchivePhoto(t.id,ce);A(Ae.photos),i.invalidateQueries({queryKey:["archives"]})}catch(Ae){console.error("Failed to upload photo:",Ae)}finally{j(!1),D.current&&(D.current.value="")}}},ve=async de=>{try{const ce=await ae.deleteArchivePhoto(t.id,de);A(ce.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(ce){console.error("Failed to delete photo:",ce)}},Le=de=>{de.preventDefault();const ce={print_name:s||void 0,printer_id:l,project_id:u,notes:h||void 0,tags:m||void 0,quantity:k,external_url:M||null};v!==t.status&&(ce.status=v),v==="failed"||v==="aborted"?ce.failure_reason=y||void 0:(t.status==="failed"||t.status==="aborted")&&(ce.failure_reason=null),pe.mutate(ce)};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.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:de=>de.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("editArchive.title")}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Le,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.name")}),a.jsx("input",{type:"text",value:s,onChange:de=>o(de.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:r("editArchive.namePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.printer")}),a.jsxs("select",{value:l??"",onChange:de=>c(de.target.value?Number(de.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:[a.jsx("option",{value:"",children:r("editArchive.noPrinter")}),q?.map(de=>a.jsx("option",{value:de.id,children:de.name},de.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(ps,{className:"w-4 h-4 inline mr-1"}),r("editArchive.project")]}),a.jsxs("select",{value:u??"",onChange:de=>d(de.target.value?Number(de.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:[a.jsx("option",{value:"",children:r("editArchive.noProject")}),I?.map(de=>a.jsx("option",{value:de.id,children:de.name},de.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Wde,{className:"w-4 h-4 inline mr-1"}),r("editArchive.itemsPrinted")]}),a.jsx("input",{type:"number",min:1,value:k,onChange:de=>E(Math.max(1,parseInt(de.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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.itemsPrintedHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.notes")}),a.jsx("textarea",{value:h,onChange:de=>p(de.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:r("editArchive.notesPlaceholder")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Db,{className:"w-4 h-4 inline mr-1"}),r("editArchive.externalLink")]}),a.jsx("input",{type:"url",value:M,onChange:de=>P(de.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"https://printables.com/model/..."}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.externalLinkHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.tags")}),se.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:se.map(de=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[a.jsx(Fh,{className:"w-3 h-3"}),de,a.jsx("button",{type:"button",onClick:()=>J(de),className:"ml-0.5 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-3 h-3"})})]},de))}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:$,type:"text",value:m,onChange:de=>x(de.target.value),onFocus:()=>{H.current!==null&&clearTimeout(H.current),F(!0)},onBlur:()=>{H.current=window.setTimeout(()=>F(!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:se.length>0?r("editArchive.addMoreTags"):r("editArchive.tagsPlaceholder")}),z&&W.length>0&&a.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:[a.jsxs("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:[V?r("editArchive.matchingTags",{query:V}):r("editArchive.existingTags")," ",r("editArchive.clickToAdd")]}),a.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:W.map(de=>a.jsx("button",{type:"button",onClick:()=>ie(de),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:de},de))})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.status")}),a.jsx("select",{value:v,onChange:de=>{S(de.target.value),de.target.value==="completed"&&b("")},className:"w-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:j6e.map(de=>a.jsx("option",{value:de,children:r(`editArchive.statuses.${de}`)},de))})]}),(v==="failed"||v==="aborted")&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.failureReason")}),a.jsxs("select",{value:y,onChange:de=>b(de.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:[a.jsx("option",{value:"",children:r("editArchive.selectReason")}),T6e.map(de=>a.jsx("option",{value:r(`editArchive.failureReasons.${de}`),children:r(`editArchive.failureReasons.${de}`)},de))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Qg,{className:"w-4 h-4 inline mr-1"}),r("editArchive.photos")]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[N.map(de=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:ae.getArchivePhotoUrl(t.id,de),alt:r("editArchive.printResult"),className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:()=>ve(de),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(en,{className:"w-3 h-3 text-white"})})]},de)),a.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:[a.jsx("input",{ref:D,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:fe,className:"hidden",disabled:T}),T?a.jsx(it,{className:"w-6 h-6 text-bambu-gray animate-spin"}):a.jsx(nr,{className:"w-6 h-6 text-bambu-gray"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("editArchive.photosHelp")})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:r("common.cancel")}),a.jsxs(Me,{type:"submit",disabled:pe.isPending,className:"flex-1",children:[a.jsx(fs,{className:"w-4 h-4"}),pe.isPending?r("common.saving"):r("common.save")]})]})]})]})})}function ite({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[s,o]=w.useState(null),l=w.useRef(null),[c,u]=w.useState({x:t,y:e,visible:!1}),[d,h]=w.useState(!1),[p,m]=w.useState({});w.useEffect(()=>{const b=k=>{i.current&&!i.current.contains(k.target)&&r()},v=k=>{k.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v),document.removeEventListener("scroll",S,!0),l.current&&clearTimeout(l.current)}},[r]),w.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const b=i.current.getBoundingClientRect(),v=window.innerWidth,S=window.innerHeight,k=8;let E=t,N=e;t+b.width>v-k&&(E=Math.max(k,v-b.width-k)),E<k&&(E=k),e+b.height>S-k&&(N=Math.max(k,S-b.height-k)),N<k&&(N=k);const A=180,M=v-E-b.width,P=E;h(M<A&&P>A),u({x:E,y:N,visible:!0})}},[t,e]);const x=(b,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=v.getBoundingClientRect(),k=window.innerHeight,E=300,M=k-S.top-8<E&&S.top>E;m(P=>({...P,[b]:M?"bottom":"top"})),o(b)},y=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return a.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 a.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const S=b.submenu&&b.submenu.length>0;return a.jsxs("div",{className:"relative",onMouseEnter:k=>S&&x(v,k.currentTarget),onMouseLeave:()=>S&&y(),children:[a.jsxs("button",{onMouseEnter:k=>S&&x(v,k.currentTarget.parentElement),onClick:()=>{S?o(s===v?null:v):b.disabled||(b.onClick(),r())},disabled:b.disabled,title:b.title,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"} ${S&&s===v?"bg-bambu-dark-tertiary":""}`,children:[b.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),a.jsx("span",{className:"flex-1",children:b.label}),S&&a.jsx(La,{className:"w-4 h-4 text-bambu-gray"})]}),S&&s===v&&a.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"} ${p[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:b.submenu.map((k,E)=>a.jsxs("button",{onClick:()=>{k.disabled||(k.onClick(),r())},disabled:k.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${k.disabled?"text-bambu-gray cursor-not-allowed":k.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[k.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:k.icon}),k.label]},E))})]},v)})})}function P6e({selectedIds:t,existingTags:e,onClose:n}){const r=Zt(),{showToast:i}=hn(),[s,o]=w.useState(""),[l,c]=w.useState(new Set),[u,d]=w.useState("add");w.useEffect(()=>{const y=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const h=st({mutationFn:async()=>{const y=Array.from(l);let b=0;for(const v of t)try{const S=await ae.getArchive(v),k=S.tags?S.tags.split(",").map(N=>N.trim()).filter(Boolean):[];let E;u==="add"?E=[...new Set([...k,...y])]:E=k.filter(N=>!l.has(N)),await ae.updateArchive(v,{tags:E.join(", ")}),b++}catch(S){throw console.error(`Failed to update archive ${v}:`,S),new Error(`Failed on archive ${v}: ${S instanceof Error?S.message:"Unknown error"}`)}return{count: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")}}),p=y=>{c(b=>{const v=new Set(b);return v.has(y)?v.delete(y):v.add(y),v})},m=()=>{s.trim()&&!l.has(s.trim())&&(c(y=>new Set([...y,s.trim()])),o(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-md",children:a.jsxs(Nt,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Fh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),a.jsx(Me,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&a.jsxs("div",{className:"flex gap-2",children:[a.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:s,onChange:y=>o(y.target.value),onKeyDown:x}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:m,disabled:!s.trim(),children:a.jsx(nr,{className:"w-4 h-4"})})]}),e.length>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>a.jsx("button",{onClick:()=>p(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&&a.jsxs("div",{children:[a.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(y=>a.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,a.jsx("button",{onClick:()=>p(y),className:"hover:opacity-70",children:a.jsx(Rt,{className:"w-3 h-3"})})]},y))})]})]}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),a.jsx(Me,{onClick:()=>h.mutate(),disabled:l.size===0||h.isPending,className:"flex-1",children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Fh,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function D6e({selectedIds:t,onClose:e}){const n=Zt(),{showToast:r}=hn(),{data:i,isLoading:s}=et({queryKey:["projects"],queryFn:()=>ae.getProjects()});w.useEffect(()=>{const d=h=>{h.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=st({mutationFn:async d=>(await ae.addArchivesToProject(d,t),d),onSuccess:d=>{const h=i?.find(p=>p.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${h?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=st({mutationFn:async()=>{for(const d of t)await ae.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 a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ps,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),s?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):a.jsxs("div",{className:"space-y-2",children:[a.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:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:a.jsx(ua,{className:"w-4 h-4 text-red-400"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&a.jsx(it,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&a.jsxs("div",{className:"flex items-center gap-2 py-2",children:[a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>a.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:[a.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:a.jsx(ps,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium truncate",children:d.name}),a.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&&a.jsx(it,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&a.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:a.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function R6e(t,e){return new Date(t,e+1,0).getDate()}function L6e(t,e){return new Date(t,e,1).getDay()}const O6e=["January","February","March","April","May","June","July","August","September","October","November","December"],F6e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function I6e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,s]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,u]=w.useState(null),[d,h]=w.useState(null),p=w.useMemo(()=>{const N=new Map;return t.forEach(A=>{const M=Qi(A.completed_at||A.created_at)||new Date,P=`${M.getFullYear()}-${String(M.getMonth()+1).padStart(2,"0")}-${String(M.getDate()).padStart(2,"0")}`,T=N.get(P)||[];T.push(A),N.set(P,T)}),N},[t]),m=R6e(o,i),x=L6e(o,i),y=()=>{i===0?(s(11),l(o-1)):s(i-1)},b=()=>{i===11?(s(0),l(o+1)):s(i+1)},v=()=>{s(r.getMonth()),l(r.getFullYear())},S=[];for(let N=0;N<x;N++)S.push(null);for(let N=1;N<=m;N++)S.push(N);const k=c?p.get(c)||[]:[],E=N=>{N!==c&&h(null),u(N)};return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Tc,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:[O6e[i]," ",o]}),a.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"})]}),a.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(La,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:F6e.map(N=>a.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:N},N))}),a.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((N,A)=>{if(N===null)return a.jsx("div",{className:"aspect-square"},`empty-${A}`);const M=`${o}-${String(i+1).padStart(2,"0")}-${String(N).padStart(2,"0")}`,P=p.get(M)||[],T=P.length>0,j=N===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),z=M===c,F=P.filter(D=>D.status==="completed").length,$=P.filter(D=>D.status==="failed").length;return a.jsxs("button",{onClick:()=>E(z?null:M),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${z?"bg-bambu-green text-white":j?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[a.jsx("span",{className:`text-sm font-medium ${j&&!z?"text-bambu-green":""}`,children:N}),T&&a.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${$>0&&F===0?"bg-red-400":$>0?"bg-yellow-400":"bg-green-400"}`}),a.jsx("span",{className:"text-xs font-medium",children:P.length})]})]},N)})}),a.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(N=>{const A=new Date(N.completed_at||N.created_at);return A.getMonth()===i&&A.getFullYear()===o}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(N=>{const A=new Date(N.completed_at||N.created_at);return A.getMonth()===i&&A.getFullYear()===o&&N.status==="completed"}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(N=>{const A=new Date(N.completed_at||N.created_at);return A.getMonth()===i&&A.getFullYear()===o&&N.status==="failed"}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),a.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?a.jsxs(a.Fragment,{children:[a.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"})}),k.length>0?a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:k.map(N=>{const A=N.id===d||N.id===n;return a.jsxs("button",{onClick:()=>{h(N.id),e?.(N)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${A?"":"hover:bg-bambu-dark-tertiary"}`,style:A?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[N.thumbnail_path?a.jsx("img",{src:ae.getArchiveThumbnail(N.id),alt:"",className:"w-12 h-12 rounded object-cover"}):a.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:N.print_name||N.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:N.status==="failed"?"text-red-400":"text-green-400",children:N.status==="failed"?"Failed":"Completed"}),N.filament_color&&a.jsx("div",{className:"flex gap-0.5",children:N.filament_color.split(",").map((M,P)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},P))})]})]})]},N.id)})}):a.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):a.jsx("div",{className:"text-center py-8",children:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function ate({archiveId:t,archiveName:e,onClose:n}){const r=ae.getArchiveQRCodeUrl(t,300);w.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=()=>{const s=document.createElement("a");s.href=r,s.download=`${e}_qrcode.png`,s.click()};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 flex flex-col items-center",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),a.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:a.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),a.jsxs(Me,{onClick:i,className:"w-full",children:[a.jsx(hi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function ste({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const m=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",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),w.useEffect(()=>{s>=n.length&&o(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const u=n[s],d=ae.getArchivePhotoUrl(t,u),h=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${s+1}.jpg`,m.click()},p=()=>{i&&c(!0)};return a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[a.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:h,children:[a.jsx(hi,{className:"w-4 h-4"}),"Download"]}),i&&a.jsx(Me,{variant:"secondary",size:"sm",onClick:p,className:"text-red-400 hover:text-red-300",children:a.jsx(en,{className:"w-4 h-4"})}),a.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-6 h-6"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&a.jsx("button",{onClick:()=>o(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(Tc,{className:"w-8 h-8 text-white"})}),a.jsx("img",{src:d,alt:`Photo ${s+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),s<n.length-1&&a.jsx("button",{onClick:()=>o(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(La,{className:"w-8 h-8 text-white"})})]}),n.length>1&&a.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,x)=>a.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===s?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:a.jsx("img",{src:ae.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),l&&a.jsx(On,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Wa(t){this.content=t}Wa.prototype={constructor:Wa,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),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Wa(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Wa(n)},addToStart:function(t,e){return new Wa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Wa(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Wa(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=Wa.from(t),t.size?new Wa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Wa.from(t),t.size?new Wa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Wa.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}};Wa.from=function(t){if(t instanceof Wa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Wa(e)};function ote(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),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=ote(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function lte(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),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=lte(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class At{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){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,s||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 s="",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:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new At(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let l=this.content[s],c=o+l.nodeSize;c>e&&((o<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=c}return new At(r,i)}cutByIndex(e,n){return e==n?At.empty:e==0&&n==this.content.length?this:new At(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new At(i,s)}addToStart(e){return new At([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new At(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return ote(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return lte(this,e,n,r)}findIndex(e){if(e==0)return pS(0,e);if(e==this.size)return pS(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),s=r+i.nodeSize;if(s>=e)return s==e?pS(n+1,s):pS(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return At.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new At(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return At.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new At(n||e,r)}static from(e){if(!e)return At.empty;if(e instanceof At)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new At([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}At.empty=new At([],0);const Pj={index:0,offset:0};function pS(t,e){return Pj.index=t,Pj.offset=e,Pj}function CN(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(!CN(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!CN(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Ur=class JD{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}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&&CN(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 JD.none;if(e instanceof JD)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Ur.none=[];class EN extends Error{}class Bt{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=ute(this.content,e+this.openStart,n);return r&&new Bt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Bt(cte(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Bt.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 Bt(At.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Bt(e,r,i)}}Bt.empty=new Bt(At.empty,0,0);function cte(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.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,s.copy(cte(s.content,e-i-1,n-i-1)))}function ute(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=ute(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function z6e(t,e,n){if(n.openStart>t.depth)throw new EN("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new EN("Inconsistent open depths");return dte(t,e,n,0)}function dte(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=dte(t,e,n,r+1);return s.copy(s.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 pm(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=U6e(n,t);return pm(s,fte(t,o,l,e,r))}else return pm(s,AN(t,e,r))}function hte(t,e){if(!e.type.compatibleContent(t.type))throw new EN("Cannot join "+e.type.name+" onto "+t.type.name)}function eR(t,e,n){let r=t.node(n);return hte(r,e.node(n)),r}function mm(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 Fy(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(mm(t.nodeAfter,r),s++));for(let l=s;l<o;l++)mm(i.child(l),r);e&&e.depth==n&&e.textOffset&&mm(e.nodeBefore,r)}function pm(t,e){return t.type.checkContent(e),t.copy(e)}function fte(t,e,n,r,i){let s=t.depth>i&&eR(t,e,i+1),o=r.depth>i&&eR(n,r,i+1),l=[];return Fy(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(hte(s,o),mm(pm(s,fte(t,e,n,r,i+1)),l)):(s&&mm(pm(s,AN(t,e,i+1)),l),Fy(e,n,i,l),o&&mm(pm(o,AN(n,r,i+1)),l)),Fy(r,null,i,l),new At(l)}function AN(t,e,n){let r=[];if(Fy(null,t,n,r),t.depth>n){let i=eR(t,e,n+1);mm(pm(i,AN(t,e,n+1)),r)}return Fy(e,null,n,r),new At(r)}function U6e(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(At.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class j0{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 s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Ur.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 s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}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 s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].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 TN(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,s=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(s),u=s-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;s=u-1,i+=c+1}return new j0(n,r,s)}static resolveCached(e,n){let r=u7.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else u7.set(e,r=new B6e);let i=r.elts[r.i]=j0.resolve(e,n);return r.i=(r.i+1)%$6e,i}}class B6e{constructor(){this.elts=[],this.i=0}}const $6e=12,u7=new WeakMap;class TN{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 H6e=Object.create(null);let Dh=class tR{constructor(e,n,r,i=Ur.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||At.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&CN(this.attrs,n||e.defaultAttrs||H6e)&&Ur.sameSet(this.marks,r||Ur.none)}copy(e=null){return e==this.content?this:new tR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new tR(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 Bt.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,s.pos-l);return new Bt(u,i.depth-o,s.depth-o)}replace(e,n,r){return z6e(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 j0.resolveCached(this,e)}resolveNoCache(e){return j0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.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()+")"),mte(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=At.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<s;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 s=this.contentMatchAt(e).matchType(r),o=s&&s.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=Ur.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(!Ur.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=At.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Dh.prototype.text=void 0;class jN extends Dh{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):mte(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 jN(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new jN(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 mte(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class zm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new V6e(e,n);if(r.next==null)return zm.empty;let i=pte(r);r.next&&r.err("Unexpected trailing text");let s=Q6e(Y6e(i));return Z6e(s,r),s}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 s=n;i&&s<r;s++)i=i.matchType(e.child(s).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 s(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return At.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:h}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let p=s(h,l.concat(d));if(p)return p}}return null}return s(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(),s=i.match;if(s.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<s.next.length;o++){let{type:l,next:c}=s.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 s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
  8160. `)}}zm.empty=new zm(!0);class V6e{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function pte(t){let e=[];do e.push(G6e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function G6e(t){let e=[];do e.push(q6e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function q6e(t){let e=X6e(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=W6e(t,e);else break;return e}function d7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function W6e(t,e){let n=d7(t),r=n;return t.eat(",")&&(t.next!="}"?r=d7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function K6e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function X6e(t){if(t.eat("(")){let e=pte(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=K6e(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 Y6e(t){let e=[[]];return i(s(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 s(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(s(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=s(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(s(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(s(o.expr,l),c),i(s(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(s(o.expr,c),d),c=d}if(o.max==-1)i(s(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(s(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 gte(t,e){return e-t}function h7(t,e){let n=[];return r(e),n.sort(gte);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:c}=s[o];!l&&n.indexOf(c)==-1&&r(c)}}}function Q6e(t){let e=Object.create(null);return n(h7(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]);h7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new zm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(gte);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function Z6e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function bte(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 xte(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function yte(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 s=t[i];s.validate&&s.validate(e[i])}}function vte(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new e$e(t,r,e[r]);return n}let f7=class wte{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=vte(e,r.attrs),this.defaultAttrs=bte(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==zm.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:xte(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Dh(this,this.computeAttrs(e),At.from(n),Ur.setFrom(r))}createChecked(e=null,n,r){return n=At.from(n),this.checkContent(n),new Dh(this,this.computeAttrs(e),n,Ur.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=At.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(At.empty,!0);return s?new Dh(this,e,n.append(s),Ur.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){yte(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:Ur.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new wte(s,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 s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function J6e(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class e$e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?J6e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class GM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=vte(e,i.attrs),this.excluded=null;let s=bte(this.attrs);this.instance=s?new Ur(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Ur(this,xte(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new GM(s,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){yte(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class _te{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Wa.from(e.nodes),n.marks=Wa.from(e.marks||{}),this.nodes=f7.compile(this.spec.nodes,this),this.marks=GM.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 s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=zm.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?m7(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:m7(this,o.split(" "))}this.nodeFromJSON=i=>Dh.fromJSON(this,i),this.markFromJSON=i=>Ur.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 f7){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 jN(r,r.defaultAttrs,e,Ur.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 m7(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);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 t$e(t){return t.tag!=null}function n$e(t){return t.style!=null}let Iy=class nR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(t$e(i))this.tags.push(i);else if(n$e(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new g7(this,n,!1);return r.addAll(e,Ur.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new g7(this,n,!0);return r.addAll(e,Ur.none,n.from,n.to),Bt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(a$e(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],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 s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=b7(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=b7(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new nR(e,nR.schemaRules(e)))}};const Ste={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},r$e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Nte={ol:!0,ul:!0},P0=1,rR=2,zy=4;function p7(t,e,n){return e!=null?(e?P0:0)|(e==="full"?rR:0):t&&t.whitespace=="pre"?P0|rR:n&~zy}class gS{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Ur.none,this.match=s||(o&zy?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(At.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&P0)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=At.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(At.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ste.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class g7{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=p7(null,n.preserveWhitespace,0)|(r?zy:0);i?s=new gS(i.type,i.attrs,Ur.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new gS(null,null,Ur.none,!0,null,o):s=new gS(e.schema.topNodeType,null,Ur.none,!0,null,o),this.nodes=[s],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,s=i.options&rR?"full":this.localPreserveWS||(i.options&P0)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
  8161. `);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,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Nte.hasOwnProperty(o)&&this.parser.normalizeLists&&i$e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:r$e.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(Ste.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let h=c&&c.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),u&&this.sync(s),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(`
  8162. `),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 s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(s,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 s,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&&(s=!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)}s&&this.sync(l)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;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,s=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);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 s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=Ur.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):x7(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=p7(e,s,o.options);o.options&zy&&o.content.length==0&&(l|=zy);let c=Ur.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):x7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new gS(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|=P0)}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),s=-(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>=s;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=s?r.node(c-s).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 i$e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Nte.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function a$e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function b7(t){let e={};for(let n in t)e[n]=t[n];return e}function x7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class Qm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Dj(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,c=0;for(;l<s.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(s[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)i=s.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(s.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}=QS(Dj(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 s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&QS(Dj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return QS(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=y7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return y7(e.marks)}}function y7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Dj(t){return t.document||window.document}const v7=new WeakMap;function s$e(t){let e=v7.get(t);return e===void 0&&v7.set(t,e=o$e(t)),e}function o$e(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function QS(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],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=s$e(r))&&s.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 h in u)if(u[h]!=null){let p=h.indexOf(" ");p>0?c.setAttributeNS(h.slice(0,p),h.slice(p+1),u[h]):h=="style"&&c.style?c.style.cssText=u[h]:c.setAttribute(h,u[h])}}for(let h=d;h<e.length;h++){let p=e[h];if(p===0){if(h<e.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:x}=QS(t,p,n,r);if(c.appendChild(m),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const kte=65535,Mte=Math.pow(2,16);function l$e(t,e){return t+e*Mte}function w7(t){return t&kte}function c$e(t){return(t-(t&kte))/Mte}const Cte=1,Ete=2,ZS=4,Ate=8;class iR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Ate)>0}get deletedBefore(){return(this.delInfo&(Cte|ZS))>0}get deletedAfter(){return(this.delInfo&(Ete|ZS))>0}get deletedAcross(){return(this.delInfo&ZS)>0}}class So{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&So.empty)return So.empty}recover(e){let n=0,r=w7(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+c$e(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=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+s],d=this.ranges[l+o],h=c+u;if(e<=h){let p=u?e==c?-1:e==h?1:n:n,m=c+i+(p<0?0:d);if(r)return m;let x=e==(n<0?c:h)?null:l$e(l/3,e-c),y=e==c?Ete:e==h?Cte:ZS;return(n<0?e!=c:e!=h)&&(y|=Ate),new iR(m,y,x)}i+=d-u}return r?e+i:new iR(e+i,0,null)}touches(e,n){let r=0,i=w7(n),s=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+s],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,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),c=o+(this.inverted?0:s),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),s+=d-u}}invert(){return new So(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?So.empty:new So(e<0?[0,-e,0]:[0,0,e])}}So.empty=new So([]);class D0{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 D0(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 D0;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 s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new iR(e,i,null)}}const Rj=Object.create(null);class ys{getMap(){return So.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Rj[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 Rj)throw new RangeError("Duplicate use of step JSON ID "+e);return Rj[e]=n,n.prototype.jsonID=e,n}}class ea{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ea(e,null)}static fail(e){return new ea(null,e)}static fromReplace(e,n,r,i){try{return ea.ok(e.replace(n,r,i))}catch(s){if(s instanceof EN)return ea.fail(s.message);throw s}}}function KO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(KO(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return At.fromArray(r)}class xh extends ys{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)),s=new Bt(KO(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 ea.fromReplace(e,this.from,this.to,s)}invert(){return new ql(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 xh(n.pos,r.pos,this.mark)}merge(e){return e instanceof xh&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new xh(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 xh(n.from,n.to,e.markFromJSON(n.mark))}}ys.jsonID("addMark",xh);class ql extends ys{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 Bt(KO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ea.fromReplace(e,this.from,this.to,r)}invert(){return new xh(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 ql(n.pos,r.pos,this.mark)}merge(e){return e instanceof ql&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ql(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 ql(n.from,n.to,e.markFromJSON(n.mark))}}ys.jsonID("removeMark",ql);class yh extends ys{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ea.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ea.fromReplace(e,this.pos,this.pos+1,new Bt(At.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new yh(this.pos,n.marks[i]);return new yh(this.pos,this.mark)}}return new Um(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new yh(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 yh(n.pos,e.markFromJSON(n.mark))}}ys.jsonID("addNodeMark",yh);class Um extends ys{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ea.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ea.fromReplace(e,this.pos,this.pos+1,new Bt(At.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new yh(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Um(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 Um(n.pos,e.markFromJSON(n.mark))}}ys.jsonID("removeNodeMark",Um);class ja extends ys{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&aR(e,this.from,this.to)?ea.fail("Structure replace would overwrite content"):ea.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new So([this.from,this.to-this.from,this.slice.size])}invert(e){return new ja(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 ja(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ja)||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?Bt.empty:new Bt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ja(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?Bt.empty:new Bt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ja(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 ja(n.from,n.to,Bt.fromJSON(e,n.slice),!!n.structure)}}ys.jsonID("replace",ja);class Da extends ys{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(aR(e,this.from,this.gapFrom)||aR(e,this.gapTo,this.to)))return ea.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ea.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ea.fromReplace(e,this.from,this.to,r):ea.fail("Content does not fit in gap")}getMap(){return new So([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 Da(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),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new Da(n.pos,r.pos,i,s,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 Da(n.from,n.to,n.gapFrom,n.gapTo,Bt.fromJSON(e,n.slice),n.insert,!!n.structure)}}ys.jsonID("replaceAround",Da);function aR(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function u$e(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let h=c.marks;if(!r.isInSet(h)&&d.type.allowsMarkType(r.type)){let p=Math.max(u,e),m=Math.min(u+c.nodeSize,n),x=r.addToSet(h);for(let y=0;y<h.length;y++)h[y].isInSet(x)||(o&&o.to==p&&o.mark.eq(h[y])?o.to=m:i.push(o=new ql(p,m,h[y])));l&&l.to==p?l.to=m:s.push(l=new xh(p,m,r))}}),i.forEach(c=>t.step(c)),s.forEach(c=>t.step(c))}function d$e(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let c=null;if(r instanceof GM){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 h=c[d],p;for(let m=0;m<i.length;m++){let x=i[m];x.step==s-1&&h.eq(i[m].style)&&(p=x)}p?(p.to=u,p.step=s):i.push({style:h,from:Math.max(l,e),to:u,step:s})}}}),i.forEach(o=>t.step(new ql(o.from,o.to,o.style)))}function XO(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<s.childCount;c++){let u=s.child(c),d=l+u.nodeSize,h=r.matchType(u.type);if(!h)o.push(new ja(l,d,Bt.empty));else{r=h;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||t.step(new ql(l,d,u.marks[p]));if(i&&u.isText&&n.whitespace!="pre"){let p,m=/\r?\n|\r/g,x;for(;p=m.exec(u.text);)x||(x=new Bt(At.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new ja(l+p.index,l+p.index+p[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(At.empty,!0);t.replace(l,l,new Bt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function h$e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Yb(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!h$e(o,l,c))break;l&&(i=1),c<o.childCount&&(s=1)}return null}function f$e(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),c=o,u=l,d=At.empty,h=0;for(let x=s,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=At.from(r.node(x).copy(d)),h++):c--;let p=At.empty,m=0;for(let x=s,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,p=At.from(i.node(x).copy(p)),m++):u++;t.step(new Da(c,u,o,l,new Bt(d.append(p),h,m),d.size-h,!0))}function YO(t,e,n=null,r=t){let i=m$e(t,e),s=i&&p$e(r,e);return s?i.map(_7).concat({type:e,attrs:n}).concat(s.map(_7)):null}function _7(t){return{type:t,attrs:null}}function m$e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function p$e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:o}function g$e(t,e,n){let r=At.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=At.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new Da(i,s,i,s,new Bt(r,0,0),n.length,!0))}function b$e(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&x$e(t.doc,t.mapping.slice(s).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!x?u=!1:!m&&x&&(u=!0)}u===!1&&jte(t,o,l,s),XO(t,t.mapping.slice(s).map(l,1),r,void 0,u===null);let d=t.mapping.slice(s),h=d.map(l,1),p=d.map(l+o.nodeSize,1);return t.step(new Da(h,p,h+1,p-1,new Bt(At.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&Tte(t,o,l,s),!1}})}function Tte(t,e,n,r){e.forEach((i,s)=>{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+s+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function jte(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
  8163. `))}})}function x$e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function y$e(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Da(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Bt(At.from(o),0,0),1,!0))}function Wu(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<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>s;u--,d--){let h=i.node(u),p=i.index(u);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(p,h.childCount),x=r&&r[d+1];x&&(m=m.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||h;if(!h.canReplace(p+1,h.childCount)||!y.type.validContent(m))return!1}let l=i.indexAfter(s),c=r&&r[0];return i.node(s).canReplaceWith(l,l,c?c.type:i.node(s+1).type)}function v$e(t,e,n=1,r){let i=t.doc.resolve(e),s=At.empty,o=At.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){s=At.from(i.node(l).copy(s));let d=r&&r[u];o=At.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new ja(e,e,new Bt(s.append(o),n,n),!0))}function ef(t,e){let n=t.resolve(e),r=n.index();return Pte(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function w$e(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function Pte(t,e){return!!(t&&e&&!t.isLeaf&&w$e(t,e))}function qM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&Pte(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function _$e(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",h=!!o.contentMatch.matchType(i);d&&!h?r=!1:!d&&h&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);jte(t,d.node(),d.before(),l)}o.inlineContent&&XO(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new ja(u,c.map(e+n,-1),Bt.empty,!0)),r===!0){let d=t.doc.resolve(u);Tte(t,d.node(),d.before(),t.steps.length)}return t}function S$e(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Dte(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)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(s==1)d=u.canReplace(c,c,i);else{let h=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=h&&u.canReplaceWith(c,c,h[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function WM(t,e,n=e,r=Bt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return Rte(i,s,r)?new ja(e,n,r):new N$e(i,s,r).fit()}function Rte(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class N$e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=At.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=At.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let c=new Bt(s,o,l);return e>-1?new Da(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new ja(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 s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Lj(this.unplaced.content,r-1).firstChild,i=s.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,h=null;if(n==1&&(o?u.matchType(o.type)||(h=u.fillBefore(At.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:h};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:d};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Lj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Bt(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=Lj(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Bt(_y(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Bt(_y(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:h,type:p}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));h=h.matchFragment(i)}let m=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),b=h.matchType(y.type);if(!b)break;u++,(u>1||c==0||y.content.size)&&(h=b,d.push(Lte(y.mark(p.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?m:-1)))}let x=u==l.childCount;x||(m=-1),this.placed=Sy(this.placed,n,At.from(d)),this.frontier[n].match=h,x&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,b=l;y<m;y++){let v=b.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),b=v.content}this.unplaced=x?e==0?Bt.empty:new Bt(_y(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new Bt(_y(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||!Oj(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],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Oj(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=Oj(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:s?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=Sy(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Sy(this.placed,this.depth,At.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(At.empty,!0);n.childCount&&(this.placed=Sy(this.placed,this.frontier.length,n))}}function _y(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(_y(t.firstChild.content,e-1,n)))}function Sy(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Sy(t.lastChild.content,e-1,n)))}function Lj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Lte(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Lte(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(At.empty,!0)))),t.copy(r)}function Oj(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!k$e(n,s.content,o)?l:null}function k$e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function M$e(t){return t.spec.defining||t.spec.definingForContent}function C$e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(Rte(i,s,r))return t.step(new ja(e,n,r));let o=Fte(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let p=i.depth,m=i.pos-1;p>0;p--,m--){let x=i.node(p).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(p)>-1?l=p:i.before(p)==m&&o.splice(1,0,-p)}let c=o.indexOf(l),u=[],d=r.openStart;for(let p=r.content,m=0;;m++){let x=p.firstChild;if(u.push(x),m==r.openStart)break;p=x.content}for(let p=d-1;p>=0;p--){let m=u[p],x=M$e(m.type);if(x&&!m.sameMarkup(i.node(Math.abs(l)-1)))d=p;else if(x||!m.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let m=(p+d+1)%(r.openStart+1),x=u[m];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 S=i.node(b-1),k=i.index(b-1);if(S.canReplaceWith(k,k,x.type,x.marks))return t.replace(i.before(b),v?s.after(b):n,new Bt(Ote(r.content,0,r.openStart,m),m,r.openEnd))}}let h=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>h));p--){let m=o[p];m<0||(e=i.before(m),n=s.after(m))}}function Ote(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(Ote(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(At.empty,!0))}return t}function E$e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=S$e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Bt(At.from(r),0,0))}function A$e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=Fte(r,i);for(let o=0;o<s.length;o++){let l=s[o],c=o==s.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 Fte(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<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;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class qg extends ys{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 ea.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ea.fromReplace(e,this.pos,this.pos+1,new Bt(At.from(i),0,n.isLeaf?0:1))}getMap(){return So.empty}invert(e){return new qg(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 qg(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 qg(n.pos,n.attr,n.value)}}ys.jsonID("attr",qg);class R0 extends ys{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 ea.ok(r)}getMap(){return So.empty}invert(e){return new R0(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 R0(n.attr,n.value)}}ys.jsonID("docAttr",R0);let yb=class extends Error{};yb=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};yb.prototype=Object.create(Error.prototype);yb.prototype.constructor=yb;yb.prototype.name="TransformError";class Ite{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new D0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new yb(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=Bt.empty){let i=WM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Bt(At.from(r),0,0))}delete(e,n){return this.replace(e,n,Bt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return C$e(this,e,n,r),this}replaceRangeWith(e,n,r){return E$e(this,e,n,r),this}deleteRange(e,n){return A$e(this,e,n),this}lift(e,n){return f$e(this,e,n),this}join(e,n=1){return _$e(this,e,n),this}wrap(e,n){return g$e(this,e,n),this}setBlockType(e,n=e,r,i=null){return b$e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return y$e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new qg(e,n,r)),this}setDocAttribute(e,n){return this.step(new R0(e,n)),this}addNodeMark(e,n){return this.step(new yh(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 Ur)n.isInSet(r.marks)&&this.step(new Um(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new Um(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return v$e(this,e,n,r),this}addMark(e,n,r){return u$e(this,e,n,r),this}removeMark(e,n,r){return d$e(this,e,n,r),this}clearIncompatible(e,n,r){return XO(this,e,n,r),this}}const Fj=Object.create(null);class Ln{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new T$e(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=Bt.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=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(s);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Bt.empty:n),l==0&&k7(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);s?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),k7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new wn(e):wg(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?wg(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):wg(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ao(e.node(0))}static atStart(e){return wg(e,e,0,0,1)||new Ao(e)}static atEnd(e){return wg(e,e,e.content.size,e.childCount,-1)||new Ao(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Fj[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 Fj)throw new RangeError("Duplicate use of selection JSON ID "+e);return Fj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return wn.between(this.$anchor,this.$head).getBookmark()}}Ln.prototype.visible=!0;class T$e{constructor(e,n){this.$from=e,this.$to=n}}let S7=!1;function N7(t){!S7&&!t.parent.inlineContent&&(S7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class wn extends Ln{constructor(e,n=e){N7(e),N7(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 Ln.near(r);let i=e.resolve(n.map(this.anchor));return new wn(i.parent.inlineContent?i:r,r)}replace(e,n=Bt.empty){if(super.replace(e,n),n==Bt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof wn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new KM(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 wn(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 s=Ln.findFrom(n,r,!0)||Ln.findFrom(n,-r,!0);if(s)n=s.$head;else return Ln.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Ln.findFrom(e,-r,!0)||Ln.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new wn(e,n)}}Ln.jsonID("text",wn);class KM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new KM(e.map(this.anchor),e.map(this.head))}resolve(e){return wn.between(e.resolve(this.anchor),e.resolve(this.head))}}class on extends Ln{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),s=e.resolve(i);return r?Ln.near(s):new on(s)}content(){return new Bt(At.from(this.node),0,0)}eq(e){return e instanceof on&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new QO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new on(e.resolve(n.anchor))}static create(e,n){return new on(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}on.prototype.visible=!1;Ln.jsonID("node",on);class QO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new KM(r,r):new QO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&on.isSelectable(r)?new on(n):Ln.near(n)}}class Ao extends Ln{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Bt.empty){if(n==Bt.empty){e.delete(0,e.doc.content.size);let r=Ln.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ao(e)}map(e){return new Ao(e)}eq(e){return e instanceof Ao}getBookmark(){return j$e}}Ln.jsonID("all",Ao);const j$e={map(){return this},resolve(t){return new Ao(t)}};function wg(t,e,n,r,i,s=!1){if(e.inlineContent)return wn.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(!s&&on.isSelectable(l))return on.create(t,n-(i<0?l.nodeSize:0))}else{let c=wg(t,l,n+i,i<0?l.childCount:0,i,s);if(c)return c}n+=l.nodeSize*i}return null}function k7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ja||i instanceof Da))return;let s=t.mapping.maps[r],o;s.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(Ln.near(t.doc.resolve(o),n))}const M7=1,bS=2,C7=4;class P$e extends Ite{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|M7)&~bS,this.storedMarks=null,this}get selectionSet(){return(this.updated&M7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=bS,this}ensureMarks(e){return Ur.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&bS)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~bS,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)||Ur.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 s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ln.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|=C7,this}get scrolledIntoView(){return(this.updated&C7)>0}}function E7(t,e){return!e||!t?t:t.bind(e)}class Ny{constructor(e,n,r){this.name=e,this.init=E7(n.init,r),this.apply=E7(n.apply,r)}}const D$e=[new Ny("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ny("selection",{init(t,e){return t.selection||Ln.atStart(e.doc)},apply(t){return t.selection}}),new Ny("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ny("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Ij{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=D$e.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 Ny(r.key,r.spec.state,r))})}}class Pg{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 s=!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 h=0;h<this.config.plugins.length;h++)i.push(h<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Pg(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new P$e(this)}static create(e){let n=new Ij(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Pg(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 Ij(this.schema,e.plugins),r=n.fields,i=new Pg(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].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],s=i.spec.state;s&&s.toJSON&&(n[r]=s.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 Ij(e.schema,e.plugins),s=new Pg(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Dh.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=Ln.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.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)){s[o.name]=u.fromJSON.call(c,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function zte(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=zte(i,e,{})),n[r]=i}return n}class yi{constructor(e){this.spec=e,this.props={},e.props&&zte(e.props,this,this.props),this.key=e.key?e.key.key:Ute("plugin")}getState(e){return e[this.key]}}const zj=Object.create(null);function Ute(t){return t in zj?t+"$"+ ++zj[t]:(zj[t]=0,t+"$")}class va{constructor(e="key"){this.key=Ute(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ZO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Bte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const $te=(t,e,n)=>{let r=Bte(t,n);if(!r)return!1;let i=JO(r);if(!i){let o=r.blockRange(),l=o&&Yb(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Qte(t,i,e,-1))return!0;if(r.parent.content.size==0&&(vb(s,"end")||on.isSelectable(s)))for(let o=r.depth;;o--){let l=WM(t.doc,r.before(o),r.after(o),Bt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(vb(s,"end")?Ln.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):on.create(c.doc,i.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},R$e=(t,e,n)=>{let r=Bte(t,n);if(!r)return!1;let i=JO(r);return i?Hte(t,i,e):!1},L$e=(t,e,n)=>{let r=Gte(t,n);if(!r)return!1;let i=eF(r);return i?Hte(t,i,e):!1};function Hte(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){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=WM(t.doc,s,c,Bt.empty);if(!u||u.from!=s||u instanceof ja&&u.slice.size>=c-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(wn.create(d.doc,s)),n(d.scrollIntoView())}return!0}function vb(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 Vte=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=JO(r)}let o=s&&s.nodeBefore;return!o||!on.isSelectable(o)?!1:(e&&e(t.tr.setSelection(on.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function JO(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 Gte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const qte=(t,e,n)=>{let r=Gte(t,n);if(!r)return!1;let i=eF(r);if(!i)return!1;let s=i.nodeAfter;if(Qte(t,i,e,1))return!0;if(r.parent.content.size==0&&(vb(s,"start")||on.isSelectable(s))){let o=WM(t.doc,r.before(),r.after(),Bt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(vb(s,"start")?Ln.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):on.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Wte=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=eF(r)}let o=s&&s.nodeAfter;return!o||!on.isSelectable(o)?!1:(e&&e(t.tr.setSelection(on.create(t.doc,s.pos)).scrollIntoView()),!0)};function eF(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 O$e=(t,e)=>{let n=t.selection,r=n instanceof on,i;if(r){if(n.node.isTextblock||!ef(t.doc,n.from))return!1;i=n.from}else if(i=qM(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(on.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},F$e=(t,e)=>{let n=t.selection,r;if(n instanceof on){if(n.node.isTextblock||!ef(t.doc,n.to))return!1;r=n.to}else if(r=qM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},I$e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Yb(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},Kte=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8164. `).scrollIntoView()),!0)};function tF(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 z$e=(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),s=n.indexAfter(-1),o=tF(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(Ln.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Xte=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ao||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=tF(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(wn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Yte=(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 s=n.before();if(Wu(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Yb(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function U$e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof on&&e.selection.node.isBlock)return!r.parentOffset||!Wu(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,c=!1,u=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){c=r.end(m)==r.pos+(r.depth-m),u=r.start(m)==r.pos-(r.depth-m),l=tF(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),s.unshift(c&&l?{type:l}:null),o=m;break}else{if(m==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof wn||e.selection instanceof Ao)&&d.deleteSelection();let h=d.mapping.map(r.pos),p=Wu(d.doc,h,s.length,s);if(p||(s[0]=l?{type:l}:null,p=Wu(d.doc,h,s.length,s)),!p)return!1;if(d.split(h,s.length,s),!c&&u&&r.node(o).type!=l){let m=d.mapping.map(r.before(o)),x=d.doc.resolve(m);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 B$e=U$e(),$$e=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(on.create(t.doc,i))),!0)};function H$e(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||ef(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Qte(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&H$e(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(s.type))&&l.matchType(o[0]||s.type).validEnd){if(n){let m=e.pos+s.nodeSize,x=At.empty;for(let v=o.length-1;v>=0;v--)x=At.from(o[v].create(null,x));x=At.from(i.copy(x));let y=t.tr.step(new Da(e.pos-1,m,e.pos,m,new Bt(x,1,0),o.length,!0)),b=y.doc.resolve(m+2*o.length);b.nodeAfter&&b.nodeAfter.type==i.type&&ef(y.doc,b.pos)&&y.join(b.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&c?null:Ln.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),p=h&&Yb(h);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(h,p).scrollIntoView()),!0;if(u&&vb(s,"start",!0)&&vb(i,"end")){let m=i,x=[];for(;x.push(m),!m.isTextblock;)m=m.lastChild;let y=s,b=1;for(;!y.isTextblock;y=y.firstChild)b++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){let v=At.empty;for(let k=x.length-1;k>=0;k--)v=At.from(x[k].copy(v));let S=t.tr.step(new Da(e.pos-x.length,e.pos+s.nodeSize,e.pos+b,e.pos+s.nodeSize-b,new Bt(v,x.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function Zte(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(wn.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const V$e=Zte(-1),G$e=Zte(1);function q$e(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&YO(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function A7(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];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),h=d.index();i=d.parent.canReplaceWith(h,h+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];s.setBlockType(l,c,t,e)}r(s.scrollIntoView())}return!0}}function nF(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}nF(ZO,$te,Vte);nF(ZO,qte,Wte);nF(Kte,Xte,Yte,B$e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function W$e(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let l=r?n.tr:null;return K$e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function K$e(t,e,n,r=null){let i=!1,s=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);s=new TN(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new TN(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=YO(s,n,r,e);return l?(t&&X$e(t,e,l,i,n),!0):!1}function X$e(t,e,n,r,i){let s=At.empty;for(let d=n.length-1;d>=0;d--)s=At.from(n[d].type.create(n[d].attrs,s));t.step(new Da(e.start-(r?2:0),e.end,e.start,e.end,new Bt(s,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,h=e.endIndex,p=!0;d<h;d++,p=!1)!p&&Wu(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function Y$e(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?Q$e(e,n,t,s):Z$e(e,n,s):!0:!1}}function Q$e(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Da(s-1,o,s,o,new Bt(At.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new TN(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Yb(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return ef(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function Z$e(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)m-=i.child(x).nodeSize,r.delete(m-1,m+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=s.node(-1),d=s.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?At.empty:At.from(i))))return!1;let h=s.pos,p=h+o.nodeSize;return r.step(new Da(h-(l?1:0),p+(c?1:0),h+1,p-1,new Bt((l?At.empty:At.from(i.copy(At.empty))).append(c?At.empty:At.from(i.copy(At.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function J$e(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,c=l.child(o-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=At.from(u?t.create():null),h=new Bt(At.from(t.create(null,At.from(l.type.create(null,d)))),u?3:1,0),p=s.start,m=s.end;n(e.tr.step(new Da(p-(u?3:1),m,p,m,h,1,!0)).scrollIntoView())}return!0}}const Qa=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},wb=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let sR=null;const ku=function(t,e,n){let r=sR||(sR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},eHe=function(){sR=null},Bm=function(t,e,n,r){return n&&(T7(t,e,n,r,-1)||T7(t,e,n,r,1))},tHe=/^(img|br|input|textarea|hr)$/i;function T7(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:ll(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ev(t)||tHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Qa(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(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?ll(t):0}else return!1}}function ll(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function nHe(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=ll(t)}else if(t.parentNode&&!Ev(t))e=Qa(t),t=t.parentNode;else return null}}function rHe(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ev(t))e=Qa(t)+1,t=t.parentNode;else return null}}function iHe(t,e,n){for(let r=e==0,i=e==ll(t);r||i;){if(t==n)return!0;let s=Qa(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==ll(t)}}function Ev(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const XM=function(t){return t.focusNode&&Bm(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Wf(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function aHe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function sHe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ll(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ll(r.startContainer),r.startOffset)}}}const Oc=typeof navigator<"u"?navigator:null,j7=typeof document<"u"?document:null,tf=Oc&&Oc.userAgent||"",oR=/Edge\/(\d+)/.exec(tf),Jte=/MSIE \d/.exec(tf),lR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tf),eo=!!(Jte||lR||oR),Rh=Jte?document.documentMode:lR?+lR[1]:oR?+oR[1]:0,fl=!eo&&/gecko\/(\d+)/i.test(tf);fl&&+(/Firefox\/(\d+)/.exec(tf)||[0,0])[1];const cR=!eo&&/Chrome\/(\d+)/.exec(tf),ms=!!cR,ene=cR?+cR[1]:0,Rs=!eo&&!!Oc&&/Apple Computer/.test(Oc.vendor),_b=Rs&&(/Mobile\/\w+/.test(tf)||!!Oc&&Oc.maxTouchPoints>2),nl=_b||(Oc?/Mac/.test(Oc.platform):!1),oHe=Oc?/Win/.test(Oc.platform):!1,zu=/Android \d/.test(tf),Av=!!j7&&"webkitFontSmoothing"in j7.documentElement.style,lHe=Av?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function cHe(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 xu(t,e){return typeof t=="number"?t:t[e]}function uHe(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 P7(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=wb(o);continue}let l=o,c=l==s.body,u=c?cHe(s):uHe(l),d=0,h=0;if(e.top<u.top+xu(r,"top")?h=-(u.top-e.top+xu(i,"top")):e.bottom>u.bottom-xu(r,"bottom")&&(h=e.bottom-e.top>u.bottom-u.top?e.top+xu(i,"top")-u.top:e.bottom-u.bottom+xu(i,"bottom")),e.left<u.left+xu(r,"left")?d=-(u.left-e.left+xu(i,"left")):e.right>u.right-xu(r,"right")&&(d=e.right-u.right+xu(i,"right")),d||h)if(c)s.defaultView.scrollBy(d,h);else{let m=l.scrollLeft,x=l.scrollTop;h&&(l.scrollTop+=h),d&&(l.scrollLeft+=d);let y=l.scrollLeft-m,b=l.scrollTop-x;e={left:e.left-y,top:e.top-b,right:e.right-y,bottom:e.bottom-b}}let p=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:wb(o)}}function dHe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,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:tne(t.dom)}}function tne(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=wb(r));return e}function hHe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;nne(n,r==0?0:r-e)}function nne(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let fg=null;function fHe(t){if(t.setActive)return t.setActive();if(fg)return t.focus(fg);let e=tne(t);t.focus(fg==null?{get preventScroll(){return fg={preventScroll:!0},!0}}:void 0),fg||(fg=!1,nne(e,0))}function rne(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=ku(d).getClientRects();else continue;for(let m=0;m<p.length;m++){let x=p[m];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&&(s=h+(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)&&(s=h+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?mHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:rne(n,i)}function mHe(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 s=th(r,1);if(s.top!=s.bottom&&rF(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function rF(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function pHe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function gHe(t,e,n){let{node:r,offset:i}=rne(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function bHe(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!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;s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function ine(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)),s=i;;){let o=t.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(rF(e,u))return ine(o,e,u)}}if((s=(s+1)%r)==i)break}return t}function xHe(t,e){let n=t.dom.ownerDocument,r,i=0,s=sHe(n,e.left,e.top);s&&({node:r,offset:i}=s);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(!rF(e,u)||(o=ine(t.dom,e,u),!o))return null}if(Rs)for(let u=o;r&&u;u=wb(u))u.draggable&&(r=void 0);if(o=pHe(o,e),r){if(fl&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let u;Av&&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=bHe(t,r,i,e))}l==null&&(l=gHe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function D7(t){return t.top<t.bottom||t.left<t.right}function th(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(D7(r))return r}return Array.prototype.find.call(n,D7)||t.getBoundingClientRect()}const yHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ane(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Av||fl;if(r.nodeType==3)if(o&&(yHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=th(ku(r,i,i),n);if(fl&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=th(ku(r,i-1,i-1),-1);if(u.top==c.top){let d=th(ku(r,i,i+1),-1);if(d.top!=c.top)return dy(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++,dy(th(ku(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==ll(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Uj(c.getBoundingClientRect(),!1)}if(s==null&&i<ll(r)){let c=r.childNodes[i];if(c.nodeType==1)return Uj(c.getBoundingClientRect(),!0)}return Uj(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==ll(r))){let c=r.childNodes[i-1],u=c.nodeType==3?ku(c,ll(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return dy(th(u,1),!1)}if(s==null&&i<ll(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?ku(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return dy(th(u,-1),!0)}return dy(th(r.nodeType==3?ku(r):r,-n),n>=0)}function dy(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 Uj(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 sne(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 vHe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return sne(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=ane(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=ku(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 wHe=/[\u0590-\u08ac]/;function _He(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!wHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:sne(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:h}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),b=x&&!m.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==y;try{l.collapse(d,h),c&&(c!=d||u!=h)&&l.extend&&l.extend(c,u)}catch{}return p!=null&&(l.caretBidiLevel=p),b}):r.pos==r.start()||r.pos==r.end()}let R7=null,L7=null,O7=!1;function SHe(t,e,n){return R7==e&&L7==n?O7:(R7=e,L7=n,O7=n=="up"||n=="down"?vHe(t,e,n):_He(t,e,n))}const ml=0,F7=1,tm=2,Fc=3;class Tv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=ml,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 s,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Qa(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 s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.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 s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}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 s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=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<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof lne){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof one&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Qa(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Qa(s.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,s=-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 h=l;h>0;h--){let p=this.children[h-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=Qa(p.dom)+1;break}e-=p.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 h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=Qa(h.dom);break}n+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}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 s=Math.min(e,n),o=Math.max(e,n);for(let m=0,x=0;m<this.children.length;m++){let y=this.children[m],b=x+y.size;if(s>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(),h=!1;if((fl||Rs)&&e==n){let{node:m,offset:x}=l;if(m.nodeType==3){if(h=!!(x&&m.nodeValue[x-1]==`
  8165. `),h&&x==m.nodeValue.length)for(let y=m,b;y;y=y.parentNode){if(b=y.nextSibling){b.nodeName=="BR"&&(l=c={node:b.parentNode,offset:Qa(b)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=m.childNodes[x-1];h=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(fl&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||h&&Rs)&&Bm(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Bm(c.node,c.offset,d.focusNode,d.focusOffset))return;let p=!1;if((u.extend||e==n)&&!(h&&fl)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>n){let x=l;l=c,c=x}let m=document.createRange();m.setEnd(c.node,c.offset),m.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(m)}}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 s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,c=o-s.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?tm:F7,e==l&&n==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Fc:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?tm:Fc}r=o}this.dirty=tm}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?tm:F7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class one extends Tv{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!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,s=this}matchesWidget(e){return this.dirty==ml&&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 NHe extends Tv{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 $m extends Tv{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=Qm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new $m(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Fc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Fc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ml){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ml}}slice(e,n,r){let i=$m.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=dR(s,n,o,r)),e>0&&(s=dR(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Lh extends Tv{constructor(e,n,r,i,s,o,l,c,u){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],c,u=l&&l(n,s,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,h=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:h}=Qm.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let p=d;return d=dne(d,r,n),u?c=new kHe(e,n,r,i,d,h||null,p,u,s,o+1):n.isText?new YM(e,n,r,i,d,p,s):new Lh(e,n,r,i,d,h||null,p,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>At.empty)}return e}matchesNode(e,n,r){return this.dirty==ml&&e.eq(this.node)&&PN(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,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,c=new CHe(this,o&&o.node,e);THe(this.node,this.innerDeco,(u,d,h)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!h&&c.syncToMarks(d==this.node.childCount?Ur.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,h,p)=>{c.syncToMarks(u.marks,r,e);let m;c.findNodeMatch(u,d,h,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(u,d,h,m,e)||c.updateNextNode(u,d,h,e,p,i)||c.addNode(u,d,h,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==tm)&&(o&&this.protectLocalComposition(e,o),cne(this.contentDOM,this.children,e),_b&&jHe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof wn)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=PHe(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new NHe(this,s,n,i);e.input.compositionNodes.push(o),this.children=dR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Fc||!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=ml}updateOuterDeco(e){if(PN(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=une(this.dom,this.nodeDOM,uR(this.outerDeco,this.node,n),uR(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 I7(t,e,n,r,i){dne(r,e,t);let s=new Lh(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class YM extends Lh{constructor(e,n,r,i,s,o,l){super(e,n,r,i,s,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==Fc||this.dirty!=ml&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ml||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=ml,!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),s=document.createTextNode(i.text);return new YM(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Fc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class lne extends Tv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ml&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class kHe extends Lh{constructor(e,n,r,i,s,o,l,c,u,d){super(e,n,r,i,s,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==Fc)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}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 cne(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=z7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof $m){let c=r?r.previousSibling:t.lastChild;cne(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=z7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Uy=function(t){t&&(this.nodeName=t)};Uy.prototype=Object.create(null);const nm=[new Uy];function uR(t,e,n){if(t.length==0)return nm;let r=n?nm[0]:new Uy,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new Uy(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new Uy(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 une(t,e,n,r){if(n==nm&&r==nm)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){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=nm[0]),i=c}MHe(i,l||nm[0],o)}return i}function MHe(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 s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function dne(t,e,n){return une(t,t,nm,uR(e,n,t.nodeType!=1))}function PN(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 z7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class CHe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=EHe(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,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=ml,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<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[s])&&!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=$m.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=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)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==Fc&&o.dom==o.contentDOM&&(o.dirty=tm),o.update(e,n,r,s)?(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,s,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Lh){let u=this.preMatch.matched.get(c);if(u!=null&&u!=s)return!1;let d=c.dom,h,p=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Fc&&PN(n,c.outerDeco));if(!p&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(h=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=tm,h.updateChildren(i,o+1),h.dirty=ml),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!PN(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Lh.create(this.top,n,r,i,s,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,s){let o=Lh.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+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 s=new one(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof $m;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof YM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Rs||ms)&&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 lne(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 EHe(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof $m)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,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function AHe(t,e){return t.type.side-e.type.side}function THe(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(s,d),u),s+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,h;for(;o<i.length&&i[o].to==s;){let b=i[o++];b.widget&&(d?(h||(h=[d])).push(b):d=b)}if(d)if(h){h.sort(AHe);for(let b=0;b<h.length;b++)n(h[b],u,!!c)}else n(d,u,!!c);let p,m;if(c)m=-1,p=c,c=null;else if(u<t.childCount)m=u,p=t.child(u++);else break;for(let b=0;b<l.length;b++)l[b].to<=s&&l.splice(b--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let x=s+p.nodeSize;if(p.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=p.cut(b-s),p=p.cut(0,b-s),x=b,m=-1)}else for(;o<i.length&&i[o].to<x;)o++;let y=p.isInline&&!p.isLeaf?l.filter(b=>!b.inline):l.slice();r(p,y,e.forChild(s,p),m),s=x}}function jHe(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 PHe(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(s+=u.nodeSize,!u.isText)break;c+=u.text}if(s>=n){if(s>=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 dR(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?s.push(c):(u<e&&s.push(c.slice(0,e-u,r)),i&&(s.push(i),i=void 0),d>n&&s.push(c.slice(n-u,c.size,r)))}return s}function iF(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=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(XM(n)){for(c=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&on.isSelectable(h)&&i.parent&&!(h.isInline&&iHe(n.focusNode,n.focusOffset,i.dom))){let p=i.posBefore;u=new on(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=o,p=o;for(let m=0;m<n.rangeCount;m++){let x=n.getRangeAt(m);h=Math.min(h,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(h<0)return null;[c,o]=p==t.state.selection.anchor?[p,h]:[h,p],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 h=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;u=aF(t,d,l,h)}return u}function hne(t){return t.editable?t.hasFocus():mne(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ku(t,e=!1){let n=t.state.selection;if(fne(t,n),!!hne(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ms){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Bm(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)RHe(t);else{let{anchor:r,head:i}=n,s,o;U7&&!(n instanceof wn)&&(n.$from.parent.inlineContent||(s=B7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=B7(t,n.to))),t.docView.setSelection(r,i,t,e),U7&&(s&&$7(s),o&&$7(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&DHe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const U7=Rs||ms&&ene<63;function B7(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Rs&&i&&i.contentEditable=="false")return Bj(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Bj(i);if(s)return Bj(s)}}function Bj(t){return t.contentEditable="true",Rs&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function $7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function DHe(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(()=>{(!hne(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function RHe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Qa(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&eo&&Rh<=11&&(n.disabled=!0,n.disabled=!1)}function fne(t,e){if(e instanceof on){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(H7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else H7(t)}function H7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function aF(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||wn.between(e,n,r)}function V7(t){return t.editable&&!t.hasFocus()?!1:mne(t)}function mne(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 LHe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Bm(e.node,e.offset,n.anchorNode,n.anchorOffset)}function hR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&Ln.findFrom(s,e)}function sh(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function G7(t,e,n){let r=t.state.selection;if(r instanceof wn)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return sh(t,new wn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=hR(t.state,e);return i&&i instanceof on?sh(t,i):!1}else if(!(nl&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?on.isSelectable(s)?sh(t,new on(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Av?sh(t,new wn(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof on&&r.node.isInline)return sh(t,new wn(e>0?r.$to:r.$from));{let i=hR(t.state,e);return i?sh(t,i):!1}}}function DN(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function By(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mg(t,e){return e<0?OHe(t):FHe(t)}function OHe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(fl&&n.nodeType==1&&r<DN(n)&&By(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(By(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(pne(n))break;{let l=n.previousSibling;for(;l&&By(l,-1);)i=n.parentNode,s=Qa(l),l=l.previousSibling;if(l)n=l,r=DN(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?fR(t,n,r):i&&fR(t,i,s)}function FHe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=DN(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(By(l,1))s=n,o=++r;else break}else{if(pne(n))break;{let l=n.nextSibling;for(;l&&By(l,1);)s=l.parentNode,o=Qa(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=DN(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&fR(t,s,o)}function pne(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function IHe(t,e){for(;t&&e==t.childNodes.length&&!Ev(t);)e=Qa(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 zHe(t,e){for(;t&&!e&&!Ev(t);)e=Qa(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 fR(t,e,n){if(e.nodeType!=3){let s,o;(o=IHe(e,n))?(e=o,n=0):(s=zHe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(XM(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Ku(t)},50)}function q7(t,e){let n=t.state.doc.resolve(e);if(!(ms||oHe)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function W7(t,e,n){let r=t.state.selection;if(r instanceof wn&&!r.empty||n.indexOf("s")>-1||nl&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=hR(t.state,e);if(o&&o instanceof on)return sh(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Ao?Ln.near(o,e):Ln.findFrom(o,e);return l?sh(t,l):!1}return!1}function K7(t,e){if(!(t.state.selection instanceof wn))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 s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function X7(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function UHe(t){if(!Rs||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;X7(t,r,"true"),setTimeout(()=>X7(t,r,"false"),20)}return!1}function BHe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function $He(t,e){let n=e.keyCode,r=BHe(e);if(n==8||nl&&n==72&&r=="c")return K7(t,-1)||mg(t,-1);if(n==46&&!e.shiftKey||nl&&n==68&&r=="c")return K7(t,1)||mg(t,1);if(n==13||n==27)return!0;if(n==37||nl&&n==66&&r=="c"){let i=n==37?q7(t,t.state.selection.from)=="ltr"?-1:1:-1;return G7(t,i,r)||mg(t,i)}else if(n==39||nl&&n==70&&r=="c"){let i=n==39?q7(t,t.state.selection.from)=="ltr"?1:-1:1;return G7(t,i,r)||mg(t,i)}else{if(n==38||nl&&n==80&&r=="c")return W7(t,-1,r)||mg(t,-1);if(n==40||nl&&n==78&&r=="c")return UHe(t)||W7(t,1,r)||mg(t,1);if(r==(nl?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function sF(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||Qm.fromSchema(t.state.schema),l=wne(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,h=0;for(;u&&u.nodeType==1&&(d=vne[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let x=l.createElement(d[m]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),h++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
  8166. `);return{dom:c,text:p,slice:e}}function gne(t,e,n,r,i){let s=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||s||!n);if(c){if(t.someProp("transformPastedText",p=>{e=p(e,s||r,t)}),s)return l=new Bt(At.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8167. `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let h=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(h)l=h;else{let p=i.marks(),{schema:m}=t.state,x=Qm.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=o.appendChild(document.createElement("p"));y&&b.appendChild(x.serializeNode(m.text(y,p)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),o=qHe(n),Av&&WHe(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 h=+d[3];h>0;h--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Iy.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!HHe.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=KHe(Y7(l,+d[1],+d[2]),d[4]);else if(l=Bt.maxOpen(VHe(l.content,i),!0),l.openStart||l.openEnd){let h=0,p=0;for(let m=l.content.firstChild;h<l.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=Y7(l,h,p)}return t.someProp("transformPasted",h=>{l=h(l,t,c)}),l}const HHe=/^(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 VHe(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)),s,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&s.length&&xne(c,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=yne(o[o.length-1],s.length));let d=bne(l,c);o.push(d),i=i.matchType(d.type),s=c}}),o)return At.from(o)}return t}function bne(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,At.from(t));return t}function xne(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=xne(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(At.from(bne(n,t,i+1))))}}function yne(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,yne(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(At.empty,!0);return t.copy(n.append(r))}function mR(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=mR(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(At.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Y7(t,e,n){return e<t.openStart&&(t=new Bt(mR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Bt(mR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const vne={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 Q7=null;function wne(){return Q7||(Q7=document.implementation.createHTMLDocument("title"))}let $j=null;function GHe(t){let e=window.trustedTypes;return e?($j||($j=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),$j.createHTML(t)):t}function qHe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=wne().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&vne[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=GHe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function WHe(t){let e=t.querySelectorAll(ms?"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 KHe(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:s,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=At.from(c.create(r[l+1],i)),s++,o++}return new Bt(i,s,o)}const Ls={},Os={},XHe={touchstart:!0,touchmove:!0};class YHe{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 QHe(t){for(let e in Ls){let n=Ls[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{JHe(t,r)&&!oF(t,r)&&(t.editable||!(r.type in Os))&&n(t,r)},XHe[e]?{passive:!0}:void 0)}Rs&&t.dom.addEventListener("input",()=>null),pR(t)}function vh(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function ZHe(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 pR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>oF(t,r))})}function oF(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function JHe(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 eVe(t,e){!oF(t,e)&&Ls[e.type]&&(t.editable||!(e.type in Os))&&Ls[e.type](t,e)}Os.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Sne(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(zu&&ms&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),_b&&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,Wf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||$He(t,n)?n.preventDefault():vh(t,"key")};Os.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Os.keypress=(t,e)=>{let n=e;if(Sne(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||nl&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof wn)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function QM(t){return{left:t.clientX,top:t.clientY}}function tVe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function lF(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function Wg(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 nVe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&on.isSelectable(r)?(Wg(t,new on(n)),!0):!1}function rVe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof on&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(on.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(Wg(t,on.create(t.state.doc,i)),!0):!1}function iVe(t,e,n,r,i){return lF(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?rVe(t,n):nVe(t,n))}function aVe(t,e,n,r){return lF(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function sVe(t,e,n,r){return lF(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||oVe(t,n,r)}function oVe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Wg(t,wn.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Wg(t,wn.create(r,l+1,l+1+o.content.size));else if(on.isSelectable(o))Wg(t,on.create(r,l));else continue;return!0}}function cF(t){return RN(t)}const _ne=nl?"metaKey":"ctrlKey";Ls.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=cF(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&tVe(n,t.input.lastClick)&&!n[_ne]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let o=t.posAtCoords(QM(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new lVe(t,o,n,!!r)):(s=="doubleClick"?aVe:sVe)(t,o.pos,o.inside,n)?n.preventDefault():vh(t,"pointer"))};class lVe{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[_ne],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);s=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&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof on&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&fl&&!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)),vh(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(()=>Ku(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(QM(e))),this.updateAllowDefault(e),this.allowDefault||!n?vh(this.view,"pointer"):iVe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Rs&&this.mightDrag&&!this.mightDrag.node.isAtom||ms&&!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)?(Wg(this.view,Ln.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):vh(this.view,"pointer")}move(e){this.updateAllowDefault(e),vh(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)}}Ls.touchstart=t=>{t.input.lastTouch=Date.now(),cF(t),vh(t,"pointer")};Ls.touchmove=t=>{t.input.lastTouch=Date.now(),vh(t,"pointer")};Ls.contextmenu=t=>cF(t);function Sne(t,e){return t.composing?!0:Rs&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const cVe=zu?5e3:-1;Os.compositionstart=Os.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof wn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),RN(t,!0),t.markCursor=null;else if(RN(t,!e.selection.empty),fl&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Nne(t,cVe)};Os.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++,Nne(t,20))};function Nne(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>RN(t),e))}function kne(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=dVe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function uVe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=nHe(e.focusNode,e.focusOffset),r=rHe(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;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 dVe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function RN(t,e=!1){if(!(zu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),kne(t),e||t.docView&&t.docView.dirty){let n=iF(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function hVe(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const L0=eo&&Rh<15||_b&&lHe<604;Ls.copy=Os.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=L0?null:n.clipboardData,o=r.content(),{dom:l,text:c}=sF(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):hVe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function fVe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function mVe(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?O0(t,r.value,null,i,e):O0(t,r.textContent,r.innerHTML,i,e)},50)}function O0(t,e,n,r,i){let s=gne(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,s||Bt.empty)))return!0;if(!s)return!1;let o=fVe(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Mne(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," "):""}Os.paste=(t,e)=>{let n=e;if(t.composing&&!zu)return;let r=L0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&O0(t,Mne(r),r.getData("text/html"),i,n)?n.preventDefault():mVe(t,n)};class Cne{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const pVe=nl?"altKey":"ctrlKey";function Ene(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[pVe]}Ls.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(QM(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof on?i.to-1:i.to))){if(r&&r.mightDrag)o=on.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(o=on.create(t.state.doc,h.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=sF(t,l);(!n.dataTransfer.files.length||!ms||ene>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(L0?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",L0||n.dataTransfer.setData("text/plain",u),t.dragging=new Cne(d,Ene(t,n),o)};Ls.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Os.dragover=Os.dragenter=(t,e)=>e.preventDefault();Os.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(QM(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=gne(t,Mne(n.dataTransfer),L0?null:n.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&Ene(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Bt.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?Dte(t.state.doc,s.pos,o):s.pos;c==null&&(c=s.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,p=u.doc;if(h?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(p))return;let m=u.doc.resolve(d);if(h&&on.isSelectable(o.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new on(m));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,b,v,S)=>x=S),u.setSelection(aF(t,m,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Ls.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())&&Ku(t)},20))};Ls.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)};Ls.beforeinput=(t,e)=>{if(ms&&zu&&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",s=>s(t,Wf(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 Os)Ls[t]=Os[t];function F0(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 LN{constructor(e,n){this.toDOM=e,this.spec=n||gm,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Es(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof LN&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&F0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Oh{constructor(e,n){this.attrs=e,this.spec=n||gm}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Es(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Oh&&F0(this.attrs,e.attrs)&&F0(this.spec,e.spec)}static is(e){return e.type instanceof Oh}destroy(){}}class uF{constructor(e,n){this.attrs=e,this.spec=n||gm}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Es(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof uF&&F0(this.attrs,e.attrs)&&F0(this.spec,e.spec)}destroy(){}}class Es{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Es(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 Es(e,e,new LN(n,r))}static inline(e,n,r,i){return new Es(e,n,new Oh(r,i))}static node(e,n,r,i){return new Es(e,n,new uF(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Oh}get widget(){return this.type instanceof LN}}const _g=[],gm={};class pi{constructor(e,n){this.local=e.length?e:_g,this.children=n.length?n:_g}static create(e,n){return n.length?ON(n,e,0,gm):us}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(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,s)}}map(e,n,r){return this==us||e.maps.length==0?this:this.mapInner(e,n,0,0,r||gm)}mapInner(e,n,r,i,s){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):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?gVe(this.children,o||[],e,n,r,i,s):o?new pi(o.sort(bm),_g):us}add(e,n){return n.length?this==us?pi.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,c)=>{let u=c+r,d;if(d=Tne(n,l,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<c;)s+=3;i[s]==c?i[s+2]=i[s+2].addInner(l,d,u+1):i.splice(s,0,c,c+l.nodeSize,ON(d,l,u+1,gm)),s+=3}});let o=Ane(s?jne(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new pi(o.length?this.local.concat(o).sort(bm):this.local,i||this.children)}remove(e){return e.length==0||this==us?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+n,c=r[s+1]+n;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>l&&h.to<c&&(e[d]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(o,l+1);u!=us?r[s+2]=u:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])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 pi(i,r):us}forChild(e,n){if(this==us)return this;if(n.isLeaf)return pi.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 s=e+1,o=s+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>s&&c.type instanceof Oh){let u=Math.max(s,c.from)-s,d=Math.min(o,c.to)-s;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new pi(i.sort(bm),_g);return r?new fh([l,r]):l}return r||us}eq(e){if(this==e)return!0;if(!(e instanceof pi)||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 dF(this.localsInner(e))}localsInner(e){if(this==us)return _g;if(e.inlineContent||!this.local.some(Oh.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Oh||n.push(this.local[r]);return n}forEachSet(e){e(this)}}pi.empty=new pi([],[]);pi.removeOverlap=dF;const us=pi.empty;class fh{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,gm));return fh.from(r)}forChild(e,n){if(n.isLeaf)return pi.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=us&&(s instanceof fh?r=r.concat(s.members):r.push(s))}return fh.from(r)}eq(e){if(!(e instanceof fh)||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 s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?dF(r?n:n.sort(bm)):_g}static from(e){switch(e.length){case 0:return us;case 1:return e[0];default:return new fh(e.every(n=>n instanceof pi)?e:e.reduce((n,r)=>n.concat(r instanceof pi?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function gVe(t,e,n,r,i,s,o){let l=t.slice();for(let u=0,d=s;u<n.maps.length;u++){let h=0;n.maps[u].forEach((p,m,x,y)=>{let b=y-x-(m-p);for(let v=0;v<l.length;v+=3){let S=l[v+1];if(S<0||p>S+d-h)continue;let k=l[v]+d-h;m>=k?l[v+1]=p<=k?-2:-1:p>=d&&b&&(l[v]+=b,l[v+1]+=b)}h+=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]+s),h=d-i;if(h<0||h>=r.content.size){c=!0;continue}let p=n.map(t[u+1]+s,-1),m=p-i,{index:x,offset:y}=r.content.findIndex(h),b=r.maybeChild(x);if(b&&y==h&&y+b.nodeSize==m){let v=l[u+2].mapInner(n,b,d+1,t[u]+s+1,o);v!=us?(l[u]=h,l[u+1]=m,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=bVe(l,t,e,n,i,s,o),d=ON(u,r,0,o);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,p=0;h<d.children.length;h+=3){let m=d.children[h];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[h],d.children[h+1],d.children[h+2])}}return new pi(e.sort(bm),l)}function Ane(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 Es(i.from+e,i.to+e,i.type))}return n}function bVe(t,e,n,r,i,s,o){function l(c,u){for(let d=0;d<c.local.length;d++){let h=c.local[d].map(r,i,u);h?n.push(h):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]+s+1);return n}function Tne(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function jne(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ON(t,e,n,r){let i=[],s=!1;e.forEach((l,c)=>{let u=Tne(t,l,c+n);if(u){s=!0;let d=ON(u,l,n+c+1,r);d!=us&&i.push(c,c+l.nodeSize,d)}});let o=Ane(s?jne(t):t,-n).sort(bm);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 pi(o,i):us}function bm(t,e){return t.from-e.from||t.to-e.to}function dF(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 s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),Z7(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Z7(e,i,r.copy(s.from,r.to)));break}}}return e}function Z7(t,e,n){for(;e<t.length&&bm(n,t[e])>0;)e++;t.splice(e,0,n)}function Hj(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=us&&e.push(r)}),t.cursorWrapper&&e.push(pi.create(t.state.doc,[t.cursorWrapper.deco])),fh.from(e)}const xVe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yVe=eo&&Rh<=11;class vVe{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 wVe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new vVe,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]);eo&&Rh<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),yVe&&(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,xVe)),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(V7(this.view)){if(this.suppressingSelectionUpdates)return Ku(this.view);if(eo&&Rh<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Bm(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 s=e.focusNode;s;s=wb(s))n.add(s);for(let s=e.anchorNode;s;s=wb(s))if(n.has(s)){r=s;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)&&V7(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let h=this.registerMutation(n[d],c);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(fl&&c.length){let d=c.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,p]=d;h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let p of d){let m=p.parentNode;m&&m.nodeName=="LI"&&(!h||NVe(e,h)!=m)&&p.remove()}}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&XM(r)&&(u=iF(e))&&u.eq(Ln.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ku(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),_Ve(e)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ku(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 h=e.addedNodes[d];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(eo&&Rh<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:p}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p)}let o=i&&i.parentNode==e.target?Qa(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?Qa(s):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 J7=new WeakMap,e9=!1;function _Ve(t){if(!J7.has(t)&&(J7.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=fl,e9)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."),e9=!0}}function t9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Bm(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function SVe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return t9(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?t9(t,n):null}function NVe(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 kVe(t,e,n){let{node:r,fromOffset:i,toOffset:s,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}],XM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ms&&t.input.lastKeyCode===8)for(let b=s;b>i;b--){let v=r.childNodes[b-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){s=b;break}if(!S||S.size)break}let h=t.state.doc,p=t.someProp("domParser")||Iy.fromSchema(t.state.schema),m=h.resolve(o),x=null,y=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:MVe,context:m});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 MVe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Rs&&/^(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||Rs&&/^(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 CVe=/^(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 EVe(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let M=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=iF(t,M);if(P&&!t.state.selection.eq(P)){if(ms&&zu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",j=>j(t,Wf(13,"Enter"))))return;let T=t.state.tr.setSelection(P);M=="pointer"?T.setMeta("pointer",!0):M=="key"&&T.scrollIntoView(),s&&T.setMeta("composition",s),t.dispatch(T)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=kVe(t,e,n),d=t.state.doc,h=d.slice(u.from,u.to),p,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,m="end"):(p=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let x=jVe(h.content,u.doc.content,u.from,p,m);if(x&&t.input.domChangeCount++,(_b&&t.input.lastIOSEnter>Date.now()-225||zu)&&i.some(M=>M.nodeType==1&&!CVe.test(M.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",M=>M(t,Wf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof wn&&!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 M=n9(t,t.state.doc,u.sel);if(M&&!M.eq(t.state.selection)){let P=t.state.tr.setSelection(M);s&&P.setMeta("composition",s),t.dispatch(P)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof wn&&(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)),eo&&Rh<=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),S=y.sameParent(b)&&y.parent.inlineContent&&v.end()>=x.endA;if((_b&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!S&&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",M=>M(t,Wf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&TVe(d,x.start,x.endA,y,b)&&t.someProp("handleKeyDown",M=>M(t,Wf(8,"Backspace")))){zu&&ms&&t.domObserver.suppressSelectionUpdates();return}ms&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),zu&&!S&&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(M){return M(t,Wf(13,"Enter"))})},20));let k=x.start,E=x.endA,N=M=>{let P=M||t.state.tr.replace(k,E,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let T=n9(t,P.doc,u.sel);T&&!(ms&&t.composing&&T.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==k||T.head==P.mapping.map(E)-1)||eo&&T.empty&&T.head==k)&&P.setSelection(T)}return s&&P.setMeta("composition",s),P.scrollIntoView()},A;if(S)if(y.pos==b.pos){eo&&Rh<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ku(t),20));let M=N(t.state.tr.delete(k,E)),P=d.resolve(x.start).marksAcross(d.resolve(x.endA));P&&M.ensureMarks(P),t.dispatch(M)}else if(x.endA==x.endB&&(A=AVe(y.parent.content.cut(y.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let M=N(t.state.tr);A.type=="add"?M.addMark(k,E,A.mark):M.removeMark(k,E,A.mark),t.dispatch(M)}else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let M=y.parent.textBetween(y.parentOffset,b.parentOffset),P=()=>N(t.state.tr.insertText(M,k,E));t.someProp("handleTextInput",T=>T(t,k,E,M,P))||t.dispatch(P())}else t.dispatch(N());else t.dispatch(N())}function n9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:aF(t,e.resolve(n.anchor),e.resolve(n.head))}function AVe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=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++)s=n[d].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(At.from(u).eq(t))return{mark:l,type:o}}function TVe(t,e,n,r,i){if(n-e<=i.pos-r.pos||Vj(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Vj(s,!0,!0));return!o.parent.isTextblock||o.pos>n||Vj(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Vj(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 s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function jVe(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==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,s-Math.min(o,l));r-=o+c-s}if(o<s&&t.size<e.size){let c=r<=s&&r>=o?s-r:0;s-=c,s&&s<e.size&&r9(e.textBetween(s-1,s+1))&&(s+=c?1:-1),l=s+(l-o),o=s}else if(l<s){let c=r<=s&&r>=l?s-r:0;s-=c,s&&s<t.size&&r9(t.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function r9(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 Pne{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 YHe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(l9),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=s9(this),a9(this),this.nodeViews=o9(this),this.docView=I7(this.state.doc,i9(this),Hj(this),this.dom,this),this.domObserver=new wVe(this,(r,i,s,o)=>EVe(this,r,i,s,o)),this.domObserver.start(),QHe(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&&pR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(l9),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,s=!1,o=!1;e.storedMarks&&this.composing&&(kne(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=o9(this);DVe(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&pR(this),this.editable=s9(this),a9(this);let c=Hj(this),u=i9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,u,c);(h||!e.selection.eq(i.selection))&&(o=!0);let p=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&dHe(this);if(o){this.domObserver.stop();let m=h&&(eo||ms)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&PVe(i.selection,e.selection);if(h){let x=ms?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=uVe(this)),(s||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=I7(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&LHe(this))?Ku(this,m):(fne(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():p&&hHe(p)}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 on){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&P7(this,n.getBoundingClientRect(),e)}else P7(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 s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Cne(e.slice,e.move,i<0?void 0:on.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 s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(eo){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&&fHe(this.dom),Ku(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 xHe(this,e)}coordsAtPos(e,n=1){return ane(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 SHe(this,n||this.state,e)}pasteHTML(e,n){return O0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return O0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return sF(this,e)}destroy(){this.docView&&(ZHe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Hj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,eHe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return eVe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Rs&&this.root.nodeType===11&&aHe(this.dom.ownerDocument)==this.dom&&SVe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Pne.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function i9(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"),[Es.node(0,t.state.doc.content.size,e)]}function a9(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:Es.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function s9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function PVe(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 o9(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 DVe(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 l9(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 Kh={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:"'"},FN={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},RVe=typeof navigator<"u"&&/Mac/.test(navigator.platform),LVe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Za=0;Za<10;Za++)Kh[48+Za]=Kh[96+Za]=String(Za);for(var Za=1;Za<=24;Za++)Kh[Za+111]="F"+Za;for(var Za=65;Za<=90;Za++)Kh[Za]=String.fromCharCode(Za+32),FN[Za]=String.fromCharCode(Za);for(var Gj in Kh)FN.hasOwnProperty(Gj)||(FN[Gj]=Kh[Gj]);function OVe(t){var e=RVe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||LVe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?FN:Kh)[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 FVe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),IVe=typeof navigator<"u"&&/Win/.test(navigator.platform);function zVe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,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))s=!0;else if(/^mod$/i.test(c))FVe?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),s&&(n="Shift-"+n),n}function UVe(t){let e=Object.create(null);for(let n in t)e[zVe(n)]=t[n];return e}function qj(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 BVe(t){return new yi({props:{handleKeyDown:Dne(t)}})}function Dne(t){let e=UVe(t);return function(n,r){let i=OVe(r),s,o=e[qj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[qj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(IVe&&r.ctrlKey&&r.altKey)&&(s=Kh[r.keyCode])&&s!=i){let l=e[qj(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var $Ve=Object.defineProperty,hF=(t,e)=>{for(var n in e)$Ve(t,n,{get:e[n],enumerable:!0})};function ZM(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=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 s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var JM=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,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(s);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:s}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),o.every(h=>h===!0)),d={...Object.fromEntries(Object.entries(n).map(([h,p])=>[h,(...x)=>{const y=this.buildProps(c,e),b=p(...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,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:ZM({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}},Rne={};hF(Rne,{blur:()=>HVe,clearContent:()=>VVe,clearNodes:()=>GVe,command:()=>qVe,createParagraphNear:()=>WVe,cut:()=>KVe,deleteCurrentNode:()=>XVe,deleteNode:()=>YVe,deleteRange:()=>QVe,deleteSelection:()=>ZVe,enter:()=>JVe,exitCode:()=>eGe,extendMarkRange:()=>tGe,first:()=>nGe,focus:()=>iGe,forEach:()=>aGe,insertContent:()=>sGe,insertContentAt:()=>cGe,joinBackward:()=>hGe,joinDown:()=>dGe,joinForward:()=>fGe,joinItemBackward:()=>mGe,joinItemForward:()=>pGe,joinTextblockBackward:()=>gGe,joinTextblockForward:()=>bGe,joinUp:()=>uGe,keyboardShortcut:()=>yGe,lift:()=>vGe,liftEmptyBlock:()=>wGe,liftListItem:()=>_Ge,newlineInCode:()=>SGe,resetAttributes:()=>NGe,scrollIntoView:()=>kGe,selectAll:()=>MGe,selectNodeBackward:()=>CGe,selectNodeForward:()=>EGe,selectParentNode:()=>AGe,selectTextblockEnd:()=>TGe,selectTextblockStart:()=>jGe,setContent:()=>PGe,setMark:()=>YGe,setMeta:()=>QGe,setNode:()=>ZGe,setNodeSelection:()=>JGe,setTextDirection:()=>eqe,setTextSelection:()=>tqe,sinkListItem:()=>nqe,splitBlock:()=>rqe,splitListItem:()=>iqe,toggleList:()=>aqe,toggleMark:()=>sqe,toggleNode:()=>oqe,toggleWrap:()=>lqe,undoInputRule:()=>cqe,unsetAllMarks:()=>uqe,unsetMark:()=>dqe,unsetTextDirection:()=>hqe,updateAttributes:()=>fqe,wrapIn:()=>mqe,wrapInList:()=>pqe});var HVe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),VVe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),GVe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,h=u.resolve(d.map(c)),p=u.resolve(d.map(c+l.nodeSize)),m=h.blockRange(p);if(!m)return;const x=Yb(m);if(l.type.isTextblock){const{defaultType:y}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(m.start,y)}(x||x===0)&&e.lift(m,x)})}),!0},qVe=t=>e=>t(e),WVe=()=>({state:t,dispatch:e})=>Xte(t,e),KVe=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new wn(r.doc.resolve(Math.max(o-1,0)))),!0},XVe=()=>({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 s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),c=i.after(s);t.delete(l,c).scrollIntoView()}return!0}return!1};function aa(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 YVe=t=>({tr:e,state:n,dispatch:r})=>{const i=aa(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const c=s.before(o),u=s.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},QVe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},ZVe=()=>({state:t,dispatch:e})=>ZO(t,e),JVe=()=>({commands:t})=>t.keyboardShortcut("Enter"),eGe=()=>({state:t,dispatch:e})=>z$e(t,e);function fF(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function IN(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:fF(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Lne(t,e,n={}){return t.find(r=>r.type===e&&IN(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function c9(t,e,n={}){return!!Lne(t,e,n)}function mF(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),!Lne([...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&&c9([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&c9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function md(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 tGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=md(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const h=mF(c,s,e);if(h&&h.from<=u&&h.to>=d){const p=wn.create(o,h.from,h.to);n.setSelection(p)}}return!0},nGe=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 One(t){return t instanceof wn}function rm(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Fne(t,e=null){if(!e)return null;const n=Ln.atStart(t),r=Ln.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?wn.create(t,rm(0,i,s),rm(t.content.size,i,s)):wn.create(t,rm(e,i,s),rm(e,i,s))}function rGe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function pF(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var iGe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(pF()||rGe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!One(n.state.selection))return o(),!0;const l=Fne(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return s&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},aGe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),sGe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Ine=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&&Ine(r)}return t};function xS(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 Ine(n)}function I0(t,e,n){if(t instanceof Dh||t instanceof At)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return At.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),I0("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new _te({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(o=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?Iy.fromSchema(c).parseSlice(xS(t),n.parseOptions):Iy.fromSchema(c).parse(xS(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Iy.fromSchema(e);return n.slice?s.parseSlice(xS(t),n.parseOptions).content:s.parse(xS(t),n.parseOptions)}return I0("",e,n)}function oGe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof ja||i instanceof Da))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(Ln.near(t.doc.resolve(o),n))}var lGe=t=>!("type"in t),cGe=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=b=>{s.emit("contentError",{editor:s,error:b,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{I0(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){c(b)}try{l=I0(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(b){return c(b),!1}let{from:d,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,m=!0;if((lGe(l)?l:[l]).forEach(b=>{b.check(),p=p?b.isText&&b.marks.length===0:!1,m=m?b.isBlock:!1}),d===h&&m){const{parent:b}=r.doc.resolve(d);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(d-=1,h+=1)}let y;if(p){if(Array.isArray(e))y=e.map(b=>b.text||"").join("");else if(e instanceof At){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,h)}else{y=l;const b=r.doc.resolve(d),v=b.node(),S=b.parentOffset===0,k=v.isText||v.isTextblock,E=v.content.size>0;S&&k&&E&&(d=Math.max(0,d-1)),r.replaceWith(d,h,y)}n.updateSelection&&oGe(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},uGe=()=>({state:t,dispatch:e})=>O$e(t,e),dGe=()=>({state:t,dispatch:e})=>F$e(t,e),hGe=()=>({state:t,dispatch:e})=>$te(t,e),fGe=()=>({state:t,dispatch:e})=>qte(t,e),mGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=qM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},pGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=qM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},gGe=()=>({state:t,dispatch:e})=>R$e(t,e),bGe=()=>({state:t,dispatch:e})=>L$e(t,e);function zne(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function xGe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,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))s=!0;else if(/^mod$/i.test(c))pF()||zne()?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}`),s&&(n=`Shift-${n}`),n}var yGe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=xGe(t).split(/-(?!$)/),o=s.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.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 Xh(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?aa(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(h,p)=>{if(h.isText)return;const m=Math.max(r,p),x=Math.min(i,p+h.nodeSize);l.push({node:h,from:m,to:x})});const c=i-r,u=l.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>IN(h.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((h,p)=>h+p.to-p.from,0)>=c}var vGe=(t,e={})=>({state:n,dispatch:r})=>{const i=aa(t,n.schema);return Xh(n,i,e)?I$e(n,r):!1},wGe=()=>({state:t,dispatch:e})=>Yte(t,e),_Ge=t=>({state:e,dispatch:n})=>{const r=aa(t,e.schema);return Y$e(r)(e,n)},SGe=()=>({state:t,dispatch:e})=>Kte(t,e);function eC(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function u9(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 NGe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=eC(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=aa(t,r.schema)),l==="mark"&&(o=md(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,h)=>{s&&s===d.type&&(c=!0,i&&n.setNodeMarkup(h,void 0,u9(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(p=>{o===p.type&&(c=!0,i&&n.addMark(h,h+d.nodeSize,o.create(u9(p.attrs,e))))})})}),c},kGe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),MGe=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ao(t.doc);t.setSelection(n)}return!0},CGe=()=>({state:t,dispatch:e})=>Vte(t,e),EGe=()=>({state:t,dispatch:e})=>Wte(t,e),AGe=()=>({state:t,dispatch:e})=>$$e(t,e),TGe=()=>({state:t,dispatch:e})=>G$e(t,e),jGe=()=>({state:t,dispatch:e})=>V$e(t,e);function gR(t,e,n={},r={}){return I0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var PGe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:c}=s;if(r.preserveWhitespace!=="full"){const u=gR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Une(t,e){const n=md(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(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 Bne(t,e){const n=new Ite(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function DGe(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 RGe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function LGe(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 tC(t){return e=>LGe(e.$from,t)}function rn(t,e,n){return t.config[e]===void 0&&t.parent?rn(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?rn(t.parent,e,n):null}):t.config[e]}function gF(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=rn(e,"addExtensions",n);return r?[e,...gF(r())]:e}).flat(10)}function bF(t,e){const n=Qm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function $ne(t){return typeof t=="function"}function vr(t,e=void 0,...n){return $ne(t)?e?t.bind(e)(...n):t(...n):t}function OGe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Sb(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 Hne(t){const e=[],{nodeExtensions:n,markExtensions:r}=Sb(t),i=[...n,...r],s={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=rn(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...s,...m}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=rn(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,h])=>{const p={...s,...h};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:o.name,name:d,attribute:p})})}),e}function Ri(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).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=s?s.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[h,p]=d.split(":").map(m=>m.trim());u.set(h,p)}),l.forEach(d=>{const[h,p]=d.split(":").map(m=>m.trim());u.set(h,p)}),r[i]=Array.from(u.entries()).map(([d,h])=>`${d}: ${h}`).join("; ")}else r[i]=s}),r},{})}function zN(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)=>Ri(n,r),{})}function FGe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function d9(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((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):FGe(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function h9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&OGe(n)?!1:n!=null))}function f9(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 IGe(t,e){var n;const r=Hne(t),{nodeExtensions:i,markExtensions:s}=Sb(t),o=(n=i.find(u=>rn(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((v,S)=>{const k=rn(S,"extendNodeSchema",h);return{...v,...k?k(u):{}}},{}),m=h9({...p,content:vr(rn(u,"content",h)),marks:vr(rn(u,"marks",h)),group:vr(rn(u,"group",h)),inline:vr(rn(u,"inline",h)),atom:vr(rn(u,"atom",h)),selectable:vr(rn(u,"selectable",h)),draggable:vr(rn(u,"draggable",h)),code:vr(rn(u,"code",h)),whitespace:vr(rn(u,"whitespace",h)),linebreakReplacement:vr(rn(u,"linebreakReplacement",h)),defining:vr(rn(u,"defining",h)),isolating:vr(rn(u,"isolating",h)),attrs:Object.fromEntries(d.map(f9))}),x=vr(rn(u,"parseHTML",h));x&&(m.parseDOM=x.map(v=>d9(v,d)));const y=rn(u,"renderHTML",h);y&&(m.toDOM=v=>y({node:v,HTMLAttributes:zN(v,d)}));const b=rn(u,"renderText",h);return b&&(m.toText=b),[u.name,m]})),c=Object.fromEntries(s.map(u=>{const d=r.filter(b=>b.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((b,v)=>{const S=rn(v,"extendMarkSchema",h);return{...b,...S?S(u):{}}},{}),m=h9({...p,inclusive:vr(rn(u,"inclusive",h)),excludes:vr(rn(u,"excludes",h)),group:vr(rn(u,"group",h)),spanning:vr(rn(u,"spanning",h)),code:vr(rn(u,"code",h)),attrs:Object.fromEntries(d.map(f9))}),x=vr(rn(u,"parseHTML",h));x&&(m.parseDOM=x.map(b=>d9(b,d)));const y=rn(u,"renderHTML",h);return y&&(m.toDOM=b=>y({mark:b,HTMLAttributes:zN(b,d)})),[u.name,m]}));return new _te({topNode:o,nodes:l,marks:c})}function zGe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function xF(t){return t.sort((n,r)=>{const i=rn(n,"priority")||100,s=rn(r,"priority")||100;return i>s?-1:i<s?1:0})}function Vne(t){const e=xF(gF(t)),n=zGe(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 Gne(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
  8168. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,h)=>{var p;c.isBlock&&u>r&&(l+=s);const m=o?.[c.type.name];if(m)return d&&(l+=m({node:c,pos:u,parent:d,index:h,range:e})),!1;c.isText&&(l+=(p=c?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),l}function UGe(t,e){const n={from:0,to:t.content.size};return Gne(t,n,e)}function qne(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function BGe(t,e){const n=aa(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Wne(t,e){const n=eC(typeof e=="string"?e:e.name,t.schema);return n==="node"?BGe(t,e):n==="mark"?Une(t,e):{}}function $Ge(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 HGe(t){const e=$Ge(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function Kne(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[s];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(s).map(l,-1),d=e.slice(s).map(c),h=e.invert().map(u,-1),p=e.invert().map(d);r.push({oldRange:{from:h,to:p},newRange:{from:u,to:d}})})}),HGe(r)}function yF(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=mF(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var VGe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function Wj(t,e){return e.nodes[t]||e.marks[t]||null}function JS(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var GGe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),n};function bR(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?md(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>IN(h.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:h,$to:p})=>{const m=h.pos,x=p.pos;t.doc.nodesBetween(m,x,(y,b)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(m,b),S=Math.min(x,b+y.nodeSize),k=S-v;o+=k,l.push(...y.marks.map(E=>({mark:E,from:v,to:S})))})}),o===0)return!1;const c=l.filter(h=>s?s.name===h.mark.type.name:!0).filter(h=>IN(h.mark.attrs,n,{strict:!1})).reduce((h,p)=>h+p.to-p.from,0),u=l.filter(h=>s?h.mark.type!==s&&h.mark.type.excludes(s):!0).reduce((h,p)=>h+p.to-p.from,0);return(c>0?c+u:c)>=o}function qGe(t,e,n={}){if(!e)return Xh(t,null,n)||bR(t,null,n);const r=eC(e,t.schema);return r==="node"?Xh(t,e,n):r==="mark"?bR(t,e,n):!1}var WGe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=tC(l=>l.type.name===e)(t.selection);if(!s)return!1;const o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},KGe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function m9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function p9(t,e){const{nodeExtensions:n}=Sb(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=vr(rn(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function nC(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(s=>{i!==!1&&(nC(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Xne(t){return t instanceof on}function XGe(t,e,n){var r;const{selection:i}=e;let s=null;if(One(i)&&(s=i.$cursor),s){const l=(r=t.storedMarks)!=null?r:s.marks();return s.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,h,p)=>{if(u)return!1;if(d.isInline){const m=!p||p.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=m&&x}return!u}),u})}var YGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,c=md(t,r.schema);if(i)if(o){const u=Une(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;r.doc.nodesBetween(d,h,(p,m)=>{const x=Math.max(m,d),y=Math.min(m+p.nodeSize,h);p.marks.find(v=>v.type===c)?p.marks.forEach(v=>{c===v.type&&n.addMark(x,y,c.create({...v.attrs,...e}))}):n.addMark(x,y,c.create(e))})});return XGe(r,n,c)},QGe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),ZGe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=aa(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>A7(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>A7(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},JGe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=rm(t,0,r.content.size),s=on.create(r,i);e.setSelection(s)}return!0},eqe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=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=s.from,l=s.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},tqe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=wn.atStart(r).from,l=wn.atEnd(r).to,c=rm(i,o,l),u=rm(s,o,l),d=wn.create(r,c,u);e.setSelection(d)}return!0},nqe=t=>({state:e,dispatch:n})=>{const r=aa(t,e.schema);return J$e(r)(e,n)};function g9(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 rqe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:c}=s,u=i.extensionManager.attributes,d=JS(u,l.node().type.name,l.node().attrs);if(s instanceof on&&s.node.isBlock)return!l.parentOffset||!Wu(o,l.pos)?!1:(r&&(t&&g9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:DGe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=h&&p?[{type:p,attrs:d}]:void 0,x=Wu(e.doc,e.mapping.map(l.pos),1,m);if(!m&&!x&&Wu(e.doc,e.mapping.map(l.pos),1,p?[{type:p}]:void 0)&&(x=!0,m=p?[{type:p,attrs:d}]:void 0),r){if(x&&(s instanceof wn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,m),p&&!h&&!l.parentOffset&&l.parent.type!==p)){const y=e.mapping.map(l.before()),b=e.doc.resolve(y);l.node(-1).canReplaceWith(b.index(),b.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}t&&g9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},iqe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=aa(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 h=c.node(-1);if(h.type!==l)return!1;const p=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let v=At.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let P=c.depth-S;P>=c.depth-3;P-=1)v=At.from(c.node(P).copy(v));const k=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,E={...JS(p,c.node().type.name,c.node().attrs),...e},N=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(E))||void 0;v=v.append(At.from(l.createAndFill(null,N)||void 0));const A=c.before(c.depth-(S-1));n.replace(A,c.after(-k),new Bt(v,4-S,0));let M=-1;n.doc.nodesBetween(A,n.doc.content.size,(P,T)=>{if(M>-1)return!1;P.isTextblock&&P.content.size===0&&(M=T+1)}),M>-1&&n.setSelection(wn.near(n.doc.resolve(M))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?h.contentMatchAt(0).defaultType:null,x={...JS(p,h.type.name,h.attrs),...e},y={...JS(p,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const b=m?[{type:l,attrs:x},{type:m,attrs:y}]:[{type:l,attrs:x}];if(!Wu(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:S}=r,{splittableMarks:k}=s.extensionManager,E=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!E||!i)return!0;const N=E.filter(A=>k.includes(A.type.name));n.ensureMarks(N)}return!0},Kj=(t,e)=>{const n=tC(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&&ef(t.doc,n.pos)&&t.join(n.pos),!0},Xj=(t,e)=>{const n=tC(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&&ef(t.doc,r)&&t.join(r),!0},aqe=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:h,splittableMarks:p}=i.extensionManager,m=aa(t,o.schema),x=aa(e,o.schema),{selection:y,storedMarks:b}=o,{$from:v,$to:S}=y,k=v.blockRange(S),E=b||y.$to.parentOffset&&y.$from.marks();if(!k)return!1;const N=tC(A=>p9(A.type.name,h))(y);if(k.depth>=1&&N&&k.depth-N.depth<=1){if(N.node.type===m)return u.liftListItem(x);if(p9(N.node.type.name,h)&&m.validContent(N.node.content)&&l)return c().command(()=>(s.setNodeMarkup(N.pos,m),!0)).command(()=>Kj(s,m)).command(()=>Xj(s,m)).run()}return!n||!E||!l?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>Kj(s,m)).command(()=>Xj(s,m)).run():c().command(()=>{const A=d().wrapInList(m,r),M=E.filter(P=>p.includes(P.type.name));return s.ensureMarks(M),A?!0:u.clearNodes()}).wrapInList(m,r).command(()=>Kj(s,m)).command(()=>Xj(s,m)).run()},sqe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=md(t,r.schema);return bR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},oqe=(t,e,n={})=>({state:r,commands:i})=>{const s=aa(t,r.schema),o=aa(e,r.schema),l=Xh(r,s,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(s,{...c,...n})},lqe=(t,e={})=>({state:n,commands:r})=>{const i=aa(t,n.schema);return Xh(n,i,e)?r.lift(i):r.wrapIn(i,e)},cqe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.tr,l=s.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(s.text){const c=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,c))}else o.delete(s.from,s.to)}return!0}}return!1},uqe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},dqe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=md(t,r.schema),{$from:u,empty:d,ranges:h}=l;if(!i)return!0;if(d&&o){let{from:p,to:m}=l;const x=(s=u.marks().find(b=>b.type===c))==null?void 0:s.attrs,y=mF(u,c,x);y&&(p=y.from,m=y.to),n.removeMark(p,m,c)}else h.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},hqe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},fqe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=eC(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=aa(t,r.schema)),l==="mark"&&(o=md(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;let p,m,x,y;n.selection.empty?r.doc.nodesBetween(d,h,(b,v)=>{s&&s===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,h),p=v,m=b)}):r.doc.nodesBetween(d,h,(b,v)=>{v<d&&s&&s===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,h),p=v,m=b),v>=d&&v<=h&&(s&&s===b.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...b.attrs,...e})),o&&b.marks.length&&b.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const k=Math.max(v,d),E=Math.min(v+b.nodeSize,h);n.addMark(k,E,o.create({...S.attrs,...e}))}}))}),m&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(b=>{o===b.type&&i&&n.addMark(x,y,o.create({...b.attrs,...e}))}))}),c},mqe=(t,e={})=>({state:n,dispatch:r})=>{const i=aa(t,n.schema);return q$e(i,e)(n,r)},pqe=(t,e={})=>({state:n,dispatch:r})=>{const i=aa(t,n.schema);return W$e(i,e)(n,r)},gqe=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={}}},rC=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},bqe=(t,e)=>{if(fF(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 yS(t){var e;const{editor:n,from:r,to:i,text:s,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(p=>p.type.spec.code))return!1;let d=!1;const h=GGe(u)+s;return o.forEach(p=>{if(d)return;const m=bqe(h,p.find);if(!m)return;const x=c.state.tr,y=ZM({state:c.state,transaction:x}),b={from:r-(m[0].length-s.length),to:i},{commands:v,chain:S,can:k}=new JM({editor:n,state:y});p.handler({state:y,range:b,match:m,commands:v,chain:S,can:k})===null||!x.steps.length||(p.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:s}),c.dispatch(x),d=!0)}),d}function xqe(t){const{editor:e,rules:n}=t,r=new yi({state:{init(){return null},apply(i,s,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=bF(At.from(d),o.schema);const{from:h}=c,p=h+d.length;yS({editor:e,from:h,to:p,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return yS({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&yS({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?yS({editor:e,from:o.pos,to:o.pos,text:`
  8169. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function yqe(t){return Object.prototype.toString.call(t).slice(8,-1)}function vS(t){return yqe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Yne(t,e){const n={...t};return vS(t)&&vS(e)&&Object.keys(e).forEach(r=>{vS(e[r])&&vS(t[r])?n[r]=Yne(t[r],e[r]):n[r]=e[r]}),n}var vF=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{...vr(rn(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...vr(rn(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Yne(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}},nf=class Qne extends vF{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Qne(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 vqe(t){return typeof t=="number"}var wqe=class{constructor(t){this.find=t.find,this.handler=t.handler}},_qe=(t,e,n)=>{if(fF(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function Sqe(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new JM({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(m,x)=>{var y,b,v,S,k;if((b=(y=m.type)==null?void 0:y.spec)!=null&&b.code||!(m.isText||m.isTextblock||m.isInline))return;const E=(k=(S=(v=m.content)==null?void 0:v.size)!=null?S:m.nodeSize)!=null?k:0,N=Math.max(r,x),A=Math.min(i,x+E);if(N>=A)return;const M=m.isText?m.text||"":m.textBetween(N-x,A-x,void 0,"");_qe(M,s.find,o).forEach(T=>{if(T.index===void 0)return;const j=N+T.index+1,z=j+T[0].length,F={from:n.tr.mapping.map(j),to:n.tr.mapping.map(z)},$=s.handler({state:n,range:F,match:T,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});h.push($)})}),h.every(m=>m!==null)}var wS=null,Nqe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function kqe(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!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:h,to:p,rule:m,pasteEvt:x})=>{const y=d.tr,b=ZM({state:d,transaction:y});if(!(!Sqe({editor:e,state:b,from:Math.max(h-1,0),to:p.b-1,rule:m,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 yi({view(h){const p=x=>{var y;r=(y=h.dom.parentElement)!=null&&y.contains(x.target)?h.dom.parentElement:null,r&&(wS=e)},m=()=>{wS&&(wS=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(h,p)=>{if(s=r===h.dom.parentElement,l=p,!s){const m=wS;m?.isEditable&&setTimeout(()=>{const x=m.state.selection;x&&m.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(h,p)=>{var m;const x=(m=p.clipboardData)==null?void 0:m.getData("text/html");return o=p,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(h,p,m)=>{const x=h[0],y=x.getMeta("uiEvent")==="paste"&&!i,b=x.getMeta("uiEvent")==="drop"&&!s,v=x.getMeta("applyPasteRules"),S=!!v;if(!y&&!b&&!S)return;if(S){let{text:N}=v;typeof N=="string"?N=N:N=bF(At.from(N),m.schema);const{from:A}=v,M=A+N.length,P=Nqe(N);return c({rule:d,state:m,from:A,to:{b:M},pasteEvt:P})}const k=p.doc.content.findDiffStart(m.doc.content),E=p.doc.content.findDiffEnd(m.doc.content);if(!(!vqe(k)||!E||k===E.b))return c({rule:d,state:m,from:k,to:E,pasteEvt:o})}}))}var iC=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Vne(t),this.schema=IGe(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:Wj(e.name,this.schema)},r=rn(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return xF([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Wj(r.name,this.schema)},s=[],o=rn(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&rn(r,"exitable",i)&&(l.ArrowRight=()=>nf.handleExit({editor:t,mark:r})),o){const p=Object.fromEntries(Object.entries(o()).map(([m,x])=>[m,()=>x({editor:t})]));l={...l,...p}}const c=BVe(l);s.push(c);const u=rn(r,"addInputRules",i);if(m9(r,t.options.enableInputRules)&&u){const p=u();if(p&&p.length){const m=xqe({editor:t,rules:p}),x=Array.isArray(m)?m:[m];s.push(...x)}}const d=rn(r,"addPasteRules",i);if(m9(r,t.options.enablePasteRules)&&d){const p=d();if(p&&p.length){const m=kqe({editor:t,rules:p});s.push(...m)}}const h=rn(r,"addProseMirrorPlugins",i);if(h){const p=h();s.push(...p)}return s})}get attributes(){return Hne(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Sb(this.extensions);return Object.fromEntries(e.filter(n=>!!rn(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:aa(n.name,this.schema)},s=rn(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(c,u,d,h,p)=>{const m=zN(c,r);return o({node:c,view:u,getPos:d,decorations:h,innerDecorations:p,editor:t,extension:n,HTMLAttributes:m})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Sb(this.extensions);return Object.fromEntries(e.filter(n=>!!rn(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:md(n.name,this.schema)},s=rn(n,"addMarkView",i);if(!s)return[];const o=(l,c,u)=>{const d=zN(l,r);return s()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:h=>{Uqe(l,t,h)}})};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:Wj(e.name,this.schema)};e.type==="mark"&&((n=vr(rn(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=rn(e,"onBeforeCreate",r),s=rn(e,"onCreate",r),o=rn(e,"onUpdate",r),l=rn(e,"onSelectionUpdate",r),c=rn(e,"onTransaction",r),u=rn(e,"onFocus",r),d=rn(e,"onBlur",r),h=rn(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),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),h&&this.editor.on("destroy",h)})}};iC.resolve=Vne;iC.sort=xF;iC.flatten=gF;var Mqe={};hF(Mqe,{ClipboardTextSerializer:()=>Jne,Commands:()=>ere,Delete:()=>tre,Drop:()=>nre,Editable:()=>rre,FocusEvents:()=>are,Keymap:()=>sre,Paste:()=>ore,Tabindex:()=>lre,TextDirection:()=>cre,focusEventsPluginKey:()=>ire});var Lr=class Zne extends vF{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Zne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Jne=Lr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new yi({key:new va("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(d=>d.$from.pos)),l=Math.max(...s.map(d=>d.$to.pos)),c=qne(n);return Gne(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),ere=Lr.create({name:"commands",addCommands(){return{...Rne}}}),tre=Lr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{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=Bne(t.before,[t,...e]);Kne(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(x,y)=>{const b=y+x.nodeSize-2,v=m.oldRange.from<=y&&b<=m.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:m.oldRange,newRange:m.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const p=d.mapping;d.steps.forEach((m,x)=>{var y,b;if(m instanceof ql){const v=p.slice(x).map(m.from,-1),S=p.slice(x).map(m.to),k=p.invert().map(v,-1),E=p.invert().map(S),N=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(M=>M.eq(m.mark)),A=(b=d.doc.nodeAt(S))==null?void 0:b.marks.some(M=>M.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:k,to:E},newRange:{from:v,to:S},partial:!!(A||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(s,0):s()}}),nre=Lr.create({name:"drop",addProseMirrorPlugins(){return[new yi({key:new va("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),rre=Lr.create({name:"editable",addProseMirrorPlugins(){return[new yi({key:new va("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ire=new va("focusEvents"),are=Lr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new yi({key:ire,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}}}})]}}),sre=Lr.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:h}=c,{pos:p,parent:m}=h,x=h.parent.isTextblock&&p>0?l.doc.resolve(p-1):h,y=x.parent.type.spec.isolating,b=h.pos-h.parentOffset,v=y&&x.parent.childCount===1?b===h.pos:Ln.atStart(u).from===p;return!d||!m.type.isTextblock||m.textContent.length||!v||v&&h.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},s={...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 pF()||zne()?s:i},addProseMirrorPlugins(){return[new yi({key:new va("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:s,from:o,to:l}=e.selection,c=Ln.atStart(e.doc).from,u=Ln.atEnd(e.doc).to;if(s||!(o===c&&l===u)||!nC(n.doc))return;const p=n.tr,m=ZM({state:n,transaction:p}),{commands:x}=new JM({editor:this.editor,state:m});if(x.clearNodes(),!!p.steps.length)return p}})]}}),ore=Lr.create({name:"paste",addProseMirrorPlugins(){return[new yi({key:new va("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),lre=Lr.create({name:"tabindex",addProseMirrorPlugins(){return[new yi({key:new va("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),cre=Lr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Sb(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 yi({key:new va("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),Cqe=class Sg{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 Sg(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 Sg(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 Sg(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=this.pos+r+(s?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 Sg(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Sg(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 s=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(s[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 s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.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)}},Eqe=`.ProseMirror {
  8170. position: relative;
  8171. }
  8172. .ProseMirror {
  8173. word-wrap: break-word;
  8174. white-space: pre-wrap;
  8175. white-space: break-spaces;
  8176. -webkit-font-variant-ligatures: none;
  8177. font-variant-ligatures: none;
  8178. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8179. }
  8180. .ProseMirror [contenteditable="false"] {
  8181. white-space: normal;
  8182. }
  8183. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8184. white-space: pre-wrap;
  8185. }
  8186. .ProseMirror pre {
  8187. white-space: pre-wrap;
  8188. }
  8189. img.ProseMirror-separator {
  8190. display: inline !important;
  8191. border: none !important;
  8192. margin: 0 !important;
  8193. width: 0 !important;
  8194. height: 0 !important;
  8195. }
  8196. .ProseMirror-gapcursor {
  8197. display: none;
  8198. pointer-events: none;
  8199. position: absolute;
  8200. margin: 0;
  8201. }
  8202. .ProseMirror-gapcursor:after {
  8203. content: "";
  8204. display: block;
  8205. position: absolute;
  8206. top: -2px;
  8207. width: 20px;
  8208. border-top: 1px solid black;
  8209. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8210. }
  8211. @keyframes ProseMirror-cursor-blink {
  8212. to {
  8213. visibility: hidden;
  8214. }
  8215. }
  8216. .ProseMirror-hideselection *::selection {
  8217. background: transparent;
  8218. }
  8219. .ProseMirror-hideselection *::-moz-selection {
  8220. background: transparent;
  8221. }
  8222. .ProseMirror-hideselection * {
  8223. caret-color: transparent;
  8224. }
  8225. .ProseMirror-focused .ProseMirror-gapcursor {
  8226. display: block;
  8227. }`;function Aqe(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 Tqe=class extends gqe{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:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Fne(e,this.options.autofocus);this.editorState=Pg.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=Aqe(Eqe,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=$ne(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 s=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(s))}),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?[rre,Jne.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),ere,are,sre,lre,nre,ore,tre,cre.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new iC(r,this)}createCommandManager(){this.commandManager=new JM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=gR(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=gR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Pne(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),s=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)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Wne(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return qGe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return bF(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8228. `,textSerializers:n={}}=t||{};return UGe(this.state.doc,{blockSeparator:e,textSerializers:{...qne(this.schema),...n}})}get isEmpty(){return nC(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 Cqe(e,this)}get $doc(){return this.$pos(0)}};function Nb(t){return new rC({find:t.find,handler:({state:e,range:n,match:r})=>{const i=vr(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=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(yF(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&s.delete(d,n.to),u>n.from&&s.delete(n.from+c,u);const p=n.from+c+o.length;s.addMark(n.from+c,p,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function ure(t){return new rC({find:t.find,handler:({state:e,range:n,match:r})=>{const i=vr(t.getAttributes,void 0,r)||{},{tr:s}=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 h=r[0][r[0].length-1];s.insertText(h,o+r[0].length-1),s.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;s.insert(u,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function xR(t){return new rC({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=vr(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,s)},undoable:t.undoable})}function kb(t){return new rC({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=vr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&YO(c,t.type,s);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:h,storedMarks:p}=e,{splittableMarks:m}=t.editor.extensionManager,x=p||h.$to.parentOffset&&h.$from.marks();if(x){const y=x.filter(b=>m.includes(b.type.name));o.ensureMarks(y)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,s).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&ef(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var jqe=t=>"touches"in t,Pqe=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,s;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),(s=t.options)!=null&&s.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"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(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,jqe(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),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return s?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+(s?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,s,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),(s=this.maxSize)!=null&&s.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 Dqe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof on){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var Rqe={};hF(Rqe,{createAtomBlockMarkdownSpec:()=>Lqe,createBlockMarkdownSpec:()=>Oqe,createInlineMarkdownSpec:()=>zqe,parseAttributes:()=>wF,parseIndentedBlocks:()=>yR,renderNestedMarkdownContent:()=>SF,serializeAttributes:()=>_F});function wF(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 s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var h;const p=parseInt(((h=d.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),m=n[p];m&&(e[u]=m.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 _F(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 Lqe(t){const{nodeName:e,name:n,parseAttributes:r=wF,serializeAttributes:i=_F,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const h={};return l.forEach(p=>{p in d&&(h[p]=d[p])}),h};return{parseMarkdown:(d,h)=>{const p={...s,...d.attributes};return h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(d){var h;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),m=(h=d.match(p))==null?void 0:h.index;return m!==void 0?m:-1},tokenize(d,h,p){const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(m);if(!x)return;const y=x[1]||"",b=r(y);if(!o.find(S=>!(S in b)))return{type:e,raw:x[0],attributes:b}}},renderMarkdown:d=>{const h=u(d.attrs||{}),p=i(h),m=p?` {${p}}`:"";return`:::${c}${m} :::`}}}function Oqe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=wF,serializeAttributes:s=_F,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=h=>{if(!c)return h;const p={};return c.forEach(m=>{m in h&&(p[m]=h[m])}),p};return{parseMarkdown:(h,p)=>{let m;if(r){const y=r(h);m=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?m=p.parseChildren(h.tokens||[]):m=p.parseInline(h.tokens||[]);const x={...o,...h.attributes};return p.createNode(e,x,m)},markdownTokenizer:{name:e,level:"block",start(h){var p;const m=new RegExp(`^:::${u}`,"m"),x=(p=h.match(m))==null?void 0:p.index;return x!==void 0?x:-1},tokenize(h,p,m){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=h.match(y);if(!b)return;const[v,S=""]=b,k=i(S);let E=1;const N=v.length;let A="";const M=/^:::([\w-]*)(\s.*)?/gm,P=h.slice(N);for(M.lastIndex=0;;){const T=M.exec(P);if(T===null)break;const j=T.index,z=T[1];if(!((x=T[2])!=null&&x.endsWith(":::"))){if(z)E+=1;else if(E-=1,E===0){const F=P.slice(0,j);A=F.trim();const $=h.slice(0,N+j+T[0].length);let D=[];if(A)if(l==="block")for(D=m.blockTokens(F),D.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=m.inlineTokens(H.text))});D.length>0;){const H=D[D.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))D.pop();else break}else D=m.inlineTokens(A);return{type:e,raw:$,attributes:k,content:A,tokens:D}}}}}},renderMarkdown:(h,p)=>{const m=d(h.attrs||{}),x=s(m),y=x?` {${x}}`:"",b=p.renderChildren(h.content||[],`
  8229. `);return`:::${u}${y}
  8230. ${b}
  8231. :::`}}}function Fqe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function Iqe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function zqe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Fqe,serializeAttributes:s=Iqe,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=p=>{if(!c)return p;const m={};return c.forEach(x=>{x in p&&(m[x]=p[x])}),m},h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,m)=>{const x={...o,...p.attributes};if(l)return m.createNode(e,x);const y=r?r(p):p.content||"";return y?m.createNode(e,x,[m.createTextNode(y)]):m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(p){const m=l?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),x=p.match(m),y=x?.index;return y!==void 0?y:-1},tokenize(p,m,x){const y=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),b=p.match(y);if(!b)return;let v="",S="";if(l){const[,E]=b;S=E}else{const[,E,N]=b;S=E,v=N||""}const k=i(S.trim());return{type:e,raw:b[0],content:v.trim(),attributes:k}}},renderMarkdown:p=>{let m="";r?m=r(p):p.content&&p.content.length>0&&(m=p.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const x=d(p.attrs||{}),y=s(x),b=y?` ${y}`:"";return l?`[${u}${b}]`:`[${u}${b}]${m}[/${u}]`}}}function yR(t,e,n){var r,i,s,o;const l=t.split(`
  8232. `),c=[];let u="",d=0;const h=e.baseIndentSize||2;for(;d<l.length;){const p=l[d],m=p.match(e.itemPattern);if(!m){if(c.length>0)break;if(p.trim()===""){d+=1,u=`${u}${p}
  8233. `;continue}else return}const x=e.extractItemData(m),{indentLevel:y,mainContent:b}=x;u=`${u}${p}
  8234. `;const v=[b];for(d+=1;d<l.length;){const N=l[d];if(N.trim()===""){const M=l.slice(d+1).findIndex(j=>j.trim()!=="");if(M===-1)break;if((((i=(r=l[d+1+M].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(N),u=`${u}${N}
  8235. `,d+=1;continue}else break}if((((o=(s=N.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>y)v.push(N),u=`${u}${N}
  8236. `,d+=1;else break}let S;const k=v.slice(1);if(k.length>0){const N=k.map(A=>A.slice(y+h)).join(`
  8237. `);N.trim()&&(e.customNestedParser?S=e.customNestedParser(N):S=n.blockTokens(N))}const E=e.createToken(x,S);c.push(E)}if(c.length!==0)return{items:c,raw:u}}function SF(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...o]=t.content,l=e.renderChildren([s]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const h=d.split(`
  8238. `).map(p=>p?e.indent(p):"").join(`
  8239. `);c.push(h)}}),c.join(`
  8240. `)}function Uqe(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((l,c)=>{const u=s.mapping.map(c),d=s.mapping.map(c)+l.nodeSize;let h=null;if(l.marks.forEach(m=>{if(m!==o)return!1;h=m}),!h)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==h.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});s.removeMark(u,d,t.type),s.addMark(u,d,m)}}),s.docChanged&&e.view.dispatch(s)}var io=class dre extends vF{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new dre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Hm(t){return new wqe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=vr(t.getAttributes,void 0,r,i);if(s===!1||s===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/),h=n.from+c.indexOf(l),p=h+l.length;if(yF(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>h).length)return null;p<n.to&&o.delete(p,n.to),h>n.from&&o.delete(n.from+d,h),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}var Yj,b9;function Bqe(){return b9||(b9=1,Yj=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,s;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(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var o=s[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),Yj}var $qe=Bqe();const Hqe=wl($qe);var Vqe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},Gqe=({contentComponent:t})=>{const e=$R.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(e)})};function qqe(){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]:lce.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 Wqe=class extends ci.Component{constructor(t){var e;super(t),this.editorContentRef=ci.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=qqe(),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 a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:Vqe(e,this.editorContentRef),...n}),t?.contentComponent&&a.jsx(Gqe,{contentComponent:t.contentComponent})]})}},Kqe=w.forwardRef((t,e)=>{const n=ci.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ci.createElement(Wqe,{key:n,innerRef:e,...t})}),Xqe=ci.memo(Kqe),Yqe=typeof window<"u"?w.useLayoutEffect:w.useEffect,Qqe=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 Zqe(t){var e;const[n]=w.useState(()=>new Qqe(t.editor)),r=yY.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:Hqe);return Yqe(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var Jqe=!1,vR=typeof window>"u",e7e=vR||!!(typeof window<"u"&&window.next),t7e=class hre{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?vR||e7e?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new Tqe(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,s)=>{var o;return i===((o=n.extensions)==null?void 0:o[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?hre.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 n7e(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new t7e(n)),i=$R.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),Zqe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var r7e=w.createContext({editor:null});r7e.Consumer;var i7e=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),a7e=()=>w.useContext(i7e);ci.forwardRef((t,e)=>{const{onDragStart:n}=a7e(),r=t.as||"div";return a.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ci.createContext({markViewContentRef:()=>{}});var UN=(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]},s7e=/^\s*>\s$/,o7e=io.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return UN("blockquote",{...Ri(this.options.HTMLAttributes,t),children:UN("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(`
  8241. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8242. `))}),r.join(`
  8243. ${n}
  8244. `)},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[kb({find:s7e,type:this.type})]}}),l7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,c7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,u7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,d7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,h7e=nf.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 UN("strong",{...Ri(this.options.HTMLAttributes,t),children:UN("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[Nb({find:l7e,type:this.type}),Nb({find:u7e,type:this.type})]},addPasteRules(){return[Hm({find:c7e,type:this.type}),Hm({find:d7e,type:this.type})]}}),f7e=/(^|[^`])`([^`]+)`(?!`)$/,m7e=/(^|[^`])`([^`]+)`(?!`)/g,p7e=nf.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ri(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[Nb({find:f7e,type:this.type})]},addPasteRules(){return[Hm({find:m7e,type:this.type})]}}),Qj=4,g7e=/^```([a-z]+)?[\s\n]$/,b7e=/^~~~([a-z]+)?[\s\n]$/,x7e=io.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Qj,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 s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Ri(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(`
  8245. `):r=`\`\`\`${i}
  8246. \`\`\``,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:Qj,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.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,m=r.doc.textBetween(u,d,`
  8247. `,`
  8248. `).split(`
  8249. `).map(x=>l+x).join(`
  8250. `);return c.replaceWith(u,d,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Qj,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=s,d=s.start(),h=s.end(),m=r.doc.textBetween(d,h,`
  8251. `,`
  8252. `).split(`
  8253. `);let x=0,y=0;const b=u-d;for(let A=0;A<m.length;A+=1){if(y+m[A].length>=b){x=A;break}y+=m[A].length+1}const S=((c=m[x].match(/^ */))==null?void 0:c[0])||"",k=Math.min(S.length,n);if(k===0)return!0;let E=d;for(let A=0;A<x;A+=1)E+=m[A].length+1;return l.delete(E,E+k),u-E<=k&&l.setSelection(wn.create(l.doc,E)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,p=r.doc.textBetween(c,u,`
  8254. `,`
  8255. `).split(`
  8256. `).map(m=>{var x;const y=((x=m.match(/^ */))==null?void 0:x[0])||"",b=Math.min(y.length,n);return m.slice(b)}).join(`
  8257. `);return l.replaceWith(c,u,r.schema.text(p)),!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 s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
  8258. `);return!s||!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:s}=n;if(!s||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(Ln.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[xR({find:g7e,type:this.type,getAttributes:t=>({language:t[1]})}),xR({find:b7e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new yi({key:new va("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,s=i?.mode;if(!n||!s)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
  8259. `));return o.replaceSelectionWith(this.type.create({language:s},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(wn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),y7e=io.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8260. `):""}),v7e=io.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",Ri(this.options.HTMLAttributes,t)]},renderText(){return`
  8261. `},renderMarkdown:()=>`
  8262. `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const h=c.filter(p=>l.includes(p.type.name));u.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),w7e=io.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]}`,Ri(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=>xR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),_7e=io.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ri(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Dqe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Xne(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(wn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(on.create(o.doc,c.pos)):o.setSelection(wn.create(o.doc,c.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,h=d?.create();h&&(o.insert(u,h),o.setSelection(wn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ure({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),S7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,N7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,k7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,M7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,C7e=nf.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",Ri(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[Nb({find:S7e,type:this.type}),Nb({find:k7e,type:this.type})]},addPasteRules(){return[Hm({find:N7e,type:this.type}),Hm({find:M7e,type:this.type})]}});const E7e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",A7e="ελ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",wR="numeric",_R="ascii",SR="alpha",$y="asciinumeric",ky="alphanumeric",NR="domain",fre="emoji",T7e="scheme",j7e="slashscheme",Zj="whitespace";function P7e(t,e){return t in e||(e[t]=[]),e[t]}function im(t,e,n){e[wR]&&(e[$y]=!0,e[ky]=!0),e[_R]&&(e[$y]=!0,e[SR]=!0),e[$y]&&(e[ky]=!0),e[SR]&&(e[ky]=!0),e[ky]&&(e[NR]=!0),e[fre]&&(e[NR]=!0);for(const r in e){const i=P7e(r,n);i.indexOf(t)<0&&i.push(t)}}function D7e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ks(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ks.groups={};Ks.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],s=e.jr[r][1];if(s&&i.test(t))return s}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||Ks.groups;let i;return e&&e.j?i=e:(i=new Ks(e),n&&r&&im(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Ks.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new Ks,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Ks,s){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(D7e(o.t,r),n);im(s,c,r)}else n&&im(s,n,r);o.t=s}return i.j[t]=o,o}};const jn=(t,e,n,r,i)=>t.ta(e,n,r,i),Ci=(t,e,n,r,i)=>t.tr(e,n,r,i),x9=(t,e,n,r,i)=>t.ts(e,n,r,i),Pt=(t,e,n,r,i)=>t.tt(e,n,r,i),Nu="WORD",kR="UWORD",mre="ASCIINUMERICAL",pre="ALPHANUMERICAL",z0="LOCALHOST",MR="TLD",CR="UTLD",e1="SCHEME",Ng="SLASH_SCHEME",NF="NUM",ER="WS",kF="NL",Hy="OPENBRACE",Vy="CLOSEBRACE",BN="OPENBRACKET",$N="CLOSEBRACKET",HN="OPENPAREN",VN="CLOSEPAREN",GN="OPENANGLEBRACKET",qN="CLOSEANGLEBRACKET",WN="FULLWIDTHLEFTPAREN",KN="FULLWIDTHRIGHTPAREN",XN="LEFTCORNERBRACKET",YN="RIGHTCORNERBRACKET",QN="LEFTWHITECORNERBRACKET",ZN="RIGHTWHITECORNERBRACKET",JN="FULLWIDTHLESSTHAN",ek="FULLWIDTHGREATERTHAN",tk="AMPERSAND",nk="APOSTROPHE",rk="ASTERISK",oh="AT",ik="BACKSLASH",ak="BACKTICK",sk="CARET",mh="COLON",MF="COMMA",ok="DOLLAR",fc="DOT",lk="EQUALS",CF="EXCLAMATION",Jo="HYPHEN",Gy="PERCENT",ck="PIPE",uk="PLUS",dk="POUND",qy="QUERY",EF="QUOTE",gre="FULLWIDTHMIDDLEDOT",AF="SEMI",mc="SLASH",Wy="TILDE",hk="UNDERSCORE",bre="EMOJI",fk="SYM";var xre=Object.freeze({__proto__:null,ALPHANUMERICAL:pre,AMPERSAND:tk,APOSTROPHE:nk,ASCIINUMERICAL:mre,ASTERISK:rk,AT:oh,BACKSLASH:ik,BACKTICK:ak,CARET:sk,CLOSEANGLEBRACKET:qN,CLOSEBRACE:Vy,CLOSEBRACKET:$N,CLOSEPAREN:VN,COLON:mh,COMMA:MF,DOLLAR:ok,DOT:fc,EMOJI:bre,EQUALS:lk,EXCLAMATION:CF,FULLWIDTHGREATERTHAN:ek,FULLWIDTHLEFTPAREN:WN,FULLWIDTHLESSTHAN:JN,FULLWIDTHMIDDLEDOT:gre,FULLWIDTHRIGHTPAREN:KN,HYPHEN:Jo,LEFTCORNERBRACKET:XN,LEFTWHITECORNERBRACKET:QN,LOCALHOST:z0,NL:kF,NUM:NF,OPENANGLEBRACKET:GN,OPENBRACE:Hy,OPENBRACKET:BN,OPENPAREN:HN,PERCENT:Gy,PIPE:ck,PLUS:uk,POUND:dk,QUERY:qy,QUOTE:EF,RIGHTCORNERBRACKET:YN,RIGHTWHITECORNERBRACKET:ZN,SCHEME:e1,SEMI:AF,SLASH:mc,SLASH_SCHEME:Ng,SYM:fk,TILDE:Wy,TLD:MR,UNDERSCORE:hk,UTLD:CR,UWORD:kR,WORD:Nu,WS:ER});const yu=/[a-z]/,hy=new RegExp("\\p{L}","u"),Jj=new RegExp("\\p{Emoji}","u"),vu=/\d/,eP=/\s/,y9="\r",tP=`
  8263. `,R7e="️",L7e="‍",nP="";let _S=null,SS=null;function O7e(t=[]){const e={};Ks.groups=e;const n=new Ks;_S==null&&(_S=v9(E7e)),SS==null&&(SS=v9(A7e)),Pt(n,"'",nk),Pt(n,"{",Hy),Pt(n,"}",Vy),Pt(n,"[",BN),Pt(n,"]",$N),Pt(n,"(",HN),Pt(n,")",VN),Pt(n,"<",GN),Pt(n,">",qN),Pt(n,"(",WN),Pt(n,")",KN),Pt(n,"「",XN),Pt(n,"」",YN),Pt(n,"『",QN),Pt(n,"』",ZN),Pt(n,"<",JN),Pt(n,">",ek),Pt(n,"&",tk),Pt(n,"*",rk),Pt(n,"@",oh),Pt(n,"`",ak),Pt(n,"^",sk),Pt(n,":",mh),Pt(n,",",MF),Pt(n,"$",ok),Pt(n,".",fc),Pt(n,"=",lk),Pt(n,"!",CF),Pt(n,"-",Jo),Pt(n,"%",Gy),Pt(n,"|",ck),Pt(n,"+",uk),Pt(n,"#",dk),Pt(n,"?",qy),Pt(n,'"',EF),Pt(n,"/",mc),Pt(n,";",AF),Pt(n,"~",Wy),Pt(n,"_",hk),Pt(n,"\\",ik),Pt(n,"・",gre);const r=Ci(n,vu,NF,{[wR]:!0});Ci(r,vu,r);const i=Ci(r,yu,mre,{[$y]:!0}),s=Ci(r,hy,pre,{[ky]:!0}),o=Ci(n,yu,Nu,{[_R]:!0});Ci(o,vu,i),Ci(o,yu,o),Ci(i,vu,i),Ci(i,yu,i);const l=Ci(n,hy,kR,{[SR]:!0});Ci(l,yu),Ci(l,vu,s),Ci(l,hy,l),Ci(s,vu,s),Ci(s,yu),Ci(s,hy,s);const c=Pt(n,tP,kF,{[Zj]:!0}),u=Pt(n,y9,ER,{[Zj]:!0}),d=Ci(n,eP,ER,{[Zj]:!0});Pt(n,nP,d),Pt(u,tP,c),Pt(u,nP,d),Ci(u,eP,d),Pt(d,y9),Pt(d,tP),Ci(d,eP,d),Pt(d,nP,d);const h=Ci(n,Jj,bre,{[fre]:!0});Pt(h,"#"),Ci(h,Jj,h),Pt(h,R7e,h);const p=Pt(h,L7e);Pt(p,"#"),Ci(p,Jj,h);const m=[[yu,o],[vu,i]],x=[[yu,null],[hy,l],[vu,s]];for(let y=0;y<_S.length;y++)Jd(n,_S[y],MR,Nu,m);for(let y=0;y<SS.length;y++)Jd(n,SS[y],CR,kR,x);im(MR,{tld:!0,ascii:!0},e),im(CR,{utld:!0,alpha:!0},e),Jd(n,"file",e1,Nu,m),Jd(n,"mailto",e1,Nu,m),Jd(n,"http",Ng,Nu,m),Jd(n,"https",Ng,Nu,m),Jd(n,"ftp",Ng,Nu,m),Jd(n,"ftps",Ng,Nu,m),im(e1,{scheme:!0,ascii:!0},e),im(Ng,{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],S=t[y][1]?{[T7e]:!0}:{[j7e]:!0};b.indexOf("-")>=0?S[NR]=!0:yu.test(b)?vu.test(b)?S[$y]=!0:S[_R]=!0:S[wR]=!0,x9(n,b,b,S)}return x9(n,"localhost",z0,{ascii:!0}),n.jd=new Ks(fk),{start:n,tokens:Object.assign({groups:e},xre)}}function yre(t,e){const n=F7e(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,h=-1,p=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(h=0,p=0,d=l):h>=0&&(h+=n[o].length,p++),u+=n[o].length,s+=n[o].length,o++;s-=h,o-=p,u-=h,i.push({t:d.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function F7e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Jd(t,e,n,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?s=t.j[c]:(s=new Ks(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new Ks(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function v9(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const U0={defaultProtocol:"http",events:null,format:w9,formatHref:w9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function TF(t,e=null){let n=Object.assign({},U0);t&&(n=Object.assign(n,t instanceof TF?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}TF.prototype={o:U0,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]:U0[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 w9(t){return t}function vre(t,e){this.t="token",this.v=t,this.tk=e}vre.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=U0.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),s=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),h=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:s,eventListeners:h}}};function aC(t,e){class n extends vre{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const _9=aC("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),S9=aC("text"),I7e=aC("nl"),NS=aC("url",{isLink:!0,toHref(t=U0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==z0&&t[1].t===mh}}),Yo=t=>new Ks(t);function z7e({groups:t}){const e=t.domain.concat([tk,rk,oh,ik,ak,sk,ok,lk,Jo,NF,Gy,ck,uk,dk,mc,fk,Wy,hk]),n=[nk,mh,MF,fc,CF,Gy,qy,EF,AF,GN,qN,Hy,Vy,$N,BN,HN,VN,WN,KN,XN,YN,QN,ZN,JN,ek],r=[tk,nk,rk,ik,ak,sk,ok,lk,Jo,Hy,Vy,Gy,ck,uk,dk,qy,mc,fk,Wy,hk],i=Yo(),s=Pt(i,Wy);jn(s,r,s),jn(s,t.domain,s);const o=Yo(),l=Yo(),c=Yo();jn(i,t.domain,o),jn(i,t.scheme,l),jn(i,t.slashscheme,c),jn(o,r,s),jn(o,t.domain,o);const u=Pt(o,oh);Pt(s,oh,u),Pt(l,oh,u),Pt(c,oh,u);const d=Pt(s,fc);jn(d,r,s),jn(d,t.domain,s);const h=Yo();jn(u,t.domain,h),jn(h,t.domain,h);const p=Pt(h,fc);jn(p,t.domain,h);const m=Yo(_9);jn(p,t.tld,m),jn(p,t.utld,m),Pt(u,z0,m);const x=Pt(h,Jo);Pt(x,Jo,x),jn(x,t.domain,h),jn(m,t.domain,h),Pt(m,fc,p),Pt(m,Jo,x);const y=Pt(m,mh);jn(y,t.numeric,_9);const b=Pt(o,Jo),v=Pt(o,fc);Pt(b,Jo,b),jn(b,t.domain,o),jn(v,r,s),jn(v,t.domain,o);const S=Yo(NS);jn(v,t.tld,S),jn(v,t.utld,S),jn(S,t.domain,o),jn(S,r,s),Pt(S,fc,v),Pt(S,Jo,b),Pt(S,oh,u);const k=Pt(S,mh),E=Yo(NS);jn(k,t.numeric,E);const N=Yo(NS),A=Yo();jn(N,e,N),jn(N,n,A),jn(A,e,N),jn(A,n,A),Pt(S,mc,N),Pt(E,mc,N);const M=Pt(l,mh),P=Pt(c,mh),T=Pt(P,mc),j=Pt(T,mc);jn(l,t.domain,o),Pt(l,fc,v),Pt(l,Jo,b),jn(c,t.domain,o),Pt(c,fc,v),Pt(c,Jo,b),jn(M,t.domain,N),Pt(M,mc,N),Pt(M,qy,N),jn(j,t.domain,N),jn(j,e,N),Pt(j,mc,N);const z=[[Hy,Vy],[BN,$N],[HN,VN],[GN,qN],[WN,KN],[XN,YN],[QN,ZN],[JN,ek]];for(let F=0;F<z.length;F++){const[$,D]=z[F],H=Pt(N,$);Pt(A,$,H),Pt(H,D,N);const q=Yo(NS);jn(H,e,q);const I=Yo();jn(H,n),jn(q,e,q),jn(q,n,I),jn(I,e,q),jn(I,n,I),Pt(q,D,N),Pt(I,D,N)}return Pt(i,z0,S),Pt(i,kF,I7e),{start:i,tokens:xre}}function U7e(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,h=null,p=-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()?(p=0,h=l):p>=0&&p++,i++,d++;if(p<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(rP(S9,e,o)),o=[]),i-=p,d-=p;const m=h.t,x=n.slice(i-d,i);s.push(rP(m,e,x))}}return o.length>0&&s.push(rP(S9,e,o)),s}function rP(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const B7e=typeof console<"u"&&console&&console.warn||(()=>{}),$7e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ti={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function H7e(){return Ks.groups={},ti.scanner=null,ti.parser=null,ti.tokenQueue=[],ti.pluginQueue=[],ti.customSchemes=[],ti.initialized=!1,ti}function N9(t,e=!1){if(ti.initialized&&B7e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${$7e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8264. 1. Must only contain digits, lowercase ASCII letters or "-"
  8265. 2. Cannot start or end with "-"
  8266. 3. "-" cannot repeat`);ti.customSchemes.push([t,e])}function V7e(){ti.scanner=O7e(ti.customSchemes);for(let t=0;t<ti.tokenQueue.length;t++)ti.tokenQueue[t][1]({scanner:ti.scanner});ti.parser=z7e(ti.scanner.tokens);for(let t=0;t<ti.pluginQueue.length;t++)ti.pluginQueue[t][1]({scanner:ti.scanner,parser:ti.parser});return ti.initialized=!0,ti}function jF(t){return ti.initialized||V7e(),U7e(ti.parser.start,t,yre(ti.scanner.start,t))}jF.scan=yre;function wre(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 TF(n),i=jF(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var PF="[\0-   ᠎ -\u2029  ]",G7e=new RegExp(PF),q7e=new RegExp(`${PF}$`),W7e=new RegExp(PF,"g");function K7e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function X7e(t){return new yi({key:new va("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),s=e.some(u=>u.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=Bne(n.doc,[...e]);if(Kne(l).forEach(({newRange:u})=>{const d=RGe(r.doc,u,m=>m.isTextblock);let h,p;if(d.length>1)h=d[0],p=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(u.from,u.to," "," ");if(!q7e.test(m))return;h=d[0],p=r.doc.textBetween(h.pos,u.to,void 0," ")}if(h&&p){const m=p.split(G7e).filter(Boolean);if(m.length<=0)return!1;const x=m[m.length-1],y=h.pos+p.lastIndexOf(x);if(!x)return!1;const b=jF(x).map(v=>v.toObject(t.defaultProtocol));if(!K7e(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=>{yF(v.from,v.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function Y7e(t){return new yi({key:new va("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;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 h=[];for(;d.nodeName!=="DIV";)h.push(d),d=d.parentNode;o=h.find(p=>p.nodeName==="A")}if(!o)return!1;const l=Wne(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(s=o?.target)!=null?s:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function Q7e(t){return new yi({key:new va("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=wre(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 Rf(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(W7e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var _re=nf.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"){N9(t);return}N9(t.scheme,t.optionalSlashes)})},onDestroy(){H7e()},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)=>!!Rf(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=>!!Rf(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=>!!Rf(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Ri(this.options.HTMLAttributes,t),0]:["a",Ri(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=>!!Rf(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=>!!Rf(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Hm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=wre(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!Rf(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.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(X7e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Rf(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(Y7e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Q7e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Z7e=_re,J7e=Object.defineProperty,e9e=(t,e)=>{for(var n in e)J7e(t,n,{get:e[n],enumerable:!0})},t9e="listItem",k9="textStyle",M9=/^\s*([-+*])\s$/,Sre=io.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",Ri(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,`
  8267. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(t9e,this.editor.getAttributes(k9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=kb({find:M9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=kb({find:M9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(k9),editor:this.editor})),[t]}}),Nre=io.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ri(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)=>SF(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)}}}),n9e={};e9e(n9e,{findListItemPos:()=>jv,getNextListDepth:()=>DF,handleBackspace:()=>AR,handleDelete:()=>TR,hasListBefore:()=>kre,hasListItemAfter:()=>r9e,hasListItemBefore:()=>Mre,listItemHasSubList:()=>Cre,nextListIsDeeper:()=>Ere,nextListIsHigher:()=>Are});var jv=(t,e)=>{const{$from:n}=e.selection,r=aa(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&l===null;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},DF=(t,e)=>{const n=jv(t,e);if(!n)return!1;const[,r]=VGe(e,t,n.$pos.pos+4);return r},kre=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},Mre=(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)},Cre=(t,e,n)=>{if(!n)return!1;const r=aa(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},AR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Xh(t.state,e)&&kre(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((p,m)=>{p.type.name===e&&u.push({node:p,pos:m})});const d=u.at(-1);if(!d)return!1;const h=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},h.end()).joinForward().run()}if(!Xh(t.state,e)||!KGe(t.state))return!1;const r=jv(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Cre(e,t.state,s);return Mre(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Ere=(t,e)=>{const n=DF(t,e),r=jv(t,e);return!r||!n?!1:n>r.depth},Are=(t,e)=>{const n=DF(t,e),r=jv(t,e);return!r||!n?!1:n<r.depth},TR=(t,e)=>{if(!Xh(t.state,e)||!WGe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Ere(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Are(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},r9e=(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)},Tre=Lr.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&&TR(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&&TR(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&&AR(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&&AR(t,n,r)&&(e=!0)}),e}}}}),C9=/^(\s*)(\d+)\.\s+(.*)$/,i9e=/^\s/;function a9e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(C9);if(!s)break;const[,o,l,c]=s,u=o.length;let d=c,h=n+1;const p=[i];for(;h<t.length;){const m=t[h];if(m.match(C9))break;if(m.trim()==="")p.push(m),d+=`
  8268. `,h+=1;else if(m.match(i9e))p.push(m),d+=`
  8269. ${m.slice(u+2)}`,h+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:p.join(`
  8270. `)}),r=h,n=h}return[e,r]}function jre(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const o=t[s];if(o.indent===e){const l=o.content.split(`
  8271. `),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(`
  8272. `).trim();if(d){const m=n.blockTokens(d);u.push(...m)}let h=s+1;const p=[];for(;h<t.length&&t[h].indent>e;)p.push(t[h]),h+=1;if(p.length>0){const m=Math.min(...p.map(y=>y.indent)),x=jre(p,m,n);u.push({type:"list",ordered:!0,start:p[0].number,items:x,raw:p.map(y=>y.raw).join(`
  8273. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),s=h}else s+=1}return i}function s9e(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 s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var o9e="listItem",E9="textStyle",A9=/^(\d+)\.\s$/,Pre=io.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",Ri(this.options.HTMLAttributes,n),0]:["ol",Ri(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?s9e(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,`
  8274. `):"",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(`
  8275. `),[s,o]=a9e(i);if(s.length===0)return;const l=jre(s,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
  8276. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(o9e,this.editor.getAttributes(E9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=kb({find:A9,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=kb({find:A9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(E9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),l9e=/^\s*(\[([( |x])?\])\s$/,c9e=io.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",Ri(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 SF(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"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var h,p;l.ariaLabel=((p=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:p.call(h,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),s.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:h}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const m=n();if(typeof m!="number")return!1;const x=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{...x?.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{i.setAttribute(d,h)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,c),Object.entries(e).forEach(([d,h])=>{i.setAttribute(d,h)}),{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[kb({find:l9e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),u9e=io.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",Ri(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,`
  8277. `):"",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=s=>{const o=yR(s,{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(s)},i=yR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.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()}}});Lr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Sre.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Nre.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Tre.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Pre.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(c9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(u9e.configure(this.options.taskList)),t}});var d9e=io.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ri(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()}}}),h9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,f9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,m9e=nf.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",Ri(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[Nb({find:h9e,type:this.type})]},addPasteRules(){return[Hm({find:f9e,type:this.type})]}}),p9e=io.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Dre=nf.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",Ri(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 s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},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()}}}),g9e=Dre;function b9e(t={}){return new yi({view(e){return new x9e(e,t)}})}class x9e{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 s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}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,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(n){let h=e.nodeBefore,p=e.nodeAfter;if(h||p){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let x=m.getBoundingClientRect(),y=h?x.bottom:x.top;h&&p&&(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 h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:h.left-p,right:h.left+p,top:h.top,bottom:h.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 h=c.getBoundingClientRect(),p=h.width/c.offsetWidth,m=h.height/c.offsetHeight;u=h.left-c.scrollLeft*p,d=h.top-c.scrollTop*m}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,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Dte(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 Ti extends Ln{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Ti.valid(r)?new Ti(r):Ln.near(r)}content(){return Bt.empty}eq(e){return e instanceof Ti&&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 Ti(e.resolve(n.pos))}getBookmark(){return new RF(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!y9e(e)||!v9e(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&&Ti.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=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(Ti.valid(c))return c}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!on.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(Ti.valid(l))return l}return null}}}Ti.prototype.visible=!1;Ti.findFrom=Ti.findGapCursorFrom;Ln.jsonID("gapcursor",Ti);class RF{constructor(e){this.pos=e}map(e){return new RF(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Ti.valid(n)?new Ti(n):Ln.near(n)}}function Rre(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function y9e(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||Rre(i.type))return!0;if(i.inlineContent)return!1}}return!0}function v9e(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||Rre(i.type))return!0;if(i.inlineContent)return!1}}return!0}function w9e(){return new yi({props:{decorations:k9e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Ti.valid(n)?new Ti(n):null},handleClick:S9e,handleKeyDown:_9e,handleDOMEvents:{beforeinput:N9e}}})}const _9e=Dne({ArrowLeft:kS("horiz",-1),ArrowRight:kS("horiz",1),ArrowUp:kS("vert",-1),ArrowDown:kS("vert",1)});function kS(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof wn){if(!s.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Ti.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Ti(u))),!0):!1}}function S9e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Ti.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&on.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Ti(r))),!0)}function N9e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Ti))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=At.empty;for(let o=r.length-1;o>=0;o--)i=At.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new Bt(i,0,0));return s.setSelection(wn.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function k9e(t){if(!(t.selection instanceof Ti))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",pi.create(t.doc,[Es.widget(t.selection.head,e,{key:"gapcursor"})])}var mk=200,Ra=function(){};Ra.prototype.append=function(e){return e.length?(e=Ra.from(e),!this.length&&e||e.length<mk&&this.leafAppend(e)||this.length<mk&&e.leafPrepend(this)||this.appendInner(e)):this};Ra.prototype.prepend=function(e){return e.length?Ra.from(e).append(this):this};Ra.prototype.appendInner=function(e){return new M9e(this,e)};Ra.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ra.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ra.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ra.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)};Ra.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};Ra.from=function(e){return e instanceof Ra?e:e&&e.length?new Lre(e):Ra.empty};var Lre=(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,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var c=s;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var c=s-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=mk)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=mk)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})(Ra);Ra.empty=new Lre([]);var M9e=(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,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},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})(Ra);const C9e=500;class Hl{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,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((h,p)=>{if(!h.step){i||(i=this.remapping(r,p+1),s=i.maps.length),s--,d.push(h);return}if(i){d.push(new pc(h.map));let m=h.step.map(i.slice(s)),x;m&&o.maybeStep(m).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new pc(x,void 0,void 0,u.length+d.length))),s--,x&&i.appendMap(x,s)}else o.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(s)):h.selection,c=new Hl(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 s=[],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 h=e.steps[d].invert(e.docs[d]),p=new pc(e.mapping.maps[d],h,n),m;(m=c&&c.merge(p))&&(p=m,d?s.pop():l=l.slice(0,l.length-1)),s.push(p),n&&(o++,n=void 0),i||(c=p)}let u=o-r.depth;return u>A9e&&(l=E9e(l,u),o-=u),new Hl(l.append(s),o)}remapping(e,n){let r=new D0;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-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 Hl(this.items.append(e.map(n=>new pc(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let c=n;this.items.forEach(p=>{let m=s.getMirror(--c);if(m==null)return;o=Math.min(o,m);let x=s.maps[m];if(p.step){let y=e.steps[m].invert(e.docs[m]),b=p.selection&&p.selection.map(s.slice(c+1,m));b&&l++,r.push(new pc(x,y,b))}else r.push(new pc(x))},i);let u=[];for(let p=n;p<o;p++)u.push(new pc(s.maps[p]));let d=this.items.slice(0,i).append(u).append(r),h=new Hl(d,l);return h.emptyItemCount()>C9e&&(h=h.compress(this.items.length-r.length)),h}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=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;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&&s++;let h=new pc(u.invert(),c,d),p,m=i.length-1;(p=i.length&&i[m].merge(h))?i[m]=p:i.push(h)}}else o.map&&r--},this.items.length,0),new Hl(Ra.from(i.reverse()),s)}}Hl.empty=new Hl(Ra.empty,0);function E9e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class pc{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 pc(n.getMap().invert(),n,this.selection)}}}class lh{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const A9e=20;function T9e(t,e,n,r){let i=n.getMeta(xm),s;if(i)return i.historyState;n.getMeta(D9e)&&(t=new lh(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(xm))return o.getMeta(xm).redo?new lh(t.done.addTransform(n,void 0,r,t1(e)),t.undone,T9(n.mapping.maps),t.prevTime,t.prevComposition):new lh(t.done,t.undone.addTransform(n,void 0,r,t1(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||!j9e(n,t.prevRanges)),u=o?iP(t.prevRanges,n.mapping):T9(n.mapping.maps);return new lh(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,t1(e)),Hl.empty,u,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new lh(t.done.rebased(n,s),t.undone.rebased(n,s),iP(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new lh(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),iP(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function j9e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function T9(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function iP(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function P9e(t,e,n){let r=t1(e),i=xm.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),c=new lh(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(xm,{redo:n,historyState:c})}let aP=!1,j9=null;function t1(t){let e=t.plugins;if(j9!=e){aP=!1,j9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){aP=!0;break}}return aP}const xm=new va("history"),D9e=new va("closeHistory");function R9e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new yi({key:xm,state:{init(){return new lh(Hl.empty,Hl.empty,null,0,-1)},apply(e,n,r){return T9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Fre:r=="historyRedo"?Ire:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Ore(t,e){return(n,r)=>{let i=xm.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=P9e(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const Fre=Ore(!1,!0),Ire=Ore(!0,!0);Lr.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 yi({key:new va("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-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}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var L9e=Lr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[b9e(this.options)]}});Lr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new yi({key:new va("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return pi.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";s.push(Es.node(u,u+c.nodeSize,{class:this.options.className}))}),pi.create(t,s)}}})]}});var O9e=Lr.create({name:"gapCursor",addProseMirrorPlugins(){return[w9e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=vr(rn(t,"allowGapCursor",n)))!=null?e:null}}});Lr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new yi({key:new va("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const s=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&nC(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const h=Es.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(h)}return this.options.includeChildren}),pi.create(t,i)}}})]}});Lr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new yi({key:new va("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Xne(n.selection)||t.view.dragging?null:pi.create(n.doc,[Es.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function P9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var F9e=Lr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new va(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 yi({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),h=l.content.size,p=u.nodes[n];if(d)return c.insert(h,p.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!P9({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!P9({node:o,types:r})}}})]}}),I9e=Lr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Fre(t,e),redo:()=>({state:t,dispatch:e})=>Ire(t,e)}},addProseMirrorPlugins(){return[R9e(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()}}}),z9e=Lr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(h7e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(o7e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Sre.configure(this.options.bulletList)),this.options.code!==!1&&i.push(p7e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(x7e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(y7e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(L9e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(O9e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(v7e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(w7e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(I9e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(_7e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(C7e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Nre.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Tre.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(_re.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Pre.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(d9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(m9e.configure(this.options.strike)),this.options.text!==!1&&i.push(p9e.configure(this.options.text)),this.options.underline!==!1&&i.push(Dre.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(F9e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),U9e=z9e,B9e=Lr.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")}}}),$9e=B9e,H9e=20,zre=(t,e=0)=>{const n=[];return!t.children.length||e>H9e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...zre(r,e+1))}),n},V9e=t=>{if(!t.children.length)return;const e=zre(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${s}`)})},Ure=nf.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&V9e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Ri(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(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),G9e=Lr.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 s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.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()}}}),Bre=Lr.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 s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.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()}}}),q9e=Lr.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()}}}),W9e=Lr.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()}}}),K9e=Lr.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()}}});Lr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(G9e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Bre.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(q9e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(W9e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(K9e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Ure.configure(this.options.textStyle)),t}});var X9e=Bre,Y9e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Q9e=io.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",Ri(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,s,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=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return u?`![${c}](${l} "${u}")`:`![${c}](${l})`},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:s,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,h])=>{if(h!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,h);break}}),l.src=o.src;const c=new Pqe({element:l,node:i,getPos:s,onResize:(d,h)=>{l.style.width=`${d}px`,l.style.height=`${h}px`},onCommit:(d,h)=>{const p=s();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:d,height:h}).run()},onUpdate:(d,h,p)=>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[ure({find:Y9e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Z9e=Q9e;function jR({content:t,onChange:e,placeholder:n}){const{t:r}=Ut(),i=n7e({extensions:[U9e.configure({heading:!1,codeBlock:!1,code:!1}),g9e,Z7e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),$9e.configure({types:["paragraph"]}),Ure,X9e,Z9e.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:l})=>{e(l.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(!i)return null;const s=({onClick:l,isActive:c=!1,children:u,title:d})=>a.jsx("button",{type:"button",onClick:l,title:d,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${c?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:u}),o=()=>{const l=window.prompt("Enter URL:");l&&i.chain().focus().setLink({href:l}).run()};return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[a.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[a.jsx(s,{onClick:()=>i.chain().focus().toggleBold().run(),isActive:i.isActive("bold"),title:r("richTextEditor.bold"),children:a.jsx(sue,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().toggleItalic().run(),isActive:i.isActive("italic"),title:r("richTextEditor.italic"),children:a.jsx(rhe,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().toggleUnderline().run(),isActive:i.isActive("underline"),title:r("richTextEditor.underline"),children:a.jsx(Yfe,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(s,{onClick:()=>i.chain().focus().toggleBulletList().run(),isActive:i.isActive("bulletList"),title:r("richTextEditor.bulletList"),children:a.jsx(jk,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().toggleOrderedList().run(),isActive:i.isActive("orderedList"),title:r("richTextEditor.numberedList"),children:a.jsx(nK,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(s,{onClick:()=>i.chain().focus().setTextAlign("left").run(),isActive:i.isActive({textAlign:"left"}),title:r("richTextEditor.alignLeft"),children:a.jsx($fe,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().setTextAlign("center").run(),isActive:i.isActive({textAlign:"center"}),title:r("richTextEditor.alignCenter"),children:a.jsx(Ife,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().setTextAlign("right").run(),isActive:i.isActive({textAlign:"right"}),title:r("richTextEditor.alignRight"),children:a.jsx(Ufe,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(s,{onClick:o,isActive:i.isActive("link"),title:r("richTextEditor.addLink"),children:a.jsx(Db,{className:"w-4 h-4"})}),i.isActive("link")&&a.jsx(s,{onClick:()=>i.chain().focus().unsetLink().run(),title:r("richTextEditor.removeLink"),children:a.jsx(Ik,{className:"w-4 h-4"})})]}),a.jsx(Xqe,{editor:i})]})}function $re({archiveId:t,archiveName:e,onClose:n}){const r=Zt(),[i,s]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:h,error:p}=et({queryKey:["archive-project-page",t],queryFn:()=>ae.getArchiveProjectPage(t)}),m=st({mutationFn:N=>ae.updateArchiveProjectPage(t,N),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),u({})}});w.useEffect(()=>{const N=A=>{A.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||""}),s(!0)},b=()=>{m.mutate(c)},v=()=>{s(!1),u({})},S=N=>{const A=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],M=new DOMParser().parseFromString(N,"text/html"),P=T=>{if(T.nodeType===Node.TEXT_NODE)return T.textContent||"";if(T.nodeType===Node.ELEMENT_NODE){const j=T,z=j.tagName.toLowerCase();if(!A.includes(z))return Array.from(j.childNodes).map(P).join("");let F="";if(z==="a"&&j.getAttribute("href")){const D=j.getAttribute("href");D?.toLowerCase().startsWith("http")&&(F=` href="${D}" target="_blank" rel="noopener noreferrer"`)}if(z==="img"){const D=j.getAttribute("src");if(!D?.toLowerCase().startsWith("http"))return"";F=` src="${D}" style="max-width: 100%; height: auto;"`}const $=Array.from(j.childNodes).map(P).join("");return["br","img"].includes(z)?`<${z}${F} />`:`<${z}${F}>${$}</${z}>`}return""};return Array.from(M.body.childNodes).map(P).join("")},k=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),E=N=>{N.target===N.currentTarget&&n()};return a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:E,children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ms,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&a.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!i&&k&&a.jsxs(Me,{variant:"ghost",size:"sm",onClick:y,children:[a.jsx(Sm,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),a.jsxs(Me,{variant:"primary",size:"sm",onClick:b,disabled:m.isPending,children:[a.jsx(fs,{className:"w-4 h-4 mr-1"}),"Save"]})]}),a.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[h&&a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),p&&a.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!k&&a.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[a.jsx(Ms,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"No project page data found in this 3MF file."}),a.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&k&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[i?a.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&&a.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),a.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zu,{className:"w-4 h-4 text-bambu-gray"}),a.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&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(Zu,{className:"w-4 h-4"}),a.jsx("span",{children:d.designer}),d.designer_user_id&&a.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:a.jsx(Wr,{className:"w-3 h-3"})})]}),d.creation_date&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(ri,{className:"w-4 h-4"}),a.jsx("span",{children:d.creation_date})]}),i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ms,{className:"w-4 h-4 text-bambu-gray"}),a.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&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(Ms,{className:"w-4 h-4"}),a.jsx("span",{children:d.license})]}),d.origin&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?a.jsx(jR,{content:c.description||"",onChange:N=>u({...c,description:N}),placeholder:"Enter description..."}):a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&a.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?a.jsxs("div",{className:"space-y-2",children:[a.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"}),a.jsx(jR,{content:c.profile_description||"",onChange:N=>u({...c,profile_description:N}),placeholder:"Profile description..."})]}):a.jsxs(a.Fragment,{children:[d.profile_title&&a.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(d.profile_description)}}),d.profile_user_name&&a.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[a.jsx(Yu,{className:"w-4 h-4"}),"Images (",x.length,")"]}),a.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((N,A)=>a.jsx("button",{onClick:()=>l(A),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:a.jsx("img",{src:N.url,alt:N.name,className:"w-full h-full object-cover"})},N.path))})]}),d.design_model_id&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.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:[a.jsx(Wr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[a.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:a.jsx(Tc,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:N=>N.stopPropagation()}),a.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:a.jsx(La,{className:"w-6 h-6 text-white"})}),a.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:a.jsx(Rt,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const J9e=[.25,.5,.75,1,1.5,2,3,4];function pg(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function eWe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=hn(),s=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[h,p]=w.useState(0),[m,x]=w.useState(0),[y,b]=w.useState(0),[v,S]=w.useState(1),[k,E]=w.useState(null),[N,A]=w.useState(null),[M,P]=w.useState(.8),[T,j]=w.useState(!1),{data:z,isLoading:F}=et({queryKey:["timelapse-info",t],queryFn:()=>ae.getTimelapseInfo(t)}),{data:$}=et({queryKey:["timelapse-thumbnails",t],queryFn:()=>ae.getTimelapseThumbnails(t,15)}),D=st({mutationFn:()=>ae.processTimelapse(t,{trimStart:m,trimEnd:y,speed:v,saveMode:"replace"},k||void 0),onSuccess:V=>{i(V.message,"success"),r?.(),n()},onError:V=>{i(V.message||"Processing failed","error")}});w.useEffect(()=>{z?.duration&&y===0&&b(z.duration)},[z?.duration,y]),w.useEffect(()=>{const V=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[n]),w.useEffect(()=>{const V=s.current;if(!V)return;const W=()=>{const fe=V.currentTime;d(fe),fe>=y&&(V.currentTime=m)},ie=()=>{p(V.duration),y===0&&b(V.duration)},J=()=>c(!0),pe=()=>c(!1);return V.addEventListener("timeupdate",W),V.addEventListener("durationchange",ie),V.addEventListener("play",J),V.addEventListener("pause",pe),()=>{V.removeEventListener("timeupdate",W),V.removeEventListener("durationchange",ie),V.removeEventListener("play",J),V.removeEventListener("pause",pe)}},[m,y]),w.useEffect(()=>{const V=o.current,W=s.current;!V||!W||!N||(V.currentTime=W.currentTime,V.playbackRate=W.playbackRate,l&&!T?V.play().catch(()=>{}):V.pause())},[l,N,T]),w.useEffect(()=>{o.current&&(o.current.volume=T?0:M)},[M,T]),w.useEffect(()=>{s.current&&(s.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const H=w.useCallback(()=>{const V=s.current;V&&(l?V.pause():(V.currentTime<m&&(V.currentTime=m),V.play()))},[l,m]),q=V=>{const W=s.current;W&&(W.currentTime=Math.max(m,Math.min(y,V)))},I=V=>{const W=V.target.files?.[0];W&&(N&&URL.revokeObjectURL(N),E(W),A(URL.createObjectURL(W)))},K=()=>{N&&URL.revokeObjectURL(N),E(null),A(null)};w.useEffect(()=>()=>{N&&URL.revokeObjectURL(N)},[N]);const Z=y-m,se=Z/v;return F?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:a.jsxs("div",{className:"flex items-center gap-3 text-white",children:[a.jsx(it,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Sh,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>D.mutate(),disabled:D.isPending,children:D.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(fs,{className:"w-4 h-4"}),"Save"]})}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[a.jsxs("div",{className:"relative",children:[a.jsx("video",{ref:s,src:e,className:"w-full rounded-lg bg-black",onClick:H,muted:!!N}),!l&&a.jsx("button",{onClick:H,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:a.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:a.jsx(jo,{className:"w-8 h-8 text-white"})})}),N&&a.jsx("audio",{ref:o,src:N,loop:!0})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(ufe,{className:"w-4 h-4"}),a.jsx("span",{children:"Trim"}),a.jsxs("span",{className:"ml-auto",children:[pg(m)," - ",pg(y)," (",pg(Z),")"]})]}),a.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("div",{className:"absolute inset-0 flex",children:$?.thumbnails.map((V,W)=>a.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${V})`}},W))}),a.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${m/h*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(h-y)/h*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${m/h*100}%`,right:`${(h-y)/h*100}%`}}),a.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/h*100}%`}}),a.jsx("input",{type:"range",min:0,max:h,step:.1,value:m,onChange:V=>{const W=parseFloat(V.target.value);W<y-1&&(x(W),s.current&&s.current.currentTime<W&&(s.current.currentTime=W))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),a.jsx("input",{type:"range",min:0,max:h,step:.1,value:y,onChange:V=>{const W=parseFloat(V.target.value);W>m+1&&b(W)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),a.jsx("input",{type:"range",min:0,max:h,step:.1,value:u,onChange:V=>q(parseFloat(V.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8278. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8279. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8280. [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:a.jsx("button",{onClick:H,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(Dk,{className:"w-5 h-5 text-white"}):a.jsx(jo,{className:"w-5 h-5 text-white"})})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Tk,{className:"w-4 h-4"}),a.jsx("span",{children:"Speed"}),a.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",pg(se),")"]})]}),a.jsx("div",{className:"flex gap-1",children:J9e.map(V=>a.jsxs("button",{onClick:()=>S(V),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===V?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[V,"x"]},V))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(VP,{className:"w-4 h-4"}),a.jsx("span",{children:"Music Overlay"})]}),k?a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(VP,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:k.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(k.size/1024/1024).toFixed(1)," MB"]})]}),a.jsx("button",{onClick:()=>j(!T),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:T?a.jsx(ame,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(rme,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("input",{type:"range",min:0,max:1,step:.1,value:M,onChange:V=>P(parseFloat(V.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8281. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8282. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),a.jsx("button",{onClick:K,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:a.jsx(en,{className:"w-4 h-4 text-red-400"})})]}):a.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:[a.jsx(ia,{className:"w-8 h-8 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),a.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),a.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:I,className:"hidden"})]})]}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Original:"})," ",pg(h)," @ ",z?.width,"x",z?.height]}),a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Output:"})," ",pg(se)," @ ",v,"x speed",k&&" + music overlay"]})]})]}),D.isPending&&a.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[a.jsx(it,{className:"w-12 h-12 text-bambu-green animate-spin"}),a.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const tWe=[.25,.5,.75,1,1.5,2,3,4];function Hre({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:s}){const o=w.useRef(null),[l,c]=w.useState(!0),[u,d]=w.useState(1),[h,p]=w.useState(0),[m,x]=w.useState(0),[y,b]=w.useState(!1);w.useEffect(()=>{const M=o.current;M&&(M.playbackRate=u)},[u]),w.useEffect(()=>{const M=P=>{P.key==="Escape"&&i()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[i]),w.useEffect(()=>{const M=o.current;if(!M)return;const P=()=>p(M.currentTime),T=()=>x(M.duration),j=()=>c(!0),z=()=>c(!1);return M.addEventListener("timeupdate",P),M.addEventListener("durationchange",T),M.addEventListener("play",j),M.addEventListener("pause",z),()=>{M.removeEventListener("timeupdate",P),M.removeEventListener("durationchange",T),M.removeEventListener("play",j),M.removeEventListener("pause",z)}},[]);const v=()=>{const M=o.current;M&&(l?M.pause():M.play())},S=M=>{const P=o.current;P&&(P.currentTime=parseFloat(M.target.value))},k=()=>{const M=o.current;M&&(M.currentTime=Math.max(0,M.currentTime-5))},E=()=>{const M=o.current;M&&(M.currentTime=Math.min(m,M.currentTime+5))},N=M=>{const P=Math.floor(M/60),T=Math.floor(M%60);return`${P}:${T.toString().padStart(2,"0")}`},A=()=>{const M=document.createElement("a");M.href=t,M.download=n,M.click()};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[a.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Sh,{className:"w-5 h-5 text-bambu-green"}),e]}),a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>b(!0),children:[a.jsx($i,{className:"w-4 h-4"}),"Edit"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:A,children:[a.jsx(hi,{className:"w-4 h-4"}),"Download"]}),a.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"p-4",children:[a.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),a.jsxs("div",{className:"mt-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:N(h)}),a.jsx("input",{type:"range",min:0,max:m||100,value:h,onChange:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8283. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8284. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8285. [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("span",{className:"text-xs text-bambu-gray w-12",children:N(m)})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:k,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:a.jsx(wfe,{className:"w-5 h-5 text-bambu-gray"})}),a.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(Dk,{className:"w-5 h-5 text-white"}):a.jsx(jo,{className:"w-5 h-5 text-white"})}),a.jsx("button",{onClick:E,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:a.jsx(c4,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),a.jsx("div",{className:"flex gap-1",children:tWe.map(M=>a.jsxs("button",{onClick:()=>d(M),className:`px-2 py-1 text-xs rounded transition-colors ${u===M?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[M,"x"]},M))})]})]})]})]})]}),y&&r&&a.jsx(eWe,{archiveId:r,timelapseSrc:t,onClose:()=>b(!1),onSave:s})]})}function nWe({archiveIds:t,onClose:e}){w.useEffect(()=>{const s=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e]);const{data:n,isLoading:r,error:i}=et({queryKey:["archive-comparison",t],queryFn:()=>ae.compareArchives(t)});return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:a.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:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?a.jsxs("div",{className:"text-center py-12 text-red-400",children:[a.jsx(kn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"Failed to load comparison"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?a.jsx(rWe,{comparison:n}):null}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx(Me,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function rWe({comparison:t}){return a.jsxs("div",{className:"space-y-6",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.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=>a.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[a.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),a.jsx("div",{className:`text-xs ${e.status==="completed"?"text-status-ok":e.status==="failed"?"text-status-error":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),a.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>a.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[a.jsx("td",{className:"py-2 pr-4 text-sm",children:a.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&a.jsx(kn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),a.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>a.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??a.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&a.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&a.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[a.jsx(kn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),a.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>a.jsxs("li",{children:[a.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&a.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[a.jsx(Kr,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[a.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),a.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?a.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>a.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[a.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",a.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):a.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):a.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:a.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function iWe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function aWe(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 s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function sWe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(t.tags||""),[d,h]=w.useState(t.notes||""),[p,m]=w.useState(t.project_id),[x,y]=w.useState(!1);return a.jsx(_t,{children:a.jsxs(Nt,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(am,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:t.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx("span",{children:iWe(t.file_size)}),a.jsx("span",{children:"·"}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),aWe(t.uploaded_at)]}),t.source_ip&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?a.jsx(Kl,{className:"w-5 h-5"}):a.jsx(tr,{className:"w-5 h-5"})}),a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:p||void 0}),disabled:i,children:i?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(As,{className:"w-4 h-4"}),"Archive"]})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:s,children:s?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4 text-red-400"})})]})]}),x&&a.jsx(On,{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&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),a.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),a.jsx("textarea",{value:d,onChange:b=>h(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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),a.jsxs("select",{value:p||"",onChange:b=>m(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:[a.jsx("option",{value:"",children:"No project"}),e.map(b=>a.jsx("option",{value:b.id,children:b.name},b.id))]})]})]})]})})}function oWe(){const t=Zt(),{showToast:e}=hn(),[n,r]=w.useState(!1),[i,s]=w.useState(!1),[o,l]=w.useState(new Set),[c,u]=w.useState(new Set),{data:d,isLoading:h}=et({queryKey:["pending-uploads"],queryFn:xg.list,refetchInterval:1e4}),{data:p}=et({queryKey:["projects"],queryFn:()=>ae.getProjects()}),m=st({mutationFn:({id:v,data:S})=>xg.archive(v,S),onMutate:({id:v})=>{l(S=>new Set(S).add(v))},onSettled:(v,S,{id:k})=>{l(E=>{const N=new Set(E);return N.delete(k),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=st({mutationFn:v=>xg.discard(v),onMutate:v=>{u(S=>new Set(S).add(v))},onSettled:(v,S,k)=>{u(E=>{const N=new Set(E);return N.delete(k),N})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=st({mutationFn:xg.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=st({mutationFn:xg.discardAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${v.discarded} files`)},onError:v=>{e(v.message||"Failed to discard all","error")}});return h?a.jsx(_t,{children:a.jsx(Nt,{className:"py-8 flex justify-center",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:a.jsxs("div",{className:"mb-6",children:[a.jsxs(_t,{className:"border-l-4 border-l-yellow-500",children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ia,{className:"w-5 h-5 text-yellow-500"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(As,{className:"w-4 h-4"}),"Archive All"]})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>s(!0),disabled:b.isPending,children:b.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(en,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),a.jsxs(Nt,{children:[a.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."}),a.jsx("div",{className:"space-y-3",children:d.map(v=>a.jsx(sWe,{upload:v,projects:p||[],onArchive:(S,k)=>m.mutate({id:S,data:k}),onDiscard:S=>x.mutate(S),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&a.jsx(On,{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&&a.jsx(On,{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(),s(!1)},onCancel:()=>s(!1)})]})}function lWe({onClose:t}){const e=Zt(),{showToast:n}=hn(),[r,i]=w.useState(""),[s,o]=w.useState(null),[l,c]=w.useState(""),[u,d]=w.useState(null),[h,p]=w.useState("count");w.useEffect(()=>{const T=j=>{j.key==="Escape"&&(s?o(null):u?d(null):t())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,s,u]);const{data:m,isLoading:x}=et({queryKey:["tags"],queryFn:ae.getTags}),y=st({mutationFn:({oldName:T,newName:j})=>ae.renameTag(T,j),onSuccess:(T,{oldName:j,newName:z})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${j}" to "${z}" in ${T.affected} archive${T.affected!==1?"s":""}`),o(null)},onError:T=>{n(T.message||"Failed to rename tag","error")}}),b=st({mutationFn:T=>ae.deleteTag(T),onSuccess:(T,j)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${j}" from ${T.affected} archive${T.affected!==1?"s":""}`),d(null)},onError:T=>{n(T.message||"Failed to delete tag","error")}}),v=T=>{o(T.name),c(T.name),d(null)},S=()=>{o(null),c("")},k=()=>{if(!s||!l.trim())return;const T=l.trim();if(T===s){S();return}y.mutate({oldName:s,newName:T})},E=T=>{T.key==="Enter"?(T.preventDefault(),k()):T.key==="Escape"&&(T.preventDefault(),S())},N=T=>{d(T),o(null)},A=()=>{u&&b.mutate(u)},M=m?.filter(T=>T.name.toLowerCase().includes(r.toLowerCase())).sort((T,j)=>h==="count"&&j.count-T.count||T.name.localeCompare(j.name)),P=m?.reduce((T,j)=>T+j.count,0)||0;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Fh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Manage Tags"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search tags...",className:"w-full pl-9 pr-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:r,onChange:T=>i(T.target.value)})]}),a.jsxs("select",{className:"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:h,onChange:T=>p(T.target.value),children:[a.jsx("option",{value:"count",children:"Sort by Count"}),a.jsx("option",{value:"name",children:"Sort by Name"})]})]}),m&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[m.length," tag",m.length!==1?"s":""," across ",P," usage",P!==1?"s":""]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-4",children:x?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):M?.length?a.jsx("div",{className:"space-y-2",children:M.map(T=>a.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group",children:s===T.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx("input",{type:"text",className:"flex-1 px-2 py-1 bg-bambu-dark-tertiary border border-bambu-green rounded text-white text-sm focus:outline-none",value:l,onChange:j=>c(j.target.value),onKeyDown:E,autoFocus:!0}),a.jsx(Me,{size:"sm",variant:"primary",onClick:k,disabled:!l.trim()||y.isPending,className:"p-1.5",children:y.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Kr,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:S,className:"p-1.5",children:a.jsx(Rt,{className:"w-4 h-4"})})]}):u===T.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx(kn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),a.jsxs("span",{className:"text-sm text-bambu-gray-light flex-1",children:['Delete "',T.name,'" from ',T.count," archive",T.count!==1?"s":"","?"]}),a.jsx(Me,{size:"sm",variant:"danger",onClick:A,disabled:b.isPending,className:"p-1.5",children:b.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:a.jsx(Rt,{className:"w-4 h-4"})})]}):a.jsxs(a.Fragment,{children:[a.jsx(Fh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-white flex-1 truncate",children:T.name}),a.jsx("span",{className:"px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs",children:T.count}),a.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.jsx("button",{onClick:()=>v(T),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename tag",children:a.jsx($i,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(T.name),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete tag",children:a.jsx(en,{className:"w-4 h-4"})})]})]})},T.name))}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:r?"No tags match your search":"No tags found"})}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function pk(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function fy(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Kf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function Vre(t){if(!t)return;const e=t.toLowerCase();return e.endsWith(".3mf")?"3mf":e.endsWith(".stl")?"stl":e.endsWith(".gcode")||e.includes(".gcode.")?"gcode":e.split(".").pop()}function cWe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,timeFormat:l="system",preferredSlicer:c="bambu_studio",t:u}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const d=Zt(),{showToast:h}=hn(),{hasPermission:p,canModify:m}=Rr(),x=m4(),[y,b]=w.useState(!1),[v,S]=w.useState(!1),[k,E]=w.useState(!1),[N,A]=w.useState(!1),[M,P]=w.useState(!1),[T,j]=w.useState(!1),[z,F]=w.useState([]),[$,D]=w.useState(!1),[H,q]=w.useState(!1),[I,K]=w.useState(!1),[Z,se]=w.useState(!1),[V,W]=w.useState(!1),[ie,J]=w.useState(!1),[pe,fe]=w.useState(null),[ve,Le]=w.useState(null),[de,ce]=w.useState(!1),Ae=w.useRef(null),re=w.useRef(null),{data:Ie}=et({queryKey:["archive-plates",t.id],queryFn:()=>ae.getArchivePlates(t.id),enabled:de,staleTime:300*1e3}),G=Ie?.plates??[],Y=Ie?.is_multi_plate??!1,ue=ve??0,B=st({mutationFn:Ce=>ae.uploadSource3mf(t.id,Ce),onSuccess:Ce=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.source3mfAttached",{filename:Ce.filename}))},onError:Ce=>{h(Ce.message||u("archives.toast.failedUploadSource3mf"),"error")}}),ee=st({mutationFn:()=>ae.deleteSource3mf(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.source3mfRemoved"))},onError:Ce=>{h(Ce.message||u("archives.toast.failedRemoveSource3mf"),"error")}}),Q=st({mutationFn:Ce=>ae.uploadF3d(t.id,Ce),onSuccess:Ce=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.f3dAttached",{filename:Ce.filename}))},onError:Ce=>{h(Ce.message||u("archives.toast.failedUploadF3d"),"error")}}),le=st({mutationFn:()=>ae.deleteF3d(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.f3dRemoved"))},onError:Ce=>{h(Ce.message||u("archives.toast.failedRemoveF3d"),"error")}}),he=st({mutationFn:()=>ae.scanArchiveTimelapse(t.id),onSuccess:Ce=>{Ce.status==="attached"?(d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.timelapseAttached",{filename:Ce.filename}))):Ce.status==="exists"?h(u("archives.toast.timelapseAlreadyAttached")):Ce.status==="not_found"&&Ce.available_files&&Ce.available_files.length>0?(F(Ce.available_files),j(!0)):h(Ce.message||u("archives.toast.noMatchingTimelapse"),"warning")},onError:Ce=>{h(Ce.message||u("archives.toast.failedScanTimelapse"),"error")}}),te=st({mutationFn:Ce=>ae.selectArchiveTimelapse(t.id,Ce),onSuccess:Ce=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.timelapseAttached",{filename:Ce.filename})),j(!1),F([])},onError:Ce=>{h(Ce.message||u("archives.toast.failedAttachTimelapse"),"error")}}),U=st({mutationFn:()=>ae.deleteArchive(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.archiveDeleted"))},onError:()=>{h(u("archives.toast.failedDeleteArchive"),"error")}}),L=st({mutationFn:()=>ae.toggleFavorite(t.id),onSuccess:Ce=>{d.invalidateQueries({queryKey:["archives"]}),h(Ce.is_favorite?u("archives.toast.addedToFavorites"):u("archives.toast.removedFromFavorites"))}}),{data:X}=et({queryKey:["archive-folders",t.id],queryFn:()=>ae.getLibraryFoldersByArchive(t.id)}),ge=st({mutationFn:Ce=>ae.updateArchive(t.id,{project_id:Ce}),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),d.invalidateQueries({queryKey:["projects"]}),h(u("archives.toast.projectUpdated"))},onError:()=>{h(u("archives.toast.failedUpdateProject"),"error")}}),_e=Ce=>{Ce.preventDefault(),fe({x:Ce.clientX,y:Ce.clientY})},$e=[...Kf(t.filename)?[{label:u("archives.menu.print"),icon:a.jsx(Nr,{className:"w-4 h-4"}),onClick:()=>S(!0),disabled:!m("archives","reprint",t.created_by_id),title:m("archives","reprint",t.created_by_id)?void 0:u("archives.permission.noReprint")},{label:u("archives.menu.schedule"),icon:a.jsx(ri,{className:"w-4 h-4"}),onClick:()=>se(!0),disabled:!p("queue:create"),title:p("queue:create")?void 0:u("archives.permission.noAddToQueue")},{label:u("archives.menu.openInBambuStudio"),icon:a.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>{const Ce=t.print_name||t.filename||"model",He=`${window.location.origin}${ae.getArchiveForSlicer(t.id,Ce)}`;vc(He,c)}}]:[{label:u("archives.menu.slice"),icon:a.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>{const Ce=t.print_name||t.filename||"model",He=`${window.location.origin}${ae.getArchiveForSlicer(t.id,Ce)}`;vc(He,c)}}],{label:t.external_url?u("archives.menu.externalLink"):u("archives.menu.viewOnMakerWorld"),icon:a.jsx(Nh,{className:"w-4 h-4"}),onClick:()=>{const Ce=t.external_url||t.makerworld_url;Ce&&window.open(Ce,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.preview3d"),icon:a.jsx(Yi,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:u("archives.menu.viewTimelapse"),icon:a.jsx(Sh,{className:"w-4 h-4"}),onClick:()=>P(!0),disabled:!t.timelapse_path},{label:u("archives.menu.scanForTimelapse"),icon:a.jsx(f1,{className:"w-4 h-4"}),onClick:()=>he.mutate(),disabled:!t.printer_id||!!t.timelapse_path||he.isPending||!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?u("archives.menu.downloadSource3mf"):u("archives.menu.uploadSource3mf"),icon:a.jsx(u1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?ae.downloadSource3mf(t.id).catch(Ce=>{console.error("Source 3MF download failed:",Ce)}):Ae.current?.click()},disabled:!t.source_3mf_path&&!m("archives","update",t.created_by_id),title:!t.source_3mf_path&&!m("archives","update",t.created_by_id)?u("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:u("archives.menu.replaceSource3mf"),icon:a.jsx(ia,{className:"w-4 h-4"}),onClick:()=>Ae.current?.click(),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},{label:u("archives.menu.removeSource3mf"),icon:a.jsx(en,{className:"w-4 h-4"}),onClick:()=>W(!0),danger:!0,disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?u("archives.menu.replaceF3d"):u("archives.menu.uploadF3d"),icon:a.jsx(Yi,{className:"w-4 h-4"}),onClick:()=>re.current?.click(),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:u("archives.menu.downloadF3d"),icon:a.jsx(hi,{className:"w-4 h-4"}),onClick:()=>{ae.downloadF3d(t.id).catch(Ce=>{console.error("F3D download failed:",Ce)})}},{label:u("archives.menu.removeF3d"),icon:a.jsx(en,{className:"w-4 h-4"}),onClick:()=>J(!0),danger:!0,disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.download"),icon:a.jsx(hi,{className:"w-4 h-4"}),onClick:()=>{ae.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(Ce=>{console.error("Archive download failed:",Ce)})},disabled:!p("archives:read"),title:p("archives:read")?void 0:u("archives.permission.noDownload")},{label:u("archives.menu.copyDownloadLink"),icon:a.jsx(Xl,{className:"w-4 h-4"}),onClick:()=>{const Ce=`${window.location.origin}${ae.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(Ce).then(()=>{h(u("archives.toast.linkCopied"))}).catch(()=>{h(u("archives.toast.failedCopyLink"),"error")})},disabled:!p("archives:read"),title:p("archives:read")?void 0:u("archives.permission.noCopyLink")},{label:u("archives.menu.qrCode"),icon:a.jsx(iK,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:t.photos?.length?u("archives.menu.viewPhotosCount",{count:t.photos.length}):u("archives.menu.viewPhotos"),icon:a.jsx(Qg,{className:"w-4 h-4"}),onClick:()=>q(!0),disabled:!t.photos?.length},{label:u("archives.menu.projectPage"),icon:a.jsx(Ms,{className:"w-4 h-4"}),onClick:()=>K(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?u("archives.menu.removeFromFavorites"):u("archives.menu.addToFavorites"),icon:a.jsx(Nm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>L.mutate(),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},{label:u("archives.menu.edit"),icon:a.jsx($i,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:u("archives.menu.goToProject",{name:t.project_name}),icon:a.jsx(ps,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:u("archives.menu.addToProject"),icon:a.jsx(ps,{className:"w-4 h-4"}),onClick:()=>{},disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives"),submenu:(()=>{const Ce=[];if(t.project_id&&Ce.push({label:u("archives.menu.removeFromProject"),icon:a.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>ge.mutate(null),disabled:!m("archives","update",t.created_by_id)}),!s)Ce.push({label:u("archives.menu.loading"),icon:a.jsx(it,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const He=s.filter(Qe=>Qe.status==="active");He.length===0?Ce.push({label:u("archives.menu.noProjectsAvailable"),icon:a.jsx(ps,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):He.forEach(Qe=>{Ce.push({label:Qe.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Qe.color||"#888"}}),onClick:()=>ge.mutate(Qe.id),disabled:t.project_id===Qe.id||!m("archives","update",t.created_by_id)})})}return Ce})()},{label:u(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(to,{className:"w-4 h-4"}):a.jsx(pl,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.delete"),icon:a.jsx(en,{className:"w-4 h-4"}),onClick:()=>E(!0),danger:!0,disabled:!m("archives","delete",t.created_by_id),title:m("archives","delete",t.created_by_id)?void 0:u("archives.permission.noDelete")}];return a.jsxs(_t,{"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:_e,onClick:i?()=>r(t.id):void 0,children:[i&&a.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:Ce=>{Ce.stopPropagation(),r(t.id)},children:n?a.jsx(to,{className:"w-5 h-5 text-bambu-green"}):a.jsx(pl,{className:"w-5 h-5 text-white"})}),a.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",onMouseEnter:()=>ce(!0),onMouseLeave:()=>ce(!1),children:[t.thumbnail_path?a.jsx("img",{src:ve!==null&&G.length>0?ae.getArchivePlateThumbnail(t.id,G[ue]?.index??0):ae.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(Yu,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),Y&&G.length>1&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:`absolute left-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${x?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:Ce=>{Ce.stopPropagation(),Le(He=>{const Qe=He??0;return Qe>0?Qe-1:G.length-1})},title:u("archives.card.previousPlate"),children:a.jsx(Tc,{className:"w-4 h-4 text-white"})}),a.jsx("button",{className:`absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${x?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:Ce=>{Ce.stopPropagation(),Le(He=>{const Qe=He??0;return Qe<G.length-1?Qe+1:0})},title:u("archives.card.nextPlate"),children:a.jsx(La,{className:"w-4 h-4 text-white"})}),a.jsx("div",{className:`absolute bottom-1 left-1/2 -translate-x-1/2 flex gap-1 px-2 py-1 rounded-full bg-black/50 transition-all ${x?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:G.map((Ce,He)=>a.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${He===ue?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:Qe=>{Qe.stopPropagation(),Le(He)},title:Ce.name||u("archives.card.plateNumber",{index:Ce.index})},Ce.index))})]}),a.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${x?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:Ce=>{Ce.stopPropagation();const He=Ce.currentTarget.getBoundingClientRect();fe({x:He.left,y:He.bottom+4})},title:u("archives.card.moreOptions"),children:a.jsx(_h,{className:"w-5 h-5 text-white"})}),a.jsx("button",{className:`absolute top-2 right-2 p-1 rounded transition-colors ${m("archives","update",t.created_by_id)?"bg-black/50 hover:bg-black/70":"bg-black/30 cursor-not-allowed"}`,onClick:Ce=>{Ce.stopPropagation(),m("archives","update",t.created_by_id)&&L.mutate()},disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?t.is_favorite?u("archives.card.removeFromFavorites"):u("archives.card.addToFavorites"):u("archives.permission.noUpdateArchives"),children:a.jsx(Nm,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"} ${m("archives","update",t.created_by_id)?"":"opacity-50"}`})}),(t.status==="failed"||t.status==="aborted")&&a.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-status-error/80 text-white",children:t.status==="aborted"?u("archives.card.cancelled"):u("archives.card.failed")}),t.duplicate_count>0&&a.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:u("archives.card.duplicateTitle"),children:[a.jsx(Xl,{className:"w-3 h-3"}),u("archives.card.duplicate")]}),t.source_3mf_path&&a.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Ce=>{Ce.stopPropagation();const He=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Qe=`${window.location.origin}${ae.getSource3mfForSlicer(t.id,He)}`;vc(Qe,c)},title:u("archives.card.openSource3mf"),children:a.jsx(u1,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&a.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:Ce=>{Ce.stopPropagation(),ae.downloadF3d(t.id).catch(He=>{console.error("F3D download failed:",He)})},title:u("archives.card.downloadF3d"),children:a.jsx(Yi,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&a.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Ce=>{Ce.stopPropagation(),P(!0)},title:u("archives.card.viewTimelapse"),children:a.jsx(Sh,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&a.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:Ce=>{Ce.stopPropagation(),q(!0)},title:t.photos.length===1?u("archives.card.viewPhoto"):u("archives.card.viewPhotos",{count:t.photos.length}),children:[a.jsx(Qg,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&a.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})]}),X&&X.length>0&&a.jsx(qs,{to:`/files?folder=${X[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Ce=>Ce.stopPropagation(),title:u("archives.card.openFolder",{name:X[0].name}),style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:a.jsx(Ql,{className:"w-4 h-4 text-yellow-400"})})]}),a.jsxs(Nt,{className:"p-4 flex-1 flex flex-col",children:[a.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:e}),a.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Kf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Kf(t.filename)?u("archives.card.slicedFile"):u("archives.card.sourceFile"),children:Kf(t.filename)?u("archives.card.gcode"):u("archives.card.source")}),t.project_name&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${s?.find(Ce=>Ce.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(Ce=>Ce.id===t.project_id)?.color||"#6b7280"},title:u("archives.card.project",{name:t.project_name}),children:t.project_name})]}),a.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)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${fy(t.print_time_seconds||0)}
  8286. Actual: ${fy(t.actual_time_seconds||0)}
  8287. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${fy(t.actual_time_seconds)}`:`Estimated: ${fy(t.print_time_seconds||0)}`,children:[a.jsx(qn,{className:"w-3 h-3"}),fy(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&a.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&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(ta,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(Ja,{className:"w-3 h-3"}),t.total_layers&&a.jsx("span",{children:t.total_layers===1?u("archives.card.layer",{count:t.total_layers}):u("archives.card.layers",{count:t.total_layers})}),t.total_layers&&t.layer_height&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&a.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.object_count===1?u("archives.card.object",{count:t.object_count}):u("archives.card.objects",{count:t.object_count}),children:[a.jsx(Yi,{className:"w-3 h-3"}),t.object_count===1?u("archives.card.object",{count:t.object_count}):u("archives.card.objects",{count:t.object_count})]}),t.sliced_for_model&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:u("archives.card.slicedFor",{model:t.sliced_for_model}),children:[a.jsx(Nr,{className:"w-3 h-3"}),t.sliced_for_model]}),t.filament_type&&a.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[a.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&a.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((Ce,He)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:Ce},title:Ce},He))})]})]}),(t.tags||t.notes)&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&a.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:a.jsx(sK,{className:"w-3 h-3"})}),t.tags?.split(",").map((Ce,He)=>a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:Ce.trim()},He))]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[a.jsx("span",{children:tb(t.created_at,l)}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1",title:u("archives.card.uploadedBy",{name:t.created_by_username}),children:[a.jsx(Zu,{className:"w-3 h-3"}),t.created_by_username]}),a.jsx("span",{children:pk(t.file_size)})]})]}),a.jsxs("div",{className:"flex gap-1 mt-3",children:[Kf(t.filename)?a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>S(!0),disabled:!m("archives","reprint",t.created_by_id),title:m("archives","reprint",t.created_by_id)?void 0:u("archives.card.noPermissionReprint"),children:[a.jsx(Nr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.reprint")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>se(!0),disabled:!p("queue:create"),title:p("queue:create")?u("archives.card.schedulePrint"):u("archives.permission.noAddToQueue"),children:[a.jsx(ri,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.schedule")})]}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const Ce=t.print_name||t.filename||"model",He=`${window.location.origin}${ae.getArchiveForSlicer(t.id,Ce)}`;vc(He,c)},title:u("archives.card.openInBambuStudio"),children:a.jsx(Wr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):a.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const Ce=t.print_name||t.filename||"model",He=`${window.location.origin}${ae.getArchiveForSlicer(t.id,Ce)}`;vc(He,c)},title:u("archives.card.openInBambuStudioToSlice"),children:[a.jsx(Wr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.slice")})]}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const Ce=t.external_url||t.makerworld_url;Ce&&window.open(Ce,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?u("archives.card.externalLink"):t.makerworld_url?u("archives.card.makerWorld",{designer:t.designer||u("archives.card.viewProject")}):u("archives.card.noExternalLink"),children:a.jsx(Nh,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:u("archives.card.preview3d"),children:a.jsx(Yi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{ae.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(Ce=>{console.error("Archive download failed:",Ce)})},title:u("archives.card.download"),children:a.jsx(hi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>A(!0),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?u("archives.card.edit"):u("archives.card.noPermissionEdit"),children:a.jsx($i,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>E(!0),disabled:!m("archives","delete",t.created_by_id),title:m("archives","delete",t.created_by_id)?u("archives.card.delete"):u("archives.card.noPermissionDelete"),children:a.jsx(en,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),N&&a.jsx(rte,{archive:t,onClose:()=>A(!1)}),y&&a.jsx(WO,{archiveId:t.id,title:t.print_name||t.filename,fileType:Vre(t.filename),onClose:()=>b(!1)}),v&&a.jsx(qu,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>S(!1)}),k&&a.jsx(On,{title:u("archives.modal.deleteArchive"),message:u("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{U.mutate(),E(!1)},onCancel:()=>E(!1)}),V&&a.jsx(On,{title:u("archives.modal.removeSource3mf"),message:u("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{ee.mutate(),W(!1)},onCancel:()=>W(!1)}),ie&&a.jsx(On,{title:u("archives.modal.removeF3d"),message:u("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{le.mutate(),J(!1)},onCancel:()=>J(!1)}),pe&&a.jsx(ite,{x:pe.x,y:pe.y,items:$e,onClose:()=>fe(null)}),M&&t.timelapse_path&&a.jsx(Hre,{src:ae.getArchiveTimelapse(t.id),title:u("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>P(!1),onEdit:()=>{d.invalidateQueries({queryKey:["archives"]}),P(!1)}}),T&&z.length>0&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),a.jsx("button",{onClick:()=>{j(!1),F([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:z.map(Ce=>a.jsxs("button",{onClick:()=>te.mutate(Ce.name),disabled:te.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:[a.jsx(Sh,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:Ce.name}),a.jsxs("p",{className:"text-sm text-gray-400",children:[pk(Ce.size),Ce.mtime&&` • ${tb(Ce.mtime,l)}`]})]})]},Ce.name))}),a.jsx("div",{className:"p-4 border-t border-gray-700",children:a.jsx(Me,{variant:"secondary",onClick:()=>{j(!1),F([])},className:"w-full",children:"Cancel"})})]})}),$&&a.jsx(ate,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),H&&t.photos&&t.photos.length>0&&a.jsx(ste,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>q(!1),onDelete:async Ce=>{try{await ae.deleteArchivePhoto(t.id,Ce),d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.photoDeleted"))}catch{h(u("archives.toast.failedDeletePhoto"),"error")}}}),I&&a.jsx($re,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>K(!1)}),Z&&a.jsx(qu,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>se(!1)}),a.jsx("input",{ref:Ae,type:"file",accept:".3mf",className:"hidden",onChange:Ce=>{const He=Ce.target.files?.[0];He&&B.mutate(He),Ce.target.value=""}}),a.jsx("input",{ref:re,type:"file",accept:".f3d",className:"hidden",onChange:Ce=>{const He=Ce.target.files?.[0];He&&Q.mutate(He),Ce.target.value=""}})]})}function uWe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,preferredSlicer:l="bambu_studio",t:c}){const u=Zt(),{showToast:d}=hn(),{hasPermission:h,canModify:p}=Rr(),[m,x]=w.useState(!1),[y,b]=w.useState(!1),[v,S]=w.useState(!1),[k,E]=w.useState(!1),[N,A]=w.useState(!1),[M,P]=w.useState(!1),[T,j]=w.useState(!1),[z,F]=w.useState([]),[$,D]=w.useState(!1),[H,q]=w.useState(!1),[I,K]=w.useState(!1),[Z,se]=w.useState(!1),[V,W]=w.useState(!1),[ie,J]=w.useState(null),pe=w.useRef(null),fe=w.useRef(null),ve=st({mutationFn:le=>ae.uploadSource3mf(t.id,le),onSuccess:le=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfAttached",{filename:le.filename}))},onError:le=>{d(le.message||c("archives.toast.failedUploadSource3mf"),"error")}}),Le=st({mutationFn:()=>ae.deleteSource3mf(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfRemoved"))},onError:le=>{d(le.message||c("archives.toast.failedRemoveSource3mf"),"error")}}),de=st({mutationFn:le=>ae.uploadF3d(t.id,le),onSuccess:le=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dAttached",{filename:le.filename}))},onError:le=>{d(le.message||c("archives.toast.failedUploadF3d"),"error")}}),ce=st({mutationFn:()=>ae.deleteF3d(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dRemoved"))},onError:le=>{d(le.message||c("archives.toast.failedRemoveF3d"),"error")}}),Ae=st({mutationFn:()=>ae.scanArchiveTimelapse(t.id),onSuccess:le=>{le.status==="attached"?(u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:le.filename}))):le.status==="exists"?d(c("archives.toast.timelapseAlreadyAttached")):le.status==="not_found"&&le.available_files&&le.available_files.length>0?(F(le.available_files),j(!0)):d(le.message||c("archives.toast.noMatchingTimelapse"),"warning")},onError:le=>{d(le.message||c("archives.toast.failedScanTimelapse"),"error")}}),re=st({mutationFn:le=>ae.selectArchiveTimelapse(t.id,le),onSuccess:le=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:le.filename})),j(!1),F([])},onError:le=>{d(le.message||c("archives.toast.failedAttachTimelapse"),"error")}}),Ie=st({mutationFn:()=>ae.deleteArchive(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.archiveDeleted"))},onError:()=>{d(c("archives.toast.failedDeleteArchive"),"error")}}),G=st({mutationFn:()=>ae.toggleFavorite(t.id),onSuccess:le=>{u.invalidateQueries({queryKey:["archives"]}),d(le.is_favorite?c("archives.toast.addedToFavorites"):c("archives.toast.removedFromFavorites"))}}),{data:Y}=et({queryKey:["archive-folders",t.id],queryFn:()=>ae.getLibraryFoldersByArchive(t.id)}),ue=st({mutationFn:le=>ae.updateArchive(t.id,{project_id:le}),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["projects"]}),d(c("archives.toast.projectUpdated"))},onError:()=>{d(c("archives.toast.failedUpdateProject"),"error")}}),B=le=>{le.preventDefault(),J({x:le.clientX,y:le.clientY})},Q=[...Kf(t.filename)?[{label:c("archives.menu.print"),icon:a.jsx(Nr,{className:"w-4 h-4"}),onClick:()=>S(!0),disabled:!p("archives","reprint",t.created_by_id),title:p("archives","reprint",t.created_by_id)?void 0:c("archives.permission.noReprint")},{label:c("archives.menu.schedule"),icon:a.jsx(ri,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!h("queue:create"),title:h("queue:create")?void 0:c("archives.permission.noAddToQueue")},{label:c("archives.menu.openInBambuStudio"),icon:a.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>{const le=t.print_name||t.filename||"model",he=`${window.location.origin}${ae.getArchiveForSlicer(t.id,le)}`;vc(he,l)}}]:[{label:c("archives.menu.slice"),icon:a.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>{const le=t.print_name||t.filename||"model",he=`${window.location.origin}${ae.getArchiveForSlicer(t.id,le)}`;vc(he,l)}}],{label:t.external_url?c("archives.menu.externalLink"):c("archives.menu.viewOnMakerWorld"),icon:a.jsx(Nh,{className:"w-4 h-4"}),onClick:()=>{const le=t.external_url||t.makerworld_url;le&&window.open(le,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.preview3d"),icon:a.jsx(Yi,{className:"w-4 h-4"}),onClick:()=>A(!0)},{label:c("archives.menu.viewTimelapse"),icon:a.jsx(Sh,{className:"w-4 h-4"}),onClick:()=>P(!0),disabled:!t.timelapse_path},{label:c("archives.menu.scanForTimelapse"),icon:a.jsx(f1,{className:"w-4 h-4"}),onClick:()=>Ae.mutate(),disabled:!t.printer_id||!!t.timelapse_path||Ae.isPending||!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?c("archives.menu.downloadSource3mf"):c("archives.menu.uploadSource3mf"),icon:a.jsx(u1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?ae.downloadSource3mf(t.id).catch(le=>{console.error("Source 3MF download failed:",le)}):pe.current?.click()},disabled:!t.source_3mf_path&&!p("archives","update",t.created_by_id),title:!t.source_3mf_path&&!p("archives","update",t.created_by_id)?c("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:c("archives.menu.replaceSource3mf"),icon:a.jsx(ia,{className:"w-4 h-4"}),onClick:()=>pe.current?.click(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.removeSource3mf"),icon:a.jsx(en,{className:"w-4 h-4"}),onClick:()=>se(!0),danger:!0,disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?c("archives.menu.replaceF3d"):c("archives.menu.uploadF3d"),icon:a.jsx(Yi,{className:"w-4 h-4"}),onClick:()=>fe.current?.click(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:c("archives.menu.downloadF3d"),icon:a.jsx(hi,{className:"w-4 h-4"}),onClick:()=>{ae.downloadF3d(t.id).catch(le=>{console.error("F3D download failed:",le)})}},{label:c("archives.menu.removeF3d"),icon:a.jsx(en,{className:"w-4 h-4"}),onClick:()=>W(!0),danger:!0,disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.download"),icon:a.jsx(hi,{className:"w-4 h-4"}),onClick:()=>{ae.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(le=>{console.error("Archive download failed:",le)})},disabled:!h("archives:read"),title:h("archives:read")?void 0:c("archives.permission.noDownload")},{label:c("archives.menu.copyDownloadLink"),icon:a.jsx(Xl,{className:"w-4 h-4"}),onClick:()=>{const le=`${window.location.origin}${ae.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(le).then(()=>{d(c("archives.toast.linkCopied"))}).catch(()=>{d(c("archives.toast.failedCopyLink"),"error")})},disabled:!h("archives:read"),title:h("archives:read")?void 0:c("archives.permission.noCopyLink")},{label:c("archives.menu.qrCode"),icon:a.jsx(iK,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:t.photos?.length?c("archives.menu.viewPhotosCount",{count:t.photos.length}):c("archives.menu.viewPhotos"),icon:a.jsx(Qg,{className:"w-4 h-4"}),onClick:()=>q(!0),disabled:!t.photos?.length},{label:c("archives.menu.projectPage"),icon:a.jsx(Ms,{className:"w-4 h-4"}),onClick:()=>K(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?c("archives.menu.removeFromFavorites"):c("archives.menu.addToFavorites"),icon:a.jsx(Nm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>G.mutate(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.edit"),icon:a.jsx($i,{className:"w-4 h-4"}),onClick:()=>x(!0),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:c("archives.menu.goToProject",{name:t.project_name}),icon:a.jsx(ps,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:c("archives.menu.addToProject"),icon:a.jsx(ps,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const le=[];if(t.project_id&&le.push({label:c("archives.menu.removeFromProject"),icon:a.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>ue.mutate(null)}),!s)le.push({label:c("archives.menu.loading"),icon:a.jsx(it,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const he=s.filter(te=>te.status==="active");he.length===0?le.push({label:c("archives.menu.noProjectsAvailable"),icon:a.jsx(ps,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):he.forEach(te=>{le.push({label:te.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:te.color||"#888"}}),onClick:()=>ue.mutate(te.id),disabled:t.project_id===te.id})})}return le})()},{label:c(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(to,{className:"w-4 h-4"}):a.jsx(pl,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.delete"),icon:a.jsx(en,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0,disabled:!p("archives","delete",t.created_by_id),title:p("archives","delete",t.created_by_id)?void 0:c("archives.permission.noDelete")}];return a.jsxs(a.Fragment,{children:[a.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:B,children:[a.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&a.jsx("button",{onClick:()=>r(t.id),children:n?a.jsx(to,{className:"w-4 h-4 text-bambu-green"}):a.jsx(pl,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?a.jsx("img",{src:ae.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):a.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:a.jsx(Yu,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),a.jsxs("div",{className:"col-span-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&a.jsx("span",{title:c("archives.list.hasTimelapse"),children:a.jsx(Sh,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),Y&&Y.length>0&&a.jsx(qs,{to:`/files?folder=${Y[0].id}`,className:"flex-shrink-0",title:c("archives.card.openFolder",{name:Y[0].name}),onClick:le=>le.stopPropagation(),children:a.jsx(Ql,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),(t.filament_type||t.sliced_for_model)&&a.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.sliced_for_model&&a.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",title:c("archives.card.slicedFor",{model:t.sliced_for_model}),children:[a.jsx(Nr,{className:"w-2.5 h-2.5"}),t.sliced_for_model]}),t.sliced_for_model&&t.filament_type&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.filament_type&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&a.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((le,he)=>a.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:le},title:le},he))})]})]}),a.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),a.jsxs("div",{className:"col-span-2 text-sm text-bambu-gray",children:[a.jsx("div",{children:eb(t.created_at)}),t.created_by_username&&a.jsxs("div",{className:"flex items-center gap-1 text-xs opacity-75",title:c("archives.card.uploadedBy",{name:t.created_by_username}),children:[a.jsx(Zu,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:pk(t.file_size)}),a.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const le=t.print_name||t.filename||"model",he=`${window.location.origin}${ae.getArchiveForSlicer(t.id,le)}`;vc(he,l)},title:c("archives.card.openInBambuStudio"),children:a.jsx(Wr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?c("archives.card.externalLink"):"MakerWorld",children:a.jsx(Nh,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{ae.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(le=>{console.error("Archive download failed:",le)})},title:c("archives.card.download"),children:a.jsx(hi,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>x(!0),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?c("archives.card.edit"):c("archives.card.noPermissionEdit"),children:a.jsx($i,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>b(!0),disabled:!p("archives","delete",t.created_by_id),title:p("archives","delete",t.created_by_id)?c("archives.card.delete"):c("archives.card.noPermissionDelete"),children:a.jsx(en,{className:"w-4 h-4 text-red-400"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:le=>{const he=le.currentTarget.getBoundingClientRect();J({x:he.left,y:he.bottom+4})},title:c("archives.card.moreOptions"),children:a.jsx(_h,{className:"w-4 h-4"})})]})]}),m&&a.jsx(rte,{archive:t,onClose:()=>x(!1)}),N&&a.jsx(WO,{archiveId:t.id,title:t.print_name||t.filename,fileType:Vre(t.filename),onClose:()=>A(!1)}),v&&a.jsx(qu,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>S(!1)}),y&&a.jsx(On,{title:c("archives.modal.deleteArchive"),message:c("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{Ie.mutate(),b(!1)},onCancel:()=>b(!1)}),Z&&a.jsx(On,{title:c("archives.modal.removeSource3mf"),message:c("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{Le.mutate(),se(!1)},onCancel:()=>se(!1)}),V&&a.jsx(On,{title:c("archives.modal.removeF3d"),message:c("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{ce.mutate(),W(!1)},onCancel:()=>W(!1)}),ie&&a.jsx(ite,{x:ie.x,y:ie.y,items:Q,onClose:()=>J(null)}),M&&t.timelapse_path&&a.jsx(Hre,{src:ae.getArchiveTimelapse(t.id),title:c("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>P(!1),onEdit:()=>{u.invalidateQueries({queryKey:["archives"]}),P(!1)}}),T&&z.length>0&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),a.jsx("button",{onClick:()=>{j(!1),F([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:z.map(le=>a.jsxs("button",{onClick:()=>re.mutate(le.name),disabled:re.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[a.jsx("div",{className:"font-medium text-white",children:le.name}),a.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[a.jsx("span",{children:pk(le.size)}),le.mtime&&a.jsx("span",{children:eb(le.mtime)})]})]},le.name))})]})}),$&&a.jsx(ate,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),H&&t.photos&&a.jsx(ste,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>q(!1),onDelete:async le=>{try{await ae.deleteArchivePhoto(t.id,le),u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.photoDeleted"))}catch{d(c("archives.toast.failedDeletePhoto"),"error")}}}),I&&a.jsx($re,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>K(!1)}),k&&a.jsx(qu,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>E(!1)}),a.jsx("input",{ref:pe,type:"file",accept:".3mf",className:"hidden",onChange:le=>{const he=le.target.files?.[0];he&&ve.mutate(he),le.target.value=""}}),a.jsx("input",{ref:fe,type:"file",accept:".f3d",className:"hidden",onChange:le=>{const he=le.target.files?.[0];he&&de.mutate(he),le.target.value=""}})]})}const dWe=[{id:"all",label:"All Archives",icon:a.jsx(Ql,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:a.jsx(qn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:a.jsx(ri,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:a.jsx(ri,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:a.jsx(Nm,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:a.jsx(Ui,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:a.jsx(Xl,{className:"w-4 h-4"})}];function hWe(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),{hasPermission:r,hasAnyPermission:i}=Rr(),s=w.useRef(null),[o,l]=w.useState(""),[c,u]=w.useState(()=>{const Ne=localStorage.getItem("archiveFilterPrinter");return Ne?Number(Ne):null}),[d,h]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[p,m]=w.useState(()=>{const Ne=localStorage.getItem("archiveFilterColors");return Ne?new Set(JSON.parse(Ne)):new Set}),[x,y]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[b,v]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[S,k]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[E,N]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[A,M]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[P,T]=w.useState(!1),[j,z]=w.useState([]),[F,$]=w.useState(!1),[D,H]=w.useState(new Set),[q,I]=w.useState(!1),[K,Z]=w.useState(!1),[se,V]=w.useState(!1),[W,ie]=w.useState(!1),[J,pe]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[fe,ve]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[Le,de]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ce,Ae]=w.useState(!1),[re,Ie]=w.useState(!1),[G,Y]=w.useState(!1),[ue,B]=w.useState(!1),[ee,Q]=w.useState(null);w.useEffect(()=>{if(ee){const Ne=setTimeout(()=>{const yt=document.querySelector(`[data-archive-id="${ee}"]`);yt&&yt.scrollIntoView({behavior:"smooth",block:"center"})},100),Je=setTimeout(()=>Q(null),5e3);return()=>{clearTimeout(Ne),clearTimeout(Je)}}},[ee]);const{data:le,isLoading:he}=et({queryKey:["archives",c],queryFn:()=>ae.getArchives(c||void 0)}),{data:te}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:U}=et({queryKey:["projects"],queryFn:()=>ae.getProjects()}),{data:L}=et({queryKey:["settings"],queryFn:ae.getSettings}),X=L?.time_format||"system",ge=L?.preferred_slicer||"bambu_studio",_e=st({mutationFn:async Ne=>(await Promise.all(Ne.map(Je=>ae.deleteArchive(Je))),Ne.length),onSuccess:Ne=>{e.invalidateQueries({queryKey:["archives"]}),H(new Set),n(`${Ne} archive${Ne!==1?"s":""} deleted`)},onError:()=>{n(t("archives.toast.failedDeleteArchives"),"error")}});w.useEffect(()=>{c!==null?localStorage.setItem("archiveFilterPrinter",c.toString()):localStorage.removeItem("archiveFilterPrinter")},[c]),w.useEffect(()=>{d?localStorage.setItem("archiveFilterMaterial",d):localStorage.removeItem("archiveFilterMaterial")},[d]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...p]))},[p]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",x)},[x]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",b.toString())},[b]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",S.toString())},[S]),w.useEffect(()=>{E?localStorage.setItem("archiveFilterTag",E):localStorage.removeItem("archiveFilterTag")},[E]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",A)},[A]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",J)},[J]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",fe)},[fe]),w.useEffect(()=>{localStorage.setItem("archiveCollection",Le)},[Le]);const Ee=new Map(te?.map(Ne=>[Ne.id,Ne.name])||[]),$e=[...new Set(le?.flatMap(Ne=>Ne.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),Ce=[...new Set(le?.flatMap(Ne=>Ne.filament_color?.split(",")||[]).filter(Boolean)||[])],He=[...new Set(le?.flatMap(Ne=>Ne.tags?.split(",").map(Je=>Je.trim())||[]).filter(Boolean)||[])].sort(),Qe=le?.filter(Ne=>{const Je=new Date,yt=Qi(Ne.created_at)||new Date(0);let Et=!0;switch(Le){case"recent":Et=Je.getTime()-yt.getTime()<1440*60*1e3;break;case"this-week":Et=Je.getTime()-yt.getTime()<10080*60*1e3;break;case"this-month":Et=yt.getMonth()===Je.getMonth()&&yt.getFullYear()===Je.getFullYear();break;case"favorites":Et=Ne.is_favorite===!0;break;case"failed":Et=Ne.status==="failed"||Ne.status==="aborted";break;case"duplicates":Et=Ne.duplicate_count>0;break}const an=(Ne.print_name||Ne.filename).toLowerCase().includes(o.toLowerCase()),jt=!d||Ne.filament_type?.split(", ").includes(d),Fe=Ne.filament_color?.split(",")||[],gt=p.size===0||(x==="or"?Fe.some(Xt=>p.has(Xt)):[...p].every(Xt=>Fe.includes(Xt))),Qt=Le==="favorites"||!b||Ne.is_favorite,tn=Le==="failed"||!S||Ne.status!=="failed"&&Ne.status!=="aborted",un=Ne.tags?.split(",").map(Xt=>Xt.trim())||[],dr=!E||un.includes(E),gr=Kf(Ne.filename);return Et&&an&&jt&&gt&&Qt&&tn&&dr&&(A==="all"||A==="gcode"&&gr||A==="source"&&!gr)}).sort((Ne,Je)=>{switch(fe){case"date-desc":return(Qi(Je.created_at)?.getTime()||0)-(Qi(Ne.created_at)?.getTime()||0);case"date-asc":return(Qi(Ne.created_at)?.getTime()||0)-(Qi(Je.created_at)?.getTime()||0);case"name-asc":return(Ne.print_name||Ne.filename).localeCompare(Je.print_name||Je.filename);case"name-desc":return(Je.print_name||Je.filename).localeCompare(Ne.print_name||Ne.filename);case"size-desc":return Je.file_size-Ne.file_size;case"size-asc":return Ne.file_size-Je.file_size;default:return 0}}),xe=q||D.size>0,ye=Ne=>{H(Je=>{const yt=new Set(Je);return yt.has(Ne)?yt.delete(Ne):yt.add(Ne),yt})},we=()=>{Qe&&H(new Set(Qe.map(Ne=>Ne.id)))},Ue=()=>{H(new Set),I(!1)},Pe=Ne=>{m(Je=>{const yt=new Set(Je);return yt.has(Ne)?yt.delete(Ne):yt.add(Ne),yt})},Ve=()=>{m(new Set)},ke=()=>{l(""),u(null),h(null),v(!1),k(!1),N(null),M("all")},Ze=o||c||d||b||S||E||A!=="all",je=w.useCallback(Ne=>{Ne.preventDefault(),Ne.dataTransfer.types.includes("Files")&&$(!0)},[]),Xe=w.useCallback(Ne=>{Ne.preventDefault(),Ne.currentTarget===Ne.target&&$(!1)},[]),Re=w.useCallback(Ne=>{Ne.preventDefault(),$(!1);const Je=Array.from(Ne.dataTransfer.files).filter(yt=>yt.name.endsWith(".3mf"));Je.length>0?(z(Je),T(!0)):Ne.dataTransfer.files.length>0&&n(t("archives.page.only3mfSupported"),"warning")},[n,t]),Oe=w.useCallback(Ne=>{const Je=Ne.target;if(Je.tagName==="INPUT"||Je.tagName==="TEXTAREA"||Je.isContentEditable){Ne.key==="Escape"&&Je.blur();return}switch(Ne.key){case"/":Ne.preventDefault(),s.current?.focus();break;case"u":case"U":!Ne.metaKey&&!Ne.ctrlKey&&(Ne.preventDefault(),T(!0));break;case"Escape":xe&&Ue();break}},[xe]);return w.useEffect(()=>(document.addEventListener("keydown",Oe),()=>document.removeEventListener("keydown",Oe)),[Oe]),a.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:je,onDragLeave:Xe,onDrop:Re,children:[F&&a.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:a.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[a.jsx(ia,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),a.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),a.jsx("p",{className:"text-bambu-gray",children:t("archives.releaseToUpload")})]})}),xe&&a.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:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ue,children:[a.jsx(Rt,{className:"w-4 h-4"}),"Close"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("span",{className:"text-white font-medium",children:[D.size," selected"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:we,children:"Select All"}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>V(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[a.jsx(Fh,{className:"w-4 h-4"}),"Tags"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ie(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[a.jsx(ps,{className:"w-4 h-4"}),"Project"]}),a.jsxs(Me,{variant:"secondary",size:"sm",disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),onClick:()=>{const Ne=Array.from(D);Promise.all(Ne.map(Je=>ae.toggleFavorite(Je))).then(()=>{e.invalidateQueries({queryKey:["archives"]}),n(`Toggled favorites for ${Ne.length} archive${Ne.length!==1?"s":""}`)}).catch(()=>{n(t("archives.toast.failedUpdateFavorites"),"error")})},children:[a.jsx(Nm,{className:"w-4 h-4"}),"Favorite"]}),a.jsxs(Me,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Z(!0),disabled:!i("archives:delete_own","archives:delete_all"),title:i("archives:delete_own","archives:delete_all")?void 0:t("archives.permission.noDelete"),children:[a.jsx(en,{className:"w-4 h-4"}),"Delete"]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),a.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:Le,onChange:Ne=>de(Ne.target.value),children:dWe.map(Ne=>a.jsx("option",{value:Ne.id,children:Ne.label},Ne.id))})]}),a.jsxs("p",{className:"text-bambu-gray",children:[Qe?.length||0," of ",le?.length||0," prints"]})]}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[a.jsxs("div",{className:"relative",children:[a.jsxs(Me,{variant:"secondary",onClick:()=>Ae(!ce),disabled:re,children:[re?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(d1,{className:"w-4 h-4"}),"Export"]}),ce&&a.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:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{Ae(!1),Ie(!0);try{const{blob:Ne,filename:Je}=await ae.exportArchives({format:"csv",printerId:c||void 0,status:Le==="failed"?"failed":void 0,search:o||void 0}),yt=URL.createObjectURL(Ne),Et=document.createElement("a");Et.href=yt,Et.download=Je,Et.click(),URL.revokeObjectURL(yt),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ie(!1)}},children:[a.jsx(Ms,{className:"w-4 h-4"}),"Export as CSV"]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{Ae(!1),Ie(!0);try{const{blob:Ne,filename:Je}=await ae.exportArchives({format:"xlsx",printerId:c||void 0,status:Le==="failed"?"failed":void 0,search:o||void 0}),yt=URL.createObjectURL(Ne),Et=document.createElement("a");Et.href=yt,Et.download=Je,Et.click(),URL.revokeObjectURL(yt),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ie(!1)}},children:[a.jsx(d1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),D.size>=2&&D.size<=5&&a.jsxs(Me,{variant:"secondary",onClick:()=>Y(!0),children:[a.jsx(Rg,{className:"w-4 h-4"}),"Compare (",D.size,")"]}),!xe&&a.jsxs(Me,{variant:"secondary",onClick:()=>I(!0),children:[a.jsx(to,{className:"w-4 h-4"}),"Select"]}),a.jsxs(Me,{onClick:()=>T(!0),disabled:!r("archives:create"),title:r("archives:create")?void 0:t("archives.permission.noCreate"),children:[a.jsx(ia,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),a.jsx(_t,{className:"mb-6",children:a.jsxs(Nt,{className:"py-4",children:[a.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[a.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{ref:s,type:"text",placeholder:t("archives.searchPlaceholder"),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:o,onChange:Ne=>l(Ne.target.value)})]}),a.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:[a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(Ak,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:c||"",onChange:Ne=>u(Ne.target.value?Number(Ne.target.value):null),children:[a.jsx("option",{value:"",children:"All Printers"}),te?.map(Ne=>a.jsx("option",{value:Ne.id,children:Ne.name},Ne.id))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(ta,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:d||"",onChange:Ne=>h(Ne.target.value||null),children:[a.jsx("option",{value:"",children:"All Materials"}),$e.map(Ne=>a.jsx("option",{value:Ne,children:Ne},Ne))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(u1,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:Ne=>M(Ne.target.value),children:[a.jsx("option",{value:"all",children:"All Files"}),a.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),a.jsx("option",{value:"source",children:"Source Only"})]})]}),a.jsxs("button",{onClick:()=>v(!b),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${b?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:t(b?"archives.showAll":"archives.showFavoritesOnly"),children:[a.jsx(Nm,{className:`w-4 h-4 ${b?"fill-yellow-400":""}`}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),a.jsxs("button",{onClick:()=>k(!S),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${S?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:t(S?"archives.showFailedPrints":"archives.hideFailedPrints"),children:[a.jsx(Ui,{className:"w-4 h-4 "}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),He.length>0&&a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(Fh,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:E||"",onChange:Ne=>N(Ne.target.value||null),children:[a.jsx("option",{value:"",children:"All Tags"}),He.map(Ne=>a.jsx("option",{value:Ne,children:Ne},Ne))]}),a.jsx("button",{onClick:()=>B(!0),className:"p-2 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",title:t("archives.manageTags"),children:a.jsx(Ok,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(i4,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:fe,onChange:Ne=>ve(Ne.target.value),children:[a.jsx("option",{value:"date-desc",children:t("archives.sortNewest")}),a.jsx("option",{value:"date-asc",children:t("archives.sortOldest")}),a.jsxs("option",{value:"name-asc",children:[t("archives.sortName")," A-Z"]}),a.jsxs("option",{value:"name-desc",children:[t("archives.sortName")," Z-A"]}),a.jsx("option",{value:"size-desc",children:t("archives.sortLargest")}),a.jsx("option",{value:"size-asc",children:t("archives.sortSmallest")})]})]}),a.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[a.jsx("button",{className:`p-2 ${J==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>pe("grid"),title:t("archives.gridView"),children:a.jsx(X0,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${J==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>pe("list"),title:t("archives.listView"),children:a.jsx(jk,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${J==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>pe("calendar"),title:t("archives.calendarView"),children:a.jsx(yue,{className:"w-4 h-4"})})]})]}),Ze&&a.jsxs(Me,{variant:"ghost",size:"sm",onClick:ke,className:"text-bambu-gray hover:text-white",children:[a.jsx(Rt,{className:"w-4 h-4"}),"Reset"]})]}),Ce.length>0&&a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),p.size>1&&a.jsx("button",{onClick:()=>y(Ne=>Ne==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${x==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:x==="or"?"Match ANY selected color":"Match ALL selected colors",children:x.toUpperCase()}),a.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:Ce.map(Ne=>a.jsx("button",{onClick:()=>Pe(Ne),className:`w-6 h-6 rounded-full border-2 transition-all ${p.has(Ne)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:Ne},title:Ne},Ne))}),p.size>0&&a.jsxs("button",{onClick:Ve,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[a.jsx(Rt,{className:"w-3 h-3"}),"Clear"]})]})]})}),a.jsx(oWe,{}),he?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.loadingArchives")}):Qe?.length===0?a.jsx(_t,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray",children:t(o?"archives.noArchivesSearch":"archives.noArchivesYet")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):J==="calendar"?a.jsx(_t,{className:"p-6",children:a.jsx(I6e,{archives:Qe||[],onArchiveClick:Ne=>{l(""),pe("grid"),Q(Ne.id)},highlightedArchiveId:ee})}):J==="grid"?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Qe?.map(Ne=>a.jsx(cWe,{archive:Ne,printerName:Ne.printer_id?Ee.get(Ne.printer_id)||"Unknown":Ne.sliced_for_model?`Sliced for ${Ne.sliced_for_model}`:"No Printer",isSelected:D.has(Ne.id),onSelect:ye,selectionMode:xe,projects:U,isHighlighted:Ne.id===ee,timeFormat:X,preferredSlicer:ge,t},Ne.id))}):J==="list"?a.jsx(_t,{children:a.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[a.jsx("div",{className:"col-span-1"}),a.jsx("div",{className:"col-span-4",children:"Name"}),a.jsx("div",{className:"col-span-2",children:"Printer"}),a.jsx("div",{className:"col-span-2",children:"Date"}),a.jsx("div",{className:"col-span-1",children:"Size"}),a.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),Qe?.map(Ne=>a.jsx(uWe,{archive:Ne,printerName:Ne.printer_id?Ee.get(Ne.printer_id)||"Unknown":Ne.sliced_for_model?`Sliced for ${Ne.sliced_for_model}`:"No Printer",isSelected:D.has(Ne.id),onSelect:ye,selectionMode:xe,projects:U,isHighlighted:Ne.id===ee,preferredSlicer:ge,t},Ne.id))]})}):null,P&&a.jsx(A6e,{onClose:()=>{T(!1),z([])},initialFiles:j}),K&&a.jsx(On,{title:t("archives.modal.deleteArchives"),message:t("archives.modal.deleteArchivesConfirm",{count:D.size}),confirmText:t("archives.modal.deleteCount",{count:D.size}),variant:"danger",onConfirm:()=>{_e.mutate(Array.from(D)),Z(!1)},onCancel:()=>Z(!1)}),se&&a.jsx(P6e,{selectedIds:Array.from(D),existingTags:He,onClose:()=>V(!1)}),W&&a.jsx(D6e,{selectedIds:Array.from(D),onClose:()=>ie(!1)}),G&&D.size>=2&&D.size<=5&&a.jsx(nWe,{archiveIds:Array.from(D),onClose:()=>{Y(!1),H(new Set),I(!1)}}),ue&&a.jsx(lWe,{onClose:()=>B(!1)})]})}function fWe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const sC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Qb(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function LF(t){return"nodeType"in t}function ao(t){var e,n;return t?Qb(t)?t:LF(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function OF(t){const{Document:e}=ao(t);return t instanceof e}function Pv(t){return Qb(t)?!1:t instanceof ao(t).HTMLElement}function Gre(t){return t instanceof ao(t).SVGElement}function Zb(t){return t?Qb(t)?t.document:LF(t)?OF(t)?t:Pv(t)||Gre(t)?t.ownerDocument:document:document:document}const Ic=sC?w.useLayoutEffect:w.useEffect;function FF(t){const e=w.useRef(t);return Ic(()=>{e.current=t}),w.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function mWe(){const t=w.useRef(null),e=w.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=w.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function B0(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return Ic(()=>{n.current!==t&&(n.current=t)},e),n}function Dv(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function gk(t){const e=FF(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function PR(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let sP={};function Rv(t,e){return w.useMemo(()=>{if(e)return e;const n=sP[t]==null?0:sP[t]+1;return sP[t]=n,t+"-"+n},[t,e])}function qre(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((s,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=s[c];d!=null&&(s[c]=d+t*u)}return s},{...e})}}const Kg=qre(1),$0=qre(-1);function pWe(t){return"clientX"in t&&"clientY"in t}function IF(t){if(!t)return!1;const{KeyboardEvent:e}=ao(t.target);return e&&t instanceof e}function gWe(t){if(!t)return!1;const{TouchEvent:e}=ao(t.target);return e&&t instanceof e}function DR(t){if(gWe(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 pWe(t)?{x:t.clientX,y:t.clientY}:null}const Mb=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[Mb.Translate.toString(t),Mb.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),D9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function bWe(t){return t.matches(D9)?t:t.querySelector(D9)}const xWe={display:"none"};function yWe(t){let{id:e,value:n}=t;return ci.createElement("div",{id:e,style:xWe},n)}function vWe(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 ci.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function wWe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Wre=w.createContext(null);function _We(t){const e=w.useContext(Wre);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function SWe(){const[t]=w.useState(()=>new Set),e=w.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[w.useCallback(r=>{let{type:i,event:s}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[t]),e]}const NWe={draggable:`
  8288. To pick up a draggable item, press the space bar.
  8289. While dragging, use the arrow keys to move the item.
  8290. Press space again to drop the item in its new position, or press escape to cancel.
  8291. `},kWe={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 MWe(t){let{announcements:e=kWe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=NWe}=t;const{announce:s,announcement:o}=wWe(),l=Rv("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),_We(w.useMemo(()=>({onDragStart(h){let{active:p}=h;s(e.onDragStart({active:p}))},onDragMove(h){let{active:p,over:m}=h;e.onDragMove&&s(e.onDragMove({active:p,over:m}))},onDragOver(h){let{active:p,over:m}=h;s(e.onDragOver({active:p,over:m}))},onDragEnd(h){let{active:p,over:m}=h;s(e.onDragEnd({active:p,over:m}))},onDragCancel(h){let{active:p,over:m}=h;s(e.onDragCancel({active:p,over:m}))}}),[s,e])),!c)return null;const d=ci.createElement(ci.Fragment,null,ci.createElement(yWe,{id:r,value:i.draggable}),ci.createElement(vWe,{id:l,announcement:o}));return n?Pu.createPortal(d,n):d}var ca;(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"})(ca||(ca={}));function bk(){}function xk(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Kre(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Jl=Object.freeze({x:0,y:0});function Xre(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Yre(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function CWe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function R9(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 Qre(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function L9(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 Zre=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=L9(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Xre(L9(c),i);s.push({id:l,data:{droppableContainer:o,value:u}})}}return s.sort(Yre)},EWe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=R9(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=R9(c),d=i.reduce((p,m,x)=>p+Xre(u[x],m),0),h=Number((d/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:h}})}}return s.sort(Yre)};function AWe(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),s=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=s-n;if(r<i&&n<s){const c=e.width*e.height,u=t.width*t.height,d=o*l,h=d/(c+u-d);return Number(h.toFixed(4))}return 0}const TWe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=AWe(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(CWe)};function jWe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Jre(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Jl}function PWe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];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 DWe=PWe(1);function RWe(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 LWe(t,e,n){const r=RWe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,h=s?t.height/s:t.height;return{width:d,height:h,top:u,right:c+d,bottom:u+h,left:c}}const OWe={ignoreTransform:!1};function Jb(t,e){e===void 0&&(e=OWe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=ao(t).getComputedStyle(t);u&&(n=LWe(n,u,d))}const{top:r,left:i,width:s,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:s,height:o,bottom:l,right:c}}function O9(t){return Jb(t,{ignoreTransform:!0})}function FWe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function IWe(t,e){return e===void 0&&(e=ao(t).getComputedStyle(t)),e.position==="fixed"}function zWe(t,e){e===void 0&&(e=ao(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=e[i];return typeof s=="string"?n.test(s):!1})}function oC(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(OF(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Pv(i)||Gre(i)||n.includes(i))return n;const s=ao(t).getComputedStyle(i);return i!==t&&zWe(i,s)&&n.push(i),IWe(i,s)?n:r(i.parentNode)}return t?r(t):n}function eie(t){const[e]=oC(t,1);return e??null}function oP(t){return!sC||!t?null:Qb(t)?t:LF(t)?OF(t)||t===Zb(t).scrollingElement?window:Pv(t)?t:null:null}function tie(t){return Qb(t)?t.scrollX:t.scrollLeft}function nie(t){return Qb(t)?t.scrollY:t.scrollTop}function RR(t){return{x:tie(t),y:nie(t)}}var Ta;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ta||(Ta={}));function rie(t){return!sC||!t?!1:t===document.scrollingElement}function iie(t){const e={x:0,y:0},n=rie(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,s=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const UWe={x:.2,y:.2};function BWe(t,e,n,r,i){let{top:s,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=UWe);const{isTop:u,isBottom:d,isLeft:h,isRight:p}=iie(t),m={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+y.height?(m.y=Ta.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&c>=e.bottom-y.height&&(m.y=Ta.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!p&&l>=e.right-y.width?(m.x=Ta.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!h&&o<=e.left+y.width&&(m.x=Ta.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:m,speed:x}}function $We(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:o}=window;return{top:0,left:0,right:s,bottom:o,width:s,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 aie(t){return t.reduce((e,n)=>Kg(e,RR(n)),Jl)}function HWe(t){return t.reduce((e,n)=>e+tie(n),0)}function VWe(t){return t.reduce((e,n)=>e+nie(n),0)}function GWe(t,e){if(e===void 0&&(e=Jb),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);eie(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const qWe=[["x",["left","right"],HWe],["y",["top","bottom"],VWe]];class zF{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=oC(n),i=aie(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of qWe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[s]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ky{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 WWe(t){const{EventTarget:e}=ao(t);return t instanceof e?t:Zb(t)}function lP(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 rl;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(rl||(rl={}));function F9(t){t.preventDefault()}function KWe(t){t.stopPropagation()}var er;(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"})(er||(er={}));const sie={start:[er.Space,er.Enter],cancel:[er.Esc],end:[er.Space,er.Enter,er.Tab]},XWe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case er.Right:return{...n,x:n.x+25};case er.Left:return{...n,x:n.x-25};case er.Down:return{...n,y:n.y+25};case er.Up:return{...n,y:n.y-25}}};class lC{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 Ky(Zb(n)),this.windowListeners=new Ky(ao(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(rl.Resize,this.handleCancel),this.windowListeners.add(rl.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(rl.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&GWe(r),n(Jl)}handleKeyDown(e){if(IF(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=sie,coordinateGetter:o=XWe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(s.end.includes(c)){this.handleEnd(e);return}if(s.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Jl;this.referenceCoordinates||(this.referenceCoordinates=d);const h=o(e,{active:n,context:r.current,currentCoordinates:d});if(h){const p=$0(h,d),m={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const b=e.code,{isTop:v,isRight:S,isLeft:k,isBottom:E,maxScroll:N,minScroll:A}=iie(y),M=$We(y),P={x:Math.min(b===er.Right?M.right-M.width/2:M.right,Math.max(b===er.Right?M.left:M.left+M.width/2,h.x)),y:Math.min(b===er.Down?M.bottom-M.height/2:M.bottom,Math.max(b===er.Down?M.top:M.top+M.height/2,h.y))},T=b===er.Right&&!S||b===er.Left&&!k,j=b===er.Down&&!E||b===er.Up&&!v;if(T&&P.x!==h.x){const z=y.scrollLeft+p.x,F=b===er.Right&&z<=N.x||b===er.Left&&z>=A.x;if(F&&!p.y){y.scrollTo({left:z,behavior:l});return}F?m.x=y.scrollLeft-z:m.x=b===er.Right?y.scrollLeft-N.x:y.scrollLeft-A.x,m.x&&y.scrollBy({left:-m.x,behavior:l});break}else if(j&&P.y!==h.y){const z=y.scrollTop+p.y,F=b===er.Down&&z<=N.y||b===er.Up&&z>=A.y;if(F&&!p.x){y.scrollTo({top:z,behavior:l});return}F?m.y=y.scrollTop-z:m.y=b===er.Down?y.scrollTop-N.y:y.scrollTop-A.y,m.y&&y.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,Kg($0(h,this.referenceCoordinates),m))}}}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()}}lC.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=sie,onActivation:i}=e,{active:s}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=s.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function I9(t){return!!(t&&"distance"in t)}function z9(t){return!!(t&&"delay"in t)}class UF{constructor(e,n,r){var i;r===void 0&&(r=WWe(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:s}=e,{target:o}=s;this.props=e,this.events=n,this.document=Zb(o),this.documentListeners=new Ky(this.document),this.listeners=new Ky(r),this.windowListeners=new Ky(ao(o)),this.initialCoordinates=(i=DR(s))!=null?i:Jl,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(rl.Resize,this.handleCancel),this.windowListeners.add(rl.DragStart,F9),this.windowListeners.add(rl.VisibilityChange,this.handleCancel),this.windowListeners.add(rl.ContextMenu,F9),this.documentListeners.add(rl.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(z9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(I9(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(rl.Click,KWe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(rl.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!i)return;const c=(n=DR(e))!=null?n:Jl,u=$0(i,c);if(!r&&l){if(I9(l)){if(l.tolerance!=null&&lP(u,l.tolerance))return this.handleCancel();if(lP(u,l.distance))return this.handleStart()}if(z9(l)&&lP(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===er.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const YWe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class cC extends UF{constructor(e){const{event:n}=e,r=Zb(n.target);super(e,YWe,r)}}cC.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 QWe={move:{name:"mousemove"},end:{name:"mouseup"}};var LR;(function(t){t[t.RightClick=2]="RightClick"})(LR||(LR={}));class ZWe extends UF{constructor(e){super(e,QWe,Zb(e.event.target))}}ZWe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===LR.RightClick?!1:(r?.({event:n}),!0)}}];const cP={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class JWe extends UF{constructor(e){super(e,cP)}static setup(){return window.addEventListener(cP.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(cP.move.name,e)};function e(){}}}JWe.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 Xy;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Xy||(Xy={}));var yk;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(yk||(yk={}));function eKe(t){let{acceleration:e,activator:n=Xy.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=yk.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:h,threshold:p}=t;const m=nKe({delta:h,disabled:!s}),[x,y]=mWe(),b=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),S=w.useMemo(()=>{switch(n){case Xy.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Xy.DraggableRect:return i}},[n,i,c]),k=w.useRef(null),E=w.useCallback(()=>{const A=k.current;if(!A)return;const M=b.current.x*v.current.x,P=b.current.y*v.current.y;A.scrollBy(M,P)},[]),N=w.useMemo(()=>l===yk.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!s||!u.length||!S){y();return}for(const A of N){if(r?.(A)===!1)continue;const M=u.indexOf(A),P=d[M];if(!P)continue;const{direction:T,speed:j}=BWe(A,P,S,e,p);for(const z of["x","y"])m[z][T[z]]||(j[z]=0,T[z]=0);if(j.x>0||j.y>0){y(),k.current=A,x(E,o),b.current=j,v.current=T;return}}b.current={x:0,y:0},v.current={x:0,y:0},y()},[e,E,r,y,s,o,JSON.stringify(S),JSON.stringify(m),x,u,N,d,JSON.stringify(p)])}const tKe={x:{[Ta.Backward]:!1,[Ta.Forward]:!1},y:{[Ta.Backward]:!1,[Ta.Forward]:!1}};function nKe(t){let{delta:e,disabled:n}=t;const r=PR(e);return Dv(i=>{if(n||!r||!i)return tKe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ta.Backward]:i.x[Ta.Backward]||s.x===-1,[Ta.Forward]:i.x[Ta.Forward]||s.x===1},y:{[Ta.Backward]:i.y[Ta.Backward]||s.y===-1,[Ta.Forward]:i.y[Ta.Forward]||s.y===1}}},[n,e,r])}function rKe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Dv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function iKe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...s]},[]),[t,e])}var H0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(H0||(H0={}));var OR;(function(t){t.Optimized="optimized"})(OR||(OR={}));const U9=new Map;function aKe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),h=b(),p=B0(h),m=w.useCallback(function(v){v===void 0&&(v=[]),!p.current&&o(S=>S===null?v:S.concat(v.filter(k=>!S.includes(k))))},[p]),x=w.useRef(null),y=Dv(v=>{if(h&&!n)return U9;if(!v||v===U9||d.current!==t||s!=null){const S=new Map;for(let k of t){if(!k)continue;if(s&&s.length>0&&!s.includes(k.id)&&k.rect.current){S.set(k.id,k.rect.current);continue}const E=k.node.current,N=E?new zF(c(E),E):null;k.rect.current=N,N&&S.set(k.id,N)}return S}return v},[t,s,n,h,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{h||m()},[n,h]),w.useEffect(()=>{s&&s.length>0&&o(null)},[JSON.stringify(s)]),w.useEffect(()=>{h||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{m(),x.current=null},l))},[l,h,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:s!=null};function b(){switch(u){case H0.Always:return!1;case H0.BeforeDragging:return n;default:return!n}}}function oie(t,e){return Dv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function sKe(t,e){return oie(t,e)}function oKe(t){let{callback:e,disabled:n}=t;const r=FF(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function uC(t){let{callback:e,disabled:n}=t;const r=FF(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function lKe(t){return new zF(Jb(t),t)}function B9(t,e,n){e===void 0&&(e=lKe);const[r,i]=w.useState(null);function s(){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=oKe({callback(c){if(t)for(const u of c){const{type:d,target:h}=u;if(d==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),l=uC({callback:s});return Ic(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function cKe(t){const e=oie(t);return Jre(t,e)}const $9=[];function uKe(t){const e=w.useRef(t),n=Dv(r=>t?r&&r!==$9&&t&&e.current&&t.parentNode===e.current.parentNode?r:oC(t):$9,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function dKe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(s=>{const o=oP(s.target);o&&n(l=>l?(l.set(o,RR(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const u=oP(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,RR(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(s)};function o(l){l.forEach(c=>{const u=oP(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>Kg(s,o),Jl):aie(t):Jl,[t,e])}function H9(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==Jl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?$0(t,n.current):Jl}function hKe(t){w.useEffect(()=>{if(!sC)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 fKe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=o=>{s(o,e)},n},{}),[t,e])}function lie(t){return w.useMemo(()=>t?FWe(t):null,[t])}const V9=[];function mKe(t,e){e===void 0&&(e=Jb);const[n]=t,r=lie(n?ao(n):null),[i,s]=w.useState(V9);function o(){s(()=>t.length?t.map(c=>rie(c)?r:new zF(e(c),c)):V9)}const l=uC({callback:o});return Ic(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function pKe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Pv(e)?e:t}function gKe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Pv(d)){r(h=>{const p=e(d);return h?{...h,width:p.width,height:p.height}:p});break}},[e]),s=uC({callback:i}),o=w.useCallback(u=>{const d=pKe(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[l,c]=gk(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const bKe=[{sensor:cC,options:{}},{sensor:lC,options:{}}],xKe={current:{}},n1={draggable:{measure:O9},droppable:{measure:O9,strategy:H0.WhileDragging,frequency:OR.Optimized},dragOverlay:{measure:Jb}};class Yy 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 yKe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Yy,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:bk},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:n1,measureDroppableContainers:bk,windowRect:null,measuringScheduled:!1},vKe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:bk,draggableNodes:new Map,over:null,measureDroppableContainers:bk},dC=w.createContext(vKe),cie=w.createContext(yKe);function wKe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Yy}}}function _Ke(t,e){switch(e.type){case ca.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ca.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 ca.DragEnd:case ca.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ca.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Yy(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case ca.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const o=new Yy(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case ca.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new Yy(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function SKe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(dC),s=PR(r),o=PR(n?.id);return w.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!IF(s)||document.activeElement===s.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 h=bWe(d);if(h){h.focus();break}}})}},[r,e,i,o,s]),null}function NKe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function kKe(t){return w.useMemo(()=>({draggable:{...n1.draggable,...t?.draggable},droppable:{...n1.droppable,...t?.droppable},dragOverlay:{...n1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function MKe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Ic(()=>{if(!o&&!l||!e){s.current=!1;return}if(s.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),h=Jre(d,r);if(o||(h.x=0),l||(h.y=0),s.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const p=eie(u);p&&p.scrollBy({top:h.y,left:h.x})}},[e,o,l,r,n])}const uie=w.createContext({...Jl,scaleX:1,scaleY:1});var ch;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(ch||(ch={}));const die=w.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=bKe,collisionDetection:h=TWe,measuring:p,modifiers:m,...x}=e;const y=w.useReducer(_Ke,void 0,wKe),[b,v]=y,[S,k]=SWe(),[E,N]=w.useState(ch.Uninitialized),A=E===ch.Initialized,{draggable:{active:M,nodes:P,translate:T},droppable:{containers:j}}=b,z=M!=null?P.get(M):null,F=w.useRef({initial:null,translated:null}),$=w.useMemo(()=>{var Xe;return M!=null?{id:M,data:(Xe=z?.data)!=null?Xe:xKe,rect:F}:null},[M,z]),D=w.useRef(null),[H,q]=w.useState(null),[I,K]=w.useState(null),Z=B0(x,Object.values(x)),se=Rv("DndDescribedBy",o),V=w.useMemo(()=>j.getEnabled(),[j]),W=kKe(p),{droppableRects:ie,measureDroppableContainers:J,measuringScheduled:pe}=aKe(V,{dragging:A,dependencies:[T.x,T.y],config:W.droppable}),fe=rKe(P,M),ve=w.useMemo(()=>I?DR(I):null,[I]),Le=je(),de=sKe(fe,W.draggable.measure);MKe({activeNode:M!=null?P.get(M):null,config:Le.layoutShiftCompensation,initialRect:de,measure:W.draggable.measure});const ce=B9(fe,W.draggable.measure,de),Ae=B9(fe?fe.parentElement:null),re=w.useRef({activatorEvent:null,active:null,activeNode:fe,collisionRect:null,collisions:null,droppableRects:ie,draggableNodes:P,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ie=j.getNodeFor((n=re.current.over)==null?void 0:n.id),G=gKe({measure:W.dragOverlay.measure}),Y=(r=G.nodeRef.current)!=null?r:fe,ue=A?(i=G.rect)!=null?i:ce:null,B=!!(G.nodeRef.current&&G.rect),ee=cKe(B?null:ce),Q=lie(Y?ao(Y):null),le=uKe(A?Ie??fe:null),he=mKe(le),te=NKe(m,{transform:{x:T.x-ee.x,y:T.y-ee.y,scaleX:1,scaleY:1},activatorEvent:I,active:$,activeNodeRect:ce,containerNodeRect:Ae,draggingNodeRect:ue,over:re.current.over,overlayNodeRect:G.rect,scrollableAncestors:le,scrollableAncestorRects:he,windowRect:Q}),U=ve?Kg(ve,T):null,L=dKe(le),X=H9(L),ge=H9(L,[ce]),_e=Kg(te,X),Ee=ue?DWe(ue,te):null,$e=$&&Ee?h({active:$,collisionRect:Ee,droppableRects:ie,droppableContainers:V,pointerCoordinates:U}):null,Ce=Qre($e,"id"),[He,Qe]=w.useState(null),xe=B?te:Kg(te,ge),ye=jWe(xe,(s=He?.rect)!=null?s:null,ce),we=w.useRef(null),Ue=w.useCallback((Xe,Re)=>{let{sensor:Oe,options:Ne}=Re;if(D.current==null)return;const Je=P.get(D.current);if(!Je)return;const yt=Xe.nativeEvent,Et=new Oe({active:D.current,activeNode:Je,event:yt,options:Ne,context:re,onAbort(jt){if(!P.get(jt))return;const{onDragAbort:gt}=Z.current,Qt={id:jt};gt?.(Qt),S({type:"onDragAbort",event:Qt})},onPending(jt,Fe,gt,Qt){if(!P.get(jt))return;const{onDragPending:un}=Z.current,dr={id:jt,constraint:Fe,initialCoordinates:gt,offset:Qt};un?.(dr),S({type:"onDragPending",event:dr})},onStart(jt){const Fe=D.current;if(Fe==null)return;const gt=P.get(Fe);if(!gt)return;const{onDragStart:Qt}=Z.current,tn={activatorEvent:yt,active:{id:Fe,data:gt.data,rect:F}};Pu.unstable_batchedUpdates(()=>{Qt?.(tn),N(ch.Initializing),v({type:ca.DragStart,initialCoordinates:jt,active:Fe}),S({type:"onDragStart",event:tn}),q(we.current),K(yt)})},onMove(jt){v({type:ca.DragMove,coordinates:jt})},onEnd:an(ca.DragEnd),onCancel:an(ca.DragCancel)});we.current=Et;function an(jt){return async function(){const{active:gt,collisions:Qt,over:tn,scrollAdjustedTranslate:un}=re.current;let dr=null;if(gt&&un){const{cancelDrop:gr}=Z.current;dr={activatorEvent:yt,active:gt,collisions:Qt,delta:un,over:tn},jt===ca.DragEnd&&typeof gr=="function"&&await Promise.resolve(gr(dr))&&(jt=ca.DragCancel)}D.current=null,Pu.unstable_batchedUpdates(()=>{v({type:jt}),N(ch.Uninitialized),Qe(null),q(null),K(null),we.current=null;const gr=jt===ca.DragEnd?"onDragEnd":"onDragCancel";if(dr){const ar=Z.current[gr];ar?.(dr),S({type:gr,event:dr})}})}}},[P]),Pe=w.useCallback((Xe,Re)=>(Oe,Ne)=>{const Je=Oe.nativeEvent,yt=P.get(Ne);if(D.current!==null||!yt||Je.dndKit||Je.defaultPrevented)return;const Et={active:yt};Xe(Oe,Re.options,Et)===!0&&(Je.dndKit={capturedBy:Re.sensor},D.current=Ne,Ue(Oe,Re))},[P,Ue]),Ve=iKe(d,Pe);hKe(d),Ic(()=>{ce&&E===ch.Initializing&&N(ch.Initialized)},[ce,E]),w.useEffect(()=>{const{onDragMove:Xe}=Z.current,{active:Re,activatorEvent:Oe,collisions:Ne,over:Je}=re.current;if(!Re||!Oe)return;const yt={active:Re,activatorEvent:Oe,collisions:Ne,delta:{x:_e.x,y:_e.y},over:Je};Pu.unstable_batchedUpdates(()=>{Xe?.(yt),S({type:"onDragMove",event:yt})})},[_e.x,_e.y]),w.useEffect(()=>{const{active:Xe,activatorEvent:Re,collisions:Oe,droppableContainers:Ne,scrollAdjustedTranslate:Je}=re.current;if(!Xe||D.current==null||!Re||!Je)return;const{onDragOver:yt}=Z.current,Et=Ne.get(Ce),an=Et&&Et.rect.current?{id:Et.id,rect:Et.rect.current,data:Et.data,disabled:Et.disabled}:null,jt={active:Xe,activatorEvent:Re,collisions:Oe,delta:{x:Je.x,y:Je.y},over:an};Pu.unstable_batchedUpdates(()=>{Qe(an),yt?.(jt),S({type:"onDragOver",event:jt})})},[Ce]),Ic(()=>{re.current={activatorEvent:I,active:$,activeNode:fe,collisionRect:Ee,collisions:$e,droppableRects:ie,draggableNodes:P,draggingNode:Y,draggingNodeRect:ue,droppableContainers:j,over:He,scrollableAncestors:le,scrollAdjustedTranslate:_e},F.current={initial:ue,translated:Ee}},[$,fe,$e,Ee,P,Y,ue,ie,j,He,le,_e]),eKe({...Le,delta:T,draggingRect:Ee,pointerCoordinates:U,scrollableAncestors:le,scrollableAncestorRects:he});const ke=w.useMemo(()=>({active:$,activeNode:fe,activeNodeRect:ce,activatorEvent:I,collisions:$e,containerNodeRect:Ae,dragOverlay:G,draggableNodes:P,droppableContainers:j,droppableRects:ie,over:He,measureDroppableContainers:J,scrollableAncestors:le,scrollableAncestorRects:he,measuringConfiguration:W,measuringScheduled:pe,windowRect:Q}),[$,fe,ce,I,$e,Ae,G,P,j,ie,He,J,le,he,W,pe,Q]),Ze=w.useMemo(()=>({activatorEvent:I,activators:Ve,active:$,activeNodeRect:ce,ariaDescribedById:{draggable:se},dispatch:v,draggableNodes:P,over:He,measureDroppableContainers:J}),[I,Ve,$,ce,v,se,P,He,J]);return ci.createElement(Wre.Provider,{value:k},ci.createElement(dC.Provider,{value:Ze},ci.createElement(cie.Provider,{value:ke},ci.createElement(uie.Provider,{value:ye},u)),ci.createElement(SKe,{disabled:l?.restoreFocus===!1})),ci.createElement(MWe,{...l,hiddenTextDescribedById:se}));function je(){const Xe=H?.autoScrollEnabled===!1,Re=typeof c=="object"?c.enabled===!1:c===!1,Oe=A&&!Xe&&!Re;return typeof c=="object"?{...c,enabled:Oe}:{enabled:Oe}}}),CKe=w.createContext(null),G9="button",EKe="Draggable";function AKe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Rv(EKe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:h,over:p}=w.useContext(dC),{role:m=G9,roleDescription:x="draggable",tabIndex:y=0}=i??{},b=c?.id===e,v=w.useContext(b?uie:CKe),[S,k]=gk(),[E,N]=gk(),A=fKe(o,e),M=B0(n);Ic(()=>(h.set(e,{id:e,key:s,node:S,activatorNode:E,data:M}),()=>{const T=h.get(e);T&&T.key===s&&h.delete(e)}),[h,e]);const P=w.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&m===G9?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,y,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:P,isDragging:b,listeners:r?void 0:A,node:S,over:p,setNodeRef:k,setActivatorNodeRef:N,transform:v}}function TKe(){return w.useContext(cie)}const jKe="Droppable",PKe={timeout:25};function DKe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Rv(jKe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(dC),d=w.useRef({disabled:n}),h=w.useRef(!1),p=w.useRef(null),m=w.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:b}={...PKe,...i},v=B0(y??r),S=w.useCallback(()=>{if(!h.current){h.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),m.current=null},b)},[b]),k=uC({callback:S,disabled:x||!o}),E=w.useCallback((P,T)=>{k&&(T&&(k.unobserve(T),h.current=!1),P&&k.observe(P))},[k]),[N,A]=gk(E),M=B0(e);return w.useEffect(()=>{!k||!N.current||(k.disconnect(),h.current=!1,k.observe(N.current))},[N,k]),w.useEffect(()=>(l({type:ca.RegisterDroppable,element:{id:r,key:s,disabled:n,node:N,rect:p,data:M}}),()=>l({type:ca.UnregisterDroppable,key:s,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:ca.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,l]),{active:o,rect:p,isOver:c?.id===r,node:N,over:c,setNodeRef:A}}function hC(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function RKe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function MS(t){return t!==null&&t>=0}function LKe(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 OKe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const BF=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=hC(e,r,n),o=e[i],l=s[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}},CS={scaleX:1,scaleY:1},FKe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:o}=t;const l=(e=s[n])!=null?e:r;if(!l)return null;if(i===n){const u=s[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...CS}:null}const c=IKe(s,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...CS}:i<n&&i>=o?{x:0,y:l.height+c,...CS}:{x:0,y:0,...CS}};function IKe(t,e,n){const r=t[e],i=t[e-1],s=t[e+1];return r?n<e?i?r.top-(i.top+i.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const hie="Sortable",fie=ci.createContext({activeIndex:-1,containerId:hie,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:BF,disabled:{draggable:!1,droppable:!1}});function mie(t){let{children:e,id:n,items:r,strategy:i=BF,disabled:s=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=TKe(),h=Rv(hie,n),p=l.rect!==null,m=w.useMemo(()=>r.map(A=>typeof A=="object"&&"id"in A?A.id:A),[r]),x=o!=null,y=o?m.indexOf(o.id):-1,b=u?m.indexOf(u.id):-1,v=w.useRef(m),S=!LKe(m,v.current),k=b!==-1&&y===-1||S,E=OKe(s);Ic(()=>{S&&x&&d(m)},[S,m,x,d]),w.useEffect(()=>{v.current=m},[m]);const N=w.useMemo(()=>({activeIndex:y,containerId:h,disabled:E,disableTransforms:k,items:m,overIndex:b,useDragOverlay:p,sortedRects:RKe(m,c),strategy:i}),[y,h,E.draggable,E.droppable,k,m,b,c,p,i]);return ci.createElement(fie.Provider,{value:N},e)}const zKe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return hC(n,r,i).indexOf(e)},UKe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==s&&i===o?!1:n?!0:o!==i&&e===c},BKe={duration:200,easing:"ease"},pie="transform",$Ke=Mb.Transition.toString({property:pie,duration:0,easing:"linear"}),HKe={roleDescription:"sortable"};function VKe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=w.useState(null),l=w.useRef(n);return Ic(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Jb(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{s&&o(null)},[s]),s}function gie(t){let{animateLayoutChanges:e=UKe,attributes:n,disabled:r,data:i,getNewIndex:s=zKe,id:o,strategy:l,resizeObserverConfig:c,transition:u=BKe}=t;const{items:d,containerId:h,activeIndex:p,disabled:m,disableTransforms:x,sortedRects:y,overIndex:b,useDragOverlay:v,strategy:S}=w.useContext(fie),k=GKe(r,m),E=d.indexOf(o),N=w.useMemo(()=>({sortable:{containerId:h,index:E,items:d},...i}),[h,i,E,d]),A=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:M,node:P,isOver:T,setNodeRef:j}=DKe({id:o,data:N,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:A,...c}}),{active:z,activatorEvent:F,activeNodeRect:$,attributes:D,setNodeRef:H,listeners:q,isDragging:I,over:K,setActivatorNodeRef:Z,transform:se}=AKe({id:o,data:N,attributes:{...HKe,...n},disabled:k.draggable}),V=fWe(j,H),W=!!z,ie=W&&!x&&MS(p)&&MS(b),J=!v&&I,pe=J&&ie?se:null,ve=ie?pe??(l??S)({rects:y,activeNodeRect:$,activeIndex:p,overIndex:b,index:E}):null,Le=MS(p)&&MS(b)?s({id:o,items:d,activeIndex:p,overIndex:b}):E,de=z?.id,ce=w.useRef({activeId:de,items:d,newIndex:Le,containerId:h}),Ae=d!==ce.current.items,re=e({active:z,containerId:h,isDragging:I,isSorting:W,id:o,index:E,items:d,newIndex:ce.current.newIndex,previousItems:ce.current.items,previousContainerId:ce.current.containerId,transition:u,wasDragging:ce.current.activeId!=null}),Ie=VKe({disabled:!re,index:E,node:P,rect:M});return w.useEffect(()=>{W&&ce.current.newIndex!==Le&&(ce.current.newIndex=Le),h!==ce.current.containerId&&(ce.current.containerId=h),d!==ce.current.items&&(ce.current.items=d)},[W,Le,h,d]),w.useEffect(()=>{if(de===ce.current.activeId)return;if(de!=null&&ce.current.activeId==null){ce.current.activeId=de;return}const Y=setTimeout(()=>{ce.current.activeId=de},50);return()=>clearTimeout(Y)},[de]),{active:z,activeIndex:p,attributes:D,data:N,rect:M,index:E,newIndex:Le,items:d,isOver:T,isSorting:W,isDragging:I,listeners:q,node:P,overIndex:b,over:K,setNodeRef:V,setActivatorNodeRef:Z,setDroppableNodeRef:j,setDraggableNodeRef:H,transform:Ie??ve,transition:G()};function G(){if(Ie||Ae&&ce.current.newIndex===E)return $Ke;if(!(J&&!IF(F)||!u)&&(W||re))return Mb.Transition.toString({...u,property:pie})}}function GKe(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 vk(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 qKe=[er.Down,er.Right,er.Up,er.Left],bie=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(qKe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const p=i.get(h.id);if(p)switch(t.code){case er.Down:r.top<p.top&&c.push(h);break;case er.Up:r.top>p.top&&c.push(h);break;case er.Left:r.left>p.left&&c.push(h);break;case er.Right:r.left<p.left&&c.push(h);break}});const u=EWe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Qre(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const h=s.get(n.id),p=s.get(d),m=p?i.get(p.id):null,x=p?.node.current;if(x&&m&&h&&p){const b=oC(x).some((A,M)=>l[M]!==A),v=xie(h,p),S=WKe(h,p),k=b||!v?{x:0,y:0}:{x:S?r.width-m.width:0,y:S?r.height-m.height:0},E={x:m.left,y:m.top};return k.x&&k.y?E:$0(E,k)}}}};function xie(t,e){return!vk(t)||!vk(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function WKe(t,e){return!vk(t)||!vk(e)||!xie(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function yie(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 KKe(t,e="system",n){if(!t)return n?.("queue.time.asap")??"ASAP";const r=Qi(t);if(!r)return n?.("queue.time.asap")??"ASAP";const i=new Date,s=r.getTime()-i.getTime();return s<-6e4?n?.("queue.time.overdue")??"Overdue":s<0?n?.("queue.time.now")??"Now":s<6e4?n?.("queue.time.lessThanMinute")??"In less than a minute":s<36e5?n?.("queue.time.inMinutes",{count:Math.round(s/6e4)})??`In ${Math.round(s/6e4)} min`:s<864e5?n?.("queue.time.inHours",{count:Math.round(s/36e5)})??`In ${Math.round(s/36e5)} hours`:tb(t,e)}function XKe({status:t,waitingReason:e,printerState:n,t:r}){if(t==="pending"&&e)return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-purple-400 bg-purple-400/10 border-purple-400/20",children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),r("queue.status.waiting")]});if(t==="printing"&&(n==="PAUSE"||n==="PAUSED"))return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-yellow-400 bg-yellow-400/10 border-yellow-400/20",children:[a.jsx(Dk,{className:"w-3.5 h-3.5"}),r("queue.status.paused")]});const i={pending:{icon:qn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:r("queue.status.pending")},printing:{icon:jo,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:r("queue.status.printing")},completed:{icon:mr,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:r("queue.status.completed")},failed:{icon:ua,color:"text-status-error bg-status-error/10 border-status-error/20",label:r("queue.status.failed")},skipped:{icon:c4,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:r("queue.status.skipped")},cancelled:{icon:Rt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:r("queue.status.cancelled")}},{icon:s,color:o,label:l}=i[t];return a.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${o}`,children:[a.jsx(s,{className:"w-3.5 h-3.5"}),l]})}function YKe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,t:s}){const[o,l]=w.useState("unchanged"),[c,u]=w.useState("unchanged"),[d,h]=w.useState("unchanged"),[p,m]=w.useState("unchanged"),[x,y]=w.useState("unchanged"),[b,v]=w.useState("unchanged"),[S,k]=w.useState("unchanged"),[E,N]=w.useState("unchanged"),[A,M]=w.useState("unchanged"),[P,T]=w.useState("unchanged"),j=()=>{const F={};o!=="unchanged"&&(F.printer_id=o),c!=="unchanged"&&(F.manual_start=c),d!=="unchanged"&&(F.auto_off_after=d),p!=="unchanged"&&(F.require_previous_success=p),x!=="unchanged"&&(F.bed_levelling=x),b!=="unchanged"&&(F.flow_cali=b),S!=="unchanged"&&(F.vibration_cali=S),E!=="unchanged"&&(F.layer_inspect=E),A!=="unchanged"&&(F.timelapse=A),P!=="unchanged"&&(F.use_ams=P),n(F)},z=o!=="unchanged"||c!=="unchanged"||d!=="unchanged"||p!=="unchanged"||x!=="unchanged"||b!=="unchanged"||S!=="unchanged"||E!=="unchanged"||A!=="unchanged"||P!=="unchanged";return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:s("queue.bulkEdit.title",{count:t})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:s("queue.bulkEdit.description")}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printer")}),a.jsxs("select",{value:o===null?"null":o==="unchanged"?"unchanged":String(o),onChange:F=>{const $=F.target.value;l($==="unchanged"?"unchanged":$==="null"?null:Number($))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"unchanged",children:s("queue.bulkEdit.noChange")}),a.jsx("option",{value:"null",children:s("queue.filter.unassigned")}),e.map(F=>a.jsx("option",{value:F.id,children:F.name},F.id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.queueOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(wu,{label:s("queue.bulkEdit.staged"),value:c,onChange:u,t:s}),a.jsx(wu,{label:s("queue.bulkEdit.autoPowerOff"),value:d,onChange:h,t:s}),a.jsx(wu,{label:s("queue.bulkEdit.requirePrevious"),value:p,onChange:m,t:s})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(wu,{label:s("queue.bulkEdit.bedLevelling"),value:x,onChange:y,t:s}),a.jsx(wu,{label:s("queue.bulkEdit.flowCalibration"),value:b,onChange:v,t:s}),a.jsx(wu,{label:s("queue.bulkEdit.vibrationCalibration"),value:S,onChange:k,t:s}),a.jsx(wu,{label:s("queue.bulkEdit.layerInspection"),value:E,onChange:N,t:s}),a.jsx(wu,{label:s("queue.bulkEdit.timelapse"),value:A,onChange:M,t:s}),a.jsx(wu,{label:s("queue.bulkEdit.useAms"),value:P,onChange:T,t:s})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:r,children:s("common.cancel")}),a.jsx(Me,{onClick:j,disabled:!z||i,children:s(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function wu({label:t,value:e,onChange:n,t:r}){return a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[a.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),a.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:r("common.off")}),a.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:r("common.on")})]})]})}function uP({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d,hasPermission:h,canModify:p,printerState:m,t:x}){const y=h("queue:reorder"),{attributes:b,listeners:v,setNodeRef:S,transform:k,transition:E,isDragging:N}=gie({id:t.id,disabled:t.status!=="pending"||!y}),A={transform:Mb.Transform.toString(k),transition:E},M=t.status==="printing",P=t.status==="pending",T=["completed","failed","skipped","cancelled"].includes(t.status);return a.jsx("div",{ref:S,style:A,className:`
  8292. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8293. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8294. ${N?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8295. ${M?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8296. `,children:a.jsxs("div",{className:"flex items-center gap-4 p-4",children:[P&&d&&a.jsx("button",{onClick:j=>{j.stopPropagation(),d()},className:`flex items-center justify-center w-6 h-6 rounded border transition-colors ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&a.jsx(Kr,{className:"w-4 h-4"})}),P?a.jsx("div",{...b,...v,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:a.jsx(kh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?a.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]}):a.jsx("div",{className:"w-8"}),a.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?a.jsx("img",{src:t.plate_id!=null?ae.getArchivePlateThumbnail(t.archive_id,t.plate_id):ae.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?ae.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):ae.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(Ja,{className:"w-6 h-6"})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?a.jsx(qs,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:x("queue.viewArchive"),children:a.jsx(Wr,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(qs,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:x("queue.viewInFileManager"),children:a.jsx(Wr,{className:"w-3.5 h-3.5"})}):null]}),a.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[a.jsxs("span",{className:`flex items-center gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[a.jsx(Nr,{className:"w-3.5 h-3.5"}),t.target_model?`${x("queue.filter.any")} ${t.target_model}${t.target_location?` @ ${t.target_location}`:""}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?x("queue.filter.unassigned"):t.printer_name||`${x("common.printer")} #${t.printer_id}`]}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Du,{className:"w-3.5 h-3.5"}),yie(t.print_time_seconds)]}),t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1.5",title:x("queue.addedBy",{name:t.created_by_username}),children:[a.jsx(Zu,{className:"w-3.5 h-3.5"}),t.created_by_username]}),P&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),KKe(t.scheduled_time,c,x)]})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&a.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:[a.jsx(tK,{className:"w-3 h-3"}),x("queue.badges.staged")]}),t.require_previous_success&&a.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:x("queue.badges.requiresPrevious")}),t.auto_off_after&&a.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:[a.jsx(cd,{className:"w-3 h-3"}),x("queue.badges.autoPowerOff")]})]}),M&&a.jsxs("div",{className:"mt-3",children:[a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:x("queue.printingInProgress")})]}),t.waiting_reason&&t.status==="pending"&&a.jsxs("p",{className:"text-xs text-purple-400 mt-2 flex items-start gap-1",children:[a.jsx(Ui,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),a.jsx("span",{children:t.waiting_reason})]}),t.error_message&&a.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[a.jsx(Ui,{className:"w-3 h-3"}),t.error_message]})]}),a.jsx(XKe,{status:t.status,waitingReason:t.waiting_reason,printerState:m,t:x}),a.jsxs("div",{className:"flex items-center gap-1",children:[M&&a.jsx(Me,{variant:"ghost",size:"sm",onClick:s,disabled:!h("printers:control"),title:h("printers:control")?x("queue.actions.stopPrint"):x("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(Iue,{className:"w-4 h-4"})}),P&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Me,{variant:"ghost",size:"sm",onClick:l,disabled:!h("printers:control"),title:h("printers:control")?x("queue.actions.startPrint"):x("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:a.jsx(jo,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:n,disabled:!p("queue","update",t.created_by_id),title:p("queue","update",t.created_by_id)?x("common.edit"):x("queue.permissions.noEdit"),children:a.jsx($i,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:r,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?x("common.cancel"):x("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),T&&a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:o,disabled:!h("queue:create"),title:h("queue:create")?x("queue.actions.requeue"):x("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:a.jsx(Ir,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:i,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?x("common.remove"):x("queue.permissions.noRemove"),children:a.jsx(en,{className:"w-4 h-4"})})]})]})]})})}function QKe(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),{hasPermission:r,hasAnyPermission:i,canModify:s}=Rr(),[o,l]=w.useState(null),[c,u]=w.useState(""),[d,h]=w.useState(""),[p,m]=w.useState(!1),[x,y]=w.useState(null),[b,v]=w.useState(null),[S,k]=w.useState(null),[E,N]=w.useState([]),[A,M]=w.useState(!1),[P,T]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[j,z]=w.useState(()=>{const te=localStorage.getItem("queue.historySortAsc");return te!==null?te==="true":!1}),[F,$]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[D,H]=w.useState(()=>{const te=localStorage.getItem("queue.pendingSortAsc");return te!==null?te==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",P)},[P]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(j))},[j]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",F)},[F]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(D))},[D]);const q=Kre(xk(cC,{activationConstraint:{distance:8}}),xk(lC,{coordinateGetter:bie})),{data:I}=et({queryKey:["settings"],queryFn:ae.getSettings}),K=I?.time_format||"system",{data:Z,isLoading:se}=et({queryKey:["queue",o,c],queryFn:()=>ae.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:V}=et({queryKey:["printers"],queryFn:()=>ae.getPrinters()}),W=st({mutationFn:te=>ae.cancelQueueItem(te),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),ie=st({mutationFn:te=>ae.removeFromQueue(te),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),J=st({mutationFn:te=>ae.stopQueueItem(te),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),pe=st({mutationFn:te=>ae.startQueueItem(te),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),fe=st({mutationFn:te=>ae.reorderQueue(te),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),ve=st({mutationFn:async()=>{const te=Z?.filter(U=>["completed","failed","skipped","cancelled"].includes(U.status))||[];for(const U of te)await ae.removeFromQueue(U.id);return te.length},onSuccess:te=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:te}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),Le=st({mutationFn:te=>ae.bulkUpdateQueue(te),onSuccess:te=>{e.invalidateQueries({queryKey:["queue"]}),N([]),M(!1),n(te.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),de=st({mutationFn:async te=>{for(const U of te)await ae.cancelQueueItem(U);return te.length},onSuccess:te=>{e.invalidateQueries({queryKey:["queue"]}),N([]),n(t("queue.toast.bulkCancelled",{count:te}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),ce=te=>{N(U=>U.includes(te)?U.filter(L=>L!==te):[...U,te])},Ae=w.useMemo(()=>{const te=new Set;return V?.forEach(U=>{U.location&&te.add(U.location)}),Z?.forEach(U=>{U.target_location&&te.add(U.target_location)}),Array.from(te).sort()},[V,Z]),re=w.useCallback(te=>d?te.target_location?te.target_location===d:te.printer_id?V?.find(L=>L.id===te.printer_id)?.location===d:!1:!0,[d,V]),Ie=w.useMemo(()=>{let te=Z?.filter(L=>L.status==="pending")||[];d&&(te=te.filter(re));const U=L=>{if(!L.scheduled_time)return 0;const X=new Date(L.scheduled_time).getTime(),ge=Date.now()+4320*60*60*1e3;return X>ge?0:X};return[...te].sort((L,X)=>{let ge;if(F==="name"){const _e=L.archive_name||L.library_file_name||"",Ee=X.archive_name||X.library_file_name||"";ge=_e.localeCompare(Ee)}else F==="printer"?ge=(L.printer_name||"").localeCompare(X.printer_name||""):F==="time"?ge=U(L)-U(X):ge=L.position-X.position;return D?ge:-ge})},[Z,F,D,re,d]),G=()=>{const te=Ie.map(U=>U.id);E.length===te.length?N([]):N(te)},Y=w.useMemo(()=>{let te=Z?.filter(U=>U.status==="printing")||[];return d&&(te=te.filter(re)),te},[Z,d,re]),ue=w.useMemo(()=>{const te=new Set;return Y.forEach(U=>{U.printer_id&&te.add(U.printer_id)}),Array.from(te)},[Y]),B=r4({queries:ue.map(te=>({queryKey:["printerStatus",te],queryFn:()=>ae.getPrinterStatus(te),refetchInterval:5e3}))}),ee=w.useMemo(()=>{const te={};return ue.forEach((U,L)=>{const X=B[L];X?.data?.state&&(te[U]=X.data.state)}),te},[ue,B]),Q=w.useMemo(()=>{let te=Z?.filter(U=>["completed","failed","skipped","cancelled"].includes(U.status))||[];return d&&(te=te.filter(re)),[...te].sort((U,L)=>{let X;if(P==="name"){const ge=U.archive_name||U.library_file_name||"",_e=L.archive_name||L.library_file_name||"";X=ge.localeCompare(_e)}else P==="printer"?X=(U.printer_name||"").localeCompare(L.printer_name||""):X=new Date(L.completed_at||L.created_at).getTime()-new Date(U.completed_at||U.created_at).getTime();return j?-X:X})},[Z,P,j,re,d]),le=w.useMemo(()=>Ie.reduce((te,U)=>te+(U.print_time_seconds||0),0),[Ie]),he=te=>{const{active:U,over:L}=te;if(!L||U.id===L.id)return;const X=Ie.findIndex(_e=>_e.id===U.id),ge=Ie.findIndex(_e=>_e.id===L.id);if(X!==-1&&ge!==-1){const Ee=hC(Ie,X,ge).map(($e,Ce)=>({id:$e.id,position:Ce+1}));fe.mutate(Ee)}};return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsx("div",{className:"flex items-center justify-between mb-8",children:a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx(nK,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[a.jsx(_t,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:a.jsx(jo,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Y.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.printing")})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:a.jsx(qn,{className:"w-5 h-5 text-yellow-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Ie.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.queued")})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:a.jsx(Du,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:yie(le)}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.totalTime")})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:a.jsx(mr,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Q.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.history")})]})]})})})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[a.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:o===-1?"unassigned":o||"",onChange:te=>{const U=te.target.value;l(U==="unassigned"?-1:U===""?null:Number(U))},children:[a.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),a.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),V?.map(te=>a.jsx("option",{value:te.id,children:te.name},te.id))]}),a.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:c,onChange:te=>u(te.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allStatus")}),a.jsx("option",{value:"pending",children:t("queue.status.pending")}),a.jsx("option",{value:"printing",children:t("queue.status.printing")}),a.jsx("option",{value:"completed",children:t("queue.status.completed")}),a.jsx("option",{value:"failed",children:t("queue.status.failed")}),a.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),a.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),Ae.length>0&&a.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:d,onChange:te=>h(te.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Ae.map(te=>a.jsx("option",{value:te,children:te},te))]}),a.jsx("div",{className:"flex-1"}),Q.length>0&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>m(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[a.jsx(en,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),se?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Z?.length===0?a.jsxs(_t,{className:"p-12 text-center border-dashed",children:[a.jsx(ri,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),a.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),a.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):a.jsxs("div",{className:"space-y-8",children:[Y.length>0&&a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),a.jsx("div",{className:"space-y-3",children:Y.map(te=>a.jsx(uP,{item:te,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>k({type:"stop",item:te}),onRequeue:()=>{},onStart:()=>{},timeFormat:K,hasPermission:r,canModify:s,printerState:te.printer_id?ee[te.printer_id]:null,t},te.id))})]}),Ie.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(qn,{className:"w-5 h-5 text-yellow-400"}),t("queue.sections.queued"),a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Ie.length}),")"]}),a.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.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:F,onChange:te=>$(te.target.value),children:[a.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),a.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>H(!D),title:t(D?"common.ascending":"common.descending"),className:"px-2",children:D?a.jsx(_m,{className:"w-4 h-4"}):a.jsx(Yg,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[a.jsxs(Me,{variant:"ghost",size:"sm",onClick:G,className:"flex items-center gap-2",children:[E.length===Ie.length&&Ie.length>0?a.jsx(to,{className:"w-4 h-4 text-bambu-green"}):a.jsx(pl,{className:"w-4 h-4"}),E.length===Ie.length&&Ie.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),E.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:E.length})}),a.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>M(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",disabled:!i("queue:update_own","queue:update_all"),title:i("queue:update_own","queue:update_all")?void 0:t("queue.permissions.noEditItems"),children:[a.jsx($i,{className:"w-4 h-4"}),t("queue.bulkEdit.editSelected")]}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>de.mutate(E),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:de.isPending||!i("queue:delete_own","queue:delete_all"),title:i("queue:delete_own","queue:delete_all")?void 0:t("queue.permissions.noCancelItems"),children:[a.jsx(Rt,{className:"w-4 h-4"}),t("queue.bulkEdit.cancelSelected")]})]})]}),a.jsx(die,{sensors:q,collisionDetection:Zre,onDragEnd:he,children:a.jsx(mie,{items:Ie.map(te=>te.id),strategy:FKe,children:a.jsx("div",{className:"space-y-3",children:Ie.map((te,U)=>a.jsx(uP,{item:te,position:U+1,onEdit:()=>y(te),onCancel:()=>k({type:"cancel",item:te}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>pe.mutate(te.id),timeFormat:K,isSelected:E.includes(te.id),onToggleSelect:()=>ce(te.id),hasPermission:r,canModify:s,t},te.id))})})})]}),Q.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(mr,{className:"w-5 h-5 text-bambu-gray"}),t("queue.sections.history"),a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Q.length}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.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:P,onChange:te=>T(te.target.value),children:[a.jsx("option",{value:"date",children:t("queue.sort.byDate")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>z(!j),title:t(j?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:j?a.jsx(_m,{className:"w-4 h-4"}):a.jsx(Yg,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-3",children:Q.slice(0,20).map((te,U)=>a.jsx(uP,{item:te,position:U+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>k({type:"remove",item:te}),onStop:()=>{},onRequeue:()=>v(te),onStart:()=>{},timeFormat:K,hasPermission:r,canModify:s,t},te.id))})]})]}),x&&a.jsx(qu,{mode:"edit-queue-item",archiveId:x.archive_id??void 0,libraryFileId:x.library_file_id??void 0,archiveName:x.archive_name||x.library_file_name||`File #${x.archive_id||x.library_file_id}`,queueItem:x,onClose:()=>y(null)}),b&&a.jsx(qu,{mode:"add-to-queue",archiveId:b.archive_id??void 0,libraryFileId:b.library_file_id??void 0,archiveName:b.archive_name||b.library_file_name||`File #${b.archive_id||b.library_file_id}`,onClose:()=>v(null)}),S&&a.jsx(On,{title:S.type==="cancel"?t("queue.confirm.cancelTitle"):S.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:S.type==="cancel"?t("queue.confirm.cancelMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):S.type==="stop"?t("queue.confirm.stopMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:S.type==="cancel"?t("queue.confirm.cancelButton"):S.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{S.type==="cancel"?W.mutate(S.item.id):S.type==="stop"?J.mutate(S.item.id):ie.mutate(S.item.id),k(null)},onCancel:()=>k(null)}),p&&a.jsx(On,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:Q.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{ve.mutate(),m(!1)},onCancel:()=>m(!1)}),A&&a.jsx(YKe,{selectedCount:E.length,printers:V?.map(te=>({id:te.id,name:te.name}))||[],onSave:te=>{Object.keys(te).length>0&&Le.mutate({item_ids:E,...te})},onClose:()=>M(!1),isSaving:Le.isPending,t})]})}function ZKe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const S=n.current;if(!S)return;const k=new ResizeObserver(E=>{const N=E[0]?.contentRect.width||0;i(N)});return k.observe(S),()=>k.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const S={};t.forEach(z=>{const F=z.split("T")[0];S[F]=(S[F]||0)+1});const k=new Date,E=new Date(k);E.setMonth(E.getMonth()-e),E.setDate(E.getDate()-E.getDay());const N=[],A=[];let M=[],P=-1;const T=new Date(E);let j=0;for(;T<=k;)T.getDay()===0&&M.length>0&&(N.push(M),M=[],j++),T.getMonth()!==P&&(A.push({month:T.toLocaleDateString("en-US",{month:"short"}),weekIndex:j}),P=T.getMonth()),M.push(new Date(T)),T.setDate(T.getDate()+1);return M.length>0&&N.push(M),{weeks:N,monthLabels:A,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const k=S/c;return k<=.25?"bg-bambu-green/30":k<=.5?"bg-bambu-green/50":k<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=s.length,p=32,m=2,x=r-p-16,y=h>0?Math.floor((x-(h-1)*m)/h):12,b=Math.max(8,Math.min(20,y)),v=b<=10?10:12;return a.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&a.jsxs("div",{children:[a.jsx("div",{className:"flex mb-1",style:{marginLeft:p+4},children:o.map(({month:S,weekIndex:k},E)=>a.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:E===0?0:`${(k-(o[E-1]?.weekIndex||0))*(b+m)-24}px`},children:S},E))}),a.jsxs("div",{className:"flex",style:{gap:m},children:[a.jsx("div",{className:"flex flex-col",style:{gap:m,marginRight:4,width:p},children:d.map((S,k)=>a.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:b,fontSize:v,visibility:k%2===1?"visible":"hidden"},children:S},S))}),s.map((S,k)=>a.jsx("div",{className:"flex flex-col",style:{gap:m},children:[0,1,2,3,4,5,6].map(E=>{const N=S.find(T=>T.getDay()===E);if(!N)return a.jsx("div",{style:{width:b,height:b}},E);const A=N.toISOString().split("T")[0],M=l[A]||0,P=A===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${u(M)} ${P?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${N.toLocaleDateString()}: ${M} print${M!==1?"s":""}`},E)})},k))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:m},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),a.jsx("span",{children:"More"})]})]})})}const ES=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function JKe(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 eXe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=JKe(n);return t.filter(x=>(Qi(x.completed_at||x.created_at)||new Date(0))>=m)},[t,n]),s=w.useMemo(()=>{const m=new Map;return i.forEach(x=>{const y=Qi(x.completed_at||x.created_at)||new Date,b=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=m.get(b)||{date:b,filament:0,cost:0,prints:0};v.filament+=x.filament_used_grams||0,v.cost+=x.cost||0,v.prints+=x.quantity||1,m.set(b,v)}),Array.from(m.values()).sort((x,y)=>x.date.localeCompare(y.date)).map(x=>({...x,dateLabel:new Date(x.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return s;const m=new Map;return i.forEach(x=>{const y=Qi(x.completed_at||x.created_at)||new Date,b=new Date(y);b.setDate(y.getDate()-y.getDay());const v=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,S=m.get(v)||{week:v,filament:0,cost:0,prints:0};S.filament+=x.filament_used_grams||0,S.cost+=x.cost||0,S.prints+=x.quantity||1,m.set(v,S)}),Array.from(m.values()).sort((x,y)=>x.week.localeCompare(y.week)).map(x=>({date:x.week,dateLabel:`Week of ${new Date(x.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...x}))},[i,s,n]),l=w.useMemo(()=>{const m=new Map;return i.forEach(x=>{const b=(x.filament_type||"Unknown").split(", ");b.forEach(v=>{const S=(x.filament_used_grams||0)/b.length;m.set(v,(m.get(v)||0)+S)})}),Array.from(m.entries()).map(([x,y])=>({name:x,value:Math.round(y)})).sort((x,y)=>y.value-x.value)},[i]),c=w.useMemo(()=>{const m=new Date,x=[];for(let y=5;y>=0;y--){const b=new Date(m.getFullYear(),m.getMonth()-y,1),v=new Date(m.getFullYear(),m.getMonth()-y+1,0),S=b.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),k=t.filter(E=>{const N=Qi(E.completed_at||E.created_at)||new Date(0);return N>=b&&N<=v});x.push({month:S,filament:Math.round(k.reduce((E,N)=>E+(N.filament_used_grams||0),0)),cost:k.reduce((E,N)=>E+(N.cost||0),0),prints:k.reduce((E,N)=>E+(N.quantity||1),0)})}return x},[t]),u=n==="7d"||n==="30d"?s:o,d=i.reduce((m,x)=>m+(x.filament_used_grams||0),0),h=i.reduce((m,x)=>m+(x.cost||0),0),p=i.reduce((m,x)=>m+(x.quantity||1),0);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),a.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(m=>a.jsx("button",{onClick:()=>r(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,h.toFixed(2)]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[p," prints"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[p>0?(d/p).toFixed(0):0,"g"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,p>0?(h/p).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),a.jsx(WS,{width:"100%",height:250,children:a.jsxs(D8e,{data:u,children:[a.jsx("defs",{children:a.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[a.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),a.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),a.jsx(yN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(wN,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(_N,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(XS,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),a.jsx(Ree,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):a.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(WS,{width:160,height:160,children:a.jsxs(j8e,{children:[a.jsx(iee,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,x)=>a.jsx(kv,{fill:ES[x%ES.length]},`cell-${x}`))}),a.jsx(XS,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m??0}g`,"Usage"]})]})}),a.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,x)=>{const y=l.reduce((v,S)=>v+S.value,0),b=y>0?(m.value/y*100).toFixed(0):0;return a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:ES[x%ES.length]}}),a.jsx("span",{className:"text-white truncate flex-1",children:m.name}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[b,"%"]})]},m.name)})})]}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),a.jsx(WS,{width:"100%",height:200,children:a.jsxs(y8e,{data:c,children:[a.jsx(yN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(wN,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),a.jsx(_N,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(XS,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,x)=>[x==="filament"?`${m??0}g`:x==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,x==="filament"?"Filament":x==="cost"?"Cost":"Prints"]}),a.jsx(bL,{}),a.jsx(uee,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function tXe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:h,isDragging:p}=gie({id:t}),m={transform:Mb.Transform.toString(d),transition:h,opacity:p?.5:1};return r?null:a.jsxs("div",{ref:u,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?"ring-2 ring-bambu-green shadow-lg":""}`,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.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:a.jsx(kh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),a.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.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?a.jsx(o4,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(s4,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),a.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:a.jsx(W0,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),a.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function nXe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:s}){const o=()=>{const E={};return t.forEach(N=>{E[N.id]=N.defaultSize||4}),E},[l,c]=w.useState(()=>{const E=localStorage.getItem(e);if(E)try{const N=JSON.parse(E);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]=w.useState(!1);w.useEffect(()=>{const E=()=>d(N=>!N);return window.addEventListener("toggle-hidden-panel",E),()=>window.removeEventListener("toggle-hidden-panel",E)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const N=t.map(A=>A.id).filter(A=>!l.order.includes(A));N.length>0&&c(A=>({...A,order:[...A.order,...N]}))},[t,l.order]);const h=Kre(xk(cC,{activationConstraint:{distance:8}}),xk(lC,{coordinateGetter:bie})),p=E=>{const{active:N,over:A}=E;A&&N.id!==A.id&&c(M=>{const P=M.order.indexOf(N.id),T=M.order.indexOf(A.id);return{...M,order:hC(M.order,P,T)}})},m=E=>{c(N=>({...N,hidden:N.hidden.includes(E)?N.hidden.filter(A=>A!==E):[...N.hidden,E]}))},x=E=>{c(N=>{const A=N.sizes[E]||4,M=A===1?2:A===2?4:1;return{...N,sizes:{...N.sizes,[E]:M}}})},y=()=>{const E={order:t.map(N=>N.id),hidden:t.filter(N=>N.defaultVisible===!1).map(N=>N.id),sizes:o()};c(E),i?.()},b=l.order.map(E=>t.find(N=>N.id===E)).filter(Boolean),v=b.filter(E=>!l.hidden.includes(E.id)),S=b.filter(E=>l.hidden.includes(E.id)),k=s?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return a.jsxs("div",{className:"space-y-4",children:[k,!r&&!s&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:y,children:[a.jsx(Po,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[a.jsx(Yl,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.length>0&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(E=>a.jsxs("button",{onClick:()=>m(E.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[a.jsx(Yl,{className:"w-3 h-3"}),E.title]},E.id))})]}),a.jsx(die,{sensors:h,collisionDetection:Zre,onDragEnd:p,children:a.jsx(mie,{items:v.map(E=>E.id),strategy:BF,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(E=>a.jsx(tXe,{id:E.id,title:E.title,component:E.component,isHidden:l.hidden.includes(E.id),size:l.sizes[E.id]||2,onToggleVisibility:()=>m(E.id),onToggleSize:()=>x(E.id)},E.id))})})}),v.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Me,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}const rXe={USD:"$",EUR:"€",GBP:"£",CHF:"Fr.",JPY:"¥",CNY:"¥",CAD:"$",AUD:"$",INR:"₹",HKD:"HK$",KRW:"₩",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"zł",BRL:"R$",TWD:"NT$",SGD:"S$",NZD:"NZ$",MXN:"MX$",CZK:"Kč",THB:"฿",ZAR:"R",TRY:"₺",RUB:"₽"};function Mu(t){return rXe[t.toUpperCase()]||t}const iXe=[{code:"USD",label:"USD ($)"},{code:"EUR",label:"EUR (€)"},{code:"GBP",label:"GBP (£)"},{code:"CHF",label:"CHF (Fr.)"},{code:"JPY",label:"JPY (¥)"},{code:"CNY",label:"CNY (¥)"},{code:"CAD",label:"CAD ($)"},{code:"AUD",label:"AUD ($)"},{code:"INR",label:"INR (₹)"},{code:"HKD",label:"HKD (HK$)"},{code:"KRW",label:"KRW (₩)"},{code:"SEK",label:"SEK (kr)"},{code:"NOK",label:"NOK (kr)"},{code:"DKK",label:"DKK (kr)"},{code:"PLN",label:"PLN (zł)"},{code:"BRL",label:"BRL (R$)"},{code:"TWD",label:"TWD (NT$)"},{code:"SGD",label:"SGD (S$)"},{code:"NZD",label:"NZD (NZ$)"},{code:"MXN",label:"MXN (MX$)"},{code:"CZK",label:"CZK (Kč)"},{code:"THB",label:"THB (฿)"},{code:"ZAR",label:"ZAR (R)"},{code:"TRY",label:"TRY (₺)"},{code:"RUB",label:"RUB (₽)"}];function aXe({stats:t,currency:e,t:n}){return a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(ta,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),a.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:a.jsx(qn,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:a.jsx(ta,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:a.jsx(IP,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:a.jsx(Ih,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:a.jsx(IP,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function sXe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,s=n===1?112:n===2?128:144,o=s/2-8,l=o*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:s,height:s},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i,"%"]})})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(mr,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ua,{className:"w-4 h-4 text-status-error flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),a.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&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),a.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(([c,u])=>a.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(c)||`${r("common.printer")} ${c}`}),a.jsx("span",{className:"text-white font-medium",children:u})]},c))})]})]})]})}function oXe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==null)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,i))-50)/100*100,c=(y=>y>=95&&y<=105?"#00ae42":y>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,h=d/2-8,p=h*2*Math.PI,m=n===1?3:n===2?6:999,x=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*p} ${p}`})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i.toFixed(0),"%"]}),a.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx(oK,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{children:r("stats.perfectEstimate")})]}),x.length>0&&a.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:x.map(([y,b])=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(y)||`${r("common.printer")} ${y}`}),a.jsxs("span",{className:`font-medium ${b>=95&&b<=105?"text-status-ok":b>105?"text-blue-400":"text-status-warning"}`,children:[b.toFixed(0),"%"]})]},y))})]})]})}function lXe({stats:t,size:e=1,t:n}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noFilamentData")});const r=Object.entries(t.prints_by_filament_type).sort(([,l],[,c])=>c-l),i=e===1?5:e===2?8:999,s=r.slice(0,i),o=r.length>i;return e===4&&s.length>4?a.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white truncate max-w-[120px]",children:l}),a.jsx("span",{className:"text-bambu-gray",children:c})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)})}):a.jsxs("div",{className:"space-y-3",children:[s.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white",children:l}),a.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.prints")]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)}),o&&a.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function cXe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return a.jsx(ZKe,{printDates:t,months:n})}function uXe({stats:t,printerMap:e,t:n}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrinterData")}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:a.jsx(Nr,{className:"w-4 h-4 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-sm",children:e.get(r)||`${n("common.printer")} ${r}`}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function dXe({archives:t,currency:e,t:n}){return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):a.jsx(eXe,{archives:t,currency:e})}function hXe({size:t=1,t:e}){const{data:n,isLoading:r}=et({queryKey:["failureAnalysis"],queryFn:()=>ae.getFailureAnalysis({days:30})});if(r)return a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,s=Object.entries(n.failures_by_reason).sort(([,c],[,u])=>u-c),o=s.slice(0,i),l=s.length>i;return a.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[a.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[a.jsx("div",{className:"flex items-center gap-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kn,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),a.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:e("stats.failedPrintsCount",{failed:n.failed_prints,total:n.total_prints})}),n.trend&&n.trend.length>=2&&a.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(u4,{className:`w-4 h-4 ${n.trend[n.trend.length-1].failure_rate<n.trend[n.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),a.jsx("span",{className:"text-bambu-gray",children:e("stats.lastWeekRate",{rate:n.trend[n.trend.length-1].failure_rate.toFixed(1)})})]})})]}),o.length>0&&a.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?e("stats.failureReasons"):e("stats.topFailureReasons")}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,u])=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:c||e("common.unknown")}),a.jsx("span",{className:"text-bambu-gray ml-2",children:u})]},c))}),l&&a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:s.length-i})})]})]})}function fXe(){const{t}=Ut(),{showToast:e}=hn(),{hasPermission:n}=Rr(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(0),[u,d]=w.useState(0),[h,p]=w.useState(!1);w.useEffect(()=>{const T=()=>{try{const z=localStorage.getItem("bambusy-dashboard-layout");if(z){const F=JSON.parse(z);d(F.hidden?.length||0)}}catch{d(0)}};T(),window.addEventListener("storage",T);const j=setInterval(T,500);return()=>{window.removeEventListener("storage",T),clearInterval(j)}},[l]);const{data:m,isLoading:x,refetch:y}=et({queryKey:["archiveStats"],queryFn:ae.getArchiveStats}),{data:b}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:v}=et({queryKey:["archives"],queryFn:()=>ae.getArchives(void 0,void 0,1e3,0)}),{data:S}=et({queryKey:["settings"],queryFn:ae.getSettings}),k=async T=>{o(!1),i(!0);try{const{blob:j,filename:z}=await ae.exportStats({format:T,days:90}),F=URL.createObjectURL(j),$=document.createElement("a");$.href=F,$.download=z,$.click(),URL.revokeObjectURL(F),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},E=async()=>{p(!0);try{const T=await ae.recalculateCosts();await y(),e(t("stats.recalculatedCosts",{count:T.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{p(!1)}},N=Mu(S?.currency||"USD"),A=new Map(b?.map(T=>[String(T.id),T.name])||[]),M=v?.map(T=>T.created_at)||[];if(x)return a.jsx("div",{className:"p-4 md:p-8",children:a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const P=[{id:"quick-stats",title:t("stats.quickStats"),component:a.jsx(aXe,{stats:m,currency:N,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:T=>a.jsx(sXe,{stats:m,printerMap:A,size:T,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:T=>a.jsx(oXe,{stats:m,printerMap:A,size:T,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:T=>a.jsx(lXe,{stats:m,size:T,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:T=>a.jsx(hXe,{size:T,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:T=>a.jsx(cXe,{printDates:M,size:T}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:a.jsx(uXe,{stats:m,printerMap:A,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:a.jsx(dXe,{archives:v||[],currency:N,t}),defaultSize:4}];return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u>0&&a.jsxs(Me,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(Yl,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),a.jsxs(Me,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),c(T=>T+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[a.jsx(Po,{className:"w-4 h-4"}),t("stats.resetLayout")]}),a.jsxs(Me,{variant:"secondary",onClick:E,disabled:h||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[h?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(bue,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Me,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(d1,{className:"w-4 h-4"}),t("stats.exportStats")]}),s&&a.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:[a.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:()=>k("csv"),children:[a.jsx(Ms,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),a.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:()=>k("xlsx"),children:[a.jsx(d1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),a.jsx(nXe,{widgets:P,storageKey:"bambusy-dashboard-layout",hideControls:!0},l)]})}function mXe({plug:t,onEdit:e}){const{t:n}=Ut(),r=Zt(),{showToast:i}=hn(),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!1),[h,p]=w.useState(!1),{data:m,isLoading:x}=et({queryKey:["smart-plug-status",t.id],queryFn:()=>ae.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:y}=et({queryKey:["printers"],queryFn:ae.getPrinters}),b=y?.find(j=>j.id===t.printer_id),v=st({mutationFn:j=>ae.controlSmartPlug(t.id,j),onMutate:async j=>{await r.cancelQueries({queryKey:["smart-plug-status",t.id]});const z=r.getQueryData(["smart-plug-status",t.id]),F=j==="on"?"ON":j==="off"||m?.state==="ON"?"OFF":"ON";return r.setQueryData(["smart-plug-status",t.id],$=>({...$,state:F})),{previousStatus:z}},onError:(j,z,F)=>{F?.previousStatus&&r.setQueryData(["smart-plug-status",t.id],F.previousStatus),i(`Failed to turn ${z} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:["smart-plug-status",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),S=st({mutationFn:j=>ae.updateSmartPlug(t.id,j),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(r.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),k=st({mutationFn:()=>ae.deleteSmartPlug(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),E=m?.state==="ON",N=t.plug_type==="mqtt"&&m?.energy?.power!==null&&m?.energy?.power!==void 0,A=(m?.reachable??!1)||N,M=v.isPending,T=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const j=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${j}/`:`http://${j}/`})();return a.jsxs(a.Fragment,{children:[a.jsx(_t,{className:"relative",children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?A?"bg-teal-500/20":"bg-red-500/20":A?E?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(l4,{className:`w-5 h-5 ${A?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx(K0,{className:`w-5 h-5 ${A?E?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(dl,{className:`w-5 h-5 ${A?E?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[x?a.jsx(it,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?a.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[a.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),A&&a.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),a.jsx("span",{className:A?E?"text-status-ok":"text-bambu-gray":"text-status-error",children:A?m?.state||"?":"Offline"})]}):A?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(Lg,{className:"w-4 h-4 text-status-ok"}),a.jsx("span",{className:E?"text-status-ok":"text-bambu-gray",children:m?.state||"Unknown"})]}):a.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[a.jsx(km,{className:"w-4 h-4"}),a.jsx("span",{children:n("smartPlugs.offline")})]}),T&&a.jsxs("a",{href:T,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:n("smartPlugs.openPlugAdminPage"),children:[a.jsx(Wr,{className:"w-3 h-3"}),n("smartPlugs.admin")]})]})]}),b&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),a.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[a.jsx(Yl,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&a.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:[a.jsx(Dg,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&a.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:[a.jsx(ri,{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}`]})]}),t.plug_type!=="mqtt"&&a.jsxs("div",{className:"flex gap-2 mb-3",children:[a.jsxs(Me,{size:"sm",variant:E?"primary":"secondary",disabled:!A||M,onClick:()=>c(!0),className:"flex-1",children:[M?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(cd,{className:"w-4 h-4"}),"On"]}),a.jsxs(Me,{size:"sm",variant:E?"secondary":"primary",disabled:!A||M,onClick:()=>d(!0),className:"flex-1",children:[M?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Rk,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&m?.energy&&a.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[m.energy.power!==null&&m.energy.power!==void 0&&a.jsxs("div",{className:"flex-1 text-center",children:[a.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(m.energy.power),"W"]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),m.energy.today!==null&&m.energy.today!==void 0&&a.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-lg font-semibold text-white",children:m.energy.today.toFixed(2)}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),a.jsxs("button",{onClick:()=>p(!h),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Qu,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),a.jsx("span",{children:h?"-":"+"})]}),h&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(X0,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:j=>S.mutate({show_in_switchbar:j.target.checked}),className:"sr-only peer"}),a.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.plug_type!=="mqtt"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.enabled,onChange:j=>S.mutate({enabled:j.target.checked}),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto On"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:j=>S.mutate({auto_on:j.target.checked}),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:j=>S.mutate({auto_off:j.target.checked}),className:"sr-only peer"}),a.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&&a.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>S.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:[a.jsx(qn,{className:"w-4 h-4"}),"Time"]}),a.jsxs("button",{onClick:()=>S.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:[a.jsx(Fk,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),a.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:j=>S.mutate({off_delay_minutes:parseInt(j.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"})]}):a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),a.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:j=>S.mutate({off_temp_threshold:parseInt(j.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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(Yf,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>o(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(en,{className:"w-4 h-4"})})]})]})]})}),s&&a.jsx(On,{title:n("smartPlugs.deleteSmartPlug"),message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{k.mutate(),o(!1)},onCancel:()=>o(!1)}),l&&a.jsx(On,{title:n("smartPlugs.turnOnSmartPlug"),message:`Are you sure you want to turn on "${t.name}"?`,confirmText:n("smartPlugs.turnOn"),variant:"default",onConfirm:()=>{v.mutate("on"),c(!1)},onCancel:()=>c(!1)}),u&&a.jsx(On,{title:n("smartPlugs.turnOffSmartPlug"),message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:n("smartPlugs.turnOff"),variant:"danger",onConfirm:()=>{v.mutate("off"),d(!1)},onCancel:()=>d(!1)})]})}function pXe({plug:t,onClose:e}){const{t:n}=Ut(),r=Zt(),i=!!t,[s,o]=w.useState(t?.plug_type||"tasmota"),[l,c]=w.useState(t?.name||""),[u,d]=w.useState(t?.ip_address||""),[h,p]=w.useState(t?.username||""),[m,x]=w.useState(t?.password||""),[y,b]=w.useState(t?.ha_entity_id||""),[v,S]=w.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[k,E]=w.useState(t?.mqtt_power_path||""),[N,A]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[M,P]=w.useState(t?.mqtt_energy_topic||""),[T,j]=w.useState(t?.mqtt_energy_path||""),[z,F]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[$,D]=w.useState(t?.mqtt_state_topic||""),[H,q]=w.useState(t?.mqtt_state_path||""),[I,K]=w.useState(t?.mqtt_state_on_value||""),[Z,se]=w.useState(t?.ha_power_entity||""),[V,W]=w.useState(t?.ha_energy_today_entity||""),[ie,J]=w.useState(t?.ha_energy_total_entity||""),[pe,fe]=w.useState(""),[ve,Le]=w.useState(""),[de,ce]=w.useState(!1),Ae=w.useRef(null),[re,Ie]=w.useState(""),[G,Y]=w.useState(!1),ue=w.useRef(null),[B,ee]=w.useState(""),[Q,le]=w.useState(!1),he=w.useRef(null),[te,U]=w.useState(""),[L,X]=w.useState(!1),ge=w.useRef(null),[_e,Ee]=w.useState(t?.printer_id||null),[$e,Ce]=w.useState(null),[He,Qe]=w.useState(null),[xe,ye]=w.useState(t?.power_alert_enabled||!1),[we,Ue]=w.useState(t?.power_alert_high?.toString()||""),[Pe,Ve]=w.useState(t?.power_alert_low?.toString()||""),[ke,Ze]=w.useState(t?.schedule_enabled||!1),[je,Xe]=w.useState(t?.schedule_on_time||""),[Re,Oe]=w.useState(t?.schedule_off_time||""),[Ne,Je]=w.useState(t?.show_in_switchbar||!1),[yt,Et]=w.useState(t?.show_on_printer_card??!0),[an,jt]=w.useState(!1),[Fe,gt]=w.useState({scanned:0,total:0}),[Qt,tn]=w.useState([]),un=w.useRef(null),{data:dr}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:gr}=et({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs}),{data:ar}=et({queryKey:["settings"],queryFn:ae.getSettings}),Xt=!!(ar?.ha_enabled&&ar?.ha_url&&ar?.ha_token);w.useEffect(()=>{const be=setTimeout(()=>{Le(pe)},300);return()=>clearTimeout(be)},[pe]),w.useEffect(()=>{const be=at=>{Ae.current&&!Ae.current.contains(at.target)&&ce(!1),ue.current&&!ue.current.contains(at.target)&&Y(!1),he.current&&!he.current.contains(at.target)&&le(!1),ge.current&&!ge.current.contains(at.target)&&X(!1)};return document.addEventListener("mousedown",be),()=>document.removeEventListener("mousedown",be)},[]);const{data:sr,isLoading:vi,error:Fa}=et({queryKey:["ha-entities",ve],queryFn:()=>ae.getHAEntities(ve||void 0),enabled:s==="homeassistant"&&Xt,retry:!1,staleTime:0}),{data:De}=et({queryKey:["ha-sensor-entities"],queryFn:ae.getHASensorEntities,enabled:s==="homeassistant"&&Xt,retry:!1,staleTime:0});w.useEffect(()=>{const be=at=>{at.key==="Escape"&&e()};return window.addEventListener("keydown",be),()=>{window.removeEventListener("keydown",be),un.current&&clearInterval(un.current)}},[e]);const nt=async()=>{jt(!0),tn([]),gt({scanned:0,total:0}),Qe(null);try{await ae.startTasmotaScan();const be=async()=>{try{const at=await ae.getTasmotaScanStatus();gt({scanned:at.scanned,total:at.total});const ht=await ae.getDiscoveredTasmotaDevices();tn(ht),at.running||(jt(!1),un.current&&(clearInterval(un.current),un.current=null))}catch(at){console.error("Polling error:",at)}};await be(),un.current=setInterval(be,500)}catch(be){jt(!1);const at=be instanceof Error?be.message:typeof be=="string"?be:JSON.stringify(be);Qe(at||"Failed to start scan")}},dt=async()=>{try{await ae.stopTasmotaScan()}catch{}jt(!1),un.current&&(clearInterval(un.current),un.current=null)},pt=be=>{d(be.ip_address),c(be.name),Ce(null)},ot=st({mutationFn:()=>ae.testSmartPlugConnection(u,h||null,m||null),onSuccess:be=>{Ce(be),Qe(null),!l&&be.device_name&&c(be.device_name)},onError:be=>{Ce(null),Qe(be.message)}}),Lt=st({mutationFn:be=>ae.createSmartPlug(be),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:be=>{Qe(be.message)}}),me=st({mutationFn:be=>ae.updateSmartPlug(t.id,be),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:be=>{Qe(be.message)}}),ze=dr?.filter(be=>s==="tasmota"?!gr?.some(ht=>ht.printer_id===be.id&&ht.id!==t?.id&&ht.plug_type==="tasmota"):!0),Ke=be=>{if(be.preventDefault(),Qe(null),!l.trim()){Qe("Name is required");return}if(s==="tasmota"&&!u.trim()){Qe("IP address is required for Tasmota plugs");return}if(s==="homeassistant"&&!y){Qe("Entity is required for Home Assistant plugs");return}if(s==="mqtt"){const ht=v.trim(),rt=M.trim(),Ct=$.trim();if(!ht&&!rt&&!Ct){Qe("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const at={name:l.trim(),plug_type:s,ip_address:s==="tasmota"?u.trim():null,ha_entity_id:s==="homeassistant"?y:null,ha_power_entity:s==="homeassistant"&&Z||null,ha_energy_today_entity:s==="homeassistant"&&V||null,ha_energy_total_entity:s==="homeassistant"&&ie||null,mqtt_power_topic:s==="mqtt"&&v.trim()||null,mqtt_power_path:s==="mqtt"&&k.trim()||null,mqtt_power_multiplier:s==="mqtt"&&parseFloat(N)||1,mqtt_energy_topic:s==="mqtt"&&M.trim()||null,mqtt_energy_path:s==="mqtt"&&T.trim()||null,mqtt_energy_multiplier:s==="mqtt"&&parseFloat(z)||1,mqtt_state_topic:s==="mqtt"&&$.trim()||null,mqtt_state_path:s==="mqtt"&&H.trim()||null,mqtt_state_on_value:s==="mqtt"&&I.trim()||null,username:s==="tasmota"&&h.trim()||null,password:s==="tasmota"&&m.trim()||null,printer_id:_e,power_alert_enabled:xe,power_alert_high:we?parseFloat(we):null,power_alert_low:Pe?parseFloat(Pe):null,schedule_enabled:ke,schedule_on_time:je||null,schedule_off_time:Re||null,show_in_switchbar:Ne,show_on_printer_card:yt};i?me.mutate(at):Lt.mutate(at)},Ge=Lt.isPending||me.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.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:be=>be.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Smart Plug":"Add Smart Plug"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Ke,className:"p-6 space-y-4 overflow-y-auto",children:[He&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:He}),!i&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{o("tasmota"),Ce(null),Qe(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(dl,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{o("homeassistant"),Ce(null),Qe(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(K0,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{o("mqtt"),Ce(null),Qe(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(l4,{className:"w-4 h-4"}),"MQTT"]})]}),!i&&s==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[an?a.jsxs(Me,{type:"button",variant:"secondary",onClick:dt,className:"w-full",children:[a.jsx(Rt,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Me,{type:"button",variant:"primary",onClick:nt,className:"w-full",children:[a.jsx(zr,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),an&&Fe.total>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:n("smartPlugs.addSmartPlug.scanningNetwork")}),a.jsxs("span",{children:[Fe.scanned," / ",Fe.total]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Fe.scanned/Fe.total*100}%`}})})]}),Qt.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Qt.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Qt.map(be=>a.jsxs("button",{type:"button",onClick:()=>pt(be),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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(dl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:be.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:be.ip_address})]})]}),be.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${be.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(cd,{className:"w-3 h-3"}),be.state]})]},be.ip_address))})]}),!an&&Qt.length===0&&Fe.total>0&&a.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),s==="homeassistant"&&a.jsxs("div",{className:"space-y-3",children:[!Xt&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),a.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:a.jsx("option",{children:n("smartPlugs.addSmartPlug.chooseEntity")})})]})]}),Xt&&a.jsxs(a.Fragment,{children:[vi&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[a.jsx(it,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),Fa&&a.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",Fa.message]}),(()=>{const be=gr?.filter(rt=>rt.ha_entity_id&&rt.id!==t?.id).map(rt=>rt.ha_entity_id)||[],at=(sr||[]).filter(rt=>!be.includes(rt.entity_id)),ht=sr?.find(rt=>rt.entity_id===y);return a.jsxs("div",{ref:Ae,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:de?pe:ht?`${ht.friendly_name} (${ht.entity_id})`:"",onChange:rt=>{fe(rt.target.value),de||ce(!0)},onFocus:()=>{ce(!0),fe("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEntities"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),y&&!de&&a.jsx("button",{type:"button",onClick:()=>{b(""),fe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),vi&&a.jsx(it,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),de&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[vi&&a.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!vi&&at.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:ve?`No entities found matching "${ve}"`:"No entities available"}),!vi&&at.map(rt=>a.jsxs("button",{type:"button",onClick:()=>{b(rt.entity_id),ce(!1),fe(""),l||c(rt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${rt.entity_id===y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:rt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:rt.entity_id}),a.jsx("span",{className:rt.state==="on"?"text-bambu-green":"",children:rt.state})]})]},rt.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ve?`Searching all entities (${at.length} found)`:`Showing switch, light, input_boolean (${at.length} available)`})]})})(),y&&De&&De.length>0&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const be=De.filter(rt=>rt.unit_of_measurement==="W"||rt.unit_of_measurement==="kW"||rt.unit_of_measurement==="mW"),at=re?be.filter(rt=>rt.entity_id.toLowerCase().includes(re.toLowerCase())||rt.friendly_name.toLowerCase().includes(re.toLowerCase())):be,ht=De.find(rt=>rt.entity_id===Z);return a.jsxs("div",{ref:ue,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:G?re:ht?`${ht.friendly_name} (${ht.state} ${ht.unit_of_measurement})`:"",onChange:rt=>{Ie(rt.target.value),G||Y(!0)},onFocus:()=>{Y(!0),Ie("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchPowerSensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Z&&!G&&a.jsx("button",{type:"button",onClick:()=>{se(""),Ie("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),G&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{se(""),Y(!1),Ie("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),at.map(rt=>a.jsxs("button",{type:"button",onClick:()=>{se(rt.entity_id),Y(!1),Ie("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===Z?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:rt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),at.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const be=De.filter(rt=>rt.unit_of_measurement==="kWh"||rt.unit_of_measurement==="Wh"||rt.unit_of_measurement==="MWh"),at=B?be.filter(rt=>rt.entity_id.toLowerCase().includes(B.toLowerCase())||rt.friendly_name.toLowerCase().includes(B.toLowerCase())):be,ht=De.find(rt=>rt.entity_id===V);return a.jsxs("div",{ref:he,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:Q?B:ht?`${ht.friendly_name} (${ht.state} ${ht.unit_of_measurement})`:"",onChange:rt=>{ee(rt.target.value),Q||le(!0)},onFocus:()=>{le(!0),ee("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),V&&!Q&&a.jsx("button",{type:"button",onClick:()=>{W(""),ee("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),Q&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{W(""),le(!1),ee("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),at.map(rt=>a.jsxs("button",{type:"button",onClick:()=>{W(rt.entity_id),le(!1),ee("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===V?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:rt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),at.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const be=De.filter(rt=>rt.unit_of_measurement==="kWh"||rt.unit_of_measurement==="Wh"||rt.unit_of_measurement==="MWh"),at=te?be.filter(rt=>rt.entity_id.toLowerCase().includes(te.toLowerCase())||rt.friendly_name.toLowerCase().includes(te.toLowerCase())):be,ht=De.find(rt=>rt.entity_id===ie);return a.jsxs("div",{ref:ge,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:L?te:ht?`${ht.friendly_name} (${ht.state} ${ht.unit_of_measurement})`:"",onChange:rt=>{U(rt.target.value),L||X(!0)},onFocus:()=>{X(!0),U("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),ie&&!L&&a.jsx("button",{type:"button",onClick:()=>{J(""),U("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),L&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{J(""),X(!1),U("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),at.map(rt=>a.jsxs("button",{type:"button",onClick:()=>{J(rt.entity_id),X(!1),U("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${rt.entity_id===ie?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:rt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[rt.entity_id," • ",rt.state," ",rt.unit_of_measurement]})]},rt.entity_id)),at.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),s==="mqtt"&&a.jsxs("div",{className:"space-y-3",children:[!ar?.mqtt_broker&&a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["MQTT broker not configured. Set broker address in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),ar?.mqtt_broker&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),a.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:v,onChange:be=>S(be.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:k,onChange:be=>E(be.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:N,onChange:be=>A(be.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:['JSON path extracts value from JSON payload (e.g., "power_l1"). Leave empty if topic publishes raw numeric values.',a.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:M,onChange:be=>P(be.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:T,onChange:be=>j(be.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:z,onChange:be=>F(be.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:$,onChange:be=>D(be.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:H,onChange:be=>q(be.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),a.jsx("input",{type:"text",value:I,onChange:be=>K(be.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.mqttStateOnValue"),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),s==="tasmota"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:u,onChange:be=>{d(be.target.value),Ce(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"}),a.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>ot.mutate(),disabled:!u.trim()||ot.isPending,children:[ot.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Lg,{className:"w-4 h-4"}),"Test"]})]})]}),s==="tasmota"&&$e&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${$e.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:$e.success?a.jsxs(a.Fragment,{children:[a.jsx(mr,{className:"w-5 h-5"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:"Connected!"}),a.jsxs("p",{className:"text-sm opacity-80",children:[$e.device_name&&`Device: ${$e.device_name} - `,"State: ",$e.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(km,{className:"w-5 h-5"}),a.jsx("span",{children:n("smartPlugs.addSmartPlug.connectionFailed")})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:l,onChange:be=>c(be.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.plugName"),className:"w-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==="tasmota"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),a.jsx("input",{type:"text",value:h,onChange:be=>p(be.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),a.jsx("input",{type:"password",value:m,onChange:be=>x(be.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"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),s!=="mqtt"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),a.jsxs("select",{value:_e??"",onChange:be=>Ee(be.target.value?Number(be.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"No printer (manual control only)"}),ze?.map(be=>a.jsx("option",{value:be.id,children:be.name},be.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Dg,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:xe,onChange:be=>ye(be.target.checked),className:"sr-only peer"}),a.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"})]})]}),xe&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),a.jsx("input",{type:"number",value:we,onChange:be=>Ue(be.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),a.jsx("input",{type:"number",value:Pe,onChange:be=>Ve(be.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"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),s!=="mqtt"&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qn,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ke,onChange:be=>Ze(be.target.checked),className:"sr-only peer"}),a.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"})]})]}),ke&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),a.jsx("input",{type:"time",value:je,onChange:be=>Xe(be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),a.jsx("input",{type:"time",value:Re,onChange:be=>Oe(be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.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."})]})]}),a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(X0,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Ne,onChange:be=>Je(be.target.checked),className:"sr-only peer"}),a.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==="homeassistant"&&a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show on Printer Card"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Display button on printer card"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:yt,onChange:be=>Et(be.target.checked),className:"sr-only peer"}),a.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"})]})]})}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:Ge,className:"flex-1",children:[Ge?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(fs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function Un({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return a.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:a.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 gXe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function bXe({provider:t,onEdit:e}){const n=Zt(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=et({queryKey:["printers"],queryFn:ae.getPrinters}),d=u?.find(y=>y.id===t.printer_id),h=st({mutationFn:y=>ae.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=st({mutationFn:()=>ae.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=st({mutationFn:()=>ae.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),x=y=>y||"";return a.jsxs(a.Fragment,{children:[a.jsx(_t,{className:"relative",children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:a.jsx(Dg,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-white",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray",children:gXe[t.provider_type]||t.provider_type})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&a.jsxs("span",{className:"text-xs text-status-ok hidden sm:inline",children:["Last: ",eb(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Qi(t.last_error_at)?.getTime()||0)>(Qi(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx(Un,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]})]}),d&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),a.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&a.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),a.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_plate_not_empty&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:"Plate Check"}),t.on_print_complete&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&a.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&a.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&a.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&a.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&&a.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&&a.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&&a.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&&a.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&&a.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&&a.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[a.jsx(h1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[a.jsx(ri,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Me,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Lk,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&a.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?a.jsx(mr,{className:"w-4 h-4"}):a.jsx(ua,{className:"w-4 h-4"}),a.jsx("span",{children:l.message})]}),a.jsxs("button",{onClick:()=>o(!s),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:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Qu,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(Kl,{className:"w-4 h-4"}):a.jsx(tr,{className:"w-4 h-4"})]}),s&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),a.jsx(Un,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Started"}),a.jsx(Un,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),a.jsx(Un,{checked:t.on_plate_not_empty??!0,onChange:y=>h.mutate({on_plate_not_empty:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),a.jsx(Un,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),a.jsx(Un,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),a.jsx(Un,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),a.jsx(Un,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),a.jsx(Un,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),a.jsx(Un,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(Un,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),a.jsx(Un,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),a.jsx(Un,{checked:t.on_ams_humidity_high??!1,onChange:y=>h.mutate({on_ams_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),a.jsx(Un,{checked:t.on_ams_temperature_high??!1,onChange:y=>h.mutate({on_ams_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),a.jsx(Un,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>h.mutate({on_ams_ht_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),a.jsx(Un,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>h.mutate({on_ams_ht_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Added"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),a.jsx(Un,{checked:t.on_queue_job_added??!1,onChange:y=>h.mutate({on_queue_job_added:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),a.jsx(Un,{checked:t.on_queue_job_assigned??!1,onChange:y=>h.mutate({on_queue_job_assigned:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Started"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),a.jsx(Un,{checked:t.on_queue_job_started??!1,onChange:y=>h.mutate({on_queue_job_started:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),a.jsx(Un,{checked:t.on_queue_job_waiting??!0,onChange:y=>h.mutate({on_queue_job_waiting:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),a.jsx(Un,{checked:t.on_queue_job_skipped??!0,onChange:y=>h.mutate({on_queue_job_skipped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),a.jsx(Un,{checked:t.on_queue_job_failed??!0,onChange:y=>h.mutate({on_queue_job_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),a.jsx(Un,{checked:t.on_queue_completed??!1,onChange:y=>h.mutate({on_queue_completed:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(h1,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx(Un,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ri,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx(Un,{checked:t.daily_digest_enabled,onChange:y=>h.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(Yf,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(en,{className:"w-4 h-4"})})]})]})]})}),r&&a.jsx(On,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{p.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const q9=[{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 xXe({provider:t,onClose:e}){const n=Zt(),r=!!t,[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,h]=w.useState(t?.quiet_hours_enabled||!1),[p,m]=w.useState(t?.quiet_hours_start||"22:00"),[x,y]=w.useState(t?.quiet_hours_end||"07:00"),[b,v]=w.useState(t?.daily_digest_enabled||!1),[S,k]=w.useState(t?.daily_digest_time||"08:00"),[E,N]=w.useState(t?.on_print_start??!1),[A,M]=w.useState(t?.on_print_complete??!0),[P,T]=w.useState(t?.on_print_failed??!0),[j,z]=w.useState(t?.on_print_stopped??!0),[F,$]=w.useState(t?.on_print_progress??!1),[D,H]=w.useState(t?.on_printer_offline??!1),[q,I]=w.useState(t?.on_printer_error??!1),[K,Z]=w.useState(t?.on_filament_low??!1),[se,V]=w.useState(t?.on_maintenance_due??!1),[W,ie]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,ee])=>[B,String(ee)])):{}),[J,pe]=w.useState(null),[fe,ve]=w.useState(null),{data:Le}=et({queryKey:["printers"],queryFn:ae.getPrinters});w.useEffect(()=>{const B=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const de=st({mutationFn:()=>ae.testNotificationConfig({provider_type:o,config:W}),onSuccess:B=>{pe(B),ve(null)},onError:B=>{pe({success:!1,message:B.message})}}),ce=st({mutationFn:B=>ae.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{ve(B.message)}}),Ae=st({mutationFn:B=>ae.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{ve(B.message)}}),re=B=>{if(B.preventDefault(),ve(null),!i.trim()){ve("Name is required");return}const ee=Y(o);for(const le of ee)if(!W[le.key]?.trim()){ve(`${le.label} is required`);return}const Q={name:i.trim(),provider_type:o,config:W,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?x:null,daily_digest_enabled:b,daily_digest_time:b?S:null,on_print_start:E,on_print_complete:A,on_print_failed:P,on_print_stopped:j,on_print_progress:F,on_printer_offline:D,on_printer_error:q,on_filament_low:K,on_maintenance_due:se};r?Ae.mutate(Q):ce.mutate(Q)},Ie=ce.isPending||Ae.isPending,G=B=>{switch(B){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1,showIf:ee=>ee.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:ee=>ee.payload_format!=="slack"}];default:return[]}},Y=B=>G(B).filter(ee=>ee.required),ue=G(o);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:B=>B.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:re,className:"p-6 space-y-4",children:[fe&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:fe}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:i,onChange:B=>s(B.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),a.jsx("select",{value:o,onChange:B=>{l(B.target.value),ie({}),pe(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:q9.map(B=>a.jsx("option",{value:B.value,children:B.label},B.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:q9.find(B=>B.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ue.filter(B=>!("showIf"in B)||B.showIf?.(W)!==!1).map(B=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&"options"in B&&B.options?a.jsx("select",{value:W[B.key]||B.options[0]?.value||"",onChange:ee=>{ie({...W,[B.key]:ee.target.value}),pe(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:B.options.map(ee=>a.jsx("option",{value:ee.value,children:ee.label},ee.value))}):a.jsx("input",{type:B.type,value:W[B.key]||"",onChange:ee=>{ie({...W,[B.key]:ee.target.value}),pe(null)},placeholder:B.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},B.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>{pe(null),de.mutate()},disabled:de.isPending||!W[Y(o)[0]?.key],className:"flex-1",children:[de.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Lk,{className:"w-4 h-4"}),"Test Configuration"]})}),J&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${J.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:J.success?a.jsxs(a.Fragment,{children:[a.jsx(mr,{className:"w-5 h-5"}),a.jsx("span",{children:J.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(ua,{className:"w-5 h-5"}),a.jsx("span",{children:J.message})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),a.jsxs("select",{value:c??"",onChange:B=>u(B.target.value?Number(B.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"All printers"}),Le?.map(B=>a.jsx("option",{value:B.id,children:B.name},B.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),a.jsx(Un,{checked:d,onChange:h})]}),d&&a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),a.jsx("input",{type:"time",value:p,onChange:B=>m(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),a.jsx("input",{type:"time",value:x,onChange:B=>y(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),a.jsx(Un,{checked:b,onChange:v})]}),b&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),a.jsx("input",{type:"time",value:S,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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Start"}),a.jsx(Un,{checked:E,onChange:N})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx(Un,{checked:A,onChange:M})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx(Un,{checked:P,onChange:T})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx(Un,{checked:j,onChange:z})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Progress"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),a.jsx(Un,{checked:F,onChange:$})]})]})]}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Offline"}),a.jsx(Un,{checked:D,onChange:H})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx(Un,{checked:q,onChange:I})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(Un,{checked:K,onChange:Z})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx(Un,{checked:se,onChange:V})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:Ie,className:"flex-1",children:[Ie?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(fs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function yXe({template:t,onClose:e}){const n=Zt(),r=w.useRef(null),[i,s]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,h]=w.useState(!0),{data:p}=et({queryKey:["template-variables"],queryFn:ae.getTemplateVariables}),m=p?.find(N=>N.event_type===t.event_type),{data:x,isLoading:y}=et({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>ae.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const N=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const b=st({mutationFn:N=>ae.updateNotificationTemplate(t.id,N),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:N=>{u(N.message)}}),v=st({mutationFn:()=>ae.resetNotificationTemplate(t.id),onSuccess:N=>{s(N.title_template),l(N.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:N=>{u(N.message)}}),S=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})},k=N=>{const A=r.current;if(!A)return;const M=A.selectionStart,P=A.selectionEnd,T=o,j=T.substring(0,M),z=T.substring(P),F=j+`{${N}}`+z;l(F),setTimeout(()=>{A.focus();const $=M+N.length+2;A.setSelectionRange($,$)},0)},E=i!==t.title_template||o!==t.body_template;return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),a.jsx("input",{type:"text",value:i,onChange:N=>s(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..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),a.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..."})]}),m&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(N=>a.jsxs("button",{type:"button",onClick:()=>k(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:[a.jsx(nr,{className:"w-3 h-3"}),N]},N))}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(Yl,{className:"w-4 h-4"}),"Live Preview"]}),a.jsx("button",{type:"button",onClick:()=>h(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&a.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),a.jsx("div",{className:"text-white font-medium",children:x.title})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),a.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):a.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[a.jsxs(Me,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Po,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Me,{onClick:S,disabled:b.isPending||!E,children:[b.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(fs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const vXe={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"},wXe={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 _Xe({onClose:t}){const e=Zt(),{showToast:n}=hn(),[r,i]=w.useState(7),[s,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=et({queryKey:["settings"],queryFn:ae.getSettings}),d=u?.time_format||"system",{data:h,isLoading:p,refetch:m,isRefetching:x}=et({queryKey:["notification-logs",r,l],queryFn:()=>ae.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=et({queryKey:["notification-log-stats",r],queryFn:()=>ae.getNotificationLogStats(r)}),b=st({mutationFn:()=>ae.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),v=S=>{const k=Qi(S);if(!k)return"";const N=new Date().getTime()-k.getTime();return N<6e4?"Just now":N<36e5?`${Math.floor(N/6e4)}m ago`:N<864e5?`${Math.floor(N/36e5)}h ago`:k.toLocaleDateString()+" "+Dme(k,d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.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:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(n0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),y&&a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:a.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[a.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",a.jsx("span",{className:"text-white font-medium",children:y.total})," notifications"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(mr,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(ua,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),a.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[a.jsxs("select",{value:r,onChange:S=>i(Number(S.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[a.jsx("option",{value:1,children:"Last 24 hours"}),a.jsx("option",{value:7,children:"Last 7 days"}),a.jsx("option",{value:30,children:"Last 30 days"}),a.jsx("option",{value:90,children:"Last 90 days"})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),a.jsx("div",{className:"flex-1"}),a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>m(),disabled:x,children:[x?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4"}),"Clear Old"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:p?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):h&&h.length>0?a.jsx("div",{className:"space-y-2",children:h.map(S=>a.jsx(SXe,{log:S,isExpanded:s===S.id,onToggle:()=>o(s===S.id?null:S.id),formatDate:v,formatFullDate:k=>tb(k,d)},S.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(n0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function SXe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return a.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:[a.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?a.jsx(mr,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(ua,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${wXe[t.event_type]||"text-bambu-gray"}`,children:vXe[t.event_type]||t.event_type}),a.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),a.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?a.jsx(Kl,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(tr,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&a.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),a.jsx("p",{className:"text-sm text-white",children:t.title})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),a.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),a.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),a.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[a.jsxs("span",{children:["Provider: ",t.provider_type]}),a.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}function NXe({formData:t,setFormData:e,groups:n,onClose:r,onCreate:i,isCreating:s,isCreateButtonDisabled:o}){const{t:l}=Ut();w.useEffect(()=>{const u=d=>{d.key==="Escape"&&r()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]);const c=u=>{e({...t,group_ids:t.group_ids.includes(u)?t.group_ids.filter(d=>d!==u):[...t.group_ids,u]})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:r,children:a.jsxs(_t,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(uh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:l("users.modal.createUser")})]}),a.jsx("p",{className:"text-sm text-bambu-gray ml-7",children:l("users.modal.advancedAuthSubtitle")||"with Advanced Authentication"})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.username")," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:t.username,onChange:u=>e({...t,username:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.usernamePlaceholder"),autoComplete:"username",required:!0})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.email")||"Email"," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"email",value:t.email,onChange:u=>e({...t,email:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.emailPlaceholder")||"user@example.com",required:!0})]}),a.jsx("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3",children:a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.form.autoGeneratedPassword")||"A secure password will be automatically generated and emailed to the user."})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:l("users.form.groups")}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[n.map(u=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.group_ids.includes(u.id),onChange:()=>c(u.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:u.name}),u.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",l("users.system"),")"]})]},u.id)),n.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:r,children:l("users.modal.cancel")}),a.jsx(Me,{onClick:i,disabled:o,children:s?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),l("users.modal.creating")]}):a.jsxs(a.Fragment,{children:[a.jsx(nr,{className:"w-4 h-4"}),l("users.modal.createUser")]})})]})]})]})})}function kXe(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),[r,i]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("auto"),[u,d]=w.useState(!1),[h,p]=w.useState(!0),[m,x]=w.useState("all"),[y,b]=w.useState(!1),[v,S]=w.useState(!1),{data:k,isLoading:E}=et({queryKey:["spoolman-settings"],queryFn:ae.getSpoolmanSettings}),{data:N,isLoading:A,refetch:M}=et({queryKey:["spoolman-status"],queryFn:ae.getSpoolmanStatus,refetchInterval:3e4}),{data:P}=et({queryKey:["printers"],queryFn:ae.getPrinters});w.useEffect(()=>{k&&(i(k.spoolman_enabled==="true"),o(k.spoolman_url||""),c(k.spoolman_sync_mode||"auto"),d(k.spoolman_disable_weight_sync==="true"),p(k.spoolman_report_partial_usage!=="false"),b(!0))},[k]),w.useEffect(()=>{if(!y||!k)return;if(k.spoolman_enabled==="true"!==r||(k.spoolman_url||"")!==s||(k.spoolman_sync_mode||"auto")!==l||k.spoolman_disable_weight_sync==="true"!==u||k.spoolman_report_partial_usage!=="false"!==h){const Z=setTimeout(()=>{T.mutate()},500);return()=>clearTimeout(Z)}},[r,s,l,u,h,y]);const T=st({mutationFn:()=>ae.updateSpoolmanSettings({spoolman_enabled:r?"true":"false",spoolman_url:s,spoolman_sync_mode:l,spoolman_disable_weight_sync:u?"true":"false",spoolman_report_partial_usage:h?"true":"false"}),onSuccess:()=>{e.invalidateQueries({queryKey:["spoolman-settings"]}),e.invalidateQueries({queryKey:["spoolman-status"]}),n(t("settings.toast.settingsSaved"))}}),j=st({mutationFn:ae.connectSpoolman,onSuccess:()=>{M()}}),z=st({mutationFn:ae.disconnectSpoolman,onSuccess:()=>{M()}}),F=st({mutationFn:ae.syncAllPrintersAms,onSuccess:K=>{K.success}}),$=st({mutationFn:K=>ae.syncPrinterAms(K),onSuccess:K=>{K.success}}),D=()=>{m==="all"?F.mutate():$.mutate(m)},H=F.isPending||$.isPending,q=m==="all"?F.data:$.data,I=m==="all"?F.isSuccess:$.isSuccess;return E?a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]}),T.isPending&&a.jsx(it,{className:"w-4 h-4 text-bambu-green animate-spin"})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.filamentTrackingDesc")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>i(!1),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50":"border-bambu-green bg-bambu-green/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx(ta,{className:`w-4 h-4 ${r?"text-bambu-gray":"text-bambu-green"}`}),a.jsx("span",{className:`text-sm font-medium ${r?"text-bambu-gray":"text-white"}`,children:t("settings.trackingModeBuiltIn")})]}),a.jsx("p",{className:`text-xs ${r?"text-bambu-gray/60":"text-bambu-gray"}`,children:t("settings.trackingModeBuiltInDesc")}),!r&&a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Kr,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]}),a.jsxs("button",{type:"button",onClick:()=>i(!0),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx(Wr,{className:`w-4 h-4 ${r?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:`text-sm font-medium ${r?"text-white":"text-bambu-gray"}`,children:"Spoolman"})]}),a.jsx("p",{className:`text-xs ${r?"text-bambu-gray":"text-bambu-gray/60"}`,children:t("settings.trackingModeSpoolmanDesc")}),r&&a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Kr,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]})]}),!r&&a.jsx("div",{className:"p-3 bg-bambu-green/5 border border-bambu-green/20 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Xs,{className:"w-4 h-4 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[a.jsx("li",{children:t("settings.builtInFeatureRfid")}),a.jsx("li",{children:t("settings.builtInFeatureUsage")}),a.jsx("li",{children:t("settings.builtInFeatureCatalog")})]})})]})}),r&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Xs,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-xs text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:t("settings.howSyncWorks")}),a.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[a.jsx("li",{children:t("settings.syncInfoRfidOnly")}),a.jsx("li",{children:t("settings.syncInfoAutoCreate")}),a.jsx("li",{children:t("settings.syncInfoThirdPartySkipped")})]}),a.jsx("p",{className:"font-medium mt-2 mb-1",children:t("settings.linkingExistingSpools")}),a.jsx("p",{className:"text-blue-300/80",children:t("settings.linkingExistingSpoolsDesc")})]})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.spoolmanUrl")}),a.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:s,onChange:K=>o(K.target.value),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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("settings.spoolmanUrlHint")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.syncMode")}),a.jsxs("select",{value:l,onChange:K=>c(K.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:[a.jsx("option",{value:"auto",children:t("settings.syncModeAuto")}),a.jsx("option",{value:"manual",children:t("settings.syncModeManual")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t(l==="auto"?"settings.syncModeAutoDesc":"settings.syncModeManualDesc")})]}),l==="auto"&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:t("spoolman.disableWeightSync")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.disableWeightSyncDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:K=>d(K.target.checked),className:"sr-only peer"}),a.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"})]})]}),u&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:t("spoolman.reportPartialUsage")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.reportPartialUsageDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:h,onChange:K=>p(K.target.checked),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("settings.status"),":"]}),A?a.jsx(it,{className:"w-4 h-4 text-bambu-gray animate-spin"}):N?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(Kr,{className:"w-4 h-4"}),t("settings.spoolmanConnected")]}):a.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[a.jsx(Rt,{className:"w-4 h-4"}),t("settings.spoolmanDisconnected")]})]}),a.jsx("div",{className:"flex gap-2",children:N?.connected?a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>z.mutate(),disabled:z.isPending,children:[z.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(che,{className:"w-4 h-4"}),t("settings.disconnect")]}):a.jsxs(Me,{size:"sm",onClick:()=>j.mutate(),disabled:j.isPending||!s,children:[j.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Mh,{className:"w-4 h-4"}),t("settings.connect")]})})]}),j.isError&&a.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:j.error.message}),N?.connected&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:t("settings.syncAmsData")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:t("settings.syncAmsDataDesc")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsxs("select",{value:m,onChange:K=>x(K.target.value==="all"?"all":Number(K.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:[a.jsx("option",{value:"all",children:t("settings.allPrinters")}),P?.map(K=>a.jsx("option",{value:K.id,children:K.name},K.id))]}),a.jsx(tr,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:D,disabled:H,children:[H?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),t("spoolman.sync")]})]})]}),I&&q&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${q.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:q.success?`Synced ${q.synced_count} spool${q.synced_count!==1?"s":""} successfully`:`Synced ${q.synced_count} spool${q.synced_count!==1?"s":""} with ${q.errors.length} error${q.errors.length!==1?"s":""}`}),q.skipped_count>0&&a.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(kn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[q.skipped_count," spool",q.skipped_count!==1?"s":""," skipped"]})]}),q.skipped_count>5&&a.jsx("button",{onClick:()=>S(!v),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:v?"Show less":"Show all"})]}),a.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(v?q.skipped:q.skipped.slice(0,5)).map((K,Z)=>a.jsxs("li",{className:"flex items-center gap-2",children:[K.color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${K.color}`}}),a.jsx("span",{children:K.location}),a.jsxs("span",{className:"text-amber-300/60",children:["- ",K.reason]})]},Z)),!v&&q.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",q.skipped_count-5," more"]})]})]}),q.errors.length>0&&a.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[a.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),a.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:q.errors.map((K,Z)=>a.jsx("li",{children:K},Z))})]})]})]})]})]})]})}function MXe(){const{t}=Ut(),{showToast:e}=hn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),c=w.useRef(null),[u,d]=w.useState(!1),[h,p]=w.useState(null),[m,x]=w.useState(""),[y,b]=w.useState(""),[v,S]=w.useState(!1),[k,E]=w.useState(null),[N,A]=w.useState(!1),M=w.useCallback(async()=>{try{const I=await ae.getSpoolCatalog();r(I)}catch{e(t("settings.catalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{M()},[M]);const P=n.filter(I=>I.name.toLowerCase().includes(o.toLowerCase())),T=async()=>{if(!m.trim()||!y){e(t("settings.catalog.nameWeightRequired"),"error");return}S(!0);try{const I=await ae.addCatalogEntry({name:m.trim(),weight:parseInt(y)});r(K=>[...K,I].sort((Z,se)=>Z.name.localeCompare(se.name))),d(!1),x(""),b(""),e(t("settings.catalog.entryAdded"),"success")}catch{e(t("settings.catalog.addFailed"),"error")}finally{S(!1)}},j=I=>{p(I.id),x(I.name),b(I.weight.toString())},z=()=>{p(null),x(""),b("")},F=async I=>{if(!m.trim()||!y){e(t("settings.catalog.nameWeightRequired"),"error");return}S(!0);try{const K=await ae.updateCatalogEntry(I,{name:m.trim(),weight:parseInt(y)});r(Z=>Z.map(se=>se.id===I?K:se).sort((se,V)=>se.name.localeCompare(V.name))),p(null),x(""),b(""),e(t("settings.catalog.entryUpdated"),"success")}catch{e(t("settings.catalog.updateFailed"),"error")}finally{S(!1)}},$=async()=>{if(k)try{await ae.deleteCatalogEntry(k.id),r(I=>I.filter(K=>K.id!==k.id)),e(t("settings.catalog.entryDeleted"),"success")}catch{e(t("settings.catalog.deleteFailed"),"error")}finally{E(null)}},D=async()=>{A(!1),s(!0);try{await ae.resetSpoolCatalog(),await M(),e(t("settings.catalog.resetSuccess"),"success")}catch{e(t("settings.catalog.resetFailed"),"error"),s(!1)}},H=()=>{const I=n.map(({name:V,weight:W})=>({name:V,weight:W})),K=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),Z=URL.createObjectURL(K),se=document.createElement("a");se.href=Z,se.download="spool-catalog.json",document.body.appendChild(se),se.click(),document.body.removeChild(se),URL.revokeObjectURL(Z),e(t("settings.catalog.exported",{count:n.length}),"success")},q=async I=>{const K=I.target.files?.[0];if(K){try{const Z=await K.text(),se=JSON.parse(Z);if(!Array.isArray(se))throw new Error("Invalid format");let V=0,W=0;for(const ie of se){if(!ie.name||typeof ie.weight!="number"){W++;continue}if(n.some(pe=>pe.name.toLowerCase()===ie.name.toLowerCase())){W++;continue}try{const pe=await ae.addCatalogEntry({name:ie.name,weight:ie.weight});r(fe=>[...fe,pe].sort((ve,Le)=>ve.name.localeCompare(Le.name))),V++}catch{W++}}e(t("settings.catalog.imported",{added:V,skipped:W}),"success")}catch{e(t("settings.catalog.importFailed"),"error")}c.current&&(c.current.value="")}};return a.jsxs(_t,{children:[a.jsxs(Mn,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(kc,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.catalog.spoolCatalog")}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("button",{onClick:H,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.exportTooltip"),children:[a.jsx(hi,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),a.jsxs("button",{onClick:()=>c.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.importTooltip"),children:[a.jsx(ia,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),a.jsx("input",{ref:c,type:"file",accept:".json",className:"hidden",onChange:q}),a.jsxs("button",{onClick:()=>A(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.resetTooltip"),children:[a.jsx(Po,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),a.jsxs("button",{onClick:()=>d(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[a.jsx(nr,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.catalog.spoolCatalogDescription")}),a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",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",placeholder:t("settings.catalog.searchCatalog"),value:o,onChange:I=>l(I.target.value)})]}),u&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.catalog.addNewEntry")}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.namePlaceholder"),value:m,onChange:I=>x(I.target.value)})}),a.jsx("input",{type:"number",className:"w-20 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-center focus:border-bambu-green focus:outline-none",placeholder:"g",value:y,onChange:I=>b(I.target.value)}),a.jsx("span",{className:"text-bambu-gray shrink-0",children:"g"}),a.jsxs("button",{onClick:T,disabled:v,className:"px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center gap-1 shrink-0",children:[v?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Kr,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{d(!1),x(""),b("")},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Rt,{className:"w-4 h-4"})})]})]}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(it,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):a.jsx("div",{className:"max-h-[400px] overflow-y-auto border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-4 py-2 text-left text-bambu-gray font-medium",children:t("common.name")}),a.jsx("th",{className:"px-4 py-2 text-right text-bambu-gray font-medium w-24",children:t("settings.catalog.weight")}),a.jsx("th",{className:"px-4 py-2 text-center text-bambu-gray font-medium w-20",children:t("settings.catalog.type")}),a.jsx("th",{className:"px-4 py-2 w-24"})]})}),a.jsx("tbody",{children:P.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-bambu-gray",children:t(o?"settings.catalog.noMatch":"settings.catalog.empty")})}):P.map(I=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:h===I.id?a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white focus:border-bambu-green focus:outline-none",value:m,onChange:K=>x(K.target.value)})}),a.jsx("td",{className:"px-4 py-2",children:a.jsx("input",{type:"number",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-right focus:border-bambu-green focus:outline-none",value:y,onChange:K=>b(K.target.value)})}),a.jsx("td",{className:"px-4 py-2 text-center",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"-"})}),a.jsx("td",{className:"px-4 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>F(I.id),disabled:v,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:v?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Kr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:z,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Rt,{className:"w-4 h-4"})})]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2 text-white",children:I.name}),a.jsxs("td",{className:"px-4 py-2 text-right font-mono text-white",children:[I.weight,"g"]}),a.jsx("td",{className:"px-4 py-2 text-center",children:I.is_default?a.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray",children:t("settings.catalog.default")}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:t("settings.catalog.custom")})}),a.jsx("td",{className:"px-4 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>j(I),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx($i,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>E(I),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(en,{className:"w-4 h-4"})})]})})]})},I.id))})]})})]}),k&&a.jsx(On,{title:t("settings.catalog.deleteEntry"),message:t("settings.catalog.deleteConfirm",{name:k.name}),confirmText:t("common.delete"),variant:"danger",onConfirm:$,onCancel:()=>E(null)}),N&&a.jsx(On,{title:t("settings.catalog.resetCatalog"),message:t("settings.catalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:D,onCancel:()=>A(!1)})]})}function CXe(){const{t}=Ut(),{showToast:e}=hn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),[c,u]=w.useState("Bambu Lab"),d=w.useRef(null),[h,p]=w.useState(!1),[m,x]=w.useState(null),[y,b]=w.useState(""),[v,S]=w.useState(""),[k,E]=w.useState("#FFFFFF"),[N,A]=w.useState(""),[M,P]=w.useState(!1),[T,j]=w.useState(!1),[z,F]=w.useState(null),[$,D]=w.useState(null),[H,q]=w.useState(!1),I=w.useCallback(async()=>{try{const ce=await ae.getColorCatalog();r(ce)}catch{e(t("settings.colorCatalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{I()},[I]);const K=[...new Set(n.map(ce=>ce.manufacturer))].sort(),Z=n.filter(ce=>{const Ae=o===""||ce.manufacturer.toLowerCase().includes(o.toLowerCase())||ce.color_name.toLowerCase().includes(o.toLowerCase())||(ce.material?.toLowerCase().includes(o.toLowerCase())??!1),re=c===""||ce.manufacturer===c;return Ae&&re}),se=()=>{b(""),S(""),E("#FFFFFF"),A("")},V=async()=>{if(!y.trim()||!v.trim()||!k){e(t("settings.colorCatalog.fieldsRequired"),"error");return}P(!0);try{const ce=await ae.addColorEntry({manufacturer:y.trim(),color_name:v.trim(),hex_color:k,material:N.trim()||null});r(Ae=>[...Ae,ce].sort((re,Ie)=>re.manufacturer.localeCompare(Ie.manufacturer)||(re.material||"").localeCompare(Ie.material||"")||re.color_name.localeCompare(Ie.color_name))),p(!1),se(),e(t("settings.colorCatalog.colorAdded"),"success")}catch{e(t("settings.colorCatalog.addFailed"),"error")}finally{P(!1)}},W=ce=>{x(ce.id),b(ce.manufacturer),S(ce.color_name),E(ce.hex_color),A(ce.material||"")},ie=()=>{x(null),se()},J=async ce=>{if(!y.trim()||!v.trim()||!k){e(t("settings.colorCatalog.fieldsRequired"),"error");return}P(!0);try{const Ae=await ae.updateColorEntry(ce,{manufacturer:y.trim(),color_name:v.trim(),hex_color:k,material:N.trim()||null});r(re=>re.map(Ie=>Ie.id===ce?Ae:Ie).sort((Ie,G)=>Ie.manufacturer.localeCompare(G.manufacturer)||(Ie.material||"").localeCompare(G.material||"")||Ie.color_name.localeCompare(G.color_name))),x(null),se(),e(t("settings.colorCatalog.colorUpdated"),"success")}catch{e(t("settings.colorCatalog.updateFailed"),"error")}finally{P(!1)}},pe=async()=>{if($)try{await ae.deleteColorEntry($.id),r(ce=>ce.filter(Ae=>Ae.id!==$.id)),e(t("settings.colorCatalog.colorDeleted"),"success")}catch{e(t("settings.colorCatalog.deleteFailed"),"error")}finally{D(null)}},fe=async()=>{q(!1),s(!0);try{await ae.resetColorCatalog(),await I(),e(t("settings.colorCatalog.resetSuccess"),"success")}catch{e(t("settings.colorCatalog.resetFailed"),"error"),s(!1)}},ve=async()=>{j(!0),F(null);try{const ce={},Ae=Ju();Ae&&(ce.Authorization=`Bearer ${Ae}`);const re=await fetch("/api/v1/inventory/colors/sync",{method:"POST",headers:ce});if(!re.ok)throw new Error("Failed to start sync");const Ie=re.body?.getReader();if(!Ie)throw new Error("No response body");const G=new TextDecoder;let Y="";for(;;){const{done:ue,value:B}=await Ie.read();if(ue)break;Y+=G.decode(B,{stream:!0});const ee=Y.split(`
  8297. `);Y=ee.pop()||"";for(const Q of ee)if(Q.startsWith("data: "))try{const le=JSON.parse(Q.slice(6));le.type==="progress"?F({fetched:le.total_fetched,total:le.total_available}):le.type==="complete"?le.added===0?e(t("settings.colorCatalog.syncUpToDate",{count:le.total_fetched}),"success"):e(t("settings.colorCatalog.syncComplete",{added:le.added,skipped:le.skipped}),"success"):le.type==="error"&&e(`${t("settings.colorCatalog.syncError")}: ${le.error}`,"error")}catch{}}await I()}catch{e(t("settings.colorCatalog.syncFailed"),"error")}finally{j(!1),F(null)}},Le=()=>{const ce=n.map(({manufacturer:G,color_name:Y,hex_color:ue,material:B})=>({manufacturer:G,color_name:Y,hex_color:ue,material:B})),Ae=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),re=URL.createObjectURL(Ae),Ie=document.createElement("a");Ie.href=re,Ie.download="color-catalog.json",document.body.appendChild(Ie),Ie.click(),document.body.removeChild(Ie),URL.revokeObjectURL(re),e(t("settings.colorCatalog.exported",{count:n.length}),"success")},de=async ce=>{const Ae=ce.target.files?.[0];if(Ae){try{const re=await Ae.text(),Ie=JSON.parse(re);if(!Array.isArray(Ie))throw new Error("Invalid format");let G=0,Y=0;for(const ue of Ie){if(!ue.manufacturer||!ue.color_name||!ue.hex_color){Y++;continue}if(n.some(ee=>ee.manufacturer.toLowerCase()===ue.manufacturer.toLowerCase()&&ee.color_name.toLowerCase()===ue.color_name.toLowerCase()&&(ee.material||"").toLowerCase()===(ue.material||"").toLowerCase())){Y++;continue}try{const ee=await ae.addColorEntry({manufacturer:ue.manufacturer,color_name:ue.color_name,hex_color:ue.hex_color,material:ue.material||null});r(Q=>[...Q,ee].sort((le,he)=>le.manufacturer.localeCompare(he.manufacturer)||(le.material||"").localeCompare(he.material||"")||le.color_name.localeCompare(he.color_name))),G++}catch{Y++}}e(t("settings.colorCatalog.imported",{added:G,skipped:Y}),"success")}catch{e(t("settings.colorCatalog.importFailed"),"error")}d.current&&(d.current.value="")}};return a.jsxs(_t,{children:[a.jsxs(Mn,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Pk,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.colorCatalog.title")}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("button",{onClick:Le,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(hi,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),a.jsxs("button",{onClick:()=>d.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(ia,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),a.jsx("input",{ref:d,type:"file",accept:".json",className:"hidden",onChange:de}),a.jsxs("button",{onClick:ve,disabled:T,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.colorCatalog.syncTooltip"),children:[T?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(jb,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:T?z?`${Math.min(z.fetched,z.total)} / ${z.total}`:t("settings.colorCatalog.starting"):t("settings.colorCatalog.sync")})]}),a.jsxs("button",{onClick:()=>q(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(Po,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),a.jsxs("button",{onClick:()=>p(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[a.jsx(nr,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.colorCatalog.description")}),a.jsxs("div",{className:"flex gap-2 flex-wrap",children:[a.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",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",placeholder:t("settings.colorCatalog.searchColors"),value:o,onChange:ce=>l(ce.target.value)})]}),a.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:c,onChange:ce=>u(ce.target.value),children:[a.jsx("option",{value:"",children:t("settings.colorCatalog.allManufacturers")}),K.map(ce=>a.jsx("option",{value:ce,children:ce},ce))]})]}),h&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.colorCatalog.addNewColor")}),a.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-2 items-end",children:[a.jsx("input",{type:"text",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.manufacturer"),value:y,onChange:ce=>b(ce.target.value)}),a.jsx("input",{type:"text",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.colorName"),value:v,onChange:ce=>S(ce.target.value)}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"color",className:"w-10 h-10 rounded cursor-pointer border border-bambu-dark-tertiary",value:k,onChange:ce=>E(ce.target.value)}),a.jsx("input",{type:"text",className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:"#FFFFFF",value:k,onChange:ce=>E(ce.target.value)})]}),a.jsx("input",{type:"text",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.materialOptional"),value:N,onChange:ce=>A(ce.target.value)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:V,disabled:M,className:"flex-1 px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center justify-center gap-1",children:[M?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Kr,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{p(!1),se()},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Rt,{className:"w-4 h-4"})})]})]})]}),(o||c)&&a.jsx("div",{className:"text-xs text-bambu-gray",children:t("settings.colorCatalog.showing",{filtered:Z.length,total:n.length})}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(it,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):a.jsx("div",{className:"max-h-[400px] overflow-auto border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium w-12"}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("settings.colorCatalog.manufacturer")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("inventory.material")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("settings.colorCatalog.colorName")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium w-24",children:t("settings.colorCatalog.hex")}),a.jsx("th",{className:"px-3 py-2 w-16"})]})}),a.jsx("tbody",{children:Z.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-bambu-gray",children:t(o||c?"settings.colorCatalog.noMatch":"settings.colorCatalog.empty")})}):Z.map(ce=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:m===ce.id?a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"color",className:"w-8 h-8 rounded cursor-pointer border border-bambu-dark-tertiary",value:k,onChange:Ae=>E(Ae.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:y,onChange:Ae=>b(Ae.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:N,onChange:Ae=>A(Ae.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:v,onChange:Ae=>S(Ae.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:k,onChange:Ae=>E(Ae.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>J(ce.id),disabled:M,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:M?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Kr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:ie,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Rt,{className:"w-4 h-4"})})]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("div",{className:"w-8 h-8 rounded border border-bambu-dark-tertiary",style:{backgroundColor:ce.hex_color},title:ce.hex_color})}),a.jsx("td",{className:"px-3 py-2 text-white",children:ce.manufacturer}),a.jsx("td",{className:"px-3 py-2 text-bambu-gray",children:ce.material||"-"}),a.jsx("td",{className:"px-3 py-2 text-white",children:ce.color_name}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-bambu-gray",children:ce.hex_color}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>W(ce),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx($i,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>D(ce),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(en,{className:"w-4 h-4"})})]})})]})},ce.id))})]})})]}),$&&a.jsx(On,{title:t("settings.colorCatalog.deleteColor"),message:t("settings.colorCatalog.deleteConfirm",{name:`${$.manufacturer} - ${$.color_name}`}),confirmText:t("common.delete"),variant:"danger",onConfirm:pe,onCancel:()=>D(null)}),H&&a.jsx(On,{title:t("settings.colorCatalog.resetCatalog"),message:t("settings.colorCatalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:fe,onCancel:()=>q(!1)})]})}function EXe({link:t,onClose:e}){const{t:n}=Ut(),r=Zt(),i=!!t,s=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,h]=w.useState(t?.icon||"link"),[p,m]=w.useState(t?.open_in_new_tab||!1),[x,y]=w.useState(!!t?.custom_icon),[b,v]=w.useState(t?.custom_icon?ae.getExternalLinkIconUrl(t.id):null),[S,k]=w.useState(null),[E,N]=w.useState(null);w.useEffect(()=>{const $=D=>{D.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const A=st({mutationFn:async $=>{const D=await ae.createExternalLink($);return S?await ae.uploadExternalLinkIcon(D.id,S):D},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:$=>{N($.message)}}),M=st({mutationFn:async $=>{let D=await ae.updateExternalLink(t.id,$);return S?D=await ae.uploadExternalLinkIcon(t.id,S):!x&&t?.custom_icon&&(D=await ae.deleteExternalLinkIcon(t.id)),D},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:$=>{N($.message)}}),P=$=>{const D=$.target.files?.[0];if(D){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(D.type)){N("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(D.size>1024*1024){N("Image file must be less than 1MB");return}k(D),y(!0);const q=new FileReader;q.onload=I=>{v(I.target?.result)},q.readAsDataURL(D)}},T=()=>{k(null),v(null),y(!1),s.current&&(s.current.value="")},j=$=>{if($.preventDefault(),N(null),!o.trim()){N("Name is required");return}if(!c.trim()){N("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){N("URL must start with http:// or https://");return}const D={name:o.trim(),url:c.trim(),icon:d,open_in_new_tab:p};i?M.mutate(D):A.mutate(D)},z=A.isPending||M.isPending,F=zk(d);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:$=>$.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:x&&b?a.jsx("img",{src:b,alt:"",className:"w-5 h-5 rounded"}):a.jsx(F,{className:"w-5 h-5"})}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:j,className:"p-6 space-y-4",children:[E&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:o,onChange:$=>l($.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),a.jsx("input",{type:"text",value:c,onChange:$=>u($.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-bambu-gray",children:n("externalLinks.openInNewTab")}),a.jsx("button",{type:"button",onClick:()=>m(!p),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${p?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${p?"translate-x-6":"translate-x-1"}`})})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),a.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),a.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:P}),x&&b?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:b,alt:"Custom icon",className:"w-8 h-8 rounded border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:T,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:a.jsx(en,{className:"w-4 h-4"})})]}):a.jsxs(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[a.jsx(ia,{className:"w-4 h-4"}),"Upload"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!x&&a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),a.jsx(vme,{value:d,onChange:h})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:z,className:"flex-1",children:[z?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(fs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function AXe(){const{t}=Ut(),e=Zt(),[n,r]=w.useState(!1),[i,s]=w.useState(null),[o,l]=w.useState(null),[c,u]=w.useState(null),{data:d,isLoading:h}=et({queryKey:["external-links"],queryFn:ae.getExternalLinks}),p=st({mutationFn:k=>ae.deleteExternalLink(k),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),m=st({mutationFn:k=>ae.reorderExternalLinks(k),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),x=(k,E)=>{u(E),k.dataTransfer.effectAllowed="move"},y=k=>{k.preventDefault(),k.dataTransfer.dropEffect="move"},b=(k,E)=>{if(k.preventDefault(),c===null||c===E||!d)return;const N=d.map(T=>T.id),A=N.indexOf(c),M=N.indexOf(E);if(A===-1||M===-1)return;const P=[...N];P.splice(A,1),P.splice(M,0,c),m.mutate(P),u(null)},v=k=>{l(k)},S=()=>{o&&(p.mutate(o.id),l(null))};return a.jsxs(a.Fragment,{children:[a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Mh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),a.jsxs(Me,{size:"sm",onClick:()=>r(!0),children:[a.jsx(nr,{className:"w-4 h-4"}),"Add Link"]})]})}),a.jsxs(Nt,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),h?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):d&&d.length>0?a.jsx("div",{className:"space-y-2",children:d.map(k=>{const E=zk(k.icon);return a.jsxs("div",{draggable:!0,onDragStart:N=>x(N,k.id),onDragOver:y,onDrop:N=>b(N,k.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${c===k.id?"opacity-50":""}`,children:[a.jsx(kh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(E,{className:"w-4 h-4"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-white font-medium truncate",children:k.name}),a.jsx(Wr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),a.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:k.url})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.jsx("button",{onClick:()=>s(k),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:t("common.edit"),children:a.jsx($i,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>v(k),disabled:p.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:t("externalLinks.deleteLink"),children:a.jsx(en,{className:"w-4 h-4"})})]})]},k.id)})}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Mh,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:t("externalLinks.noLinksConfigured")}),a.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(n||i)&&a.jsx(EXe,{link:i,onClose:()=>{r(!1),s(null)}}),o&&a.jsx(On,{title:"Delete Link",message:`Are you sure you want to delete "${o.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:S,onCancel:()=>l(null)})]})}function TXe(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),[r,i]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("immediate"),[u,d]=w.useState("3DPrinter-X1-Carbon"),[h,p]=w.useState(null),[m,x]=w.useState(""),[y,b]=w.useState(!1),[v,S]=w.useState(null),{data:k,isLoading:E}=et({queryKey:["virtual-printer-settings"],queryFn:DS.getSettings,refetchInterval:1e4}),{data:N}=et({queryKey:["virtual-printer-models"],queryFn:DS.getModels}),{data:A}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:M}=et({queryKey:["network-interfaces"],queryFn:()=>ae.getNetworkInterfaces().then(I=>I.interfaces),enabled:r});w.useEffect(()=>{if(k){i(k.enabled);let I=k.mode==="queue"?"review":k.mode;I!=="immediate"&&I!=="review"&&I!=="print_queue"&&I!=="proxy"&&(I="immediate"),c(I),d(k.model),p(k.target_printer_id),x(k.remote_interface_ip||"")}},[k]);const P=st({mutationFn:I=>DS.updateSettings(I),onSuccess:()=>{e.invalidateQueries({queryKey:["virtual-printer-settings"]}),n(t("virtualPrinter.toast.updated")),S(null)},onError:I=>{if(n(I.message||t("virtualPrinter.toast.failedToUpdate"),"error"),k){i(k.enabled);const K=k.mode==="queue"?"review":k.mode;c(["immediate","review","print_queue","proxy"].includes(K)?K:"immediate"),d(k.model),p(k.target_printer_id)}S(null)}}),T=()=>{const I=!r;if(I){if(l==="proxy"){if(!h){n(t("virtualPrinter.toast.targetPrinterRequired"),"error");return}}else if(!s&&!k?.access_code_set){n(t("virtualPrinter.toast.accessCodeRequired"),"error");return}}i(I),S("toggle"),P.mutate({enabled:I,access_code:l!=="proxy"&&s||void 0,mode:l,target_printer_id:l==="proxy"?h??void 0:void 0})},j=()=>{if(!s){n(t("virtualPrinter.toast.accessCodeEmpty"),"error");return}if(s.length!==8){n(t("virtualPrinter.toast.accessCodeLength"),"error");return}S("accessCode"),P.mutate({access_code:s}),o("")},z=I=>{c(I),S("mode"),P.mutate({mode:I})},F=I=>{p(I),S("targetPrinter"),P.mutate({target_printer_id:I})},$=I=>{d(I),S("model"),P.mutate({model:I})},D=I=>{x(I),S("remoteInterface"),P.mutate({remote_interface_ip:I})};if(E)return a.jsx(_t,{children:a.jsx(Nt,{className:"py-8 flex justify-center",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const H=k?.status,q=H?.running||!1;return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Nr,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("virtualPrinter.title")})]}),H&&a.jsxs("div",{className:`flex items-center gap-2 text-sm ${q?"text-green-400":"text-bambu-gray"}`,children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${q?"bg-green-400 animate-pulse":"bg-gray-500"}`}),t(q?"virtualPrinter.running":"virtualPrinter.stopped")]})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t(l==="proxy"?"virtualPrinter.description.proxy":"virtualPrinter.description.default")}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.enable.title")}),a.jsx("div",{className:"text-sm text-bambu-gray",children:q?l==="proxy"?t("virtualPrinter.enable.proxyingTo",{name:A?.find(I=>I.id===h)?.name||"printer"}):t("virtualPrinter.enable.visibleInSlicer"):t("virtualPrinter.enable.notActive")})]}),a.jsx("button",{onClick:T,disabled:v==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${r?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${v==="toggle"?"opacity-50":""}`,children:a.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${r?"translate-x-6":""}`})})]}),l!=="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.model.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:t("virtualPrinter.model.description")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:u,onChange:I=>$(I.target.value),disabled:v==="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:N?.models&&Object.entries(N.models).sort(([,I],[,K])=>I.localeCompare(K)).map(([I,K])=>a.jsx("option",{value:I,children:K},I))}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),r&&q&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[a.jsx(Xs,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.model.restartWarning")]})]}),l!=="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.accessCode.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:k?.access_code_set?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Kr,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.isSet")]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(kn,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.notSet")]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:y?"text":"password",value:s,onChange:I=>o(I.target.value),placeholder:k?.access_code_set?t("virtualPrinter.accessCode.placeholderChange"):t("virtualPrinter.accessCode.placeholder"),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"}),a.jsx("button",{onClick:()=>b(!y),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:y?a.jsx(W0,{className:"w-4 h-4"}):a.jsx(Yl,{className:"w-4 h-4"})})]}),a.jsx(Me,{onClick:j,disabled:!s||v==="accessCode",variant:"primary",children:v==="accessCode"?a.jsx(it,{className:"w-4 h-4 animate-spin"}):t("common.save")})]}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[t("virtualPrinter.accessCode.hint"),s&&a.jsxs("span",{className:s.length===8?"text-green-400":"text-yellow-400",children:[" ",t("virtualPrinter.accessCode.charCount",{count:s.length})]})]})]}),l==="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.targetPrinter.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:h?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Kr,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.configured")]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(kn,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.notConfigured")]})}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:h??"",onChange:I=>{const K=parseInt(I.target.value,10);isNaN(K)||F(K)},disabled:v==="targetPrinter",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:[a.jsx("option",{value:"",children:t("virtualPrinter.targetPrinter.placeholder")}),A?.map(I=>a.jsxs("option",{value:I.id,children:[I.name," (",I.ip_address,")"]},I.id))]}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:t("virtualPrinter.targetPrinter.hint")}),!A?.length&&a.jsxs("p",{className:"text-xs text-yellow-400 mt-2",children:[a.jsx(kn,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.targetPrinter.noPrinters")]})]}),r&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.remoteInterface.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:m?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Kr,{className:"w-4 h-4"}),t("virtualPrinter.remoteInterface.configured")]}):a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(Xs,{className:"w-4 h-4"}),t("virtualPrinter.remoteInterface.optional")]})}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:m,onChange:I=>D(I.target.value),disabled:v==="remoteInterface",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:[a.jsx("option",{value:"",children:t("virtualPrinter.remoteInterface.placeholder")}),M?.map(I=>a.jsxs("option",{value:I.ip,children:[I.name," (",I.ip,") - ",I.subnet]},I.ip))]}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:t("virtualPrinter.remoteInterface.hint")})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.mode.title")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{onClick:()=>z("immediate"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.archive")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.archiveDesc")})]}),a.jsxs("button",{onClick:()=>z("review"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="review"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.review")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.reviewDesc")})]}),a.jsxs("button",{onClick:()=>z("print_queue"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="print_queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.queue")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.queueDesc")})]}),a.jsxs("button",{onClick:()=>z("proxy"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="proxy"?"border-blue-500 bg-blue-500/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-white font-medium",children:[a.jsx(dB,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.proxyDesc")})]})]})]})]})]})}),a.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[a.jsx(_t,{className:"border-l-4 border-l-yellow-500",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-white font-medium mb-2",children:t("virtualPrinter.setupRequired.title")}),a.jsx("p",{className:"text-bambu-gray mb-3",children:t("virtualPrinter.setupRequired.description")}),a.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:[a.jsx(Wr,{className:"w-4 h-4"}),t("virtualPrinter.setupRequired.readGuide")]})]})]})})}),a.jsx(_t,{children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Xs,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:a.jsxs("strong",{className:"text-white",children:[t(l==="proxy"?"virtualPrinter.howItWorks.titleProxy":"virtualPrinter.howItWorks.title"),":"]})}),l==="proxy"?a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep1")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep2")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep3")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep4")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep5")})]}):a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:t("virtualPrinter.howItWorks.step1")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step2")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step3")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step4")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step5")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step6")})]})]})]})})}),H&&q&&a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h3",{className:"text-md font-semibold text-white",children:t("virtualPrinter.status.title")})}),a.jsx(Nt,{children:H.mode==="proxy"&&H.proxy?a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.targetPrinter")}),a.jsx("div",{className:"text-white",children:A?.find(I=>I.id===h)?.name||H.proxy.target_host}),a.jsx("div",{className:"text-xs text-bambu-gray font-mono",children:H.proxy.target_host})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),a.jsxs("div",{className:"text-white flex items-center gap-1.5",children:[a.jsx(dB,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpPort")}),a.jsx("div",{className:"text-white font-mono",children:H.proxy.ftp_port})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttPort")}),a.jsx("div",{className:"text-white font-mono",children:H.proxy.mqtt_port})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpConnections")}),a.jsx("div",{className:"text-white",children:H.proxy.ftp_connections??0})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttConnections")}),a.jsx("div",{className:"text-white",children:H.proxy.mqtt_connections??0})]})]}):a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.printerName")}),a.jsx("div",{className:"text-white",children:H.name})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.model")}),a.jsx("div",{className:"text-white",children:H.model_name||H.model})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.serialNumber")}),a.jsx("div",{className:"text-white font-mono",children:H.serial})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),a.jsx("div",{className:"text-white capitalize",children:H.mode})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.pendingFiles")}),a.jsx("div",{className:"text-white",children:H.pending_files})]})]})})]})]})]})}function W9({status:t}){if(!t)return null;const e={success:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400"},n={success:a.jsx(mr,{className:"w-3 h-3"}),failed:a.jsx(ua,{className:"w-3 h-3"}),skipped:a.jsx(c4,{className:"w-3 h-3"}),running:a.jsx(it,{className:"w-3 h-3 animate-spin"})};return a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${e[t]||"bg-gray-500/20 text-gray-400"}`,children:[n[t],t.charAt(0).toUpperCase()+t.slice(1)]})}function jXe(t){return t?new Date(t).toLocaleString():"-"}function K9(t){if(!t)return"-";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime(),i=Math.round(r/6e4);if(i<0){const s=Math.abs(i);if(s<60)return`${s}m ago`;const o=Math.floor(s/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const s=Math.floor(i/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}}function PXe(){const t=Zt(),{showToast:e}=hn(),{t:n}=Ut(),[r,i]=w.useState(""),[s,o]=w.useState(""),[l,c]=w.useState("main"),[u,d]=w.useState(!1),[h,p]=w.useState("daily"),[m,x]=w.useState(!0),[y,b]=w.useState(!0),[v,S]=w.useState(!1),[k,E]=w.useState(!0),[N,A]=w.useState(!1),[M,P]=w.useState(!1),[T,j]=w.useState(""),[z,F]=w.useState(!1),[$,D]=w.useState(null),[H,q]=w.useState(null),I=w.useRef(null);w.useEffect(()=>{if(N||M){const U=L=>(L.preventDefault(),L.returnValue="A backup operation is in progress. Are you sure you want to leave?",L.returnValue);return window.addEventListener("beforeunload",U),()=>window.removeEventListener("beforeunload",U)}},[N,M]);const[K,Z]=w.useState(!1),[se,V]=w.useState(null),W=w.useRef(null),ie=w.useRef(!1),{data:J,isLoading:pe}=et({queryKey:["github-backup-config"],queryFn:ae.getGitHubBackupConfig}),{data:fe}=et({queryKey:["github-backup-status"],queryFn:ae.getGitHubBackupStatus,refetchInterval:te=>te.state.data?.is_running?500:1e4}),{data:ve}=et({queryKey:["github-backup-logs"],queryFn:()=>ae.getGitHubBackupLogs(20)}),{data:Le}=et({queryKey:["cloud-status"],queryFn:ae.getCloudStatus}),{data:de}=et({queryKey:["printers"],queryFn:ae.getPrinters}),ce=r4({queries:(de??[]).map(te=>({queryKey:["printerStatus",te.id],queryFn:()=>ae.getPrinterStatus(te.id),staleTime:1e4,refetchInterval:3e4}))}),Ae=(de??[]).map((te,U)=>({printer:te,connected:ce[U]?.data?.connected??!1})),re=Ae.length,Ie=Ae.filter(te=>te.connected).length,G=re>0&&Ie===0,Y=Ie>0&&Ie<re;w.useEffect(()=>{J&&(i(J.repository_url),c(J.branch),d(J.schedule_enabled),p(J.schedule_type),x(J.backup_kprofiles),b(J.backup_cloud_profiles),S(J.backup_settings),E(J.enabled),o(""),setTimeout(()=>{ie.current=!0},100))},[J]);const ue=w.useCallback(async(te=!1)=>{if(J?.has_token)try{te&&s?(await ae.saveGitHubBackupConfig({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:v,enabled:k}),o(""),e("Token updated")):(await ae.updateGitHubBackupConfig({repository_url:r,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:v,enabled:k}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(U){e(`Failed to save: ${U.message}`,"error")}},[J?.has_token,r,s,l,u,h,m,y,v,k,t,e]);w.useEffect(()=>{if(!(!ie.current||!J?.has_token))return W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{ue(!1)},500),()=>{W.current&&clearTimeout(W.current)}},[r,l,u,h,m,y,v,k,ue,J?.has_token]),w.useEffect(()=>{if(!(!ie.current||!J?.has_token||!s))return W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{ue(!0)},1e3),()=>{W.current&&clearTimeout(W.current)}},[s,ue,J?.has_token]);const B=st({mutationFn:te=>ae.saveGitHubBackupConfig(te),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),o(""),ie.current=!0},onError:te=>{e(`Failed to save: ${te.message}`,"error")}}),ee=st({mutationFn:ae.triggerGitHubBackup,onSuccess:te=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),te.success?te.files_changed>0?e(`Backup complete - ${te.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${te.message}`,"error")},onError:te=>{e(`Backup failed: ${te.message}`,"error")}}),Q=st({mutationFn:()=>ae.clearGitHubBackupLogs(0),onSuccess:te=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${te.deleted} logs`)},onError:te=>{e(`Failed to clear logs: ${te.message}`,"error")}}),le=async()=>{Z(!0),V(null);try{let te;if(s){if(!r){e("Enter repository URL","error"),Z(!1);return}te=await ae.testGitHubConnection(r,s)}else if(J?.has_token)te=await ae.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Z(!1);return}V({success:te.success,message:te.message})}catch(te){V({success:!1,message:te.message})}finally{Z(!1)}},he=()=>{if(!r){e("Repository URL is required","error");return}if(!s){e("Access token is required","error");return}B.mutate({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:v,enabled:k})};return pe?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"})}):a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(zP,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),J&&Le?.is_authenticated&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),a.jsx(Un,{checked:k,onChange:E})]})]})}),a.jsx(Nt,{className:"space-y-4",children:Le?.is_authenticated?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),a.jsx("input",{type:"text",value:r,onChange:te=>{i(te.target.value),V(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",J?.has_token&&a.jsx("span",{className:"text-green-400",children:"(saved)"})]}),a.jsx("input",{type:"password",value:s,onChange:te=>{o(te.target.value),V(null)},placeholder:J?.has_token?"Enter new token to update":"ghp_xxxxxxxxxxxx",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Branch"}),a.jsx("input",{type:"text",value:l,onChange:te=>c(te.target.value),placeholder:"main",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Auto-backup"}),a.jsxs("select",{value:u?h:"disabled",onChange:te=>{te.target.value==="disabled"?d(!1):(d(!0),p(te.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:[a.jsx("option",{value:"disabled",children:"Manual only"}),a.jsx("option",{value:"hourly",children:"Hourly"}),a.jsx("option",{value:"daily",children:"Daily"}),a.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:`flex items-start gap-2 ${G?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[a.jsx("input",{type:"checkbox",checked:m,onChange:te=>x(te.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:G}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-sm ${G?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),G&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(kn,{className:"w-3 h-3"}),"No printers connected"]}),Y&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(kn,{className:"w-3 h-3"}),Ie,"/",re," connected"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:y,onChange:te=>b(te.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:!Le?.is_authenticated}),a.jsxs("div",{children:[a.jsx("span",{className:`text-sm ${Le?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:v,onChange:te=>S(te.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white text-sm",children:"App Settings"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (complete database)"})]})]})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[fe?.configured&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:fe.last_backup_at?a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Last backup: ",K9(fe.last_backup_at)]}),a.jsx(W9,{status:fe.last_backup_status})]}):a.jsx("span",{children:"No backups yet"})}),fe.next_scheduled_run&&a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx(qn,{className:"w-3 h-3 inline mr-1"}),"Next: ",K9(fe.next_scheduled_run)]})]}),se&&a.jsxs("div",{className:`text-sm flex items-center gap-1 ${se.success?"text-green-400":"text-red-400"}`,children:[se.success?a.jsx(mr,{className:"w-4 h-4"}):a.jsx(ua,{className:"w-4 h-4"}),se.message]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:fe?.configured?a.jsx(a.Fragment,{children:ee.isPending||fe.is_running?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:fe.progress||"Starting backup..."})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>ee.mutate(),disabled:!J?.enabled,children:[a.jsx(jo,{className:"w-4 h-4"}),"Backup Now"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:le,disabled:K,children:[K?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Test"]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"primary",size:"sm",onClick:he,disabled:B.isPending||!r||!s,children:[B.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(mr,{className:"w-4 h-4"}),"Enable Backup"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:le,disabled:K||!r||!s,children:[K?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(kn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),ve&&ve.length>0&&a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(n0,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>Q.mutate(),disabled:Q.isPending,children:[a.jsx(en,{className:"w-4 h-4"}),"Clear"]})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),a.jsx("tbody",{children:ve.slice(0,10).map(te=>a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[a.jsx("td",{className:"py-2 px-2 text-white",children:jXe(te.started_at)}),a.jsx("td",{className:"py-2 px-2",children:a.jsx(W9,{status:te.status})}),a.jsx("td",{className:"py-2 px-2",children:te.commit_sha?a.jsxs("a",{href:`${J?.repository_url}/commit/${te.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[te.commit_sha.substring(0,7),a.jsx(Wr,{className:"w-3 h-3"})]}):a.jsx("span",{className:"text-bambu-gray",children:"-"})})]},te.id))})]})})})]})]}),a.jsx("div",{className:"space-y-6",children:a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kc,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Create a complete backup of your Bambuddy data including the database, archives, uploads, and all files."}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Download Backup"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),a.jsxs(Me,{variant:"secondary",size:"sm",disabled:N||M,onClick:async()=>{A(!0),j("Preparing backup...");try{j("Creating backup archive... This may take a while for large archives.");const{blob:te,filename:U}=await ae.exportBackup();j("Downloading backup file...");const L=URL.createObjectURL(te),X=document.createElement("a");X.href=L,X.download=U,X.click(),URL.revokeObjectURL(L),e("Backup downloaded successfully")}catch(te){e(`Failed to create backup: ${te instanceof Error?te.message:"Unknown error"}`,"error")}finally{A(!1),j("")}},children:[a.jsx(hi,{className:"w-4 h-4"}),"Download"]})]}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:n("backup.restoreBackup")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.restoreDescription")}),a.jsx("p",{className:"text-xs text-bambu-gray-light mt-1",children:n("backup.restoreNote")})]}),a.jsx("input",{ref:I,type:"file",accept:".zip",className:"hidden",onChange:te=>{const U=te.target.files?.[0];U&&(D(U),F(!0)),te.target.value=""}}),a.jsxs(Me,{variant:"secondary",size:"sm",disabled:M||N,onClick:()=>I.current?.click(),children:[a.jsx(ia,{className:"w-4 h-4"}),"Restore"]})]}),H&&a.jsx("div",{className:`p-3 rounded-lg ${H.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[H.success?a.jsx(mr,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):a.jsx(ua,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:H.success?"text-green-200":"text-red-200",children:[H.message,H.success&&a.jsx("div",{className:"mt-2",children:a.jsxs(Me,{size:"sm",onClick:()=>window.location.reload(),children:[a.jsx(Po,{className:"w-3 h-3"}),"Reload Now"]})})]})]})}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(kn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-yellow-200",children:[a.jsx("span",{className:"font-medium",children:"Restore replaces all data."})," ",a.jsx("span",{className:"text-yellow-200/70",children:"Your current database and files will be completely replaced. A restart is required after restore."})]})]})})]})]})}),z&&$&&a.jsx(On,{title:"Restore Backup",message:`Are you sure you want to restore from "${$.name}"? This will completely replace your current database and all files. The application will need to be restarted after restore.`,confirmText:"Restore Backup",variant:"danger",onConfirm:async()=>{F(!1),P(!0),q(null);try{j("Uploading backup file...");const te=await ae.importBackup($);q(te),te.success?e("Backup restored. Please restart Bambuddy.","success"):e(te.message,"error")}catch(te){const U=te instanceof Error?te.message:"Failed to restore backup";q({success:!1,message:U}),e(U,"error")}finally{P(!1),j(""),D(null)}},onCancel:()=>{F(!1),D(null)}}),(N||M)&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),a.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:N?"Creating Backup":"Restoring Backup"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:T||(N?"Preparing...":"Processing...")}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(kn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-yellow-200 text-left",children:"Please do not close this page or navigate away. This operation may take several minutes for large backups."})]})})]})})]})}function DXe(){const{t}=Ut(),{showToast:e}=hn(),n=Zt(),[r,i]=w.useState({smtp_host:"",smtp_port:587,smtp_username:"",smtp_password:"",smtp_security:"starttls",smtp_auth_enabled:!0,smtp_from_email:"",smtp_from_name:"BamBuddy"}),[s,o]=w.useState(""),{data:l,isLoading:c}=et({queryKey:["smtpSettings"],queryFn:()=>ae.getSMTPSettings()}),{data:u}=et({queryKey:["advancedAuthStatus"],queryFn:()=>ae.getAdvancedAuthStatus()});w.useEffect(()=>{l&&i({...l,smtp_password:""})},[l]);const d=st({mutationFn:b=>ae.saveSMTPSettings(b),onSuccess:()=>{n.invalidateQueries({queryKey:["smtpSettings"]}),n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(t("settings.email.success.settingsSaved"),"success")},onError:b=>{e(b.message,"error")}}),h=st({mutationFn:b=>ae.testSMTP(b),onSuccess:b=>{e(b.message,b.success?"success":"error")},onError:b=>{e(b.message,"error")}}),p=st({mutationFn:b=>b?ae.enableAdvancedAuth():ae.disableAdvancedAuth(),onSuccess:b=>{n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(b.message,"success")},onError:b=>{e(b.message,"error")}}),m=()=>{if(!r.smtp_host||!r.smtp_from_email){e(t("settings.email.errors.requiredFields"),"error");return}if(r.smtp_auth_enabled&&!r.smtp_username){e(t("settings.email.errors.usernameRequired"),"error");return}d.mutate(r)},x=()=>{if(!s){e(t("settings.email.errors.enterTestEmail"),"error");return}if(!r.smtp_host||!r.smtp_from_email){e(t("settings.email.errors.smtpServerAndEmail"),"error");return}if(r.smtp_auth_enabled&&(!r.smtp_username||!r.smtp_password)){e(t("settings.email.errors.usernamePasswordRequired"),"error");return}h.mutate({smtp_host:r.smtp_host,smtp_port:r.smtp_port,smtp_username:r.smtp_username,smtp_password:r.smtp_password,smtp_security:r.smtp_security,smtp_auth_enabled:r.smtp_auth_enabled,smtp_from_email:r.smtp_from_email,test_recipient:s})},y=()=>{if(!u?.advanced_auth_enabled&&!u?.smtp_configured){e(t("settings.email.errors.configureSmtpFirst"),"error");return}p.mutate(!u?.advanced_auth_enabled)};return c?a.jsx("div",{className:"flex items-center justify-center p-12",children:a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"})}):a.jsxs("div",{className:"space-y-6",children:[u?.smtp_configured&&a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(r0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.advancedAuth")||"Advanced Authentication"})]}),a.jsx(Me,{onClick:y,disabled:p.isPending,variant:u?.advanced_auth_enabled?"danger":"primary",children:u?.advanced_auth_enabled?a.jsxs(a.Fragment,{children:[a.jsx(PS,{className:"w-4 h-4"}),t("settings.email.disable")||"Disable"]}):a.jsxs(a.Fragment,{children:[a.jsx(Lf,{className:"w-4 h-4"}),t("settings.email.enable")||"Enable"]})})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"space-y-4",children:u?.advanced_auth_enabled?a.jsx("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(mr,{className:"w-5 h-5 text-green-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-white font-medium",children:t("settings.email.advancedAuthEnabled")||"Advanced Authentication is enabled"}),a.jsxs("ul",{className:"text-sm text-green-300 space-y-1 list-disc list-inside",children:[a.jsx("li",{children:t("settings.email.feature1")||"Passwords are auto-generated and emailed to new users"}),a.jsx("li",{children:t("settings.email.feature2")||"Users can login with username or email"}),a.jsx("li",{children:t("settings.email.feature3")||"Forgot password feature is available"}),a.jsx("li",{children:t("settings.email.feature4")||"Admins can reset user passwords via email"})]})]})]})}):a.jsx("div",{className:"bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-white font-medium",children:t("settings.email.advancedAuthDisabled")||"Advanced Authentication is disabled"}),a.jsx("p",{className:"text-sm text-yellow-300",children:t("settings.email.advancedAuthDisabledDesc")||"Enable advanced authentication to activate email-based features for user management."})]})]})})})})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.smtpSettings")||"SMTP Configuration"})}),a.jsx(Nt,{children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[t("settings.email.smtpHost")||"SMTP Server"," *"]}),a.jsx("input",{type:"text",value:r.smtp_host,onChange:b=>i({...r,smtp_host:b.target.value}),placeholder:"smtp.gmail.com",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.smtpPort")||"SMTP Port"}),a.jsx("input",{type:"number",value:r.smtp_port,onChange:b=>i({...r,smtp_port:parseInt(b.target.value)||587}),placeholder:"587",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.security")||"Security"}),a.jsxs("select",{value:r.smtp_security,onChange:b=>i({...r,smtp_security:b.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[a.jsx("option",{value:"starttls",children:t("settings.email.securityOptions.starttls")}),a.jsx("option",{value:"ssl",children:t("settings.email.securityOptions.ssl")}),a.jsx("option",{value:"none",children:t("settings.email.securityOptions.none")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.authentication")||"Authentication"}),a.jsxs("select",{value:r.smtp_auth_enabled?"true":"false",onChange:b=>i({...r,smtp_auth_enabled:b.target.value==="true"}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[a.jsx("option",{value:"true",children:t("settings.email.authOptions.enabled")}),a.jsx("option",{value:"false",children:t("settings.email.authOptions.disabled")})]})]})]}),r.smtp_auth_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.username")||"Username"}),a.jsx("input",{type:"text",value:r.smtp_username||"",onChange:b=>i({...r,smtp_username:b.target.value}),placeholder:"your.email@gmail.com",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.password")||"Password"}),a.jsx("input",{type:"password",value:r.smtp_password||"",onChange:b=>i({...r,smtp_password:b.target.value}),placeholder:l?"••••••••":"App password",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[t("settings.email.fromEmail")||"From Email"," *"]}),a.jsx("input",{type:"email",value:r.smtp_from_email,onChange:b=>i({...r,smtp_from_email:b.target.value}),placeholder:"your@email.com",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.fromName")||"From Name"}),a.jsx("input",{type:"text",value:r.smtp_from_name,onChange:b=>i({...r,smtp_from_name:b.target.value}),placeholder:"BamBuddy",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]})]}),a.jsx("div",{className:"flex gap-2",children:a.jsx(Me,{onClick:m,disabled:d.isPending,className:"flex-1",children:d.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),t("settings.email.saving")||"Saving..."]}):t("settings.email.save")||"Save Settings"})})]})})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.testConnection")||"Test SMTP Connection"})}),a.jsx(Nt,{children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.testRecipient")||"Test Recipient Email"}),a.jsx("input",{type:"email",value:s,onChange:b=>o(b.target.value),placeholder:"test@example.com",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]}),a.jsx(Me,{onClick:x,disabled:h.isPending,variant:"secondary",children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),t("settings.email.sending")||"Sending..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Lk,{className:"w-4 h-4"}),t("settings.email.sendTest")||"Send Test Email"]})})]})})]})]})}const RXe={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 LXe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function My(t,e,n=0){if(n>5)return"...";if(e.$ref)return My(t,LXe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const s=My(t,i,n+1);typeof s=="object"&&s!==null&&Object.assign(r,s)}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?[My(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,s]of Object.entries(e.properties))r[i]=My(t,s,n+1);return r}return{};default:return null}}function OXe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[s,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[h,p]=w.useState(null),[m,x]=w.useState(!1),[y,b]=w.useState(!1);w.useEffect(()=>{if(s&&n.parameters){const P={};for(const T of n.parameters)T.schema?.default!==void 0&&(P[T.name]=String(T.schema.default));c(T=>({...P,...T}))}},[s,n.parameters]),w.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!u){const P=n.requestBody.content["application/json"].schema,T=My(r,P);d(JSON.stringify(T,null,2))}},[s,n.requestBody,r,u]);const S=(()=>{const P=[];for(const T of n.parameters||[])if(T.in==="path"||T.required){const j=l[T.name];(j===void 0||j==="")&&P.push(T.name)}return P})(),k=async()=>{if(S.length>0){p({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}x(!0),p(null);try{let P=t;const T=new URLSearchParams;for(const se of n.parameters||[]){const V=l[se.name];V!==void 0&&V!==""&&(se.in==="path"?P=P.replace(`{${se.name}}`,encodeURIComponent(V)):se.in==="query"&&T.append(se.name,V))}const j=T.toString(),z=`${P}${j?`?${j}`:""}`,F={"Content-Type":"application/json"};i&&(F["X-API-Key"]=i);const $={method:e.toUpperCase(),headers:F};["post","put","patch"].includes(e)&&u&&($.body=u);const D=performance.now(),H=await fetch(z,$),q=Math.round(performance.now()-D),I={};H.headers.forEach((se,V)=>{I[V]=se});let K;H.headers.get("content-type")?.includes("application/json")?K=await H.json():K=await H.text(),p({status:H.status,statusText:H.statusText,headers:I,body:K,duration:q})}catch(P){p({status:0,statusText:"Network Error",headers:{},body:P instanceof Error?P.message:"Unknown error",duration:0})}finally{x(!1)}},E=async()=>{if(h){const P=typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2);try{await navigator.clipboard.writeText(P),b(!0),setTimeout(()=>b(!1),2e3)}catch{const T=document.createElement("textarea");T.value=P,T.style.position="fixed",T.style.left="-999999px",document.body.appendChild(T),T.select(),document.execCommand("copy"),document.body.removeChild(T),b(!0),setTimeout(()=>b(!1),2e3)}}},N=(n.parameters||[]).filter(P=>P.in==="path"),A=(n.parameters||[]).filter(P=>P.in==="query"),M=["post","put","patch"].includes(e)&&n.requestBody;return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[s?a.jsx(tr,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):a.jsx(La,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${RXe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),a.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&a.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),s&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&a.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),N.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),a.jsx("div",{className:"space-y-2",children:N.map(P=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[P.name,P.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),a.jsx("input",{type:"text",value:l[P.name]||"",onChange:T=>c(j=>({...j,[P.name]:T.target.value})),placeholder:P.description||P.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"})]},P.name))})]}),A.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),a.jsx("div",{className:"space-y-2",children:A.map(P=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[P.name,P.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),P.schema?.enum?a.jsxs("select",{value:l[P.name]||"",onChange:T=>c(j=>({...j,[P.name]:T.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"-- Select --"}),P.schema.enum.map(T=>a.jsx("option",{value:T,children:T},T))]}):a.jsx("input",{type:"text",value:l[P.name]||"",onChange:T=>c(j=>({...j,[P.name]:T.target.value})),placeholder:P.description||P.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"})]},P.name))})]}),M&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),a.jsx("textarea",{value:u,onChange:P=>d(P.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..."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{onClick:k,disabled:m,children:[m?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(jo,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&a.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[a.jsx(Ui,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),h&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",a.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${h.status>=200&&h.status<300?"bg-green-500/20 text-green-400":h.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[h.status," ",h.statusText]}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[h.duration,"ms"]})]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:E,children:y?a.jsx(mr,{className:"w-3 h-3 text-green-400"}):a.jsx(Xl,{className:"w-3 h-3"})})]}),a.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 h.body=="string"?h.body:JSON.stringify(h.body,null,2)})]})]})]})}function FXe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[s,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function b(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await v.json();n(S)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}b()},[]),r)return a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(s||!e)return a.jsx(_t,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(Ui,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),a.jsx("p",{children:"Failed to load API schema"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s})]})})});const h={};for(const[b,v]of Object.entries(e.paths))for(const[S,k]of Object.entries(v)){if(S==="parameters")continue;const E=k.tags||["Other"];for(const N of E)h[N]||(h[N]=[]),h[N].push({path:b,method:S,spec:k})}const p=Object.entries(h).map(([b,v])=>{if(!u)return{tag:b,endpoints:v};const S=v.filter(({path:k,method:E,spec:N})=>{const A=u.toLowerCase();return k.toLowerCase().includes(A)||E.toLowerCase().includes(A)||(N.summary?.toLowerCase()||"").includes(A)||(N.description?.toLowerCase()||"").includes(A)});return{tag:b,endpoints:S}}).filter(({endpoints:b})=>b.length>0).sort((b,v)=>b.tag.localeCompare(v.tag)),m=b=>{c(v=>{const S=new Set(v);return S.has(b)?S.delete(b):S.add(b),S})},x=()=>{c(new Set(p.map(b=>b.tag)))},y=()=>{c(new Set)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("div",{className:"flex-1",children:a.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"})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:y,children:"Collapse All"}),a.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[a.jsx(Wr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[p.reduce((b,v)=>b+v.endpoints.length,0)," endpoints in ",p.length," categories"]}),a.jsx("div",{className:"space-y-3",children:p.map(({tag:b,endpoints:v})=>a.jsxs(_t,{children:[a.jsx("button",{onClick:()=>m(b),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:a.jsxs("div",{className:"flex items-center gap-2",children:[l.has(b)?a.jsx(tr,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(La,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:b.replace(/-/g," ")}),a.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)&&a.jsx(Nt,{className:"pt-0 space-y-2",children:v.map(({path:S,method:k,spec:E})=>a.jsx(OXe,{path:S,method:k,spec:E,schema:e,apiKey:t},`${k}-${S}`))})]},b))})]})}const IXe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function zXe(){const t=Zt(),e=Uc(),[n,r]=YR(),{t:i,i18n:s}=Ut(),{showToast:o}=hn(),{authEnabled:l,user:c,refreshAuth:u}=Rr(),{mode:d,darkStyle:h,darkBackground:p,darkAccent:m,lightStyle:x,lightBackground:y,lightAccent:b,setDarkStyle:v,setDarkBackground:S,setDarkAccent:k,setLightStyle:E,setLightBackground:N,setLightAccent:A}=Gm(),[M,P]=w.useState(null),[T,j]=w.useState(!1),[z,F]=w.useState(null),[$,D]=w.useState(!1),[H,q]=w.useState(null),[I,K]=w.useState(null),[Z,se]=w.useState(!1),[V,W]=w.useState(mK()),ie=n.get("tab"),J=ie==="email",pe=J?"users":ie&&IXe.includes(ie)?ie:"general",[fe,ve]=w.useState(pe),[Le,de]=w.useState(J?"email":"users"),ce=oe=>{ve(oe),oe==="users"&&de("users"),oe==="general"?n.delete("tab"):n.set("tab",oe),r(n,{replace:!0})},[Ae,re]=w.useState(!1),[Ie,G]=w.useState(""),[Y,ue]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[B,ee]=w.useState(null),[Q,le]=w.useState(null),[he,te]=w.useState(""),[U,L]=w.useState(!1),[X,ge]=w.useState(!1),[_e,Ee]=w.useState(null),[$e,Ce]=w.useState(!1),[He,Qe]=w.useState(!1),[xe,ye]=w.useState(!1),[we,Ue]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[Pe,Ve]=w.useState(!1),[ke,Ze]=w.useState(!1),[je,Xe]=w.useState(!1),[Re,Oe]=w.useState(null),[Ne,Je]=w.useState(null),[yt,Et]=w.useState(null),[an,jt]=w.useState(!1),[Fe,gt]=w.useState({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),[Qt,tn]=w.useState(!1),[un,dr]=w.useState(null),[gr,ar]=w.useState(null),[Xt,sr]=w.useState({name:"",description:"",permissions:[]}),[vi,Fa]=w.useState(new Set),[De,nt]=w.useState(null),[dt,pt]=w.useState(!1),[ot,Lt]=w.useState({}),[me,ze]=w.useState({}),Ke=oe=>{W(oe),Cme(oe),o(i("settings.toast.settingsSaved"),"success")},Ge=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:be,isLoading:at}=et({queryKey:["settings"],queryFn:ae.getSettings}),{data:ht,isLoading:rt}=et({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs}),{data:Ct,isLoading:Vt}=et({queryKey:["smart-plugs-energy",ht?.map(oe=>oe.id)],queryFn:async()=>{if(!ht||ht.length===0)return null;const oe=await Promise.all(ht.filter(vs=>vs.enabled).map(async vs=>{try{const ts=await ae.getSmartPlugStatus(vs.id);return{plug:vs,status:ts}}catch{return{plug:vs,status:null}}}));let Mt=0,zn=0,Zn=0,Fo=0,gd=0;for(const{plug:vs,status:ts}of oe){const mC=vs.plug_type==="mqtt"&&ts?.energy?.power!=null;(ts?.reachable||mC)&&ts?.energy&&(gd++,ts.energy?.power!=null&&(Mt+=ts.energy.power),ts.energy?.today!=null&&(zn+=ts.energy.today),ts.energy?.yesterday!=null&&(Zn+=ts.energy.yesterday),ts.energy?.total!=null&&(Fo+=ts.energy.total))}return{totalPower:Mt,totalToday:zn,totalYesterday:Zn,totalLifetime:Fo,reachableCount:gd,totalPlugs:ht.filter(vs=>vs.enabled).length}},enabled:fe==="plugs"&&!!ht&&ht.length>0,refetchInterval:fe==="plugs"?1e4:!1}),{data:Dt,isLoading:Tt}=et({queryKey:["notification-providers"],queryFn:ae.getNotificationProviders}),{data:Jt,isLoading:Kt}=et({queryKey:["api-keys"],queryFn:ae.getAPIKeys}),fn=st({mutationFn:oe=>ae.createAPIKey(oe),onSuccess:oe=>{ee(oe.key||null),re(!1),G(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:oe=>{o(`Failed to create API key: ${oe.message}`,"error")}}),Cn=st({mutationFn:oe=>ae.deleteAPIKey(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:oe=>{o(`Failed to delete API key: ${oe.message}`,"error")}}),{data:gn}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:Gt,isLoading:mn}=et({queryKey:["notification-templates"],queryFn:ae.getNotificationTemplates}),{data:pn}=et({queryKey:["virtual-printer-settings"],queryFn:DS.getSettings,refetchInterval:1e4}),Hr=pn?.status?.running??!1,{data:Vr}=et({queryKey:["ffmpeg-status"],queryFn:ae.checkFfmpeg}),{data:Tn}=et({queryKey:["version"],queryFn:ae.getVersion}),{data:_n,refetch:$n,isRefetching:mi}=et({queryKey:["updateCheck"],queryFn:ae.checkForUpdates,staleTime:300*1e3}),{data:hr,refetch:wi}=et({queryKey:["updateStatus"],queryFn:ae.getUpdateStatus,refetchInterval:oe=>{const Mt=oe.state.data;return Mt?.status==="downloading"||Mt?.status==="installing"?1e3:!1}}),{data:bt}=et({queryKey:["mqtt-status"],queryFn:ae.getMQTTStatus,refetchInterval:fe==="network"?5e3:!1}),{data:Ft}=et({queryKey:["github-backup-status"],queryFn:ae.getGitHubBackupStatus}),{data:Kn}=et({queryKey:["cloud-status"],queryFn:ae.getCloudStatus}),{data:wt={advanced_auth_enabled:!1,smtp_configured:!1}}=et({queryKey:["advancedAuthStatus"],queryFn:()=>ae.getAdvancedAuthStatus()}),{hasPermission:rr}=Rr(),{data:Yr=[],isLoading:ai}=et({queryKey:["users"],queryFn:()=>ae.getUsers(),enabled:l&&rr("users:read")}),{data:_i=[],isLoading:wa}=et({queryKey:["groups"],queryFn:()=>ae.getGroups(),enabled:l&&rr("groups:read")}),{data:$t}=et({queryKey:["permissions"],queryFn:()=>ae.getPermissions(),enabled:l&&rr("groups:read")}),bn=st({mutationFn:oe=>ae.createUser(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Ze(!1),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:oe=>{o(oe.message,"error")}}),_a=st({mutationFn:({id:oe,data:Mt})=>ae.updateUser(oe,Mt),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Xe(!1),Oe(null),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:oe=>{o(oe.message,"error")}}),si=st({mutationFn:({id:oe,deleteItems:Mt})=>ae.deleteUser(oe,Mt),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),Je(null),Et(null)},onError:oe=>{o(oe.message,"error")}}),Qr=st({mutationFn:oe=>ae.resetUserPassword({user_id:oe}),onSuccess:oe=>{o(oe.message,"success")},onError:oe=>{o(oe.message,"error")}}),nc=async oe=>{Je(oe),jt(!0);try{const Mt=await ae.getUserItemsCount(oe);Et(Mt)}catch{Et({archives:0,queue_items:0,library_files:0})}finally{jt(!1)}},Or=st({mutationFn:oe=>ae.createGroup(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),tn(!1),Si(),o(i("settings.toast.groupCreated"))},onError:oe=>{o(oe.message,"error")}}),Nl=st({mutationFn:({id:oe,data:Mt})=>ae.updateGroup(oe,Mt),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),dr(null),Si(),o(i("settings.toast.groupUpdated"))},onError:oe=>{o(oe.message,"error")}}),Oo=st({mutationFn:oe=>ae.deleteGroup(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:oe=>{o(oe.message,"error")}}),Sa=()=>{const oe=wt?.advanced_auth_enabled||!1;if(!Fe.username){o(i("settings.toast.fillRequiredFields"),"error");return}if(oe&&!Fe.email){o("Email is required when advanced authentication is enabled","error");return}if(!oe){if(!Fe.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(Fe.password!==Fe.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(Fe.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}bn.mutate({username:Fe.username,password:oe?void 0:Fe.password,email:Fe.email||void 0,role:Fe.role,group_ids:Fe.group_ids.length>0?Fe.group_ids:void 0})},kl=oe=>{if(Fe.password){if(Fe.password!==Fe.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(Fe.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const Mt={username:Fe.username||void 0,password:Fe.password||void 0,role:Fe.role,group_ids:Fe.group_ids};Mt.password||delete Mt.password,_a.mutate({id:oe,data:Mt})},Ml=oe=>{Oe(oe.id),gt({username:oe.username,password:"",email:oe.email||"",confirmPassword:"",role:oe.role,group_ids:oe.groups?.map(Mt=>Mt.id)||[]}),Xe(!0)},Ia=oe=>{gt(Mt=>({...Mt,group_ids:Mt.group_ids.includes(oe)?Mt.group_ids.filter(zn=>zn!==oe):[...Mt.group_ids,oe]}))},Si=()=>{sr({name:"",description:"",permissions:[]}),Fa(new Set)},rc=()=>{if(!Xt.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Or.mutate({name:Xt.name,description:Xt.description||void 0,permissions:Xt.permissions})},Gr=()=>{if(un){if(!Xt.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Nl.mutate({id:un.id,data:{name:Xt.name!==un.name?Xt.name:void 0,description:Xt.description,permissions:Xt.permissions}})}},Ni=oe=>{dr(oe),sr({name:oe.name,description:oe.description||"",permissions:oe.permissions});const Mt=new Set;$t?.categories.forEach(zn=>{zn.permissions.some(Zn=>oe.permissions.includes(Zn.value))&&Mt.add(zn.name)}),Fa(Mt)},so=oe=>{Fa(Mt=>{const zn=new Set(Mt);return zn.has(oe)?zn.delete(oe):zn.add(oe),zn})},br=oe=>{sr(Mt=>{const zn=Mt.permissions.includes(oe)?Mt.permissions.filter(Zn=>Zn!==oe):[...Mt.permissions,oe];return{...Mt,permissions:zn}})},Xn=(oe,Mt)=>{sr(zn=>{const Zn=oe.permissions.map(vs=>vs.value),Fo=zn.permissions.filter(vs=>!Zn.includes(vs)),gd=Mt?[...Fo,...Zn]:Fo;return{...zn,permissions:gd}})},Cl=oe=>oe.permissions.every(Mt=>Xt.permissions.includes(Mt.value)),rf=oe=>{const Mt=oe.permissions.filter(zn=>Xt.permissions.includes(zn.value));return Mt.length>0&&Mt.length<oe.permissions.length},Vc=st({mutationFn:ae.applyUpdate,onSuccess:oe=>{oe.is_docker?o(oe.message,"error"):wi()}}),[pd,af]=w.useState(null),sf=st({mutationFn:ae.testAllNotificationProviders,onSuccess:oe=>{af(oe),t.invalidateQueries({queryKey:["notification-providers"]}),oe.failed===0?o(`All ${oe.tested} providers tested successfully!`,"success"):o(`${oe.success}/${oe.tested} providers succeeded`,oe.failed>0?"error":"success")},onError:oe=>{o(`Failed to test providers: ${oe.message}`,"error")}}),El=st({mutationFn:async oe=>{if(!ht)return{success:0,failed:0};const Mt=ht.filter(Zn=>Zn.enabled),zn=await Promise.all(Mt.map(async Zn=>{try{return await ae.controlSmartPlug(Zn.id,oe),{success:!0}}catch{return{success:!1}}}));return{success:zn.filter(Zn=>Zn.success).length,failed:zn.filter(Zn=>!Zn.success).length}},onSuccess:(oe,Mt)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),oe.failed===0?o(`All ${oe.success} plugs turned ${Mt}`,"success"):o(`${oe.success} plugs turned ${Mt}, ${oe.failed} failed`,"error")},onError:oe=>{o(`Failed: ${oe.message}`,"error")}}),ic=w.useRef(null),of=w.useRef(!1),Lv=w.useRef(!0);w.useEffect(()=>{if(be&&!M){const oe={...be,external_url:be.external_url||window.location.origin};P(oe),setTimeout(()=>{Lv.current=!1},100)}},[be,M]);const Ov=st({mutationFn:ae.updateSettings,onSuccess:oe=>{t.setQueryData(["settings"],oe),P(oe),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:oe=>{o(`Failed to save: ${oe.message}`,"error")},onSettled:()=>{of.current=!1}}),Fv=st({mutationFn:({id:oe,data:Mt})=>ae.updatePrinter(oe,Mt),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:oe=>{o(`Failed to update printer: ${oe.message}`,"error")}});w.useEffect(()=>{if(!(Lv.current||!M||!be||!(be.auto_archive!==M.auto_archive||be.save_thumbnails!==M.save_thumbnails||be.capture_finish_photo!==M.capture_finish_photo||be.default_filament_cost!==M.default_filament_cost||be.currency!==M.currency||be.energy_cost_per_kwh!==M.energy_cost_per_kwh||be.energy_tracking_mode!==M.energy_tracking_mode||be.check_updates!==M.check_updates||(be.check_printer_firmware??!0)!==(M.check_printer_firmware??!0)||be.notification_language!==M.notification_language||be.ams_humidity_good!==M.ams_humidity_good||be.ams_humidity_fair!==M.ams_humidity_fair||be.ams_temp_good!==M.ams_temp_good||be.ams_temp_fair!==M.ams_temp_fair||be.ams_history_retention_days!==M.ams_history_retention_days||be.per_printer_mapping_expanded!==M.per_printer_mapping_expanded||be.date_format!==M.date_format||be.time_format!==M.time_format||be.default_printer_id!==M.default_printer_id||be.ftp_retry_enabled!==M.ftp_retry_enabled||be.ftp_retry_count!==M.ftp_retry_count||be.ftp_retry_delay!==M.ftp_retry_delay||be.ftp_timeout!==M.ftp_timeout||be.mqtt_enabled!==M.mqtt_enabled||be.mqtt_broker!==M.mqtt_broker||be.mqtt_port!==M.mqtt_port||be.mqtt_username!==M.mqtt_username||be.mqtt_password!==M.mqtt_password||be.mqtt_topic_prefix!==M.mqtt_topic_prefix||be.mqtt_use_tls!==M.mqtt_use_tls||be.external_url!==M.external_url||be.ha_enabled!==M.ha_enabled||be.ha_url!==M.ha_url||be.ha_token!==M.ha_token||(be.library_archive_mode??"ask")!==(M.library_archive_mode??"ask")||Number(be.library_disk_warning_gb??5)!==Number(M.library_disk_warning_gb??5)||(be.camera_view_mode??"window")!==(M.camera_view_mode??"window")||(be.preferred_slicer??"bambu_studio")!==(M.preferred_slicer??"bambu_studio")||be.prometheus_enabled!==M.prometheus_enabled||be.prometheus_token!==M.prometheus_token))&&!of.current)return ic.current&&clearTimeout(ic.current),ic.current=setTimeout(()=>{if(of.current)return;of.current=!0;const Mt={auto_archive:M.auto_archive,save_thumbnails:M.save_thumbnails,capture_finish_photo:M.capture_finish_photo,default_filament_cost:M.default_filament_cost,currency:M.currency,energy_cost_per_kwh:M.energy_cost_per_kwh,energy_tracking_mode:M.energy_tracking_mode,check_updates:M.check_updates,check_printer_firmware:M.check_printer_firmware,notification_language:M.notification_language,ams_humidity_good:M.ams_humidity_good,ams_humidity_fair:M.ams_humidity_fair,ams_temp_good:M.ams_temp_good,ams_temp_fair:M.ams_temp_fair,ams_history_retention_days:M.ams_history_retention_days,per_printer_mapping_expanded:M.per_printer_mapping_expanded,date_format:M.date_format,time_format:M.time_format,default_printer_id:M.default_printer_id,ftp_retry_enabled:M.ftp_retry_enabled,ftp_retry_count:M.ftp_retry_count,ftp_retry_delay:M.ftp_retry_delay,ftp_timeout:M.ftp_timeout,mqtt_enabled:M.mqtt_enabled,mqtt_broker:M.mqtt_broker,mqtt_port:M.mqtt_port,mqtt_username:M.mqtt_username,mqtt_password:M.mqtt_password,mqtt_topic_prefix:M.mqtt_topic_prefix,mqtt_use_tls:M.mqtt_use_tls,external_url:M.external_url,ha_enabled:M.ha_enabled,ha_url:M.ha_url,ha_token:M.ha_token,library_archive_mode:M.library_archive_mode,library_disk_warning_gb:M.library_disk_warning_gb,camera_view_mode:M.camera_view_mode,preferred_slicer:M.preferred_slicer,prometheus_enabled:M.prometheus_enabled,prometheus_token:M.prometheus_token};Ov.mutate(Mt)},500),()=>{ic.current&&clearTimeout(ic.current)}},[M,be,Ov]);const xn=w.useCallback((oe,Mt)=>{P(zn=>zn?{...zn,[oe]:Mt}:null)},[]),fC=async(oe,Mt,zn)=>{if(!Mt){o(i("settings.toast.enterCameraUrl"),"error");return}ze(Zn=>({...Zn,[oe]:!0})),Lt(Zn=>({...Zn,[oe]:null}));try{const Zn=await ae.testExternalCamera(oe,Mt,zn);Lt(Fo=>({...Fo,[oe]:Zn})),Zn.success?o(i("settings.toast.cameraConnected",{resolution:Zn.resolution||""}),"success"):o(Zn.error||i("settings.toast.connectionFailed"),"error")}catch(Zn){const Fo=Zn instanceof Error?Zn.message:i("settings.toast.testFailed");Lt(gd=>({...gd,[oe]:{success:!1,error:Fo}})),o(Fo,"error")}finally{ze(Zn=>({...Zn,[oe]:!1}))}},[ex,Iv]=w.useState({}),tx=w.useRef({}),zv=w.useRef(new Set);w.useEffect(()=>{if(gn){const oe={};gn.forEach(Mt=>{Mt.external_camera_url&&!zv.current.has(Mt.id)&&(oe[Mt.id]=Mt.external_camera_url,zv.current.add(Mt.id))}),Object.keys(oe).length>0&&Iv(Mt=>({...Mt,...oe}))}},[gn]);const Uv=(oe,Mt)=>{Iv(zn=>({...zn,[oe]:Mt})),tx.current[oe]&&clearTimeout(tx.current[oe]),tx.current[oe]=setTimeout(()=>{Fv.mutate({id:oe,data:{external_camera_url:Mt||null}})},800)},Bv=(oe,Mt)=>{const zn={};Mt.type!==void 0&&(zn.external_camera_type=Mt.type||null),Mt.enabled!==void 0&&(zn.external_camera_enabled=Mt.enabled),Fv.mutate({id:oe,data:zn})};return at||!M?a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:i("settings.title")}),a.jsx("p",{className:"text-bambu-gray",children:i("settings.configureBambuddy")})]}),a.jsxs("div",{className:"flex flex-wrap gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>ce("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${fe==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:i("settings.tabs.general")}),a.jsxs("button",{onClick:()=>ce("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(dl,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),ht&&ht.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ht.length})]}),a.jsxs("button",{onClick:()=>ce("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Dg,{className:"w-4 h-4"}),i("settings.tabs.notifications"),Dt&&Dt.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Dt.length})]}),a.jsxs("button",{onClick:()=>ce("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(ade,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),a.jsxs("button",{onClick:()=>ce("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Lg,{className:"w-4 h-4"}),i("settings.tabs.network"),a.jsx("span",{className:`w-2 h-2 rounded-full ${bt?.enabled?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ce("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(tl,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),Jt&&Jt.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Jt.length})]}),a.jsxs("button",{onClick:()=>ce("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Nr,{className:"w-4 h-4"}),i("settings.tabs.virtualPrinter"),a.jsx("span",{className:`w-2 h-2 rounded-full ${Hr?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ce("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(uh,{className:"w-4 h-4"}),i("settings.tabs.users"),l&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]}),a.jsxs("button",{onClick:()=>ce("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${fe==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(kc,{className:"w-4 h-4"}),i("settings.tabs.backup"),a.jsx("span",{className:`w-2 h-2 rounded-full ${Kn?.is_authenticated&&Ft?.configured&&Ft?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),fe==="general"&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Nh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:s.language,onChange:oe=>{s.changeLanguage(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:qU.map(oe=>a.jsxs("option",{value:oe.code,children:[oe.nativeName," (",oe.name,")"]},oe.code))}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:V,onChange:oe=>Ke(oe.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:i0.map(oe=>a.jsx("option",{value:oe.to,children:i(oe.labelKey)},oe.id))}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:M.date_format||"system",onChange:oe=>xn("date_format",oe.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:i("settings.systemDefault")}),a.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),a.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),a.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:M.time_format||"system",onChange:oe=>xn("time_format",oe.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:i("settings.systemDefault")}),a.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),a.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:M.default_printer_id??"",onChange:oe=>xn("default_printer_id",oe.target.value?Number(oe.target.value):null),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"",children:i("settings.noDefaultPrinter")}),gn?.map(oe=>a.jsx("option",{value:oe.id,children:oe.name},oe.id))]}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.preferredSlicer")}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:M.preferred_slicer??"bambu_studio",onChange:oe=>xn("preferred_slicer",oe.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"bambu_studio",children:"Bambu Studio"}),a.jsx("option",{value:"orcaslicer",children:"OrcaSlicer"})]}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.preferredSlicerDescription")})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.sidebarOrder")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ge,children:[a.jsx(Po,{className:"w-4 h-4"}),"Reset"]})]})]})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Pk,{className:"w-5 h-5"}),"Appearance"]})}),a.jsxs(Nt,{className:"space-y-6",children:[a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",d==="dark"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:p,onChange:oe=>{S(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"}),a.jsx("option",{value:"oled",children:"OLED Black"}),a.jsx("option",{value:"slate",children:"Slate Blue"}),a.jsx("option",{value:"forest",children:"Forest Green"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:m,onChange:oe=>{k(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:h,onChange:oe=>{v(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",d==="light"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:y,onChange:oe=>{N(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:b,onChange:oe=>{A(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:x,onChange:oe=>{E(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Auto-archive prints"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.auto_archive,onChange:oe=>xn("auto_archive",oe.target.checked),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.saveThumbnails")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.save_thumbnails,onChange:oe=>xn("save_thumbnails",oe.target.checked),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.captureFinishPhoto")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.capture_finish_photo,onChange:oe=>xn("capture_finish_photo",oe.target.checked),className:"sr-only peer"}),a.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"})]})]}),M.capture_finish_photo&&Vr&&!Vr.installed&&a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(kn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),a.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(d4,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),a.jsxs("select",{value:M.camera_view_mode??"window",onChange:oe=>xn("camera_view_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"window",children:i("settings.newWindow")}),a.jsx("option",{value:"embedded",children:i("settings.embeddedOverlay")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:M.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:i("settings.externalCameras")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Configure external cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, HTTP snapshots, and USB cameras (V4L2). When enabled, the external camera is used for live view and finish photos."}),gn&&gn.length>0?a.jsx("div",{className:"space-y-3",children:gn.map(oe=>a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-white font-medium text-sm",children:oe.name}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:oe.external_camera_enabled,onChange:Mt=>Bv(oe.id,{enabled:Mt.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),oe.external_camera_enabled&&a.jsxs("div",{className:"space-y-2 mt-2",children:[a.jsx("input",{type:"text",placeholder:oe.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:ex[oe.id]??oe.external_camera_url??"",onChange:Mt=>Uv(oe.id,Mt.target.value),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:oe.external_camera_type||"mjpeg",onChange:Mt=>Bv(oe.id,{type:Mt.target.value}),className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),a.jsx("option",{value:"rtsp",children:"RTSP Stream"}),a.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),a.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>fC(oe.id,ex[oe.id]??oe.external_camera_url??"",oe.external_camera_type||"mjpeg"),disabled:me[oe.id]||!(ex[oe.id]??oe.external_camera_url),children:me[oe.id]?a.jsx(it,{className:"w-4 h-4 animate-spin"}):"Test"})]}),ot[oe.id]&&a.jsx("div",{className:`text-xs flex items-center gap-1 ${ot[oe.id]?.success?"text-green-500":"text-red-500"}`,children:ot[oe.id]?.success?a.jsxs(a.Fragment,{children:[a.jsx(mr,{className:"w-3 h-3"}),"Connected",ot[oe.id]?.resolution&&` (${ot[oe.id]?.resolution})`]}):a.jsxs(a.Fragment,{children:[a.jsx(ua,{className:"w-3 h-3"}),ot[oe.id]?.error||i("settings.toast.connectionFailed")]})})]})]},oe.id))}):a.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),a.jsx("select",{value:M.currency,onChange:oe=>xn("currency",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:iXe.map(oe=>a.jsx("option",{value:oe.code,children:oe.label},oe.code))})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:Mu(M.currency)}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:M.default_filament_cost,onChange:oe=>xn("default_filament_cost",parseFloat(oe.target.value)||0),style:{paddingLeft:`${Math.max(2,Mu(M.currency).length*.6+1)}rem`},className:"w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:Mu(M.currency)}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:M.energy_cost_per_kwh,onChange:oe=>xn("energy_cost_per_kwh",parseFloat(oe.target.value)||0),style:{paddingLeft:`${Math.max(2,Mu(M.currency).length*.6+1)}rem`},className:"w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),a.jsxs("select",{value:M.energy_tracking_mode||"total",onChange:oe=>xn("energy_tracking_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"print",children:i("settings.printsOnly")}),a.jsx("option",{value:"total",children:i("settings.totalConsumption")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:M.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ms,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),a.jsxs("select",{value:M.library_archive_mode??"ask",onChange:oe=>xn("library_archive_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"always",children:i("settings.archiveMode.always")}),a.jsx("option",{value:"never",children:i("settings.archiveMode.never")}),a.jsx("option",{value:"ask",children:i("settings.archiveMode.ask")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:M.library_disk_warning_gb??5,onChange:oe=>xn("library_disk_warning_gb",parseFloat(oe.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[a.jsx(AXe,{}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.checkForUpdatesLabel")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.check_updates,onChange:oe=>xn("check_updates",oe.target.checked),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.checkPrinterFirmware")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.check_printer_firmware??!0,onChange:oe=>xn("check_printer_firmware",oe.target.checked),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.currentVersion")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Tn?.version||"..."]})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>$n(),disabled:mi,children:[mi?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Check now"]})]}),_n?.update_available?a.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",_n.latest_version]}),_n.release_name&&_n.release_name!==_n.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:_n.release_name})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[_n.release_notes&&a.jsx("button",{onClick:()=>Ce(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),_n.release_url&&a.jsx("a",{href:_n.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:i("settings.viewReleaseOnGitHub"),children:a.jsx(Wr,{className:"w-4 h-4"})})]})]}),hr?.status==="downloading"||hr?.status==="installing"?a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:hr.message})]}),a.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${hr.progress}%`}})})]}):hr?.status==="complete"?a.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:hr.message}):hr?.status==="error"?a.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:hr.error||hr.message}):_n?.is_docker?a.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),a.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"})]}):a.jsxs(Me,{className:"mt-3",onClick:()=>Vc.mutate(),disabled:Vc.isPending,children:[Vc.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(hi,{className:"w-4 h-4"}),"Install Update"]})]}):_n?.error?a.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: ",_n.error]}):_n&&!_n.update_available?a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.clearNotificationLogs")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.clearNotificationLogsDescription")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>L(!0),children:[a.jsx(en,{className:"w-4 h-4"}),i("common.clear")]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.resetUiPreferences")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.resetUiPreferencesDescription")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ge(!0),children:[a.jsx(en,{className:"w-4 h-4"}),"Reset"]})]}),a.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Backup & Restore"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ce("backup"),children:[a.jsx(kc,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),fe==="network"&&M&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Nh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),a.jsx("input",{type:"text",value:M.external_url??"",onChange:oe=>xn("external_url",oe.target.value),placeholder:"http://192.168.1.100:8000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ir,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.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."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableRetry")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.ftp_retry_enabled??!0,onChange:oe=>xn("ftp_retry_enabled",oe.target.checked),className:"sr-only peer"}),a.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"})]})]}),M.ftp_retry_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:M.ftp_retry_count??3,onChange:oe=>xn("ftp_retry_count",parseInt(oe.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[1,2,3,4,5,6,7,8,9,10].map(oe=>a.jsxs("option",{value:oe,children:[oe," ",oe===1?"time":"times"]},oe))}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:M.ftp_retry_delay??2,onChange:oe=>xn("ftp_retry_delay",parseInt(oe.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[1,2,3,5,10,15,20,30].map(oe=>a.jsxs("option",{value:oe,children:[oe," ",oe===1?"second":"seconds"]},oe))}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:M.ftp_timeout??30,onChange:oe=>xn("ftp_timeout",parseInt(oe.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[10,15,20,30,45,60,90,120].map(oe=>a.jsxs("option",{value:oe,children:[oe," seconds"]},oe))}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Increase for printers with weak WiFi"})]})]})]})]})]}),a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(K0,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),M.ha_enabled&&De&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${De.success?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${De.success?"text-green-400":"text-red-400"}`,children:De.success?"Connected":"Disconnected"})]})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, input_boolean, and script entities."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-white",children:i("settings.enableHomeAssistant")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.homeAssistantDescription")}),M.ha_env_managed&&a.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[a.jsx(Lf,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:i("settings.autoEnabledViaEnv")})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.ha_enabled??!1,onChange:oe=>xn("ha_enabled",oe.target.checked),disabled:M.ha_env_managed,className:"sr-only peer"}),a.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 ${M.ha_env_managed?"opacity-60 cursor-not-allowed":""}`})]})]}),M.ha_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Home Assistant URL",M.ha_url_from_env&&a.jsx("span",{className:"ml-2 text-xs text-bambu-green",children:i("settings.environmentManagedLabel")})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",value:M.ha_url??"",onChange:oe=>xn("ha_url",oe.target.value),placeholder:"http://192.168.1.100:8123",disabled:M.ha_url_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${M.ha_url_from_env?"opacity-60 cursor-not-allowed":""}`}),M.ha_url_from_env&&a.jsx(Lf,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),M.ha_url_from_env&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.urlFromEnvReadOnly")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Long-Lived Access Token",M.ha_token_from_env&&a.jsx("span",{className:"ml-2 text-xs text-bambu-green",children:i("settings.environmentManagedLabel")})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"password",value:M.ha_token??"",onChange:oe=>xn("ha_token",oe.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",disabled:M.ha_token_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${M.ha_token_from_env?"opacity-60 cursor-not-allowed":""}`}),M.ha_token_from_env&&a.jsx(Lf,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),M.ha_token_from_env?a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.tokenFromEnvReadOnly")}):a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),M.ha_url&&M.ha_token&&a.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:a.jsxs(Me,{variant:"secondary",size:"sm",disabled:dt,onClick:async()=>{pt(!0),nt(null);try{const oe=await ae.testHAConnection(M.ha_url,M.ha_token);nt(oe)}catch(oe){nt({success:!1,message:null,error:oe instanceof Error?oe.message:i("common.unknownError")})}finally{pt(!1)}},children:[dt?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Lg,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Lg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),bt?.enabled&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${bt.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${bt.connected?"text-green-400":"text-red-400"}`,children:bt.connected?"Connected":"Disconnected"})]})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.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."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableMqtt")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.mqtt_enabled??!1,onChange:oe=>xn("mqtt_enabled",oe.target.checked),className:"sr-only peer"}),a.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"})]})]}),M.mqtt_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),a.jsx("input",{type:"text",value:M.mqtt_broker??"",onChange:oe=>xn("mqtt_broker",oe.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"})]}),a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),a.jsx("input",{type:"number",min:"1",max:"65535",value:M.mqtt_port??1883,onChange:oe=>xn("mqtt_port",Math.min(65535,Math.max(1,parseInt(oe.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"})]}),a.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.mqtt_use_tls??!1,onChange:oe=>{const Mt=oe.target.checked;xn("mqtt_use_tls",Mt);const zn=M.mqtt_port??1883;Mt&&zn===1883?xn("mqtt_port",8883):!Mt&&zn===8883&&xn("mqtt_port",1883)},className:"sr-only peer"}),a.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"})]}),a.jsx("span",{className:"text-white text-sm",children:i("settings.useTls")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),a.jsx("input",{type:"text",value:M.mqtt_username??"",onChange:oe=>xn("mqtt_username",oe.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),a.jsx("input",{type:"password",value:M.mqtt_password??"",onChange:oe=>xn("mqtt_password",oe.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),a.jsx("input",{type:"text",value:M.mqtt_topic_prefix??"bambuddy",onChange:oe=>xn("mqtt_topic_prefix",oe.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"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",M.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),bt&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${bt.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:"text-bambu-gray",children:bt.connected?a.jsxs(a.Fragment,{children:[i("settings.mqttConnectedTo")," ",a.jsxs("span",{className:"text-white",children:[bt.broker,":",bt.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),a.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(GP,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableMetricsEndpoint")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.prometheusDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.prometheus_enabled??!1,onChange:oe=>xn("prometheus_enabled",oe.target.checked),className:"sr-only peer"}),a.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"})]})]}),M.prometheus_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bearer Token (optional)"}),a.jsx("input",{type:"password",value:M.prometheus_token??"",onChange:oe=>xn("prometheus_token",oe.target.value),placeholder:i("settings.leaveEmptyForNoAuth"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["If set, requests must include ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer <token>"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-white mb-2",children:i("settings.availableMetrics")}),a.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),a.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),De&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[De.success?a.jsx(mr,{className:"w-8 h-8 text-green-400"}):a.jsx(ua,{className:"w-8 h-8 text-red-400"}),a.jsx("h3",{className:"text-lg font-medium text-white",children:De.success?"Connection Successful":"Connection Failed"})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:De.success?De.message||"Successfully connected to Home Assistant.":De.error||"Failed to connect to Home Assistant."}),a.jsx("div",{className:"flex justify-end",children:a.jsx(Me,{variant:"primary",onClick:()=>nt(null),children:"OK"})})]})}),fe==="plugs"&&a.jsxs("div",{className:"max-w-4xl",children:[a.jsxs("div",{className:"flex items-start justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(dl,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ht&&ht.filter(oe=>oe.enabled).length>1&&a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Ee("on"),disabled:El.isPending,title:i("settings.turnAllPlugsOn"),children:[El.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(cd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),a.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Ee("off"),disabled:El.isPending,title:i("settings.turnAllPlugsOff"),children:[El.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Rk,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),a.jsxs(Me,{className:"whitespace-nowrap",onClick:()=>{F(null),j(!0)},children:[a.jsx(nr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ht&&ht.length>0&&a.jsxs(_t,{className:"mb-6",children:[a.jsx(Mn,{children:a.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[a.jsx(Ih,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Vt&&a.jsx(it,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),a.jsx(Nt,{children:Ct?a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Ih,{className:"w-3 h-3"}),"Current Power"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Ct.totalPower.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Ct.reachableCount,"/",Ct.totalPlugs," plugs online"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(ri,{className:"w-3 h-3"}),"Today"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Ct.totalToday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(M?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ct.totalToday*(M?.energy_cost_per_kwh??0)).toFixed(2)," ",Mu(M?.currency||"USD")]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(GP,{className:"w-3 h-3"}),"Yesterday"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Ct.totalYesterday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(M?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ct.totalYesterday*(M?.energy_cost_per_kwh??0)).toFixed(2)," ",Mu(M?.currency||"USD")]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(IP,{className:"w-3 h-3"}),"Total"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Ct.totalLifetime.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(M?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ct.totalLifetime*(M?.energy_cost_per_kwh??0)).toFixed(2)," ",Mu(M?.currency||"USD")]})]})]}):Vt?null:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),rt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ht&&ht.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ht.map(oe=>a.jsx(mXe,{plug:oe,onEdit:Mt=>{F(Mt),j(!0)}},oe.id))}):a.jsx(_t,{children:a.jsx(Nt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(dl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.noSmartPlugsTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.noSmartPlugsDescription")}),a.jsxs(Me,{onClick:()=>{F(null),j(!0)},children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),fe==="notifications"&&a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Dg,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>se(!0),children:[a.jsx(n0,{className:"w-4 h-4"}),i("settings.log")]}),Dt&&Dt.length>0&&a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>{af(null),sf.mutate()},disabled:sf.isPending,children:[sf.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Lk,{className:"w-4 h-4"}),i("settings.testAll")]}),a.jsxs(Me,{size:"sm",onClick:()=>{q(null),D(!0)},children:[a.jsx(nr,{className:"w-4 h-4"}),"Add"]})]})]}),a.jsx(_t,{className:"mb-4",children:a.jsx(Nt,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),a.jsx("select",{value:M.notification_language||"en",onChange:oe=>xn("notification_language",oe.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:qU.map(oe=>a.jsx("option",{value:oe.code,children:oe.nativeName},oe.code))})]})})}),pd&&a.jsx(_t,{className:"mb-4",children:a.jsxs(Nt,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm font-medium text-white",children:i("settings.testResults")}),a.jsx("button",{onClick:()=>af(null),className:"text-bambu-gray hover:text-white text-xs",children:i("common.dismiss")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(mr,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:pd.success})]}),pd.failed>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(ua,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:pd.failed})]})]}),pd.results.filter(oe=>!oe.success).length>0&&a.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:pd.results.filter(oe=>!oe.success).map(oe=>a.jsxs("div",{className:"text-xs text-red-400",children:[a.jsxs("span",{className:"font-medium",children:[oe.provider_name,":"]})," ",oe.message]},oe.provider_id))})]})}),Tt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Dt&&Dt.length>0?a.jsx("div",{className:"space-y-3",children:Dt.map(oe=>a.jsx(bXe,{provider:oe,onEdit:Mt=>{q(Mt),D(!0)}},oe.id))}):a.jsx(_t,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Dg,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:i("settings.noProvidersTitle")}),a.jsx("p",{className:"text-xs mb-3",children:i("settings.noProvidersDescription")}),a.jsxs(Me,{size:"sm",onClick:()=>{q(null),D(!0)},children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.addProvider")]})]})})})]}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[a.jsx(Ms,{className:"w-5 h-5 text-bambu-green"}),i("settings.messageTemplates")]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:i("settings.messageTemplatesDescription")}),mn?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Gt&&Gt.length>0?a.jsx("div",{className:"space-y-2",children:Gt.map(oe=>a.jsx(_t,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>K(oe),children:a.jsx(Nt,{className:"py-2.5 px-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium text-sm truncate",children:oe.name}),a.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:oe.title_template})]}),a.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:Mt=>{Mt.stopPropagation(),K(oe)},children:a.jsx(Yf,{className:"w-4 h-4 text-bambu-gray"})})]})})},oe.id))}):a.jsx(_t,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Ms,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),fe==="apikeys"&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(tl,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiKeys")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiKeysDescription")})]}),a.jsxs(Me,{size:"sm",onClick:()=>re(!0),className:"flex-shrink-0",children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.createKey")]})]}),B&&a.jsx(_t,{className:"mb-6 border-bambu-green",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(mr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:i("settings.apiKeyCreated")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:i("settings.apiKeyCopyWarning")}),a.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[a.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:B}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(B);else{const oe=document.createElement("textarea");oe.value=B,oe.style.position="fixed",oe.style.left="-999999px",document.body.appendChild(oe),oe.select(),document.execCommand("copy"),document.body.removeChild(oe)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:a.jsx(Xl,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{te(B),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>ee(null),children:i("common.dismiss")})]})]})]})})}),Ae&&a.jsxs(_t,{className:"mb-6",children:[a.jsx(Mn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keyName")}),a.jsx("input",{type:"text",value:Ie,onChange:oe=>G(oe.target.value),placeholder:i("settings.keyNamePlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("common.permissions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Y.can_read_status,onChange:oe=>ue(Mt=>({...Mt,can_read_status:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.readStatus")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.readStatusDescription")})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Y.can_queue,onChange:oe=>ue(Mt=>({...Mt,can_queue:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.manageQueue")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.manageQueueDescription")})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Y.can_control_printer,onChange:oe=>ue(Mt=>({...Mt,can_control_printer:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.controlPrinter")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.controlPrinterDescription")})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(Me,{onClick:()=>fn.mutate({name:Ie||i("settings.unnamedKey"),...Y}),disabled:fn.isPending,children:[fn.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(nr,{className:"w-4 h-4"}),i("settings.createKey")]}),a.jsx(Me,{variant:"secondary",onClick:()=>re(!1),children:i("common.cancel")})]})]})]}),Kt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Jt&&Jt.length>0?a.jsx("div",{className:"space-y-3",children:Jt.map(oe=>a.jsx(_t,{children:a.jsx(Nt,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(tl,{className:`w-5 h-5 ${oe.enabled?"text-bambu-green":"text-bambu-gray"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:oe.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[oe.key_prefix,"••••••••",oe.last_used&&` · ${i("settings.lastUsed")}: ${eb(oe.last_used)}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex gap-1 text-xs",children:[oe.can_read_status&&a.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:i("settings.read")}),oe.can_queue&&a.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),oe.can_control_printer&&a.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:i("settings.control")})]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>le(oe.id),children:a.jsx(en,{className:"w-4 h-4 text-red-400"})})]})]})})},oe.id))}):a.jsx(_t,{children:a.jsx(Nt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(tl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.apiKeysEmptyTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.apiKeysEmptyDescription")}),a.jsxs(Me,{onClick:()=>re(!0),children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),a.jsxs(_t,{className:"mt-6",children:[a.jsx(Mn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),a.jsxs(Nt,{className:"space-y-3 text-sm",children:[a.jsx("p",{className:"text-bambu-gray",children:i("settings.webhookApiKeyHint")}),a.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getAllStatus")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getSpecificStatus")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-green-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.addToQueue")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.pausePrint")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.resumePrint")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-red-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.stopPrint")]})]})]})]})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Nh,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiBrowser")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiBrowserDescription")})]}),a.jsx(_t,{className:"mb-4",children:a.jsxs(Nt,{className:"py-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("settings.apiKeyForTesting")}),a.jsx("input",{type:"text",value:he,onChange:oe=>te(oe.target.value),placeholder:i("settings.apiKeyPlaceholder"),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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:i("settings.apiKeyHint")})]})}),a.jsx(FXe,{apiKey:he})]})]}),fe==="virtual-printer"&&a.jsx(TXe,{}),fe==="filament"&&M&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsxs("div",{className:"lg:w-1/3 space-y-6",children:[a.jsx(kXe,{}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.amsThresholdsDescription")}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(a4,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"font-medium",children:i("settings.humidity")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodGreen")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:M.ams_humidity_good??40,onChange:oe=>xn("ams_humidity_good",parseInt(oe.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"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:M.ams_humidity_fair??60,onChange:oe=>xn("ams_humidity_fair",parseInt(oe.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"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairBad")})]}),a.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Fk,{className:"w-4 h-4 text-orange-400"}),a.jsx("span",{className:"font-medium",children:i("settings.temperature")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodBlue")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:M.ams_temp_good??28,onChange:oe=>xn("ams_temp_good",parseFloat(oe.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"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:M.ams_temp_fair??35,onChange:oe=>xn("ams_temp_fair",parseFloat(oe.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"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairHot")})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(kc,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"font-medium",children:i("settings.historyRetention")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keepSensorHistory")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"365",value:M.ams_history_retention_days??30,onChange:oe=>xn("ams_history_retention_days",parseInt(oe.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"}),a.jsx("span",{className:"text-bambu-gray",children:i("common.days")})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.historyRetentionDescription")})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Nr,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"font-medium",children:i("settings.printModal")})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-white",children:i("settings.expandCustomMapping")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:i("settings.expandCustomMappingDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.per_printer_mapping_expanded??!1,onChange:oe=>xn("per_printer_mapping_expanded",oe.target.checked),className:"sr-only peer"}),a.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"})]})]})]})]})]})]}),a.jsxs("div",{className:"lg:w-2/3 space-y-6",children:[a.jsx(MXe,{}),a.jsx(CXe,{})]})]})}),Q!==null&&a.jsx(On,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{Cn.mutate(Q),le(null)},onCancel:()=>le(null)}),T&&a.jsx(pXe,{plug:z,onClose:()=>{j(!1),F(null)}}),$&&a.jsx(xXe,{provider:H,onClose:()=>{D(!1),q(null)}}),I&&a.jsx(yXe,{template:I,onClose:()=>K(null)}),Z&&a.jsx(_Xe,{onClose:()=>se(!1)}),U&&a.jsx(On,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{L(!1);try{const oe=await ae.clearNotificationLogs(30);o(oe.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>L(!1)}),X&&a.jsx(On,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{ge(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>ge(!1)}),_e&&a.jsx(On,{title:`Turn All Plugs ${_e==="on"?"On":"Off"}`,message:`This will turn ${_e==="on"?"ON":"OFF"} all ${ht?.filter(oe=>oe.enabled).length||0} enabled smart plugs. ${_e==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${_e==="on"?"On":"Off"}`,variant:_e==="off"?"danger":"warning",onConfirm:()=>{const oe=_e;Ee(null),El.mutate(oe)},onCancel:()=>Ee(null)}),$e&&_n?.release_notes&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Ce(!1),children:a.jsxs(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs(Mn,{className:"flex flex-row items-center justify-between shrink-0",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",_n.latest_version]}),_n.release_name&&_n.release_name!==_n.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray",children:_n.release_name})]}),a.jsx("button",{onClick:()=>Ce(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx(Nt,{className:"overflow-y-auto flex-1",children:a.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:_n.release_notes})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[_n.release_url&&a.jsx("a",{href:_n.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:a.jsxs(Me,{variant:"secondary",className:"w-full",children:[a.jsx(Wr,{className:"w-4 h-4"}),"View on GitHub"]})}),a.jsx(Me,{onClick:()=>Ce(!1),className:"flex-1",children:"Close"})]})]})}),fe==="users"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex gap-1 border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>de("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${Le==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(uh,{className:"w-4 h-4"}),i("settings.tabs.users")]}),a.jsxs("button",{onClick:()=>de("email"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${Le==="email"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(r0,{className:"w-4 h-4"}),i("settings.tabs.emailAuth")||"Email Authentication",wt?.advanced_auth_enabled&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]})]}),Le==="users"&&a.jsxs(a.Fragment,{children:[a.jsx(_t,{children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?a.jsx(Lf,{className:"w-5 h-5 text-green-400"}):a.jsx(PS,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:i("settings.authentication")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&a.jsxs(Me,{variant:"secondary",onClick:()=>Qe(!0),children:[a.jsx(PS,{className:"w-4 h-4"}),i("common.disable")]}):a.jsxs(Me,{onClick:()=>e("/setup"),children:[a.jsx(Lf,{className:"w-4 h-4"}),i("common.enable")]})]})})}),wt?.advanced_auth_enabled&&a.jsx(_t,{className:"border-blue-500/30 bg-blue-500/5",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0",children:a.jsx(r0,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:i("settings.email.advancedAuthEnabled")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.email.advancedAuthEnabledDesc")})]})]})})}),l&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[c&&a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(uh,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),a.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>ye(!0),children:[a.jsx(tl,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),c.groups?.map(oe=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${oe.name==="Administrators"?"bg-purple-500/20 text-purple-300":oe.name==="Operators"?"bg-blue-500/20 text-blue-300":oe.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:oe.name},oe.id))]})]})})})]}),a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(uh,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),rr("users:create")&&a.jsxs(Me,{size:"sm",onClick:()=>{Ze(!0),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),a.jsx(Nt,{children:ai?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Yr.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noUsersFound")}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:Yr.map(oe=>a.jsxs("div",{className:"py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:oe.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[oe.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),oe.groups?.map(Mt=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${Mt.name==="Administrators"?"bg-purple-500/20 text-purple-300":Mt.name==="Operators"?"bg-blue-500/20 text-blue-300":Mt.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:Mt.name},Mt.id))]})]}),a.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[rr("users:update")&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>Ml(oe),children:a.jsx(Yf,{className:"w-4 h-4"})}),rr("users:delete")&&oe.id!==c?.id&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>nc(oe.id),children:a.jsx(en,{className:"w-4 h-4"})})]})]},oe.id))})})]})]}),a.jsx("div",{children:a.jsxs(_t,{children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(NE,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),rr("groups:create")&&a.jsxs(Me,{size:"sm",onClick:()=>{tn(!0),Si()},children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),a.jsx(Nt,{children:wa?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):_i.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noGroupsFound")}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:_i.map(oe=>a.jsxs("div",{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(NE,{className:`w-4 h-4 ${oe.name==="Administrators"?"text-purple-400":oe.name==="Operators"?"text-blue-400":oe.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),a.jsx("span",{className:"text-white font-medium",children:oe.name}),oe.is_system&&a.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:i("settings.system")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[rr("groups:update")&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>Ni(oe),children:a.jsx(Yf,{className:"w-4 h-4"})}),rr("groups:delete")&&!oe.is_system&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>ar(oe.id),children:a.jsx(en,{className:"w-4 h-4"})})]})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:oe.description||i("settings.noDescription")}),a.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[a.jsx("span",{children:i("settings.userCount",{count:oe.user_count})}),a.jsx("span",{children:i("settings.permissionCount",{count:oe.permissions.length})})]})]},oe.id))})})]})})]}),!l&&a.jsx(_t,{children:a.jsx(Nt,{className:"py-6",children:a.jsxs("div",{className:"text-center",children:[a.jsx(PS,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:i("settings.authDisabledTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:i("settings.authDisabledMessage")}),a.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(mr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature1")})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(mr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature2")})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(mr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),a.jsxs(Me,{onClick:()=>e("/setup"),children:[a.jsx(Lf,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),Le==="email"&&a.jsx("div",{className:"max-w-2xl",children:a.jsx(DXe,{})})]}),ke&&!wt?.advanced_auth_enabled&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Ze(!1),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(uh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{Ze(!1),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),a.jsx("input",{type:"text",value:Fe.username,onChange:oe=>gt({...Fe,username:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterUsername"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.password")}),a.jsx("input",{type:"password",value:Fe.password,onChange:oe=>gt({...Fe,password:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterPassword"),autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),a.jsx("input",{type:"password",value:Fe.confirmPassword,onChange:oe=>gt({...Fe,confirmPassword:oe.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${Fe.confirmPassword&&Fe.password!==Fe.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),Fe.confirmPassword&&Fe.password!==Fe.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[_i.map(oe=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Fe.group_ids.includes(oe.id),onChange:()=>Ia(oe.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:oe.name}),oe.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},oe.id)),_i.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{Ze(!1),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Me,{onClick:Sa,disabled:bn.isPending||!Fe.username||!Fe.password||Fe.password!==Fe.confirmPassword||Fe.password.length<6,children:bn.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(nr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),ke&&wt?.advanced_auth_enabled&&a.jsx(NXe,{formData:Fe,setFormData:gt,groups:_i,onClose:()=>{Ze(!1),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},onCreate:Sa,isCreating:bn.isPending,isCreateButtonDisabled:bn.isPending||!Fe.username||!Fe.email}),je&&Re!==null&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Xe(!1),Oe(null),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yf,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{Xe(!1),Oe(null),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("settings.username")," ",wt?.advanced_auth_enabled&&a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:Fe.username,onChange:oe=>gt({...Fe,username:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterUsername"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("users.form.email")||"Email"," ",wt?.advanced_auth_enabled?a.jsx("span",{className:"text-red-400",children:"*"}):a.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",i("users.form.optional")||"optional",")"]})]}),a.jsx("input",{type:"email",value:Fe.email,onChange:oe=>gt({...Fe,email:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("users.form.emailPlaceholder")||"user@example.com",required:wt?.advanced_auth_enabled})]}),!wt?.advanced_auth_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("users.form.password")||"Password"," ",a.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",i("users.form.leaveBlankToKeep")||"leave blank to keep current",")"]})]}),a.jsx("input",{type:"password",value:Fe.password,onChange:oe=>gt({...Fe,password:oe.target.value,confirmPassword:""}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterNewPassword"),autoComplete:"new-password",minLength:6})]}),Fe.password&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),a.jsx("input",{type:"password",value:Fe.confirmPassword,onChange:oe=>gt({...Fe,confirmPassword:oe.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${Fe.confirmPassword&&Fe.password!==Fe.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),Fe.confirmPassword&&Fe.password!==Fe.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),wt?.advanced_auth_enabled&&a.jsxs("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("users.form.passwordManagedByAdvancedAuth")||'Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.'}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>Re&&Qr.mutate(Re),disabled:Qr.isPending||!Fe.email,className:"w-full",children:Qr.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("users.form.resettingPassword")||"Resetting Password..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Po,{className:"w-4 h-4"}),i("users.form.resetPassword")||"Reset Password"]})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("users.form.groups")||"Groups"}),a.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:_i.map(oe=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Fe.group_ids.includes(oe.id),onChange:()=>Ia(oe.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:oe.name}),oe.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",i("users.system")||"System",")"]})]},oe.id))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{Xe(!1),Oe(null),gt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i("users.modal.cancel")||"Cancel"}),a.jsx(Me,{onClick:()=>kl(Re),disabled:_a.isPending||!Fe.username||wt?.advanced_auth_enabled&&!Fe.email||!!(!wt?.advanced_auth_enabled&&Fe.password&&(Fe.password!==Fe.confirmPassword||Fe.password.length<6)),children:_a.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("users.modal.saving")||"Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(fs,{className:"w-4 h-4"}),i("users.modal.saveChanges")||"Save Changes"]})})]})]})]})}),Ne!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{Je(null),Et(null)},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[a.jsx(en,{className:"w-5 h-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),a.jsx(Nt,{className:"space-y-4",children:an?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):yt&&yt.archives+yt.queue_items+yt.library_files>0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.userHasCreated")}),a.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[yt.archives>0&&a.jsxs("li",{children:[yt.archives," archive",yt.archives!==1?"s":""]}),yt.queue_items>0&&a.jsxs("li",{children:[yt.queue_items," queue item",yt.queue_items!==1?"s":""]}),yt.library_files>0&&a.jsxs("li",{children:[yt.library_files," library file",yt.library_files!==1?"s":""]})]}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.userItemsQuestion")}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Me,{variant:"danger",onClick:()=>si.mutate({id:Ne,deleteItems:!0}),disabled:si.isPending,className:"justify-center",children:"Delete user AND their items"}),a.jsx(Me,{variant:"secondary",onClick:()=>si.mutate({id:Ne,deleteItems:!1}),disabled:si.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),a.jsx(Me,{variant:"ghost",onClick:()=>{Je(null),Et(null)},disabled:si.isPending,className:"justify-center",children:"Cancel"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.deleteUserConfirm")}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.actionCannotBeUndone")}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Me,{variant:"ghost",onClick:()=>{Je(null),Et(null)},disabled:si.isPending,children:"Cancel"}),a.jsx(Me,{variant:"danger",onClick:()=>si.mutate({id:Ne,deleteItems:!1}),disabled:si.isPending,children:"Delete User"})]})]})})]})}),(Qt||un)&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{tn(!1),dr(null),Si()},children:a.jsxs(_t,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:oe=>oe.stopPropagation(),children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(NE,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:un?"Edit Group":"Create Group"})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{tn(!1),dr(null),Si()},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.groupName")}),a.jsx("input",{type:"text",value:Xt.name,onChange:oe=>sr({...Xt,name:oe.target.value}),disabled:un?.is_system,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50",placeholder:i("settings.enterGroupName")}),un?.is_system&&a.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:i("settings.systemGroupWarning")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Description"}),a.jsx("textarea",{value:Xt.description,onChange:oe=>sr({...Xt,description:oe.target.value}),rows:2,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors resize-none",placeholder:i("settings.enterDescriptionOptional")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Permissions (",Xt.permissions.length," selected)"]}),a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:$t?.categories.map(oe=>a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary cursor-pointer hover:bg-bambu-dark-tertiary transition-colors",onClick:()=>so(oe.name),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:Mt=>{Mt.stopPropagation(),Xn(oe,!Cl(oe))},className:`w-5 h-5 rounded border flex items-center justify-center transition-colors ${Cl(oe)?"bg-bambu-green border-bambu-green":rf(oe)?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:(Cl(oe)||rf(oe))&&a.jsx(Kr,{className:"w-3 h-3 text-white"})}),a.jsx("span",{className:"text-white font-medium",children:oe.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",oe.permissions.filter(Mt=>Xt.permissions.includes(Mt.value)).length,"/",oe.permissions.length,")"]})]}),vi.has(oe.name)?a.jsx(tr,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(La,{className:"w-4 h-4 text-bambu-gray"})]}),vi.has(oe.name)&&a.jsx("div",{className:"p-3 bg-bambu-dark space-y-2",children:oe.permissions.map(Mt=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Xt.permissions.includes(Mt.value),onChange:()=>br(Mt.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:Mt.label})]},Mt.value))})]},oe.name))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{tn(!1),dr(null),Si()},children:"Cancel"}),a.jsx(Me,{onClick:un?Gr:rc,disabled:Or.isPending||Nl.isPending||!Xt.name.trim(),children:Or.isPending||Nl.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),un?"Saving...":"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(fs,{className:"w-4 h-4"}),un?"Save Changes":"Create Group"]})})]})]})]})}),gr!==null&&a.jsx(On,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{Oo.mutate(gr),ar(null)},onCancel:()=>ar(null)}),fe==="backup"&&a.jsx(PXe,{}),He&&a.jsx(On,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await ae.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await u(),Qe(!1),window.location.href="/"}catch(oe){const Mt=oe instanceof Error?oe.message:i("settings.toast.authDisableFailed");o(Mt,"error")}},onCancel:()=>Qe(!1)}),xe&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{ye(!1),Ue({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(tl,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{ye(!1),Ue({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),a.jsx("input",{type:"password",value:we.currentPassword,onChange:oe=>Ue({...we,currentPassword:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterCurrentPassword"),autoComplete:"current-password"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),a.jsx("input",{type:"password",value:we.newPassword,onChange:oe=>Ue({...we,newPassword:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterNewPasswordMin6"),autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),a.jsx("input",{type:"password",value:we.confirmPassword,onChange:oe=>Ue({...we,confirmPassword:oe.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${we.confirmPassword&&we.newPassword!==we.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),we.confirmPassword&&we.newPassword!==we.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{ye(!1),Ue({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),a.jsx(Me,{onClick:async()=>{if(we.newPassword!==we.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(we.newPassword.length<6){o(i("settings.toast.passwordTooShort"),"error");return}Ve(!0);try{await ae.changePassword(we.currentPassword,we.newPassword),o(i("settings.toast.passwordChanged"),"success"),ye(!1),Ue({currentPassword:"",newPassword:"",confirmPassword:""})}catch(oe){const Mt=oe instanceof Error?oe.message:"Failed to change password";o(Mt,"error")}finally{Ve(!1)}},disabled:Pe||!we.currentPassword||!we.newPassword||we.newPassword!==we.confirmPassword||we.newPassword.length<6,children:Pe?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(tl,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const vie=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},UXe=t=>t.startsWith("HH")?"HF":"S",BXe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},FR=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 dP({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:o}){const l=UXe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&s?s():e()};return a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?a.jsx(to,{className:"w-4 h-4 text-bambu-green"}):a.jsx(pl,{className:"w-4 h-4"})}),a.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:vie(t.k_value)}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&a.jsx("span",{title:"Has note",children:a.jsx(sK,{className:"w-3 h-3 text-yellow-500"})}),a.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&a.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&&a.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:a.jsx(Xl,{className:"w-4 h-4"})})]})}function hP({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u,hasPermission:d}){const{t:h}=Ut(),{showToast:p}=hn(),[m,x]=w.useState(t?.name||""),[y,b]=w.useState(t?.k_value?vie(t.k_value):"0.020"),[v,S]=w.useState(t?.filament_id||""),[k,E]=w.useState(t?.nozzle_id?BXe(t.nozzle_id):"HH00"),[N,A]=w.useState(t?.nozzle_diameter||n),[M,P]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[T,j]=w.useState(!1),[z,F]=w.useState({current:0,total:0}),[$,D]=w.useState(s),H=ci.useMemo(()=>{const W=new Map;for(const ie of r)if(ie.filament_id&&!W.has(ie.filament_id)){const J=FR(ie.name||"");W.set(ie.filament_id,{id:ie.filament_id,name:J||ie.filament_id})}return Array.from(W.values()).sort((ie,J)=>ie.name.localeCompare(J.name))},[r]),q=st({mutationFn:W=>(console.log("[KProfile] Calling API..."),ae.setKProfile(e,W)),onSuccess:W=>{if(console.log("[KProfile] Save success:",W),p(h("kProfiles.toast.profileSaved")),u&&$!==s){let ie;$===""&&o?ie=o:t&&t.slot_id>0?ie=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:ie=`name_${m}_${v}`,u(ie,$)}j(!0),setTimeout(()=>{j(!1),c()},2500)},onError:W=>{console.error("[KProfile] Save error:",W),p(W.message,"error"),j(!1)}}),I=st({mutationFn:W=>(console.log("[KProfile] Deleting profile..."),ae.deleteKProfile(e,W)),onSuccess:W=>{console.log("[KProfile] Delete success:",W),p(h("kProfiles.toast.profileDeleted")),j(!0),setTimeout(()=>{j(!1),l()},4e3)},onError:W=>{console.error("[KProfile] Delete error:",W),p(W.message,"error"),j(!1)}}),[K,Z]=w.useState(!1),se=()=>{t&&I.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})},V=async W=>{if(W.preventDefault(),i&&!t&&M.length===0){p(h("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const ie=parseFloat(y).toFixed(6),J=`${k}-${N}`;if(t||M.length===1){const fe={name:m,k_value:ie,filament_id:v,nozzle_id:J,nozzle_diameter:N,extruder_id:t?t.extruder_id:M[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",fe),q.mutate(fe);return}j(!0),F({current:1,total:M.length});const pe=M.map(fe=>({name:m,k_value:ie,filament_id:v,nozzle_id:J,nozzle_diameter:N,extruder_id:fe,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${pe.length} profiles in batch:`,pe);try{if(await ae.setKProfilesBatch(e,pe),p(h("kProfiles.toast.profilesSaved",{count:M.length})),u&&$){const fe=`name_${m}_${v}`;u(fe,$)}}catch(fe){console.error("[KProfile] Failed to save batch:",fe),p(h("kProfiles.toast.failedToSaveBatch"),"error"),j(!1),F({current:0,total:0});return}F({current:M.length,total:M.length}),setTimeout(()=>{j(!1),F({current:0,total:0}),c()},3e3)};return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[a.jsxs(_t,{className:"w-full max-w-md relative",children:[T&&a.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:z.total>1?h("kProfiles.modal.savingExtruder",{current:z.current,total:z.total}):h("kProfiles.modal.syncing")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:h("kProfiles.modal.pleaseWait")})]}),a.jsxs(Nt,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:h(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),a.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:T,children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:V,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.profileName")}),a.jsx("input",{type:"text",value:m,onChange:W=>x(W.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:h("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.kValue")}),a.jsx("input",{type:"text",inputMode:"decimal",value:y,onChange:W=>{const ie=W.target.value;(ie===""||/^\d*\.?\d*$/.test(ie))&&b(ie)},onBlur:W=>{const ie=parseFloat(W.target.value);isNaN(ie)||b((Math.trunc(ie*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:h("kProfiles.modal.kValuePlaceholder"),required:!0}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:h("kProfiles.modal.kValueHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.filament")}),a.jsxs("select",{value:v,onChange:W=>{const ie=W.target.value;if(S(ie),!t&&ie&&!m){const J=H.find(pe=>pe.id===ie);J&&x(`${k==="HH00"?"HF":"S"} ${J.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:[a.jsx("option",{value:"",children:h("kProfiles.modal.selectFilament")}),t?.filament_id&&a.jsx("option",{value:t.filament_id,children:H.find(W=>W.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&H.map(W=>a.jsx("option",{value:W.id,children:W.name},W.id))]}),!t&&H.length===0&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:h("kProfiles.modal.noFilamentsHelp")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.flowType")}),a.jsxs("select",{value:k,onChange:W=>{const ie=W.target.value;if(E(ie),!t&&v&&!m){const J=H.find(pe=>pe.id===v);J&&x(`${ie==="HS00"?"HF":"S"} ${J.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:[a.jsx("option",{value:"HH00",children:h("kProfiles.modal.highFlow")}),a.jsx("option",{value:"HS00",children:h("kProfiles.modal.standard")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.nozzleSize")}),a.jsxs("select",{value:N,onChange:W=>A(W.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:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h(t?"kProfiles.modal.extruder":"kProfiles.modal.extruders")}),t?a.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?h("kProfiles.modal.left"):h("kProfiles.modal.right")}):a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.includes(1),onChange:W=>{W.target.checked?P([...M,1]):P(M.filter(ie=>ie!==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"}),a.jsx("span",{className:"text-white",children:h("kProfiles.modal.left")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:M.includes(0),onChange:W=>{W.target.checked?P([...M,0]):P(M.filter(ie=>ie!==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"}),a.jsx("span",{className:"text-white",children:h("kProfiles.modal.right")})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.notes")}),a.jsx("textarea",{value:$,onChange:W=>D(W.target.value),placeholder:h("kProfiles.modal.notesPlaceholder"),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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:h("kProfiles.modal.notesHelp")})]}),a.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&a.jsx(Me,{type:"button",variant:"secondary",onClick:()=>Z(!0),disabled:I.isPending||T||!d("kprofiles:delete"),title:d("kprofiles:delete")?void 0:h("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:I.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4"})}),a.jsx(Me,{type:"button",variant:"secondary",onClick:l,disabled:T,className:"flex-1",children:h("common.cancel")}),a.jsxs(Me,{type:"submit",disabled:q.isPending||T||!d(t?"kprofiles:update":"kprofiles:create"),title:d(t?"kprofiles:update":"kprofiles:create")?void 0:h(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[q.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Tk,{className:"w-4 h-4"}),h("common.save")]})]})]})]})]}),K&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.jsx(_t,{className:"w-full max-w-sm",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(en,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:h("kProfiles.deleteConfirm.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h("kProfiles.deleteConfirm.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:h("kProfiles.deleteConfirm.message",{name:t?.name})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>Z(!1),className:"flex-1",children:h("common.cancel")}),a.jsxs(Me,{onClick:()=>{Z(!1),se()},disabled:I.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[I.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4"}),h("common.delete")]})]})]})})})]})}const AS={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function $Xe(){const{t}=Ut(),{showToast:e}=hn(),{hasPermission:n}=Rr(),[r,i]=w.useState(null),[s,o]=w.useState(()=>localStorage.getItem(AS.NOZZLE_DIAMETER)||"0.4"),[l,c]=w.useState(null),[u,d]=w.useState(!1),[h,p]=w.useState(null),[m,x]=w.useState(""),[y,b]=w.useState("all"),[v,S]=w.useState("all"),[k,E]=w.useState(()=>localStorage.getItem(AS.SORT_OPTION)||"name"),[N,A]=w.useState(!1),[M,P]=w.useState(new Set),[T,j]=w.useState(!1),[z,F]=w.useState(!1),$=w.useCallback(Q=>`${Q.slot_id}_${Q.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(AS.NOZZLE_DIAMETER,s)},[s]),w.useEffect(()=>{localStorage.setItem(AS.SORT_OPTION,k)},[k]);const{data:D,isLoading:H}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:q,isLoading:I,isFetching:K,error:Z,refetch:se}=et({queryKey:["kprofiles",r,s],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",s);const Q=await ae.getKProfiles(r,s);return console.log("[KProfiles] Received profiles:",Q?.profiles?.length||0,"profiles"),Q},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:V}=et({queryKey:["kprofiles",r,"0.4"],queryFn:()=>ae.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:W,refetch:ie}=et({queryKey:["kprofile-notes",r],queryFn:()=>ae.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),J=Z?.message?.includes("not connected");w.useEffect(()=>{if(!r&&D&&D.length>0){const Q=D.find(le=>le.is_active);Q&&i(Q.id)}},[r,D]),w.useEffect(()=>{if(r){const Q=setTimeout(()=>{se()},150);return()=>clearTimeout(Q)}},[r,s]);const pe=D?.filter(Q=>Q.is_active)||[],fe=ci.useMemo(()=>q?.profiles?q.profiles.filter(le=>{const he=m.toLowerCase(),te=!he||le.name.toLowerCase().includes(he)||le.filament_id.toLowerCase().includes(he),U=y==="all"||y==="left"&&le.extruder_id===1||y==="right"&&le.extruder_id===0,L=v==="all"||v==="hf"&&le.nozzle_id.startsWith("HH")||v==="s"&&le.nozzle_id.startsWith("HS");return te&&U&&L}).sort((le,he)=>{switch(k){case"k_value":return parseFloat(le.k_value)-parseFloat(he.k_value);case"filament":return FR(le.name).localeCompare(FR(he.name));case"name":default:return le.name.localeCompare(he.name)}}):[],[q?.profiles,m,y,v,k]),ve=D?.find(Q=>Q.id===r),Le=ve?.nozzle_count===2;w.useEffect(()=>{const Q=le=>{le.target instanceof HTMLInputElement||le.target instanceof HTMLTextAreaElement||le.target instanceof HTMLSelectElement||l||u||h||(le.key==="r"||le.key==="R"?(le.preventDefault(),se()):le.key==="n"||le.key==="N"?(le.preventDefault(),d(!0)):le.key==="Escape"&&N&&(le.preventDefault(),A(!1),P(new Set)))};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[l,u,h,N,se]);const de=w.useCallback(()=>{if(!q?.profiles||q.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const Q={version:1,exported_at:new Date().toISOString(),printer:ve?.name||"Unknown",nozzle_diameter:s,profiles:q.profiles.map(U=>({name:U.name,k_value:U.k_value,filament_id:U.filament_id,nozzle_id:U.nozzle_id,nozzle_diameter:U.nozzle_diameter,extruder_id:U.extruder_id}))},le=new Blob([JSON.stringify(Q,null,2)],{type:"application/json"}),he=URL.createObjectURL(le),te=document.createElement("a");te.href=he,te.download=`kprofiles_${ve?.name||"printer"}_${s}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(he),e(t("kProfiles.toast.exportedProfiles",{count:q.profiles.length}))},[q?.profiles,ve,s,e,t]),ce=w.useCallback(()=>{const Q=document.createElement("input");Q.type="file",Q.accept=".json",Q.onchange=async le=>{const he=le.target.files?.[0];if(he)try{const te=await he.text(),U=JSON.parse(te);if(!U.profiles||!Array.isArray(U.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let L=0;for(const X of U.profiles)if(!(!X.name||!X.k_value||!X.filament_id))try{await ae.setKProfile(r,{name:X.name,k_value:parseFloat(X.k_value).toFixed(6),filament_id:X.filament_id,nozzle_id:X.nozzle_id||`HH00-${s}`,nozzle_diameter:X.nozzle_diameter||s,extruder_id:X.extruder_id??0,slot_id:0}),L++,await new Promise(ge=>setTimeout(ge,500))}catch(ge){console.error("Failed to import profile:",X.name,ge)}e(t("kProfiles.toast.importedProfiles",{count:L,total:U.profiles.length})),se()}catch(te){console.error("Import error:",te),e(t("kProfiles.toast.failedToParseImport"),"error")}},Q.click()},[r,s,e,se,t]),Ae=w.useCallback(Q=>{P(le=>{const he=new Set(le);return he.has(Q)?he.delete(Q):he.add(Q),he})},[]),re=w.useCallback(()=>{P(new Set(fe.map(Q=>$(Q))))},[fe,$]),Ie=w.useCallback(()=>{M.size!==0&&j(!0)},[M.size]),G=w.useCallback(async()=>{const Q=fe.filter(he=>M.has($(he)));F(!0);let le=0;for(const he of Q)try{await ae.deleteKProfile(r,{slot_id:he.slot_id,extruder_id:he.extruder_id,nozzle_id:he.nozzle_id,nozzle_diameter:he.nozzle_diameter,filament_id:he.filament_id,setting_id:he.setting_id}),le++,await new Promise(te=>setTimeout(te,300))}catch(te){console.error("Failed to delete profile:",he.name,te)}e(t("kProfiles.toast.profilesDeleted",{count:le})),F(!1),j(!1),A(!1),P(new Set),se()},[r,M,fe,e,se,$,t]),Y=w.useCallback(Q=>{const le=[];return Q.setting_id&&le.push(Q.setting_id),le.push(`slot_${Q.slot_id}_${Q.filament_id}_${Q.extruder_id}`),le.push(`name_${Q.name}_${Q.filament_id}`),le},[]),ue=w.useCallback(async(Q,le)=>{if(r)try{await ae.setKProfileNote(r,Q,le),ie()}catch(he){console.error("Failed to save note:",he),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,ie,e,t]),B=w.useCallback(Q=>{if(!W?.notes)return{note:"",key:null};const le=Y(Q);for(const he of le)if(W.notes[he])return{note:W.notes[he],key:he};return{note:"",key:null}},[W,Y]),ee=w.useCallback(Q=>B(Q).note,[B]);return H?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!D||D.length===0?a.jsx(_t,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Ui,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noPrintersConfigured")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.addPrinterInSettings")})]})}):pe.length===0?a.jsx(_t,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Nr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noActivePrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.enablePrinterConnection")})]})}):a.jsxs(a.Fragment,{children:[K&&!I&&a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[a.jsx(it,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:t("kProfiles.loadingProfiles")})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1 min-w-48",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.printer")}),a.jsx("select",{value:r||"",onChange:Q=>i(parseInt(Q.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:pe.map(Q=>a.jsx("option",{value:Q.id,children:Q.name},Q.id))})]}),a.jsxs("div",{className:"w-32",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.nozzle")}),a.jsxs("select",{value:s,onChange:Q=>o(Q.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:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:()=>se(),disabled:K||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[a.jsx(Ir,{className:`w-4 h-4 ${K?"animate-spin":""}`}),t("kProfiles.refresh")]}),a.jsxs(Me,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[a.jsx(nr,{className:"w-4 h-4"}),t("kProfiles.addProfile")]})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[a.jsxs("div",{className:"flex-1 min-w-48 relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:m,onChange:Q=>x(Q.target.value),placeholder:t("kProfiles.searchPlaceholder"),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"})]}),Le&&a.jsx("div",{className:"w-36",children:a.jsxs("select",{value:y,onChange:Q=>b(Q.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:[a.jsx("option",{value:"all",children:t("kProfiles.allExtruders")}),a.jsx("option",{value:"left",children:t("kProfiles.leftOnly")}),a.jsx("option",{value:"right",children:t("kProfiles.rightOnly")})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:v,onChange:Q=>S(Q.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:[a.jsx("option",{value:"all",children:t("kProfiles.allFlow")}),a.jsx("option",{value:"hf",children:t("kProfiles.hfOnly")}),a.jsx("option",{value:"s",children:t("kProfiles.sOnly")})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:k,onChange:Q=>E(Q.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:[a.jsx("option",{value:"name",children:t("kProfiles.sortName")}),a.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),a.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[a.jsxs(Me,{variant:"secondary",onClick:de,disabled:!q?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[a.jsx(hi,{className:"w-4 h-4"}),t("kProfiles.export")]}),a.jsxs(Me,{variant:"secondary",onClick:ce,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[a.jsx(ia,{className:"w-4 h-4"}),t("kProfiles.import")]}),a.jsx("div",{className:"flex-1"}),N?a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",onClick:re,children:[a.jsx(to,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),a.jsxs(Me,{variant:"secondary",onClick:Ie,disabled:M.size===0||!n("kprofiles:delete"),className:"text-red-500 hover:bg-red-500/10",title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(en,{className:"w-4 h-4"}),t("kProfiles.delete")," (",M.size,")"]}),a.jsxs(Me,{variant:"secondary",onClick:()=>{A(!1),P(new Set)},children:[a.jsx(Rt,{className:"w-4 h-4"}),t("common.cancel")]})]}):a.jsxs(Me,{variant:"secondary",onClick:()=>A(!0),disabled:!fe.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(to,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),I?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):J?a.jsx(_t,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(km,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.printerOffline")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),a.jsxs(Me,{variant:"secondary",onClick:()=>se(),children:[a.jsx(Ir,{className:"w-4 h-4"}),t("common.refresh")]})]})}):fe.length>0?Le?a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.leftExtruder")}),a.jsx("div",{className:"space-y-1",children:fe.filter(Q=>Q.extruder_id===1).map(Q=>a.jsx(dP,{profile:Q,onEdit:()=>c(Q),onCopy:()=>p(Q),selectionMode:N,isSelected:M.has($(Q)),onToggleSelect:()=>Ae($(Q)),note:ee(Q)},$(Q)))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.rightExtruder")}),a.jsx("div",{className:"space-y-1",children:fe.filter(Q=>Q.extruder_id===0).map(Q=>a.jsx(dP,{profile:Q,onEdit:()=>c(Q),onCopy:()=>p(Q),selectionMode:N,isSelected:M.has($(Q)),onToggleSelect:()=>Ae($(Q)),note:ee(Q)},$(Q)))})]})]}):a.jsx("div",{className:"space-y-1",children:fe.map(Q=>a.jsx(dP,{profile:Q,onEdit:()=>c(Q),onCopy:()=>p(Q),selectionMode:N,isSelected:M.has($(Q)),onToggleSelect:()=>Ae($(Q)),note:ee(Q)},$(Q)))}):m||y!=="all"||v!=="all"?a.jsx(_t,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(zr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noMatchingProfiles")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.noMatchingProfilesDesc")})]})}):a.jsx(_t,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Tk,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noKProfiles")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:s})}),a.jsxs(Me,{onClick:()=>d(!0),children:[a.jsx(nr,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:Q,key:le}=B(l);return a.jsx(hP,{profile:l,printerId:r,nozzleDiameter:s,existingProfiles:V?.profiles||q?.profiles,isDualNozzle:Le,initialNote:Q,initialNoteKey:le,onSaveNote:ue,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),se()},onSave:()=>{c(null),se()}})})(),u&&r&&a.jsx(hP,{printerId:r,nozzleDiameter:s,existingProfiles:V?.profiles||q?.profiles,isDualNozzle:Le,onSaveNote:ue,hasPermission:n,onClose:()=>{d(!1),se()},onSave:()=>{d(!1),se()}}),h&&r&&a.jsx(hP,{printerId:r,nozzleDiameter:s,existingProfiles:V?.profiles||q?.profiles,isDualNozzle:Le,onSaveNote:ue,hasPermission:n,profile:{...h,slot_id:0,name:`${h.name} (Copy)`},onClose:()=>{p(null),se()},onSave:()=>{p(null),se()}}),T&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-sm",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(en,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:t("kProfiles.bulkDelete.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("kProfiles.bulkDelete.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:t("kProfiles.bulkDelete.message",{count:M.size})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>j(!1),disabled:z,className:"flex-1",children:t("common.cancel")}),a.jsxs(Me,{onClick:G,disabled:z,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[z?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}const wie=["PLA","PETG","ABS","ASA","TPU","PC","PA","PVA","HIPS","PP","PET","NYLON"],HXe={PLA:"E8E8E8",PETG:"4A90D9",ABS:"E67E22",ASA:"D35400",TPU:"9B59B6",PC:"BDC3C7",PA:"2ECC71",NYLON:"2ECC71",PVA:"F1C40F",HIPS:"95A5A6",PP:"ECF0F1",PET:"3498DB"};function VXe(t){const e=t.toUpperCase();for(const n of wie)if(new RegExp(`\\b${n}\\b`).test(e))return n;return null}function GXe(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const r of wie){const i=n.indexOf(r);if(i>0){const s=e.slice(0,i).trim();if(s&&s.length>1)return s}}return null}function fP({preset:t,onDelete:e,onExpand:n,isExpanded:r}){const{t:i}=Ut(),{hasPermission:s}=Rr(),o=t.filament_type||VXe(t.name),l=t.filament_vendor||GXe(t.name);let c=null,u=!1;if(t.default_filament_colour)try{const d=JSON.parse(t.default_filament_colour),h=Array.isArray(d)?d[0]:d;typeof h=="string"&&/^#?[0-9a-fA-F]{6,8}$/.test(h.replace("#",""))&&(c=h.replace("#","").slice(0,6),u=!0)}catch{const d=t.default_filament_colour;/^#?[0-9a-fA-F]{6,8}$/.test(d.replace("#",""))&&(c=d.replace("#","").slice(0,6),u=!0)}return!c&&o&&(c=HXe[o.toUpperCase()]||null),a.jsx(_t,{className:"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors",children:a.jsxs(Nt,{className:"p-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.preset_type==="filament"&&a.jsx("div",{className:`w-4 h-4 rounded-full border border-white/20 flex-shrink-0 ${!u&&!c?"opacity-25":u?"":"opacity-50"}`,style:{backgroundColor:c?`#${c}`:"#666"}}),a.jsx("span",{className:"text-sm font-medium text-white truncate",children:t.name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:o}),l&&a.jsx("span",{className:"text-xs text-bambu-gray",children:l}),a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400",children:i("profiles.localProfiles.badge")})]})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s("settings:update")&&a.jsx("button",{onClick:()=>e(t.id),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",title:i("profiles.localProfiles.delete"),children:a.jsx(en,{className:"w-3.5 h-3.5"})}),a.jsx("button",{onClick:()=>n(r?null:t.id),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:r?a.jsx(Kl,{className:"w-3.5 h-3.5"}):a.jsx(tr,{className:"w-3.5 h-3.5"})})]})]}),r&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary text-xs space-y-1.5",children:[o&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.filamentType")}),a.jsx("span",{className:"text-white",children:o})]}),l&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.vendor")}),a.jsx("span",{className:"text-white",children:l})]}),t.nozzle_temp_min!=null&&t.nozzle_temp_max!=null&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.nozzleTemp")}),a.jsxs("span",{className:"text-white",children:[t.nozzle_temp_min,"–",t.nozzle_temp_max,"°C"]})]}),t.filament_cost&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.cost")}),a.jsx("span",{className:"text-white",children:t.filament_cost})]}),t.filament_density&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.density")}),a.jsxs("span",{className:"text-white",children:[t.filament_density," g/cm³"]})]}),t.pressure_advance&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.pressureAdvance")}),a.jsx("span",{className:"text-white",children:t.pressure_advance})]}),t.compatible_printers&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.compatiblePrinters")}),a.jsx("span",{className:"text-white truncate ml-2",children:(()=>{try{return JSON.parse(t.compatible_printers).join(", ")}catch{return t.compatible_printers}})()})]}),t.inherits&&t.inherits!==t.name&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.inheritsFrom")}),a.jsx("span",{className:"text-white truncate ml-2",children:t.inherits})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.source")}),a.jsx("span",{className:"text-white capitalize",children:t.source})]})]})]})})}function qXe(){const{t}=Ut(),{hasPermission:e}=Rr(),n=Zt(),{showToast:r}=hn(),[i,s]=w.useState(""),[o,l]=w.useState(null),[c,u]=w.useState(!1),[d,h]=w.useState(null),{data:p,isLoading:m}=et({queryKey:["localPresets"],queryFn:()=>ae.getLocalPresets()}),x=st({mutationFn:async M=>{const P=[];for(const T of Array.from(M)){const j=new FormData;j.append("file",T),P.push(await ae.importLocalPresets(j))}return P},onSuccess:M=>{n.invalidateQueries({queryKey:["localPresets"]});let P=0,T=0,j=0;for(const z of M)P+=z.imported,T+=z.skipped,j+=z.errors.length;P>0&&r(t("profiles.localProfiles.toast.importSuccess",{count:P})),T>0&&r(t("profiles.localProfiles.toast.importSkipped",{count:T}),"warning"),j>0&&r(t("profiles.localProfiles.toast.importError",{count:j}),"error")},onError:M=>{r(M.message,"error")}}),y=st({mutationFn:M=>ae.deleteLocalPreset(M),onSuccess:()=>{n.invalidateQueries({queryKey:["localPresets"]}),h(null),r(t("profiles.localProfiles.toast.deleted"))}}),b=w.useCallback(M=>{!M||M.length===0||x.mutate(M)},[x]),v=w.useCallback(M=>{M.preventDefault(),u(!1),b(M.dataTransfer.files)},[b]),S=w.useCallback(M=>{if(!i)return M;const P=i.toLowerCase();return M.filter(T=>T.name.toLowerCase().includes(P)||T.filament_type?.toLowerCase().includes(P)||T.filament_vendor?.toLowerCase().includes(P))},[i]),k=w.useMemo(()=>S(p?.filament||[]),[p?.filament,S]),E=w.useMemo(()=>S(p?.printer||[]),[p?.printer,S]),N=w.useMemo(()=>S(p?.process||[]),[p?.process,S]),A=k.length+E.length+N.length;return m?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"space-y-6",children:[e("settings:update")&&a.jsxs("div",{onDragOver:M=>{M.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:v,className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("input",{type:"file",accept:".json,.zip,.orca_filament,.bbscfg,.bbsflmt",multiple:!0,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",onChange:M=>b(M.target.files)}),x.isPending?a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(it,{className:"w-5 h-5 text-bambu-green animate-spin"}),a.jsx("span",{className:"text-bambu-gray",children:t("profiles.localProfiles.importing")})]}):a.jsxs(a.Fragment,{children:[a.jsx(ia,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-white font-medium",children:t("profiles.localProfiles.import")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("profiles.localProfiles.importDesc")})]})]}),A>0&&a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:i,onChange:M=>s(M.target.value),placeholder:t("profiles.localProfiles.search"),className:"w-full pl-9 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),A===0&&!m&&a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Pb,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50"}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.localProfiles.noPresets")}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:t("profiles.localProfiles.importDesc")})]}),A>0&&a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[k.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Ck,{className:"w-4 h-4 text-bambu-green"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",k.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:k.map(M=>a.jsx(fP,{preset:M,onDelete:P=>h(P),onExpand:l,isExpanded:o===M.id},M.id))})]}),N.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Ja,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",N.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:N.map(M=>a.jsx(fP,{preset:M,onDelete:P=>h(P),onExpand:l,isExpanded:o===M.id},M.id))})]}),E.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Qu,{className:"w-4 h-4 text-orange-400"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",E.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:E.map(M=>a.jsx(fP,{preset:M,onDelete:P=>h(P),onExpand:l,isExpanded:o===M.id},M.id))})]})]}),d!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-6 max-w-sm mx-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Ui,{className:"w-5 h-5 text-red-400"}),a.jsx("h3",{className:"text-white font-medium",children:t("profiles.localProfiles.deleteConfirmTitle")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:t("profiles.localProfiles.deleteConfirm")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>h(null),children:t("profiles.localProfiles.cancel")}),a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>y.mutate(d),disabled:y.isPending,children:[y.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4"}),t("profiles.localProfiles.delete")]})]})]})})]})}function $F(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,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=s?(s[1]||s[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 V0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function WXe(t,e){const n=Qi(t);if(!n)return"";const i=new Date().getTime()-n.getTime(),s=Math.floor(i/6e4),o=Math.floor(i/36e5),l=Math.floor(i/864e5);return s<1?e("profiles.time.justNow"):s<60?e("profiles.time.minsAgo",{count:s}):o<24?e("profiles.time.hoursAgo",{count:o}):l<7?e("profiles.time.daysAgo",{count:l}):n.toLocaleDateString()}function KXe({onSuccess:t,t:e}){const{showToast:n}=hn(),[r,i]=w.useState("email"),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(""),[h,p]=w.useState(""),[m,x]=w.useState("global"),[y,b]=w.useState(null),[v,S]=w.useState(null),k=st({mutationFn:()=>ae.cloudLogin(s,l,m),onSuccess:P=>{P.success?(n(e("profiles.login.toast.loggedIn")),t()):P.needs_verification?(b(P.verification_type||"email"),S(P.tfa_key||null),P.verification_type==="totp"?n(e("profiles.login.toast.enterTotp")):n(e("profiles.login.toast.codeSent")),i("code")):n(P.message,"error")},onError:P=>n(P.message,"error")}),E=st({mutationFn:()=>ae.cloudVerify(s,u,v||void 0),onSuccess:P=>{P.success?(n(e("profiles.login.toast.loggedIn")),t()):n(P.message,"error")},onError:P=>n(P.message,"error")}),N=st({mutationFn:()=>ae.cloudSetToken(h),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:P=>n(P.message,"error")}),A=P=>{P.preventDefault(),r==="email"?k.mutate():r==="code"?E.mutate():r==="token"&&N.mutate()},M=k.isPending||E.isPending||N.isPending;return a.jsx(_t,{className:"max-w-md mx-auto",children:a.jsxs(Nt,{children:[a.jsxs("div",{className:"text-center mb-6",children:[a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:a.jsx(jb,{className:"w-6 h-6 text-bambu-green"})}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:e("profiles.login.title")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:e("profiles.login.subtitle")})]}),a.jsxs("form",{onSubmit:A,className:"space-y-4",children:[r==="email"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.email")}),a.jsx("input",{type:"email",value:s,onChange:P=>o(P.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.password")}),a.jsx("input",{type:"password",value:l,onChange:P=>c(P.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.region")}),a.jsxs("select",{value:m,onChange:P=>x(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",children:[a.jsx("option",{value:"global",children:e("profiles.login.regionGlobal")}),a.jsx("option",{value:"china",children:e("profiles.login.regionChina")})]})]})]}),r==="code"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e(y==="totp"?"profiles.login.totpCode":"profiles.login.verificationCode")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:y==="totp"?e("profiles.login.enterTotpHint"):e("profiles.login.checkEmail",{email:s})}),a.jsx("input",{type:"text",value:u,onChange:P=>d(P.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})]}),r==="token"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.accessToken")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.accessTokenHint")}),a.jsx("textarea",{value:h,onChange:P=>p(P.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})]}),a.jsxs("div",{className:"flex gap-2",children:[r==="code"&&a.jsx(Me,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),a.jsxs(Me,{type:"submit",disabled:M,className:"flex-1",children:[M?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(hB,{className:"w-4 h-4"}),e(r==="email"?"profiles.login.loginButton":r==="code"?"profiles.login.verifyButton":"profiles.login.setTokenButton")]})]}),r==="email"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(tl,{className:"w-4 h-4"}),e("profiles.login.useToken")]})}),r==="token"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(hB,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function gg({label:t,value:e,options:n,onChange:r}){const[i,s]=w.useState(!1),o=n.find(l=>l.value===e);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>s(!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:[a.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),a.jsx("span",{children:o?.label||"All"}),a.jsx(tr,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),a.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=>a.jsxs("button",{onClick:()=>{r(l.value),s(!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:[a.jsx("span",{children:l.label}),l.count!==void 0&&a.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function XXe(){const[t,e]=w.useState(!1);w.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?a.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:a.jsx(_m,{className:"w-5 h-5"})}):null}function mP({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:o,t:l}){const c=$F(t.name),u=V0(t.setting_id);return a.jsxs("div",{className:"flex items-center gap-2 group",children:[a.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:a.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&a.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:s+1}),!i&&u&&a.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:l("profiles.presets.myPreset")}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),c.filamentType&&t.type==="filament"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.filamentType}),c.layerHeight&&t.type==="process"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.layerHeight}),c.printer&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.printer})]})}),a.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:l("profiles.presets.duplicate"),children:a.jsx(Xl,{className:"w-4 h-4"})})]})}function IR(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(`
  8298. `)){const i=t.replace(/\\n/g,`
  8299. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8300. `);if(i.length>1)return`"""
  8301. `+i.map(s=>n+" "+s).join(`
  8302. `)+`
  8303. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8304. `+t.map(i=>n+" "+IR(i,e+1)).join(`,
  8305. `)+`
  8306. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8307. `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+IR(o,e+1)).join(`,
  8308. `)+`
  8309. `+n+"}"}return String(t)}function YXe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=hn(),c=Zt(),[u,d]=w.useState(!1),{data:h,isLoading:p}=et({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ae.getCloudSettingDetail(t.setting_id)}),m=st({mutationFn:()=>ae.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>l(b.message,"error")}),x=V0(t.setting_id),y=$F(t.name,h?.setting?.inherits);return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),x&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),y.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:y.printer})]})]})]}),a.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:p?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.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:IR(h)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?a.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[a.jsx(kn,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>d(!1),disabled:m.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Me,{variant:"danger",onClick:()=>m.mutate(),disabled:m.isPending,className:"flex-1",children:[m.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(en,{className:"w-4 h-4"}),o("common.delete")]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Me,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(Xl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",onClick:i,disabled:p||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx($i,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Me,{variant:"danger",onClick:()=>d(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(en,{className:"w-4 h-4"})})]})]})})]})})})}function _ie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Sie(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function QXe({onClose:t,onApply:e,t:n}){const{showToast:r}=hn(),[i,s]=w.useState(_ie),[o,l]=w.useState("all"),[c,u]=w.useState(null),[d,h]=w.useState(""),[p,m]=w.useState(""),[x,y]=w.useState("{}"),[b,v]=w.useState(null),[S,k]=w.useState(null),E=o==="all"?i:i.filter($=>$.type===o),N=$=>{s($),Sie($)},A=$=>{const D=i.filter(H=>H.id!==$);N(D),k(null),r(n("profiles.templates.toast.deleted"))},M=$=>{u($.id),h($.name),m($.description),y(JSON.stringify($.settings,null,2)),v(null)},P=()=>{if(!(!c||!d.trim()))try{const $=JSON.parse(x),D=i.map(H=>H.id===c?{...H,name:d.trim(),description:p.trim(),settings:$}:H);N(D),u(null),r(n("profiles.templates.toast.updated"))}catch($){v($.message)}},T=()=>{u(null),h(""),m(""),y("{}"),v(null)},j=$=>{const D=i.map(H=>H.id===$?{...H,showInModal:!H.showInModal}:H);N(D)},z={filament:{label:n("profiles.presets.types.filament"),icon:Ck,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:Qu,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Nr,color:"text-purple-400"}},F=S?i.find($=>$.id===S):null;return w.useEffect(()=>{const $=D=>{D.key==="Escape"&&(S?k(null):c?T():t())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[S,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(_t,{className:"w-full max-w-md",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:a.jsx(kn,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),a.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:F.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>k(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Me,{onClick:()=>A(S),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(en,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Jg,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map($=>a.jsx("button",{onClick:()=>l($),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===$?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:$==="all"?n("common.all"):z[$].label},$))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:E.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(Jg,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:n("profiles.templates.noTemplates")}),a.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):a.jsx("div",{className:"space-y-2",children:E.map($=>{const D=z[$.type],H=D.icon;return c===$.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:d,onChange:q=>h(q.target.value),placeholder:n("profiles.templates.namePlaceholder"),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}),a.jsx("input",{type:"text",value:p,onChange:q=>m(q.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),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"})]}),a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),a.jsx("textarea",{value:x,onChange:q=>{y(q.target.value),v(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 ${b?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),b&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:b})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:P,disabled:!d.trim(),children:[a.jsx(fs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:T,children:"Cancel"})]})]},$.id):a.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:[a.jsx(H,{className:`w-5 h-5 ${D.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:$.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:$.description})]}),a.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys($.settings).length})}),a.jsx("button",{onClick:()=>j($.id),className:`p-1 transition-colors ${$.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:$.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:$.showInModal?a.jsx(Yl,{className:"w-4 h-4"}):a.jsx(W0,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e($),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),a.jsx("button",{onClick:()=>M($),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx($i,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>k($.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(en,{className:"w-4 h-4"})})]},$.id)})})})]})})]})}function Nie({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=w.useState("changes"),[c,u]=w.useState(""),d=w.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),y=[];for(const b of x){if(b==="inherits"||b==="version")continue;const v=e[b],S=n[b],k=b in e,E=b in n;let N;!k&&E?N="added":k&&!E?N="removed":JSON.stringify(v)!==JSON.stringify(S)?N="changed":N="same",y.push({key:b,left:v,right:S,status:N})}return y.sort((b,v)=>{const S={changed:0,added:1,removed:2,same:3};return S[b.status]!==S[v.status]?S[b.status]-S[v.status]:b.key.localeCompare(v.key)})},[e,n]),h=w.useMemo(()=>{let x=[...d];if(o==="changes"&&(x=x.filter(y=>y.status!=="same")),c){const y=c.toLowerCase();x=x.filter(b=>b.key.toLowerCase().includes(y)||String(b.left).toLowerCase().includes(y)||String(b.right).toLowerCase().includes(y))}return x},[d,o,c]),p=w.useMemo(()=>({added:d.filter(x=>x.status==="added").length,removed:d.filter(x=>x.status==="removed").length,changed:d.filter(x=>x.status==="changed").length,same:d.filter(x=>x.status==="same").length}),[d]),m=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const y=String(x);if(y.includes("\\n")||y.length>100){const b=y.split("\\n").length;if(b>1)return`[${b} lines of G-code/script]`;if(y.length>100)return y.substring(0,100)+"…"}return y};return w.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Rg,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.left")}),a.jsx("p",{className:"text-white font-medium truncate",children:r})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.right")}),a.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(nr,{className:"w-3.5 h-3.5"}),p.added," ",s("profiles.diff.added")]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(HP,{className:"w-3.5 h-3.5"}),p.removed," ",s("profiles.diff.removed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(OP,{className:"w-3.5 h-3.5"}),p.changed," ",s("profiles.diff.changed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(SE,{className:"w-3.5 h-3.5"}),p.same," ",s("profiles.diff.same")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:s("profiles.diff.searchFields"),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"})]}),p.same>0&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("profiles.diff.changes")}),a.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("common.all")})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(SE,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:a.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left p-3 w-1/3",children:s("profiles.diff.field")}),a.jsx("th",{className:"text-left p-3 w-1/3",children:r}),a.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),a.jsx("tbody",{children:h.map(x=>{const y={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],b={added:a.jsx(nr,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(HP,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(OP,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(SE,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${y}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[b,a.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(x.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(x.right)})})]},x.key)})})]})})]})})})}function ZXe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=hn(),s=Zt(),o=!!e?.setting_id,[l,c]=w.useState("common"),[u,d]=w.useState(e?.type||"filament"),[h,p]=w.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[m,x]=w.useState(e?.base_id||""),[y,b]=w.useState(""),[v,S]=w.useState(e?.setting||{inherits:""}),[k,E]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[N,A]=w.useState(null),[M,P]=w.useState(""),[T,j]=w.useState(!1),[z,F]=w.useState(""),[$,D]=w.useState(!1),[H,q]=w.useState(_ie),[I,K]=w.useState(!1),[Z,se]=w.useState(""),[V,W]=w.useState(""),[ie,J]=w.useState(!0),[pe,fe]=w.useState(null),[ve,Le]=w.useState(!1),de=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),ce=w.useMemo(()=>de.filter(we=>V0(we.setting_id)),[de]),{data:Ae}=et({queryKey:["cloudFields",u],queryFn:()=>ae.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:re}=et({queryKey:["allPresetDetails",u,ce.map(we=>we.setting_id).join(",")],queryFn:async()=>{const we={};for(let Pe=0;Pe<ce.length;Pe+=5){const Ve=ce.slice(Pe,Pe+5);(await Promise.all(Ve.map(async Ze=>{try{const je=await ae.getCloudSettingDetail(Ze.setting_id);return{id:Ze.setting_id,detail:je}}catch{return null}}))).forEach(Ze=>{Ze&&(we[Ze.id]=Ze.detail)})}return we},enabled:ce.length>0,staleTime:1e3*60*10}),{data:Ie,isLoading:G}=et({queryKey:["cloudSettingDetail",m],queryFn:()=>ae.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{l!=="json"&&E(JSON.stringify(v,null,2))},[v,l]);const Y=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(Ue=>!V0(Ue.setting_id)).sort((Ue,Pe)=>Ue.name.localeCompare(Pe.name)),[n,u]);w.useEffect(()=>{if(!m)return;const we=Y.find(Ue=>Ue.setting_id===m);we&&(b(we.name),o||(S({inherits:we.name}),E(JSON.stringify({inherits:we.name},null,2))))},[m,Y,o]);const ue=w.useMemo(()=>{const we=Ae?.fields||[],Ue=new Set(we.map(Ze=>Ze.key)),Pe=new Set,Ve=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);re&&Object.values(re).forEach(Ze=>{Ze?.setting&&Object.keys(Ze.setting).forEach(je=>{!Ue.has(je)&&!Ve.has(je)&&Pe.add(je)})}),Object.keys(v).forEach(Ze=>{!Ue.has(Ze)&&!Ve.has(Ze)&&Pe.add(Ze)});const ke=Array.from(Pe).sort().map(Ze=>({key:Ze,label:Ze.replace(/_/g," ").replace(/\b\w/g,je=>je.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...we,...ke]},[Ae,re,v,r]),B=ue.filter(we=>we.label.toLowerCase().includes(M.toLowerCase())||we.key.toLowerCase().includes(M.toLowerCase())),ee=()=>{if(z.trim()){const we=z.trim().toLowerCase().replace(/\s+/g,"_");Q(we,""),F(""),D(!1),i(r("profiles.presets.toast.fieldAdded",{key:we}))}},Q=(we,Ue)=>{S(Pe=>{const Ve={...Pe};return Ue===""||Ue===void 0?delete Ve[we]:Ve[we]=Ue,Ve})},le=we=>{S(Ue=>({...Ue,...we.settings})),fe(we.name),i(r("profiles.templates.toast.applied"))},he=()=>{if(!Z.trim())return;const we={...v};if(delete we.inherits,Object.keys(we).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const Ue={id:Date.now().toString(),name:Z.trim(),description:V.trim()||r("profiles.presets.customTemplate"),type:u,settings:we,showInModal:ie},Pe=[...H,Ue];q(Pe),Sie(Pe),K(!1),se(""),W(""),J(!0),i(r("profiles.templates.toast.created"))},te=w.useMemo(()=>H.filter(we=>we.type===u&&we.showInModal),[u,H]),U=we=>{E(we);try{const Ue=JSON.parse(we);S(Ue),A(null)}catch(Ue){A(Ue.message)}},L=we=>{we.preventDefault(),j(!1);const Ue=we.dataTransfer.files[0];if(Ue&&Ue.name.endsWith(".json")){const Pe=new FileReader;Pe.onload=Ve=>{try{const ke=Ve.target?.result,Ze=JSON.parse(ke),je=Ze.setting||Ze;S(Xe=>({...Xe,...je})),E(JSON.stringify({...v,...je},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},Pe.readAsText(Ue)}},X=st({mutationFn:()=>{const we={...v},Ue=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";we[Ue]=`"${h}"`;const Pe={type:u,name:h,base_id:m,setting:we};return ae.createCloudSetting(Pe)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:we=>i(we.message,"error")}),ge=st({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return ae.updateCloudSetting(e.setting_id,{name:h,setting:v})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:we=>i(we.message,"error")}),_e=o?ge:X,Ee=Ie?.setting?.inherits,$e=Ee?Y.find(we=>we.name===Ee):void 0,{data:Ce}=et({queryKey:["cloudSettingDetail",$e?.setting_id],queryFn:()=>ae.getCloudSettingDetail($e.setting_id),enabled:!!$e?.setting_id}),He=w.useMemo(()=>{const we=Ce?.setting||{},Ue=Ie?.setting||{},Pe=m&&re?.[m]?.setting?re[m].setting:{};return{...we,...Ue,...Pe}},[m,Ie,Ce,re]),Qe=we=>{if(we==null)return"";if(Array.isArray(we)){const Ue=[...new Set(we.map(Pe=>String(Pe)))];return Ue.length===1?Ue[0]:we.join(", ")}return String(we)},xe=we=>{const Ue=v[we.key],Pe=He[we.key],Ve=Qe(Pe),ke=G?r("common.loading"):Ve||"",Ze="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(we.type==="boolean"){const je=Ue==="1"||Ue===void 0&&Pe==="1";return a.jsx("button",{type:"button",onClick:()=>Q(we.key,Ue==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${je?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${je?"translate-x-3.5":"translate-x-0.5"}`})})}return we.type==="select"?a.jsxs("select",{value:Ue||"",onChange:je=>Q(we.key,je.target.value),className:Ze,children:[a.jsx("option",{value:"",children:ke}),we.options?.map(je=>a.jsx("option",{value:je.value,children:je.label},je.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:we.type==="number"?"number":"text",value:Ue!==void 0?String(Ue):"",onChange:je=>Q(we.key,je.target.value),step:we.step,min:we.min,max:we.max,placeholder:ke,className:Ze}),we.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:we.unit})]})},ye=w.useMemo(()=>Ie?.setting?Ie.setting:{},[Ie]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:we=>{we.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:L,children:[ve&&m&&a.jsx(Nie,{onClose:()=>Le(!1),leftPreset:ye,rightPreset:v,leftLabel:r("profiles.presets.baseLabel",{name:y||m}),rightLabel:r("profiles.presets.currentLabel",{name:h||r("profiles.presets.newPreset")}),t:r}),a.jsx(_t,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[m&&a.jsxs("button",{onClick:()=>Le(!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:r("profiles.presets.compareWithBase"),children:[a.jsx(Rg,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),a.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]})]}),T&&a.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:a.jsxs("div",{className:"text-center",children:[a.jsx(ia,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),a.jsxs("select",{value:u,onChange:we=>{d(we.target.value),x("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),a.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),a.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),a.jsxs("select",{value:m,onChange:we=>x(we.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:[a.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),Y.map(we=>a.jsx("option",{value:we.setting_id,children:we.name},we.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),a.jsx("input",{type:"text",value:h,onChange:we=>p(we.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:r("profiles.presets.myCustomPreset")})]})]}),y&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Kr,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:y}),G&&a.jsx(it,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(fB,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),a.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(jk,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),a.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(ZW,{className:"w-4 h-4"}),"JSON",N&&a.jsx(Ui,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("button",{onClick:()=>{const we={name:h,type:u,base_id:m,setting:v},Ue=new Blob([JSON.stringify(we,null,2)],{type:"application/json"}),Pe=URL.createObjectURL(Ue),Ve=document.createElement("a");Ve.href=Pe,Ve.download=`${h||"preset"}.json`,document.body.appendChild(Ve),Ve.click(),document.body.removeChild(Ve),URL.revokeObjectURL(Pe),i(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[a.jsx(hi,{className:"w-4 h-4"}),r("common.download")]}),a.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:r("profiles.presets.importFromJson"),children:[a.jsx(ia,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:we=>{const Ue=we.target.files?.[0];if(Ue){const Pe=new FileReader;Pe.onload=Ve=>{try{const ke=JSON.parse(Ve.target?.result),Ze=ke.setting||ke;S(je=>({...je,...Ze})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},Pe.readAsText(Ue)}}})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[l==="common"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(Jg,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(v).filter(we=>we!=="inherits").length>0&&a.jsxs("button",{onClick:()=>K(!I),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(fs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),I&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Z,onChange:we=>se(we.target.value),placeholder:r("profiles.templates.namePlaceholder"),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}),a.jsx("input",{type:"text",value:V,onChange:we=>W(we.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),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"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:he,disabled:!Z.trim(),children:[a.jsx(fs,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>K(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>J(!ie),className:`flex items-center gap-1.5 text-xs transition-colors ${ie?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[ie?a.jsx(Yl,{className:"w-3.5 h-3.5"}):a.jsx(W0,{className:"w-3.5 h-3.5"}),r(ie?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),pe&&a.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:[a.jsx(Kr,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",a.jsx("span",{className:"font-medium",children:pe})]}),a.jsx("button",{onClick:()=>fe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[te.map(we=>a.jsxs("button",{onClick:()=>le(we),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:we.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:we.description})]},we.id)),te.length===0&&a.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:ue.slice(0,10).map(we=>a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:we.label}),a.jsx("div",{className:"w-48",children:xe(we)})]},we.key))})]}),Object.keys(v).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([we])=>we!=="inherits").map(([we,Ue])=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[we,": ",String(Ue).slice(0,20),a.jsx("button",{onClick:()=>Q(we,void 0),className:"hover:text-white",children:a.jsx(Rt,{className:"w-3 h-3"})})]},we))})]})]}),l==="fields"&&a.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:re?r("profiles.templates.fieldsCount",{count:ue.length}):r("common.loading")})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:M,onChange:we=>P(we.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),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"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[B.filter(we=>!(we.key in v)).map(we=>{const Ue=He[we.key],Pe=Qe(Ue);return a.jsxs("div",{onClick:()=>{S(Ve=>({...Ve,[we.key]:Pe||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white truncate",children:we.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:we.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Pe&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Pe,children:[Pe.slice(0,20),Pe.length>20?"...":""]}),a.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:a.jsx(nr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},we.key)}),B.filter(we=>!(we.key in v)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(M?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:$?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:z,onChange:we=>F(we.target.value),onKeyDown:we=>we.key==="Enter"&&ee(),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}),a.jsx(Me,{size:"sm",onClick:ee,disabled:!z.trim(),children:a.jsx(nr,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{D(!1),F("")},children:a.jsx(Rt,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>D(!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:[a.jsx(nr,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(v).filter(we=>we!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([we])=>we!=="inherits").map(([we,Ue])=>{const Pe=ue.find(Ve=>Ve.key===we);return a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:Pe?.label||we}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:we})]}),a.jsx("button",{onClick:()=>Q(we,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),Pe?xe(Pe):a.jsx("input",{type:"text",value:String(Ue),onChange:Ve=>Q(we,Ve.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"})]},we)}),Object.keys(v).filter(we=>we!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(fB,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),a.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(v).filter(we=>we!=="inherits").length>0&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsxs("button",{onClick:()=>{K(!0),c("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:[a.jsx(fs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&a.jsxs("div",{className:"space-y-2",children:[N&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Ui,{className:"w-4 h-4"}),N]}),a.jsx("textarea",{value:k,onChange:we=>U(we.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${N?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Me,{onClick:()=>_e.mutate(),disabled:_e.isPending||!h.trim()||!o&&!m||!!N,className:"flex-1",children:[_e.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):o?a.jsx(fs,{className:"w-4 h-4"}):a.jsx(nr,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function JXe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=w.useState(""),[u,d]=w.useState("all"),[h,p]=w.useState("all"),[m,x]=w.useState("all"),[y,b]=w.useState("all"),[v,S]=w.useState("all"),[k,E]=w.useState("all"),[N,A]=w.useState(null),[M,P]=w.useState(!1),[T,j]=w.useState(!1),[z,F]=w.useState(null),[$,D]=w.useState(null),[H,q]=w.useState(null),[I,K]=w.useState(!1),[Z,se]=w.useState([null,null]),[V,W]=w.useState(!1),[ie,J]=w.useState(null),pe=Zt(),fe=w.useMemo(()=>[...t.filament.map(ee=>({...ee,type:"filament"})),...t.printer.map(ee=>({...ee,type:"printer"})),...t.process.map(ee=>({...ee,type:"process"}))].map(ee=>({...ee,meta:$F(ee.name)})),[t]),ve=w.useMemo(()=>{const B=new Set,ee=new Set,Q=new Set;return fe.forEach(le=>{le.meta.nozzle&&B.add(le.meta.nozzle),le.meta.filamentType&&ee.add(le.meta.filamentType),le.meta.layerHeight&&Q.add(le.meta.layerHeight)}),{printers:i.map(le=>({id:le.id.toString(),name:le.name})),nozzles:Array.from(B).sort((le,he)=>parseFloat(le)-parseFloat(he)),filaments:Array.from(ee).sort(),layerHeights:Array.from(Q).sort((le,he)=>parseFloat(le)-parseFloat(he))}},[fe,i]),Le=w.useMemo(()=>m==="all"?null:i.find(ee=>ee.id.toString()===m)?.model||null,[m,i]),de=w.useMemo(()=>fe.filter(B=>u==="all"||B.type===u).filter(B=>{if(h==="all")return!0;const ee=V0(B.setting_id);return h==="custom"?ee:!ee}).filter(B=>{if(m==="all"||!Le)return!0;const ee=B.meta.printer?.toLowerCase()||"",Q=Le.toLowerCase();return ee.includes(Q)||Q.includes(ee)}).filter(B=>y==="all"||B.meta.nozzle===y).filter(B=>v==="all"||B.meta.filamentType===v).filter(B=>k==="all"||B.meta.layerHeight===k).filter(B=>l===""||B.name.toLowerCase().includes(l.toLowerCase())).sort((B,ee)=>B.name.localeCompare(ee.name)),[fe,u,h,m,Le,y,v,k,l]),ce=B=>{if(I){const ee=Z[0]?.setting_id===B.setting_id,Q=Z[1]?.setting_id===B.setting_id;if(ee)se([Z[1],null]);else if(Q)se([Z[0],null]);else if(!Z[0])se([B,null]);else if(Z[1]){if(Z[0].type!==B.type)return;se([Z[0],B])}else{if(Z[0].type!==B.type)return;se([Z[0],B])}}else A(B)},Ae=B=>{if(Z[0]?.setting_id===B.setting_id)return 0;if(Z[1]?.setting_id===B.setting_id)return 1},re=async B=>{try{const ee=await ae.getCloudSettingDetail(B.setting_id),Q=B.type==="process"?"print":B.type;F({type:Q,name:B.name,base_id:ee.base_id||"GFSA00",setting:ee.setting||{}}),A(null)}catch(ee){console.error("Failed to fetch preset details for duplication:",ee)}},Ie=async B=>{try{pe.removeQueries({queryKey:["cloudSettingDetail",B.setting_id]});const ee=await ae.getCloudSettingDetail(B.setting_id),Q=B.type==="process"?"print":B.type;D({type:Q,name:B.name,base_id:ee.base_id||"GFSA00",setting:ee.setting||{},setting_id:B.setting_id}),A(null)}catch(ee){console.error("Failed to fetch preset details for editing:",ee)}},G=()=>{d("all"),p("all"),x("all"),b("all"),S("all"),E("all"),c("")},Y=u!=="all"||h!=="all"||m!=="all"||y!=="all"||v!=="all"||k!=="all"||l!=="",ue=t.filament.length+t.printer.length+t.process.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:l,onChange:B=>c(B.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),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"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:I?"primary":"secondary",onClick:()=>{I?(K(!1),se([null,null])):K(!0)},children:[a.jsx(Rg,{className:"w-4 h-4"}),o(I?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>j(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(Jg,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Me,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(Ir,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Me,{onClick:()=>P(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(nr,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(Ak,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(gg,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:ue},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:B=>d(B)}),a.jsx(gg,{label:o("profiles.cloudView.filters.owner"),value:h,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:B=>p(B)}),ve.printers.length>0&&a.jsx(gg,{label:o("profiles.cloudView.filters.printer"),value:m,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ve.printers.map(B=>({value:B.id,label:B.name}))],onChange:x}),ve.nozzles.length>0&&a.jsx(gg,{label:o("profiles.cloudView.filters.nozzle"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ve.nozzles.map(B=>({value:B,label:B}))],onChange:b}),ve.filaments.length>0&&(u==="all"||u==="filament")&&a.jsx(gg,{label:o("profiles.cloudView.filters.filament"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ve.filaments.map(B=>({value:B,label:B}))],onChange:S}),ve.layerHeights.length>0&&(u==="all"||u==="process")&&a.jsx(gg,{label:o("profiles.cloudView.filters.layer"),value:k,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ve.layerHeights.map(B=>({value:B,label:B}))],onChange:E}),Y&&a.jsx("button",{onClick:G,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),I&&a.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Rg,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),a.jsx("span",{className:"text-bambu-gray",children:Z[0]?o("profiles.cloudView.selectAnotherPreset",{type:Z[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Z[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Z[0]?Z[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(OP,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Z[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Z[1]?Z[1].name:o("profiles.cloudView.selectSecond")})]}),Z[0]&&Z[1]&&a.jsxs(Me,{size:"sm",onClick:async()=>{try{const[B,ee]=await Promise.all([ae.getCloudSettingDetail(Z[0].setting_id),ae.getCloudSettingDetail(Z[1].setting_id)]);J([B.setting||{},ee.setting||{}]),W(!0)}catch{}},children:[a.jsx(Rg,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",WXe(e.toISOString(),o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:de.length,total:ue})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),a.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),de.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(Ja,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),Y&&a.jsx("button",{onClick:G,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Ck,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(B=>B.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(B=>B.type==="filament").map(B=>a.jsx(mP,{setting:B,onClick:()=>ce(B),onDuplicate:()=>re(B),compareMode:I,isCompareSelected:Ae(B)!==void 0,compareIndex:Ae(B),compareDisabled:I&&!!Z[0]&&Z[0].type!==B.type,t:o},B.setting_id)),de.filter(B=>B.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Qu,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(B=>B.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(B=>B.type==="process").map(B=>a.jsx(mP,{setting:B,onClick:()=>ce(B),onDuplicate:()=>re(B),compareMode:I,isCompareSelected:Ae(B)!==void 0,compareIndex:Ae(B),compareDisabled:I&&!!Z[0]&&Z[0].type!==B.type,t:o},B.setting_id)),de.filter(B=>B.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Nr,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(B=>B.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(B=>B.type==="printer").map(B=>a.jsx(mP,{setting:B,onClick:()=>ce(B),onDuplicate:()=>re(B),compareMode:I,isCompareSelected:Ae(B)!==void 0,compareIndex:Ae(B),compareDisabled:I&&!!Z[0]&&Z[0].type!==B.type,t:o},B.setting_id)),de.filter(B=>B.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),N&&a.jsx(YXe,{setting:N,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>re(N),onEdit:()=>Ie(N),hasPermission:s,t:o}),(M||z||$||H)&&a.jsx(ZXe,{onClose:()=>{P(!1),F(null),D(null),q(null)},initialData:$||z||(H?{type:H.type,name:"",base_id:"",setting:H.setting}:void 0),allPresets:t,t:o}),T&&a.jsx(QXe,{onClose:()=>j(!1),onApply:B=>{q({type:B.type,setting:B.settings}),j(!1)},t:o}),V&&ie&&Z[0]&&Z[1]&&a.jsx(Nie,{onClose:()=>{W(!1),J(null)},leftPreset:ie[0],rightPreset:ie[1],leftLabel:Z[0].name,rightLabel:Z[1].name,t:o})]})}function eYe(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),{hasPermission:r}=Rr(),[i,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:u}=et({queryKey:["cloudStatus"],queryFn:ae.getCloudStatus}),{data:d=[]}=et({queryKey:["printers"],queryFn:ae.getPrinters}),{data:h,isLoading:p,refetch:m,dataUpdatedAt:x}=et({queryKey:["cloudSettings"],queryFn:()=>ae.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{x&&l(new Date(x))},[x]);const y=st({mutationFn:ae.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),b=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-6 lg:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.jsxs("button",{onClick:()=>s("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(jb,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),a.jsxs("button",{onClick:()=>s("local"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="local"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Pb,{className:"w-4 h-4"}),t("profiles.tabs.local")]}),a.jsxs("button",{onClick:()=>s("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Tk,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&a.jsxs(a.Fragment,{children:[c?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",a.jsx("span",{className:"text-white",children:c.email})]})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>y.mutate(),disabled:y.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx($P,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?p?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx(JXe,{settings:h,lastSyncTime:o,onRefresh:()=>m(),isRefreshing:p,printers:d,hasPermission:r,t}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),a.jsx(Me,{onClick:()=>m(),children:t("profiles.retry")})]}):a.jsx(KXe,{onSuccess:b,t})]}),i==="local"&&a.jsx(qXe,{}),i==="kprofiles"&&a.jsx($Xe,{}),a.jsx(XXe,{})]})}const Cy={Droplet:Ck,Flame:Mde,Ruler:ife,Sparkles:Jg,Square:pl,Cable:pue,Wrench:Mm,Calendar:ri,Timer:Du,Cog:Que,Fan:JW,Zap:Ih,Wind:cK,Thermometer:Fk,Layers:Ja,Box:Yi,Target:oK,RefreshCw:Ir,Settings:Ok,Filter:Ak,CircleDot:Oue};function Qy(t){return t&&Cy[t]||Mm}function bg(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const i=Math.round(t);return n?n("maintenance.days",{count:i}):`${i} days`}if(t<180){const i=Math.round(t/7);return i===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:i}):`${i} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const i=r/7;return i<12?`${i<2?i.toFixed(1):Math.round(i)}w`:`${Math.round(i/4)}mo`}}function pP(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function tYe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,h=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":s?"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":h?"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":s||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":h?"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":s?"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":h?"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":s||o||d||h?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":s||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 nYe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=Qy(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const m=t.days_since_maintenance??0;return Math.max(0,Math.min(100,m/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),u=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",d=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",h=()=>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",p=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const m=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:bg(Math.abs(m),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:bg(m,"days",i)}):i("maintenance.timeLeft",{duration:bg(m,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:bg(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:bg(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:bg(t.hours_until_due,"hours",i)})};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${h()}`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.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:[a.jsx(s,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&a.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`})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&a.jsx("span",{title:i("maintenance.timeBasedInterval"),children:a.jsx(ri,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const m=t.maintenance_type_wiki_url||tYe(t.maintenance_type_name,t.printer_model);return m?a.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:a.jsx(Wr,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&a.jsx(kn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(qn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Kr,{className:"w-3 h-3"}),p()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:a.jsx(Un,{checked:t.enabled,onChange:m=>n(t.id,m),disabled:!r("maintenance:update")})}),a.jsxs(Me,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[a.jsx(Po,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function rYe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:s}){const[o,l]=w.useState(!0),[c,u]=w.useState(!1),[d,h]=w.useState(t.total_print_hours.toFixed(1)),p=[...t.maintenance_items].sort((y,b)=>y.is_due&&!b.is_due?-1:!y.is_due&&b.is_due?1:y.is_warning&&!b.is_warning?-1:!y.is_warning&&b.is_warning?1:y.maintenance_type_id-b.maintenance_type_id),m=p.find(y=>y.enabled&&(y.is_due||y.is_warning)),x=()=>{const y=parseFloat(d);!isNaN(y)&&y>=0&&(r(t.printer_id,y),u(!1))};return a.jsxs(_t,{className:"overflow-hidden",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&a.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:[a.jsx(kn,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&a.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:[a.jsx(qn,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&a.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:[a.jsx(Kr,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),a.jsxs("button",{onClick:()=>l(!o),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:[o?a.jsx(Kl,{className:"w-4 h-4"}):a.jsx(tr,{className:"w-4 h-4"}),s(o?"common.collapse":"common.expand")]})]}),a.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:a.jsx(Du,{className:"w-4 h-4 text-bambu-gray"})}),c?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:d,onChange:y=>h(y.target.value),onKeyDown:y=>{y.key==="Enter"&&x(),y.key==="Escape"&&u(!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}),a.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),a.jsx(Me,{size:"sm",onClick:x,children:s("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:s("common.cancel")})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(h(Math.round(t.total_print_hours).toString()),u(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:s("maintenance.noPermissionEditHours"),children:[a.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),a.jsx(Sm,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),m&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${m.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const y=Qy(m.maintenance_type_icon);return a.jsx(y,{className:`w-4 h-4 ${m.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${m.is_due?"text-red-400":"text-amber-400"}`,children:m.maintenance_type_name}),a.jsx("div",{className:`text-xs ${m.is_due?"text-red-400/70":"text-amber-400/70"}`,children:m.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&a.jsx(Nt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:p.map(y=>a.jsx(nYe,{item:y,onPerform:e,onToggle:n,hasPermission:i,t:s},y.id))})})]})}function iYe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onAssignType:o,onRemoveItem:l,hasPermission:c,t:u}){const[d,h]=w.useState(null),[p,m]=w.useState(""),[x,y]=w.useState("hours"),[b,v]=w.useState(!1),[S,k]=w.useState(""),[E,N]=w.useState("100"),[A,M]=w.useState("hours"),[P,T]=w.useState("Wrench"),[j,z]=w.useState(""),[F,$]=w.useState(new Set),[D,H]=w.useState(null),q=w.useMemo(()=>t?t.map(Q=>({id:Q.printer_id,name:Q.printer_name})):[],[t]),I=Q=>t?t.filter(le=>le.maintenance_items.some(he=>he.maintenance_type_id===Q)).map(le=>({printerId:le.printer_id,printerName:le.printer_name,itemId:le.maintenance_items.find(he=>he.maintenance_type_id===Q)?.id})):[],K=Q=>{if(!t)return[];const le=new Set(I(Q).map(he=>he.printerId));return q.filter(he=>!le.has(he.id))},[Z,se]=w.useState(null),[V,W]=w.useState(""),[ie,J]=w.useState(""),[pe,fe]=w.useState("hours"),[ve,Le]=w.useState("Wrench"),[de,ce]=w.useState(""),Ae=Q=>{se(Q),W(Q.name),J(Q.default_interval_hours.toString()),fe(Q.interval_type||"hours"),Le(Q.icon||"Wrench"),ce(Q.wiki_url||"")},re=()=>{Z&&V.trim()&&parseFloat(ie)>0&&(i(Z.id,{name:V.trim(),default_interval_hours:parseFloat(ie),interval_type:pe,icon:ve,wiki_url:de.trim()||null}),se(null))},Ie=(Q,le,he)=>{const te=parseFloat(p);if(!isNaN(te)&&te>0){const U=Math.abs(te-le)<.01?null:te;n(Q,{custom_interval_hours:U,custom_interval_type:x!==he?x:null})}h(null)},G=Q=>{Q.preventDefault(),S.trim()&&parseFloat(E)>0&&F.size>0&&(r({name:S.trim(),default_interval_hours:parseFloat(E),interval_type:A,icon:P,wiki_url:j.trim()||null},Array.from(F)),k(""),N("100"),M("hours"),z(""),$(new Set),v(!1))},Y=Q=>{$(le=>{const he=new Set(le);return he.has(Q)?he.delete(Q):he.add(Q),he})},ue=t?.map(Q=>({printerId:Q.printer_id,printerName:Q.printer_name,items:Q.maintenance_items.sort((le,he)=>le.maintenance_type_id-he.maintenance_type_id)})).sort((Q,le)=>Q.printerName.localeCompare(le.printerName))||[],B=e.filter(Q=>Q.is_system),ee=e.filter(Q=>!Q.is_system);return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.maintenanceTypes")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.maintenanceTypesDescription")})]}),a.jsxs(Me,{onClick:()=>v(!b),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionEditTypes"),children:[a.jsx(nr,{className:"w-4 h-4"}),u("maintenance.addCustomType")]})]}),b&&a.jsx(_t,{className:"mb-6",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("form",{onSubmit:G,children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"lg:col-span-2",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("common.name")}),a.jsx("input",{type:"text",value:S,onChange:Q=>k(Q.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:u("maintenance.exampleName"),autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalType")}),a.jsxs("select",{value:A,onChange:Q=>{M(Q.target.value),Q.target.value==="days"?N("30"):N("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:[a.jsx("option",{value:"hours",children:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalValue",{type:A==="days"?u("maintenance.calendarDays").toLowerCase():u("common.hours")})}),a.jsx("input",{type:"number",value:E,onChange:Q=>N(Q.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"})]})]}),a.jsx("div",{className:"mt-4 flex items-end justify-between",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.icon")}),a.jsx("div",{className:"flex gap-1",children:Object.keys(Cy).map(Q=>{const le=Cy[Q];return a.jsx("button",{type:"button",onClick:()=>T(Q),className:`p-2 rounded-lg transition-colors ${P===Q?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(le,{className:"w-4 h-4"})},Q)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.documentationLink")}),a.jsx("input",{type:"url",value:j,onChange:Q=>z(Q.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/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.assignToPrinters")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(Q=>a.jsx("button",{type:"button",onClick:()=>Y(Q.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${F.has(Q.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:Q.name},Q.id))}),F.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:u("maintenance.selectAtLeastOnePrinter")})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:()=>{v(!1),$(new Set)},children:u("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!S.trim()||F.size===0,children:u("maintenance.addType")})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[B.map(Q=>{const le=Qy(Q.icon),he=Q.interval_type||"hours";return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:a.jsx(le,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-white truncate",children:Q.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[he==="days"?a.jsx(ri,{className:"w-3 h-3"}):a.jsx(Du,{className:"w-3 h-3"}),pP(Q.default_interval_hours,he,u)]})]})]})},Q.id)}),ee.map(Q=>{const le=Qy(Q.icon),he=Q.interval_type||"hours";if(Z?.id===Q.id)return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("input",{type:"text",value:V,onChange:ge=>W(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",placeholder:u("common.name"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:pe,onChange:ge=>fe(ge.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:[a.jsx("option",{value:"hours",children:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:ie,onChange:ge=>J(ge.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"})]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Cy).map(ge=>{const _e=Cy[ge];return a.jsx("button",{type:"button",onClick:()=>Le(ge),className:`p-1.5 rounded transition-colors ${ve===ge?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx(_e,{className:"w-3.5 h-3.5"})},ge)})}),a.jsx("input",{type:"url",value:de,onChange:ge=>ce(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",placeholder:u("maintenance.documentationLink")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{size:"sm",onClick:re,disabled:!V.trim(),children:u("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>se(null),children:u("common.cancel")})]})]})},Q.id);const U=I(Q.id),L=K(Q.id),X=D===Q.id;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:a.jsx(le,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-white truncate",children:Q.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:u("maintenance.custom")})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[he==="days"?a.jsx(ri,{className:"w-3 h-3"}):a.jsx(Du,{className:"w-3 h-3"}),pP(Q.default_interval_hours,he,u)]})]}),a.jsxs("button",{onClick:()=>H(X?null:Q.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${U.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:u("maintenance.printersAssignedClick",{count:U.length}),children:[a.jsx(Nr,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:U.length}),a.jsx(tr,{className:`w-3 h-3 transition-transform ${X?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>Ae(Q),disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:u("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${c("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Sm,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(u("maintenance.deleteTypeConfirm",{name:Q.name}))&&s(Q.id)},disabled:!c("maintenance:delete"),title:c("maintenance:delete")?void 0:u("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${c("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(en,{className:"w-4 h-4"})})]}),X&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:u("maintenance.assignedToPrinters")}),U.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:u("maintenance.noPrintersAssigned")}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:U.map(ge=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[ge.printerName,a.jsx("button",{onClick:()=>ge.itemId&&l(ge.itemId),disabled:!c("maintenance:delete"),title:c("maintenance:delete")?u("maintenance.removeFromPrinter"):u("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${c("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},ge.printerId))}),L.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:u("maintenance.addPrinterShort")}),L.map(ge=>a.jsxs("button",{onClick:()=>o(ge.id,Q.id),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${c("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",ge.name]},ge.id))]})]})]},Q.id)})]})]}),ue.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.intervalOverrides")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.intervalOverridesDescription")})]}),a.jsx("div",{className:"space-y-4",children:ue.map(Q=>a.jsx(_t,{children:a.jsxs(Nt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:Q.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:Q.items.map(le=>{const he=Qy(le.maintenance_type_icon),te=e.find(_e=>_e.id===le.maintenance_type_id),U=te?.default_interval_hours||le.interval_hours,L=te?.interval_type||"hours",X=le.interval_type||"hours",ge=d===le.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(he,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:le.maintenance_type_name}),ge?a.jsxs("div",{className:"flex items-center gap-1",children:[x==="days"?a.jsx(ri,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(Du,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:x,onChange:_e=>y(_e.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[a.jsx("option",{value:"hours",children:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:p,onChange:_e=>m(_e.target.value),onKeyDown:_e=>{_e.key==="Enter"&&Ie(le.id,U,L),_e.key==="Escape"&&h(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),a.jsx(Me,{size:"sm",onClick:()=>Ie(le.id,U,L),children:"OK"})]}):a.jsxs("button",{onClick:()=>{c("maintenance:update")&&(h(le.id),m(le.interval_hours.toString()),y(X))},disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:u("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${c("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[X==="days"?a.jsx(ri,{className:"w-3 h-3"}):a.jsx(Du,{className:"w-3 h-3"}),pP(le.interval_hours,X,u),a.jsx(Sm,{className:"w-3 h-3 text-bambu-gray"})]})]},le.id)})})]})},Q.printerId))})]}),ue.length===0&&a.jsx(_t,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx(qn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:u("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:u("maintenance.intervalOverridesDescription")})]})})]})}function aYe(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),{hasPermission:r}=Rr(),[i,s]=w.useState("status"),{data:o,isLoading:l}=et({queryKey:["maintenanceOverview"],queryFn:ae.getMaintenanceOverview}),{data:c}=et({queryKey:["maintenanceTypes"],queryFn:ae.getMaintenanceTypes}),u=st({mutationFn:({id:N,notes:A})=>ae.performMaintenance(N,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:N=>{n(N.message,"error")}}),d=st({mutationFn:({id:N,data:A})=>ae.updateMaintenanceItem(N,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:N=>{n(N.message,"error")}}),h=st({mutationFn:({id:N,data:A})=>ae.updateMaintenanceType(N,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:N=>{n(N.message,"error")}}),p=st({mutationFn:ae.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:N=>{n(N.message,"error")}}),m=st({mutationFn:({printerId:N,hours:A})=>ae.setPrinterHours(N,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:N=>{n(N.message,"error")}}),x=st({mutationFn:({printerId:N,typeId:A})=>ae.assignMaintenanceType(N,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:N=>{n(N.message,"error")}}),y=st({mutationFn:ae.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:N=>{n(N.message,"error")}}),b=N=>{u.mutate({id:N})},v=(N,A)=>{d.mutate({id:N,data:{enabled:A}})},S=(N,A)=>{m.mutate({printerId:N,hours:A})};if(l)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})});const k=o?.reduce((N,A)=>N+A.due_count,0)||0,E=o?.reduce((N,A)=>N+A.warning_count,0)||0;return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?a.jsxs(a.Fragment,{children:[k>0&&a.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:k})}),k>0&&E>0&&" · ",E>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:E})}),k===0&&E===0&&a.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>s("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),a.jsx("button",{onClick:()=>s("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),i==="status"?a.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((N,A)=>{const M=N.due_count*10+N.warning_count,P=A.due_count*10+A.warning_count;return M!==P?P-M:N.printer_name.localeCompare(A.printer_name)}).map(N=>a.jsx(rYe,{overview:N,onPerform:b,onToggle:v,onSetHours:S,hasPermission:r,t},N.printer_id)):a.jsx(_t,{children:a.jsxs(Nt,{className:"text-center py-16",children:[a.jsx(Mm,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):a.jsx(iYe,{overview:o,types:c||[],onUpdateInterval:(N,A)=>d.mutate({id:N,data:A}),onAddType:async(N,A)=>{const M=await ae.createMaintenanceType(N);for(const P of A)await ae.assignMaintenanceType(P,M.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(N,A)=>h.mutate({id:N,data:A}),onDeleteType:N=>p.mutate(N),onAssignType:(N,A)=>x.mutate({printerId:N,typeId:A}),onRemoveItem:N=>y.mutate(N),hasPermission:r,t})]})}const X9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function kie({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.description||""),[u,d]=w.useState(t?.color||X9[0]),[h,p]=w.useState(t?.target_count?.toString()||""),[m,x]=w.useState(t?.target_parts_count?.toString()||""),[y,b]=w.useState(t?.status||"active"),[v,S]=w.useState(t?.tags||""),[k,E]=w.useState(t?.due_date?.split("T")[0]||""),[N,A]=w.useState(t?.priority||"normal"),M=P=>{P.preventDefault(),n({name:s.trim(),description:l.trim()||void 0,color:u,target_count:h?parseInt(h,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:v.trim()||void 0,due_date:k||void 0,priority:N,...t&&{status:y}})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),a.jsxs("form",{onSubmit:M,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),a.jsx("input",{type:"text",value:s,onChange:P=>o(P.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:i("projects.namePlaceholder"),required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),a.jsx("textarea",{value:l,onChange:P=>c(P.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:i("projects.descriptionPlaceholder"),rows:2})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:X9.map(P=>a.jsx("button",{type:"button",onClick:()=>d(P),className:`w-8 h-8 rounded-full transition-transform ${u===P?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:P}},P))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),a.jsx("input",{type:"number",value:h,onChange:P=>p(P.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:i("projects.targetPlatesPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),a.jsx("input",{type:"number",value:m,onChange:P=>x(P.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:i("projects.targetPartsPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),a.jsx("input",{type:"text",value:v,onChange:P=>S(P.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:i("projects.tagsPlaceholder")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),a.jsx("input",{type:"date",value:k,onChange:P=>E(P.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),a.jsxs("select",{value:N,onChange:P=>A(P.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:[a.jsx("option",{value:"low",children:i("projects.priorityLow")}),a.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),a.jsx("option",{value:"high",children:i("projects.priorityHigh")}),a.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),a.jsxs("select",{value:y,onChange:P=>b(P.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:[a.jsx("option",{value:"active",children:i("projects.statusActive")}),a.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),a.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function sYe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:s}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",u=t.status==="archived",[d,h]=w.useState(!1),m=c?{icon:Zg,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:As,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:qn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:ps,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return a.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:[a.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`}}),a.jsxs("div",{className:"p-5 pl-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg ${m.bg} flex-shrink-0`,children:a.jsx(m.icon,{className:`w-5 h-5 ${m.color}`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.plates")]}):t.completed_count>0?a.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," ",s("projects.parts")]}):null,c&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),u&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),t.description&&a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const x=t.archives.map(S=>S.filament_type).filter(Boolean).flatMap(S=>S.split(",").map(k=>k.trim())).filter(Boolean),y=[...new Set(x)],b=t.archives.map(S=>S.filament_color).filter(Boolean).flatMap(S=>S.split(",").map(k=>k.trim())).filter(S=>S.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(S)),v=[...new Set(b)];return y.length===0&&v.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[y.slice(0,3).map(S=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:S},S)),v.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(S=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:S.startsWith("#")?S:`#${S}`},title:S},S)),v.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:x=>x.stopPropagation(),children:[a.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:()=>h(!d),children:a.jsx(_h,{className:"w-4 h-4"})}),d&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!1)}),a.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:[a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),h(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:s("projects.noEditPermission"),children:[a.jsx(Sm,{className:"w-4 h-4"}),s("common.edit")]}),a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),h(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:s("projects.noDeletePermission"),children:[a.jsx(en,{className:"w-4 h-4"}),s("common.delete")]})]})]})]})]}),a.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?a.jsxs("div",{className:"space-y-3",children:[t.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.plates")}),a.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.parts")}),a.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?a.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(As,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(kn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(x=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?a.jsx("img",{src:ae.getArchiveThumbnail(x.id),alt:x.print_name||"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:a.jsx(ta,{className:"w-6 h-6"})}),x.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(kn,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),a.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.printJobs"),children:[a.jsx(Ja,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[a.jsx(ta,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[a.jsx(kn,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:s("projects.inQueue"),children:[a.jsx(BP,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(La,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function oYe(){const{t}=Ut(),e=Uc(),n=Zt(),{showToast:r}=hn(),{hasPermission:i}=Rr(),[s,o]=w.useState(!1),[l,c]=w.useState(),[u,d]=w.useState("active"),[h,p]=w.useState(null),{data:m,isLoading:x}=et({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>ae.getProjects(u==="all"?void 0:u)}),y=st({mutationFn:$=>ae.createProject($),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:$=>{r($.message,"error")}}),b=st({mutationFn:({id:$,data:D})=>ae.updateProject($,D),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:$=>{r($.message,"error")}}),v=st({mutationFn:$=>ae.deleteProject($),onSuccess:()=>{p(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:$=>{p(null),r($.message,"error")}}),S=st({mutationFn:$=>ae.importProject($),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:$=>{r($.message,"error")}}),k=w.useRef(null),E=async()=>{try{const $=await ae.getProjects(),D=await Promise.all($.map(async K=>await ae.exportProjectJson(K.id))),H=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),q=URL.createObjectURL(H),I=document.createElement("a");I.href=q,I.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,I.click(),URL.revokeObjectURL(q),r(t("projects.toast.exported"),"success")}catch($){r($.message,"error")}},N=()=>{k.current?.click()},A=async $=>{const D=$.target.files?.[0];if(D){try{if(D.name.toLowerCase().endsWith(".zip"))await ae.importProjectFile(D),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const q=await D.text(),I=JSON.parse(q),K=Array.isArray(I)?I:[I];for(const Z of K)await S.mutateAsync(Z);K.length>1&&r(t("projects.toast.multipleImported",{count:K.length}),"success")}}catch(H){r(`${t("projects.toast.importFailed")}: ${H.message}`,"error")}$.target.value=""}},M=$=>{l?b.mutate({id:l.id,data:$}):y.mutate($)},P=$=>{c($),o(!0)},T=$=>{e(`/projects/${$.id}`)},j=$=>{p($)},z=()=>{h!==null&&v.mutate(h)},F=m?.reduce(($,D)=>($[D.status]=($[D.status]||0)+1,$.all=($.all||0)+1,$),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:k,type:"file",accept:".json,.zip",onChange:A,className:"hidden"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(ps,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:N,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(ia,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Me,{variant:"secondary",onClick:E,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(hi,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Me,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(nr,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:qn},{key:"completed",label:t("projects.statusCompleted"),icon:Zg},{key:"archived",label:t("projects.statusArchived"),icon:As},{key:"all",label:t("common.all"),icon:ps}].map(({key:$,label:D,icon:H})=>a.jsxs("button",{onClick:()=>d($),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===$?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx(H,{className:"w-4 h-4"}),a.jsx("span",{children:D}),F[$]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===$?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:F[$]})]},$))}),x?a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):m?.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(ps,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:u==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:u})}),u==="all"&&a.jsxs(Me,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(nr,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:m?.map($=>a.jsx(sYe,{project:$,onClick:()=>T($),onEdit:()=>P($),onDelete:()=>j($.id),hasPermission:i,t},$.id))}),h!==null&&a.jsx(On,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:z,onCancel:()=>p(null)}),s&&a.jsx(kie,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:M,isLoading:y.isPending||b.isPending,t})]})}function lYe(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 cYe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function uYe({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,i={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function Y9({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(_t,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",title:i,children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function dYe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(ta,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:e("projectDetail.noPrints")})]}):a.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(n=>a.jsxs(qs,{to:`/archives?search=${encodeURIComponent(n.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:[n.thumbnail_path?a.jsx("img",{src:ae.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(ta,{className:"w-8 h-8"})}),n.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(ua,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(mr,{className:"w-4 h-4 text-bambu-green"})}),a.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:a.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function hYe({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:i}=n[t]||n.normal;return a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&a.jsx(kn,{className:"w-3 h-3"}),i]})}function fYe(t){return t?eb(t,{year:"numeric",month:"short",day:"numeric"}):""}function gP(t,e){if(!t)return null;const n=Qi(t);if(!n)return null;const r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:i===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:i<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:i})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:i})}}function mYe(){const{id:t}=Nk(),e=Uc(),{t:n}=Ut(),r=Zt(),{showToast:i}=hn(),{hasPermission:s}=Rr(),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(""),p=parseInt(t||"0",10),{data:m,isLoading:x,error:y}=et({queryKey:["project",p],queryFn:()=>ae.getProject(p),enabled:p>0}),{data:b,isLoading:v}=et({queryKey:["project-archives",p],queryFn:()=>ae.getProjectArchives(p),enabled:p>0}),{data:S,isLoading:k}=et({queryKey:["project-bom",p],queryFn:()=>ae.getProjectBOM(p),enabled:p>0}),{data:E,isLoading:N}=et({queryKey:["project-timeline",p],queryFn:()=>ae.getProjectTimeline(p,20),enabled:p>0}),{data:A}=et({queryKey:["settings"],queryFn:ae.getSettings}),{data:M}=et({queryKey:["project-folders",p],queryFn:()=>ae.getLibraryFoldersByProject(p),enabled:p>0}),P=Mu(A?.currency||"USD"),T=A?.time_format||"system",j=st({mutationFn:Pe=>ae.updateProject(p,Pe),onSuccess:()=>{r.invalidateQueries({queryKey:["project",p]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:Pe=>{i(Pe.message,"error")}}),z=()=>{h(m?.notes||""),u(!0)},F=()=>{j.mutate({notes:d})},$=()=>{u(!1),h("")},[D,H]=w.useState(""),[q,I]=w.useState(1),[K,Z]=w.useState(""),[se,V]=w.useState(""),[W,ie]=w.useState(""),[J,pe]=w.useState(!1),[fe,ve]=w.useState(!1),[Le,de]=w.useState(null),[ce,Ae]=w.useState(""),[re,Ie]=w.useState(1),[G,Y]=w.useState(""),[ue,B]=w.useState(""),[ee,Q]=w.useState(""),[le,he]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),te=st({mutationFn:Pe=>ae.createBOMItem(p,Pe),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),H(""),I(1),Z(""),V(""),ie(""),pe(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:Pe=>i(Pe.message,"error")}),U=st({mutationFn:({itemId:Pe,data:Ve})=>ae.updateBOMItem(p,Pe,Ve),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),de(null)},onError:Pe=>i(Pe.message,"error")}),L=st({mutationFn:Pe=>ae.deleteBOMItem(p,Pe),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:Pe=>i(Pe.message,"error")}),X=Pe=>{Pe.preventDefault(),D.trim()&&te.mutate({name:D.trim(),quantity_needed:q,unit_price:K?parseFloat(K):void 0,sourcing_url:se.trim()||void 0,remarks:W.trim()||void 0})},ge=Pe=>{const Ve=Pe.is_complete?0:Pe.quantity_needed;U.mutate({itemId:Pe.id,data:{quantity_acquired:Ve}})},_e=(Pe,Ve)=>{he({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Ve}),onConfirm:()=>{he(ke=>({...ke,isOpen:!1})),L.mutate(Pe)}})},Ee=Pe=>{de(Pe),Ae(Pe.name),Ie(Pe.quantity_needed),Y(Pe.unit_price?.toString()||""),B(Pe.sourcing_url||""),Q(Pe.remarks||"")},$e=Pe=>{Pe.preventDefault(),!(!Le||!ce.trim())&&U.mutate({itemId:Le.id,data:{name:ce.trim(),quantity_needed:re,unit_price:G?parseFloat(G):void 0,sourcing_url:ue.trim()||void 0,remarks:ee.trim()||void 0}})},Ce=()=>{de(null)},He=async()=>{try{const{blob:Pe,filename:Ve}=await ae.exportProjectZip(Number(p)),ke=URL.createObjectURL(Pe),Ze=document.createElement("a");Ze.href=ke,Ze.download=Ve||`${m?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,Ze.click(),URL.revokeObjectURL(ke),i(n("projectDetail.toast.projectExported"),"success")}catch(Pe){i(Pe.message,"error")}},Qe=st({mutationFn:()=>ae.createTemplateFromProject(p),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:Pe=>i(Pe.message,"error")}),xe=Pe=>tb(Pe,T,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(y||!m)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:y?`${n("common.error")}: ${y.message}`:n("projectDetail.notFound")}),a.jsx(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const ye=m.stats,we=ye?.progress_percent??0,Ue=ye?.parts_progress_percent??0;return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(qs,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),a.jsx(La,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:m.name})]}),a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:a.jsx(Xce,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:m.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:m.name}),m.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:m.description})]})]}),a.jsx(uYe,{status:m.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:He,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(hi,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Me,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(Sm,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(m.target_count||m.target_parts_count)&&a.jsx(_t,{children:a.jsxs(Nt,{className:"p-4 space-y-4",children:[m.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.total_archives||0," / ",m.target_count," ",n("projectDetail.progress.printJobs")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(we,100)}%`,backgroundColor:we>=100?"#22c55e":m.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:we.toFixed(0)})}),ye?.remaining_prints!=null&&ye.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_prints})})]})]}),m.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.completed_prints||0," / ",m.target_parts_count," ",n("projectDetail.progress.parts")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ue,100)}%`,backgroundColor:Ue>=100?"#22c55e":m.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Ue.toFixed(0)})}),ye?.remaining_parts!=null&&ye.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_parts})})]})]})]})}),ye&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(_t,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(ta,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[ye.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),ye.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:ye.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:ye.completed_prints})})]})]})})}),a.jsx(Y9,{icon:qn,label:n("projectDetail.stats.printTime"),value:lYe(ye.total_print_time_hours),color:"text-yellow-400"}),a.jsx(Y9,{icon:Nr,label:n("projectDetail.stats.filamentUsed"),value:cYe(ye.total_filament_grams),color:"text-purple-400"})]}),ye&&(ye.estimated_cost>0||m.budget)&&a.jsx(_t,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[P,ye.estimated_cost.toFixed(2)]})]}),ye.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[ye.total_energy_kwh.toFixed(2)," kWh",ye.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",P,ye.total_energy_cost.toFixed(2),")"]})]})]}),m.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[P,m.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),a.jsxs("p",{className:`text-lg font-semibold ${m.budget-ye.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[P,(m.budget-ye.estimated_cost).toFixed(2)]})]})]})]})]})}),m.children&&m.children.length>0&&a.jsx(_t,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(Pde,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:m.children.length})]}),a.jsx("div",{className:"space-y-2",children:m.children.map(Pe=>a.jsxs(qs,{to:`/projects/${Pe.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Pe.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:Pe.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Pe.status==="completed"?"bg-status-ok/20 text-status-ok":Pe.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Pe.status})]}),Pe.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[Pe.progress_percent.toFixed(0),"%"]})]},Pe.id))})]})}),m.parent_id&&m.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Ja,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(qs,{to:`/projects/${m.parent_id}`,className:"text-bambu-green hover:underline",children:m.parent_name})]}),(m.tags||m.due_date||m.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[m.priority&&m.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),a.jsx(hYe,{priority:m.priority,t:n})]}),m.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ri,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:fYe(m.due_date)}),gP(m.due_date,n)&&a.jsxs("span",{className:`text-xs ${gP(m.due_date,n).color}`,children:["(",gP(m.due_date,n).label,")"]})]}),m.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Fh,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:m.tags.split(",").map((Pe,Ve)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Pe.trim()},Ve))})]})]}),a.jsx(_t,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ms,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:$,disabled:j.isPending,children:[a.jsx(Rt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Me,{size:"sm",onClick:F,disabled:j.isPending,children:[j.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(fs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:z,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(Sm,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(jR,{content:d,onChange:h,placeholder:n("projectDetail.notes.placeholder")}):m.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:m.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),a.jsx(_t,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ql,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(qs,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),M&&M.length>0?a.jsx("div",{className:"space-y-2",children:M.map(Pe=>a.jsxs(qs,{to:`/files?folder=${Pe.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx(Ql,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:Pe.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:Pe.file_count})})]})]}),a.jsx(La,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Pe.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(_t,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(aK,{className:"w-5 h-5"}),n("projectDetail.bom.title"),ye&&ye.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:ye.bom_completed_items,total:ye.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[S&&S.some(Pe=>Pe.is_complete)&&a.jsx("button",{onClick:()=>ve(!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:n(fe?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!J&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>pe(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(nr,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),J&&a.jsxs("form",{onSubmit:X,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:D,onChange:Pe=>H(Pe.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:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:q,onChange:Pe=>I(parseInt(Pe.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:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:K,onChange:Pe=>Z(Pe.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:n("projectDetail.bom.price",{currency:P})})]})]}),a.jsx("input",{type:"url",value:se,onChange:Pe=>V(Pe.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:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:W,onChange:Pe=>ie(Pe.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:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>pe(!1),children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!D.trim()||te.isPending,children:te.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),k?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?a.jsxs("div",{className:"space-y-2",children:[S.filter(Pe=>!fe||!Pe.is_complete).map(Pe=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${Pe.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:Le?.id===Pe.id?a.jsxs("form",{onSubmit:$e,className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:ce,onChange:Ve=>Ae(Ve.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:n("projectDetail.bom.partName"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:re,onChange:Ve=>Ie(parseInt(Ve.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:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:G,onChange:Ve=>Y(Ve.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:n("projectDetail.bom.price",{currency:P})})]})]}),a.jsx("input",{type:"url",value:ue,onChange:Ve=>B(Ve.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:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:ee,onChange:Ve=>Q(Ve.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:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:Ce,children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!ce.trim()||U.isPending,children:U.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>s("projects:update")&&ge(Pe),disabled:U.isPending||!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Pe.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:Pe.is_complete&&a.jsx(mr,{className:"w-3 h-3"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("p",{className:`text-sm font-medium ${Pe.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Pe.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Pe.quantity_needed]})]}),Pe.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[P,(Pe.unit_price*Pe.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&Ee(Pe),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:a.jsx($i,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&_e(Pe.id,Pe.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:a.jsx(en,{className:"w-4 h-4"})})]})]}),Pe.sourcing_url&&a.jsxs("a",{href:Pe.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:Ve=>Ve.stopPropagation(),children:[a.jsx(Wr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Pe.sourcing_url).hostname.replace("www.","")}catch{return Pe.sourcing_url}})()})]}),Pe.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Pe.remarks})]})]})},Pe.id)),S.some(Pe=>Pe.unit_price!==null)&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),a.jsxs("span",{className:"text-white font-medium",children:[P,S.reduce((Pe,Ve)=>Pe+(Ve.unit_price||0)*Ve.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(_t,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(n0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),N?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):E&&E.length>0?a.jsx("div",{className:"space-y-3",children:E.slice(0,10).map((Pe,Ve)=>a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Pe.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":Pe.event_type==="print_failed"?"bg-status-error/20 text-status-error":Pe.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Pe.event_type==="print_completed"&&a.jsx(mr,{className:"w-4 h-4"}),Pe.event_type==="print_failed"&&a.jsx(ua,{className:"w-4 h-4"}),Pe.event_type==="print_started"&&a.jsx(Nr,{className:"w-4 h-4"}),Pe.event_type==="queued"&&a.jsx(BP,{className:"w-4 h-4"}),Pe.event_type==="project_created"&&a.jsx(nr,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:Pe.title}),Pe.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Pe.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:xe(Pe.timestamp)})]})]},Ve))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!m.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Qe.mutate(),disabled:Qe.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[Qe.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Xl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),ye&&(ye.queued_prints>0||ye.in_progress_prints>0)&&a.jsx(_t,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(BP,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(qs,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[ye.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:ye.in_progress_prints})}),ye.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:ye.queued_prints})})]})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(ta,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:b?.length||0})]})}),v?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(dYe,{archives:b||[],t:n})]}),o&&a.jsx(kie,{t:n,project:{...m,archive_count:ye?.total_archives||0,total_items:ye?.total_items||0,completed_count:ye?.completed_prints||0,failed_count:ye?.failed_prints||0,queue_count:ye?.queued_prints||0,progress_percent:ye?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:Pe=>j.mutate(Pe),isLoading:j.isPending}),le.isOpen&&a.jsx(On,{title:le.title,message:le.message,confirmText:n("common.delete"),variant:"danger",onConfirm:le.onConfirm,onCancel:()=>he(Pe=>({...Pe,isOpen:!1}))})]})}function kg(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function pYe(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 gYe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(""),l=c=>{c.preventDefault(),n({name:s.trim(),parent_id:t})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),a.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),a.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function bYe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=w.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),a.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),a.jsx("input",{type:"text",value:o,onChange:u=>l(u.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?a.jsx(it,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function xYe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=w.useState(null),u=(h,p=0)=>{const m=[];for(const x of h)m.push({id:x.id,name:x.name,depth:p}),x.children.length>0&&m.push(...u(x.children,p+1));return m},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(t)];return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(h=>a.jsxs("button",{onClick:()=>c(h.id),disabled:h.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===h.id?"bg-bambu-green/20 text-bambu-green":h.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+h.depth*16}px`},children:[a.jsx(Ql,{className:"w-4 h-4"}),h.name,h.id===n&&a.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},h.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Me,{onClick:()=>i(l),disabled:s,children:s?a.jsx(it,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function yYe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[s,o]=w.useState("project"),[l,c]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&o("archive")});const{data:u}=et({queryKey:["projects"],queryFn:()=>ae.getProjects()}),{data:d}=et({queryKey:["archives-for-link"],queryFn:()=>ae.getArchives(void 0,void 0,100)}),h=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},p=()=>{n({project_id:0,archive_id:0})},m=t.project_id||t.archive_id;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Mh,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(XW,{className:"w-4 h-4"}),i("fileManager.project")]}),a.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(As,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?u&&u.length>0?u.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:x.name})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(am,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&a.jsxs(Me,{variant:"danger",onClick:p,disabled:r,children:[a.jsx(Ik,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[a.jsx(Me,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{onClick:h,disabled:!l||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function vYe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=w.useState([]),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(!0),[p,m]=w.useState(!1),[x,y]=w.useState(!0),b=w.useRef(null),v=H=>{H.preventDefault(),l(!0)},S=H=>{H.preventDefault(),l(!1)},k=H=>{H.preventDefault(),l(!1);const q=Array.from(H.dataTransfer.files);N(q)},E=H=>{H.target.files&&N(Array.from(H.target.files))},N=H=>{const q=H.map(I=>({file:I,status:"pending",isZip:I.name.toLowerCase().endsWith(".zip"),is3mf:I.name.toLowerCase().endsWith(".3mf")}));s(I=>[...I,...q])},A=H=>{s(q=>q.filter((I,K)=>K!==H))},M=i.some(H=>H.isZip&&H.status==="pending"),P=i.some(H=>H.file.name.toLowerCase().endsWith(".stl")&&H.status==="pending"),T=i.some(H=>H.is3mf&&H.status==="pending"),j=async()=>{if(i.length!==0){u(!0);for(let H=0;H<i.length;H++)if(i[H].status==="pending"){s(q=>q.map((I,K)=>K===H?{...I,status:"uploading"}:I));try{if(i[H].isZip){const q=await ae.extractZipFile(i[H].file,t,d,p,x);s(I=>I.map((K,Z)=>Z===H?{...K,status:q.errors.length>0&&q.extracted===0?"error":"success",extractedCount:q.extracted,error:q.errors.length>0?`${q.errors.length} files failed`:void 0}:K))}else await ae.uploadLibraryFile(i[H].file,t,x),s(q=>q.map((I,K)=>K===H?{...I,status:"success"}:I))}catch(q){s(I=>I.map((K,Z)=>Z===H?{...K,status:"error",error:q instanceof Error?q.message:"Upload failed"}:K))}}u(!1),n(),e()}},z=i.filter(H=>H.status==="pending").length,F=i.filter(H=>H.status==="success").length,$=i.filter(H=>H.status==="error").length,D=i.length>0&&z===0&&!c;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:v,onDragLeave:S,onDrop:k,onClick:()=>b.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[a.jsx(ia,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),a.jsx("input",{ref:b,type:"file",multiple:!0,className:"hidden",onChange:E}),M&&a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(As,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:d,onChange:H=>h(H.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:H=>m(H.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),T&&a.jsx("div",{className:"p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Nr,{className:"w-5 h-5 text-purple-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-purple-300 font-medium",children:r("fileManager.threemfDetected")}),a.jsx("p",{className:"text-xs text-purple-300/70 mt-1",children:r("fileManager.threemfExtractionInfo")})]})]})}),(P||M)&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Yu,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(M&&!P?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:H=>y(H.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map((H,q)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[H.isZip?a.jsx(As,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(Ek,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:H.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(H.file.size/1024/1024).toFixed(2)," MB",H.isZip&&H.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),H.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:H.extractedCount})]})]})]}),H.status==="pending"&&a.jsx("button",{onClick:()=>A(q),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray"})}),H.status==="uploading"&&a.jsx(it,{className:"w-4 h-4 text-bambu-green animate-spin"}),H.status==="success"&&a.jsx(mr,{className:"w-4 h-4 text-green-500"}),H.status==="error"&&a.jsx("span",{title:H.error,children:a.jsx(ua,{className:"w-4 h-4 text-red-500"})})]},q))}),D&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:F}),$>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:$})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:r(D?"common.close":"common.cancel")}),!D&&a.jsx(Me,{onClick:j,disabled:z===0||c,children:c?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(ia,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",z>0?`(${z})`:""]})})]})]})})}function Mie({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,h]=w.useState(!0),[p,m]=w.useState(!1),x=t.children.length>0,y=t.project_id||t.archive_id;return a.jsxs("div",{children:[a.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[x?a.jsx("button",{onClick:b=>{b.stopPropagation(),h(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(La,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(Ql,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),a.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),y&&a.jsxs("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[a.jsx(Mh,{className:"w-3 h-3"}),t.project_name?a.jsx(XW,{className:"w-3 h-3"}):a.jsx(As,{className:"w-3 h-3"})]}),t.file_count>0&&a.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!y&&a.jsx("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:a.jsx(Mh,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),a.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:b=>b.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>m(!p),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(_h,{className:"w-3.5 h-3.5 text-bambu-gray"})}),p&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[a.jsx($i,{className:"w-3.5 h-3.5"}),u("common.rename")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[a.jsx(Mh,{className:"w-3.5 h-3.5"}),u(y?"fileManager.changeLink":"fileManager.linkTo")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),m(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[a.jsx(en,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),x&&d&&a.jsx("div",{children:t.children.map(b=>a.jsx(Mie,{folder:b,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:u},b.id))})]})}function zR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function wYe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:u,onGenerateThumbnail:d,thumbnailVersion:h,hasPermission:p,canModify:m,authEnabled:x,t:y}){const[b,v]=w.useState(!1);return a.jsxs("div",{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[a.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?a.jsx("img",{src:`${ae.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(am,{className:"w-12 h-12 text-bambu-gray/30"}),a.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[a.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[a.jsx("span",{children:kg(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),pYe(t.print_time_seconds)]})]}),t.sliced_for_model&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(Nr,{className:"w-3 h-3"}),t.sliced_for_model]}),t.print_count>0&&a.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:y("fileManager.printedCount",{count:t.print_count})}),x&&t.created_by_username&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(Zu,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:S=>S.stopPropagation(),children:[a.jsx("button",{onClick:()=>v(!b),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(_h,{className:"w-4 h-4 text-bambu-gray"})}),b&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>v(!1)}),a.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&zR(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("printers:control")&&(l(t),v(!1))},disabled:!p("printers:control"),title:p("printers:control")?void 0:y("fileManager.noPermissionPrint"),children:[a.jsx(Nr,{className:"w-3.5 h-3.5"}),y("common.print")]}),o&&zR(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("queue:create")&&(o(t.id),v(!1))},disabled:!p("queue:create"),title:p("queue:create")?void 0:y("fileManager.noPermissionAddToQueue"),children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),y("fileManager.schedulePrint")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(c(t),v(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(Yi,{className:"w-3.5 h-3.5"}),"3D Preview"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(s(t.id),v(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:y("fileManager.noPermissionDownload"),children:[a.jsx(hi,{className:"w-3.5 h-3.5"}),y("common.download")]}),u&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","update",t.created_by_id)&&(u(t),v(!1))},disabled:!m("library","update",t.created_by_id),title:m("library","update",t.created_by_id)?void 0:y("fileManager.noPermissionRenameFile"),children:[a.jsx($i,{className:"w-3.5 h-3.5"}),y("common.rename")]}),d&&t.file_type==="stl"&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","update",t.created_by_id)&&(d(t),v(!1))},disabled:!m("library","update",t.created_by_id),title:m("library","update",t.created_by_id)?void 0:y("fileManager.noPermissionGenerateThumbnail"),children:[a.jsx(Yu,{className:"w-3.5 h-3.5"}),y("fileManager.generateThumbnail")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","delete",t.created_by_id)&&(i(t.id),v(!1))},disabled:!m("library","delete",t.created_by_id),title:m("library","delete",t.created_by_id)?void 0:y("fileManager.noPermissionDeleteFile"),children:[a.jsx(en,{className:"w-3.5 h-3.5"}),y("common.delete")]})]})]})]}),a.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function _Ye(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),{hasPermission:r,hasAnyPermission:i,canModify:s,authEnabled:o}=Rr(),[l]=YR(),c=l.get("folder"),u=c?parseInt(c,10):null,[d,h]=w.useState(u),[p,m]=w.useState([]),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[S,k]=w.useState(!1),[E,N]=w.useState(null),[A,M]=w.useState(null),[P,T]=w.useState(null),[j,z]=w.useState(null),[F,$]=w.useState(null),[D,H]=w.useState(null),[q,I]=w.useState({}),[K,Z]=w.useState(null),[se,V]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[W,ie]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[J,pe]=w.useState(()=>{const Fe=localStorage.getItem("library-sidebar-width");return Fe?parseInt(Fe,10):256}),[fe,ve]=w.useState(!1),Le=w.useRef(null);w.useEffect(()=>{if(!fe)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Fe=Qt=>{if(!Le.current)return;const tn=Le.current.parentElement?.getBoundingClientRect();if(!tn)return;const un=Qt.clientX-tn.left,dr=Math.min(500,Math.max(200,un));pe(dr)},gt=()=>{ve(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(J))};return document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",gt),()=>{document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",gt),document.body.style.userSelect="",document.body.style.cursor=""}},[fe,J]);const[de,ce]=w.useState(""),[Ae,re]=w.useState("all"),[Ie,G]=w.useState(""),[Y,ue]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[B,ee]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),Q=m4();w.useEffect(()=>{const Fe=l.get("folder");if(Fe){const gt=parseInt(Fe,10);h(gt)}},[l]);const{data:le}=et({queryKey:["settings"],queryFn:()=>ae.getSettings()}),{data:he,isLoading:te}=et({queryKey:["library-folders"],queryFn:()=>ae.getLibraryFolders()}),{data:U,isLoading:L}=et({queryKey:["library-files",d],queryFn:()=>ae.getLibraryFiles(d,d===null)}),{data:X}=et({queryKey:["library-stats"],queryFn:()=>ae.getLibraryStats()}),{data:ge}=et({queryKey:["users"],queryFn:()=>ae.getUsers()}),_e=w.useMemo(()=>{if(!U)return[];const Fe=new Set(U.map(gt=>gt.file_type));return Array.from(Fe).sort()},[U]),Ee=w.useMemo(()=>{if(!U)return[];let Fe=[...U];if(de.trim()){const gt=de.toLowerCase();Fe=Fe.filter(Qt=>Qt.filename.toLowerCase().includes(gt)||Qt.print_name&&Qt.print_name.toLowerCase().includes(gt))}if(Ae!=="all"&&(Fe=Fe.filter(gt=>gt.file_type===Ae)),Ie.trim()){const gt=Ie.toLowerCase();Fe=Fe.filter(Qt=>Qt.created_by_username&&Qt.created_by_username.toLowerCase().includes(gt))}return Fe.sort((gt,Qt)=>{let tn=0;switch(Y){case"name":tn=(gt.print_name||gt.filename).localeCompare(Qt.print_name||Qt.filename);break;case"date":tn=new Date(gt.created_at).getTime()-new Date(Qt.created_at).getTime();break;case"size":tn=gt.file_size-Qt.file_size;break;case"type":tn=gt.file_type.localeCompare(Qt.file_type);break;case"prints":tn=gt.print_count-Qt.print_count;break}return B==="asc"?tn:-tn}),Fe},[U,de,Ae,Ie,Y,B]),$e=w.useMemo(()=>{if(!X||!le)return!1;const Fe=(le.library_disk_warning_gb||5)*1024*1024*1024;return X.disk_free_bytes<Fe},[X,le]),Ce=st({mutationFn:Fe=>ae.createLibraryFolder(Fe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),y(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:Fe=>n(Fe.message,"error")}),He=st({mutationFn:Fe=>ae.deleteLibraryFolder(Fe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),d===A?.id&&h(null),M(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:Fe=>{M(null),n(Fe.message,"error")}}),Qe=st({mutationFn:Fe=>ae.deleteLibraryFile(Fe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),m(Fe=>Fe.filter(gt=>gt!==A?.id)),M(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:Fe=>{M(null),n(Fe.message,"error")}}),xe=st({mutationFn:Fe=>ae.bulkDeleteLibrary(Fe,[]),onSuccess:(Fe,gt)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:gt.length}),"success"),m([]),M(null)},onError:Fe=>{M(null),n(Fe.message,"error")}}),ye=st({mutationFn:({fileIds:Fe,folderId:gt})=>ae.moveLibraryFiles(Fe,gt),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),m([]),v(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:Fe=>n(Fe.message,"error")}),we=st({mutationFn:({id:Fe,data:gt})=>ae.updateLibraryFolder(Fe,gt),onSuccess:(Fe,gt)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),N(null);const Qt=gt.data.project_id===0&&gt.data.archive_id===0;n(t(Qt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:Fe=>n(Fe.message,"error")}),Ue=st({mutationFn:({id:Fe,filename:gt})=>ae.updateLibraryFile(Fe,{filename:gt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),H(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:Fe=>{H(null),n(Fe.message,"error")}}),Pe=st({mutationFn:({id:Fe,name:gt})=>ae.updateLibraryFolder(Fe,{name:gt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),H(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:Fe=>{H(null),n(Fe.message,"error")}}),Ve=st({mutationFn:()=>ae.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:Fe=>{if(e.invalidateQueries({queryKey:["library-files"]}),Fe.succeeded>0){const gt=Date.now(),Qt={};Fe.results.forEach(tn=>{tn.success&&(Qt[tn.file_id]=gt)}),I(tn=>({...tn,...Qt}))}Fe.succeeded>0&&Fe.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:Fe.succeeded}),"success"):Fe.succeeded>0&&Fe.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:Fe.succeeded,failed:Fe.failed}),"success"):Fe.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:Fe.results[0]?.error||"Unknown error"}),"error")},onError:Fe=>n(Fe.message,"error")}),ke=st({mutationFn:Fe=>ae.batchGenerateStlThumbnails({file_ids:[Fe]}),onSuccess:Fe=>{if(e.invalidateQueries({queryKey:["library-files"]}),Fe.succeeded>0){const gt=Fe.results[0]?.file_id;gt&&I(Qt=>({...Qt,[gt]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:Fe.results[0]?.error||"Unknown error"}),"error")},onError:Fe=>n(Fe.message,"error")}),Ze=w.useCallback(Fe=>{const gt=Fe.toLowerCase();return gt.endsWith(".gcode")||gt.includes(".gcode.")},[]),je=w.useMemo(()=>U?U.filter(Fe=>p.includes(Fe.id)&&Ze(Fe.filename)):[],[U,p,Ze]),Xe=w.useCallback(Fe=>{m(gt=>gt.includes(Fe)?gt.filter(Qt=>Qt!==Fe):[...gt,Fe])},[]),Re=w.useCallback(()=>{Ee.length>0&&m(Ee.map(Fe=>Fe.id))},[Ee]),Oe=w.useCallback(()=>{m([])},[]),Ne=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},Je=Fe=>{ae.downloadLibraryFile(Fe).catch(gt=>{console.error("Library file download failed:",gt)})},yt=()=>{A&&(A.type==="file"?Qe.mutate(A.id):A.type==="folder"?He.mutate(A.id):A.type==="bulk"&&xe.mutate(p))},Et=He.isPending||Qe.isPending||xe.isPending,an=Fe=>{V(Fe),localStorage.setItem("library-view-mode",Fe)},jt=te||L;return a.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Ql,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[a.jsx("button",{onClick:()=>an("grid"),className:`p-1.5 rounded transition-colors ${se==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(X0,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>an("list"),className:`p-1.5 rounded transition-colors ${se==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(jk,{className:"w-4 h-4"})})]}),a.jsxs(Me,{variant:"secondary",onClick:()=>Ve.mutate(),disabled:Ve.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[Ve.isPending?a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(Yu,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>y(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(Tde,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Me,{onClick:()=>k(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(ia,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),$e&&X&&le&&a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[a.jsx(kn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),a.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:kg(X.disk_free_bytes),total:kg(X.disk_total_bytes),threshold:le.library_disk_warning_gb})})]})]}),X&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Ek,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),a.jsx("span",{className:"text-white font-medium",children:X.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Ql,{className:"w-4 h-4 text-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),a.jsx("span",{className:"text-white font-medium",children:X.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Pb,{className:"w-4 h-4 text-amber-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),a.jsx("span",{className:"text-white font-medium",children:kg(X.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),a.jsx("span",{className:`font-medium ${$e?"text-amber-500":"text-white"}`,children:kg(X.disk_free_bytes)})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[a.jsx("div",{className:"lg:hidden",children:a.jsxs("select",{value:d??"",onChange:Fe=>h(Fe.target.value?parseInt(Fe.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),he&&(()=>{const Fe=(gt,Qt=0)=>{const tn=[];for(const un of gt)tn.push({id:un.id,name:un.name,fileCount:un.file_count,depth:Qt}),un.children.length>0&&tn.push(...Fe(un.children,Qt+1));return tn};return Fe(he).map(gt=>a.jsxs("option",{value:gt.id,children:["│ ".repeat(gt.depth),"📂 ",gt.name," ",gt.fileCount>0?`(${gt.fileCount})`:""]},gt.id))})()]})}),a.jsxs("div",{ref:Le,className:"hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${J}px`},children:[a.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${fe?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:Fe=>{Fe.preventDefault(),ve(!0)},onDoubleClick:()=>{pe(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${fe?"opacity-100":""}`,children:[a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),a.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),a.jsx("button",{onClick:()=>{const Fe=!W;ie(Fe),localStorage.setItem("library-wrap-folders",String(Fe))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${W?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(W?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${d===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>h(null),children:[a.jsx(am,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),he?.map(Fe=>a.jsx(Mie,{folder:Fe,selectedFolderId:d,onSelect:h,onDelete:gt=>M({type:"folder",id:gt}),onLink:N,onRename:gt=>H({type:"folder",id:gt.id,name:gt.name}),wrapNames:W,hasPermission:r,t},Fe.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[U&&U.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[a.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:de,onChange:Fe=>ce(Fe.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ak,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:Ae,onChange:Fe=>re(Fe.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"all",children:t("fileManager.allTypes")}),_e.map(Fe=>a.jsx("option",{value:Fe,children:Fe.toUpperCase()},Fe))]})]}),o&&a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:Ie,onChange:Fe=>G(Fe.target.value),list:"usernames-list",className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${Ie?"pr-7":""}`,style:Ie?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),Ie&&a.jsx("button",{onClick:()=>G(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:a.jsx(Rt,{className:"w-3 h-3"})}),a.jsx("datalist",{id:"usernames-list",children:ge?.map(Fe=>a.jsx("option",{value:Fe.username},Fe.id))})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:Y,onChange:Fe=>{const gt=Fe.target.value;ue(gt),localStorage.setItem("library-sort-field",gt)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:t("common.name")}),a.jsx("option",{value:"date",children:t("common.date")}),a.jsx("option",{value:"size",children:t("fileManager.size")}),a.jsx("option",{value:"type",children:t("common.type")}),a.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),a.jsx("button",{onClick:()=>ee(Fe=>{const gt=Fe==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",gt),gt}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(B==="asc"?"fileManager.ascending":"fileManager.descending"),children:B==="asc"?a.jsx(eue,{className:"w-4 h-4 text-white"}):a.jsx(qce,{className:"w-4 h-4 text-white"})})]}),(de||Ae!=="all"||Ie)&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:Ee.length,total:U.length})})]}),Ee.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[p.length===Ee.length&&p.length>0?a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Oe,children:[a.jsx(pl,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Re,children:[a.jsx(to,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),p.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:p.length})}),a.jsx("div",{className:"hidden sm:block flex-1"}),a.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[je.length===1&&a.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>z(je[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(jo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),je.length===1&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>$(je[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(qn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[a.jsx(Fhe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{p.length===1?M({type:"file",id:p[0]}):M({type:"bulk",id:0,count:p.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(en,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Oe,children:[a.jsx(Rt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),jt?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):U?.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(am,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(d!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(d!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),a.jsxs(Me,{onClick:()=>k(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(nr,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):Ee.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(zr,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),a.jsx(Me,{variant:"secondary",onClick:()=>{ce(""),re("all")},children:t("fileManager.clearFilters")})]}):se==="grid"?a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:Ee.map(Fe=>a.jsx(wYe,{file:Fe,isSelected:p.includes(Fe.id),isMobile:Q,t,onSelect:Xe,onDelete:gt=>M({type:"file",id:gt}),onDownload:Je,onAddToQueue:gt=>{const Qt=U?.find(tn=>tn.id===gt);Qt&&$(Qt)},onPrint:T,onPreview3d:Z,onRename:gt=>H({type:"file",id:gt.id,name:gt.filename}),onGenerateThumbnail:gt=>ke.mutate(gt.id),thumbnailVersion:q[Fe.id],hasPermission:r,canModify:s,authEnabled:o},Fe.id))})}):a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("div",{className:`hidden sm:grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[a.jsx("div",{className:"w-6"}),a.jsx("div",{children:t("common.name")}),o&&a.jsx("div",{children:t("fileManager.uploadedBy",{defaultValue:"Uploaded By"})}),a.jsx("div",{children:t("common.type")}),a.jsx("div",{children:t("fileManager.size")}),a.jsx("div",{children:t("fileManager.prints")}),a.jsx("div",{})]}),Ee.map(Fe=>a.jsxs("div",{className:`grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${p.includes(Fe.id)?"bg-bambu-green/10":""}`,onClick:()=>Xe(Fe.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${p.includes(Fe.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:p.includes(Fe.id)&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("div",{className:"relative group/thumb",children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:Fe.thumbnail_path?a.jsx("img",{src:`${ae.getLibraryFileThumbnailUrl(Fe.id)}${q[Fe.id]?`?v=${q[Fe.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(am,{className:"w-5 h-5 text-bambu-gray/50"})})}),Fe.thumbnail_path&&a.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:a.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:a.jsx("img",{src:`${ae.getLibraryFileThumbnailUrl(Fe.id)}${q[Fe.id]?`?v=${q[Fe.id]}`:""}`,alt:Fe.filename,className:"w-full h-full object-contain"})})})]}),a.jsx("div",{className:"min-w-0",children:a.jsx("div",{className:"text-sm text-white truncate",children:Fe.print_name||Fe.filename})})]}),o&&a.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:Fe.created_by_username?a.jsxs(a.Fragment,{children:[a.jsx(Zu,{className:"w-3 h-3"}),a.jsx("span",{className:"truncate",children:Fe.created_by_username})]}):"-"}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${Fe.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":Fe.file_type==="gcode"?"bg-blue-500/20 text-blue-400":Fe.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Fe.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:kg(Fe.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Fe.print_count>0?`${Fe.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:gt=>gt.stopPropagation(),children:[zR(Fe.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&T(Fe),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:a.jsx(Nr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{r("queue:create")&&$(Fe)},className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.schedulePrint"):t("fileManager.noPermissionAddToQueue"),disabled:!r("queue:create"),children:a.jsx(qn,{className:"w-4 h-4"})})]}),(Fe.file_type==="3mf"||Fe.file_type==="gcode"||Fe.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&Z(Fe),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:a.jsx(Yi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&Je(Fe.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:a.jsx(hi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",Fe.created_by_id)&&H({type:"file",id:Fe.id,name:Fe.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",Fe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Fe.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",Fe.created_by_id),children:a.jsx($i,{className:"w-4 h-4"})}),Fe.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",Fe.created_by_id)&&ke.mutate(Fe.id),className:`p-1.5 rounded transition-colors ${s("library","update",Fe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Fe.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:ke.isPending||!s("library","update",Fe.created_by_id),children:a.jsx(Yu,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",Fe.created_by_id)&&M({type:"file",id:Fe.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",Fe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",Fe.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",Fe.created_by_id),children:a.jsx(en,{className:"w-4 h-4"})})]})]},Fe.id))]})})]})]}),x&&a.jsx(gYe,{parentId:d,onClose:()=>y(!1),onSave:Fe=>Ce.mutate(Fe),isLoading:Ce.isPending,t}),b&&he&&a.jsx(xYe,{folders:he,selectedFiles:p,currentFolderId:d,onClose:()=>v(!1),onMove:Fe=>ye.mutate({fileIds:p,folderId:Fe}),isLoading:ye.isPending,t}),S&&a.jsx(vYe,{folderId:d,onClose:()=>k(!1),onUploadComplete:Ne,t}),E&&a.jsx(yYe,{folder:E,onClose:()=>N(null),onLink:Fe=>we.mutate({id:E.id,data:Fe}),isLoading:we.isPending,t}),A&&a.jsx(On,{title:A.type==="folder"?t("fileManager.deleteFolder"):A.type==="bulk"?t("fileManager.deleteFilesCount",{count:A.count}):t("fileManager.deleteFile"),message:A.type==="folder"?t("fileManager.deleteFolderConfirm"):A.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:A.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Et,loadingText:t("fileManager.deleting"),onConfirm:yt,onCancel:()=>M(null)}),P&&a.jsx(qu,{mode:"reprint",libraryFileId:P.id,archiveName:P.print_name||P.filename,onClose:()=>T(null),onSuccess:()=>{T(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),j&&a.jsx(qu,{mode:"reprint",libraryFileId:j.id,archiveName:j.print_name||j.filename,onClose:()=>z(null),onSuccess:()=>{z(null),m([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),F&&a.jsx(qu,{mode:"add-to-queue",libraryFileId:F.id,archiveName:F.print_name||F.filename,onClose:()=>$(null),onSuccess:()=>{$(null),m([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),K&&a.jsx(WO,{libraryFileId:K.id,title:K.print_name||K.filename,fileType:K.file_type,onClose:()=>Z(null)}),D&&a.jsx(bYe,{type:D.type,currentName:D.name,onClose:()=>H(null),onSave:Fe=>{D.type==="file"?Ue.mutate({id:D.id,filename:Fe}):Pe.mutate({id:D.id,name:Fe})},isLoading:Ue.isPending||Pe.isPending,t})]})}const bP=5,SYe=2e3,NYe=3e4,kYe=5e3;function MYe(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),{hasPermission:r}=Rr(),{printerId:i}=Nk(),s=parseInt(i||"0",10),[o,l]=w.useState("stream"),[c,u]=w.useState(!1),[d,h]=w.useState(!1),[p,m]=w.useState(!0),[x,y]=w.useState(Date.now()),[b,v]=w.useState(!1),[S,k]=w.useState(!1),[E,N]=w.useState(0),[A,M]=w.useState(!1),[P,T]=w.useState(0),[j,z]=w.useState(1),[F,$]=w.useState({x:0,y:0}),[D,H]=w.useState(!1),[q,I]=w.useState({x:0,y:0}),[K,Z]=w.useState(null),[se,V]=w.useState(null),W=w.useRef(null),ie=w.useRef(null),J=w.useRef(null),pe=w.useRef(null),fe=w.useRef(null),{data:ve}=et({queryKey:["printer",s],queryFn:()=>ae.getPrinter(s),enabled:s>0}),{data:Le}=et({queryKey:["printerStatus",s],queryFn:()=>ae.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),de=st({mutationFn:ye=>ae.setChamberLight(s,ye),onMutate:async ye=>{await e.cancelQueries({queryKey:["printerStatus",s]});const we=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],Ue=>({...Ue,chamber_light:ye})),{previousStatus:we}},onSuccess:(ye,we)=>{n(`Chamber light ${we?"on":"off"}`)},onError:(ye,we,Ue)=>{Ue?.previousStatus&&e.setQueryData(["printerStatus",s],Ue.previousStatus),n(ye.message||t("printers.toast.failedToControlChamberLight"),"error")}}),ce=(Le?.state==="RUNNING"||Le?.state==="PAUSE"||Le?.state==="PAUSED")&&(Le?.printable_objects_count??0)>=2;w.useEffect(()=>(ve&&(document.title=`${ve.name} - Camera`),()=>{document.title="Bambuddy"}),[ve]);const Ae=w.useRef(!1);w.useEffect(()=>{const ye=`/api/v1/printers/${s}/camera/stop`;Ae.current=!1;const we=()=>{if(s>0&&!Ae.current){Ae.current=!0;const Ve={},ke=Ju();ke&&(Ve.Authorization=`Bearer ${ke}`),fetch(ye,{method:"POST",keepalive:!0,headers:Ve}).catch(()=>{})}},Ue=()=>{we()};window.addEventListener("beforeunload",Ue);const Pe=W.current;return()=>{window.removeEventListener("beforeunload",Ue),Pe&&(Pe.src=""),we()}},[s]),w.useEffect(()=>{if(p&&!b){const we=setTimeout(()=>{m(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(we)}},[o,p,x,b]),w.useEffect(()=>{const ye=()=>{const we=!!document.fullscreenElement;k(we),z(1),$({x:0,y:0}),o==="stream"&&!b&&(W.current&&(W.current.src=""),setTimeout(()=>{m(!0),y(Date.now())},200))};return document.addEventListener("fullscreenchange",ye),()=>document.removeEventListener("fullscreenchange",ye)},[o,b]),w.useEffect(()=>{let ye;const we=()=>{clearTimeout(ye),ye=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",we),()=>{clearTimeout(ye),window.removeEventListener("resize",we)}},[]),w.useEffect(()=>()=>{J.current&&clearTimeout(J.current),pe.current&&clearInterval(pe.current),fe.current&&clearInterval(fe.current)},[]);const re=w.useCallback(()=>{if(E>=bP){M(!1),h(!0);return}const ye=Math.min(SYe*Math.pow(2,E),NYe);M(!0),T(Math.ceil(ye/1e3)),pe.current=setInterval(()=>{T(we=>we<=1?(pe.current&&clearInterval(pe.current),0):we-1)},1e3),J.current=setTimeout(()=>{N(we=>we+1),M(!1),m(!0),h(!1),W.current&&(W.current.src=""),y(Date.now())},ye)},[E]);w.useEffect(()=>{if(o!=="stream"||p||A||b){fe.current&&(clearInterval(fe.current),fe.current=null);return}return fe.current=setInterval(async()=>{try{const ye=await ae.getCameraStatus(s);(ye.stalled||!ye.active&&!d)&&(console.log(`Stream issue detected: stalled=${ye.stalled}, active=${ye.active}, reconnecting...`),fe.current&&(clearInterval(fe.current),fe.current=null),m(!1),re())}catch{}},kYe),()=>{fe.current&&(clearInterval(fe.current),fe.current=null)}},[o,p,d,A,b,s,re]);const Ie=()=>{m(!1),o==="stream"&&E<bP?re():h(!0)},G=()=>{if(m(!1),h(!1),N(0),M(!1),J.current&&clearTimeout(J.current),pe.current&&clearInterval(pe.current),W.current&&!localStorage.getItem("cameraWindowState")){const ye=W.current,we=ye.naturalWidth,Ue=ye.naturalHeight;if(we>0&&Ue>0){const ke=window.outerWidth-window.innerWidth,Ze=window.outerHeight-window.innerHeight,je=we+16+ke,Xe=Ue+45+16+Ze;try{window.resizeTo(je,Xe)}catch{}}}},Y=()=>{if(s>0){const ye={},we=Ju();we&&(ye.Authorization=`Bearer ${we}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:ye}).catch(()=>{})}},ue=ye=>{o===ye||b||(v(!0),m(!0),h(!1),N(0),M(!1),z(1),$({x:0,y:0}),J.current&&clearTimeout(J.current),pe.current&&clearInterval(pe.current),W.current&&(W.current.src=""),o==="stream"&&Y(),setTimeout(()=>{l(ye),y(Date.now()),v(!1)},100))},B=()=>{b||(v(!0),m(!0),h(!1),N(0),M(!1),J.current&&clearTimeout(J.current),pe.current&&clearInterval(pe.current),W.current&&(W.current.src=""),o==="stream"&&Y(),setTimeout(()=>{y(Date.now()),v(!1)},100))},ee=()=>{ie.current&&(document.fullscreenElement?document.exitFullscreen():ie.current.requestFullscreen())},Q=()=>{z(ye=>Math.min(ye+.5,4))},le=()=>{z(ye=>{const we=Math.max(ye-.5,1);return we===1&&$({x:0,y:0}),we})},he=ye=>{ye.preventDefault(),ye.deltaY<0?Q():le()},te=ye=>{j>1&&(ye.preventDefault(),H(!0),I({x:ye.clientX-F.x,y:ye.clientY-F.y}))},U=w.useCallback(()=>{if(!ie.current)return{x:300,y:200};const ye=ie.current.getBoundingClientRect(),we=ye.width*(j-1)/2,Ue=ye.height*(j-1)/2;return{x:Math.max(50,we),y:Math.max(50,Ue)}},[j]),L=ye=>{if(D&&j>1){const we=ye.clientX-q.x,Ue=ye.clientY-q.y,Pe=U();$({x:Math.max(-Pe.x,Math.min(Pe.x,we)),y:Math.max(-Pe.y,Math.min(Pe.y,Ue))})}},X=()=>{H(!1)},ge=ye=>{if(ye.length<2)return 0;const we=ye[0].clientX-ye[1].clientX,Ue=ye[0].clientY-ye[1].clientY;return Math.sqrt(we*we+Ue*Ue)},_e=ye=>ye.length<2?{x:ye[0].clientX,y:ye[0].clientY}:{x:(ye[0].clientX+ye[1].clientX)/2,y:(ye[0].clientY+ye[1].clientY)/2},Ee=ye=>{ye.touches.length===2?(ye.preventDefault(),Z(ge(ye.touches)),V(_e(ye.touches))):ye.touches.length===1&&j>1&&(ye.preventDefault(),H(!0),I({x:ye.touches[0].clientX-F.x,y:ye.touches[0].clientY-F.y}))},$e=ye=>{if(ye.touches.length===2&&K!==null){ye.preventDefault();const we=ge(ye.touches),Ue=we/K;z(Ve=>{const ke=Math.max(1,Math.min(4,Ve*Ue));return ke===1&&$({x:0,y:0}),ke}),Z(we);const Pe=_e(ye.touches);if(se){const Ve=U();$(ke=>({x:Math.max(-Ve.x,Math.min(Ve.x,ke.x+(Pe.x-se.x))),y:Math.max(-Ve.y,Math.min(Ve.y,ke.y+(Pe.y-se.y)))}))}V(Pe)}else if(ye.touches.length===1&&D&&j>1){ye.preventDefault();const we=ye.touches[0].clientX-q.x,Ue=ye.touches[0].clientY-q.y,Pe=U();$({x:Math.max(-Pe.x,Math.min(Pe.x,we)),y:Math.max(-Pe.y,Math.min(Pe.y,Ue))})}},Ce=ye=>{ye.touches.length<2&&(Z(null),V(null)),ye.touches.length===0&&H(!1)},He=()=>{z(1),$({x:0,y:0})},Qe=b?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${x}`:`/api/v1/printers/${s}/camera/snapshot?t=${x}`,xe=p||b||A;return s?a.jsxs("div",{ref:ie,className:"min-h-screen bg-black flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[a.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(Qg,{className:"w-4 h-4"}),ve?.name||`Printer ${s}`]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[a.jsx("button",{onClick:()=>ue("stream"),disabled:xe,className:`px-3 py-1 text-xs rounded transition-colors ${o==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),a.jsx("button",{onClick:()=>ue("snapshot"),disabled:xe,className:`px-3 py-1 text-xs rounded transition-colors ${o==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),a.jsx("button",{onClick:()=>de.mutate(!Le?.chamber_light),disabled:!Le?.connected||de.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${Le?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:r("printers:control")?t("camera.chamberLight"):t("printers.permission.noControl"),children:a.jsx(H4,{on:Le?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>u(!0),disabled:!ce||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${ce&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(ce?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:a.jsx(Yk,{className:"w-4 h-4 text-bambu-gray"})}),a.jsx("button",{onClick:B,disabled:xe,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(Ir,{className:`w-4 h-4 text-bambu-gray ${xe?"animate-spin":""}`})}),a.jsx("button",{onClick:ee,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(S?"camera.exitFullscreen":"camera.fullscreen"),children:S?a.jsx(rK,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(khe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:he,onMouseMove:L,onMouseUp:X,onMouseLeave:X,onTouchStart:Ee,onTouchMove:$e,onTouchEnd:Ce,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(p||b)&&!A&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(Ir,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t(o==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),A&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(km,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:P,attempt:E+1,max:bP})}),a.jsx("button",{onClick:B,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),d&&!A&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(kn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),a.jsx("button",{onClick:B,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),a.jsx("img",{ref:W,src:Qe,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${j}) translate(${F.x/j}px, ${F.y/j}px)`,cursor:j>1?D?"grabbing":"grab":"default"},onError:Qe?Ie:void 0,onLoad:Qe?G:void 0,onMouseDown:te,draggable:!1},x),a.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[a.jsx("button",{onClick:le,disabled:j<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(f4,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:He,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(j*100),"%"]}),a.jsx("button",{onClick:Q,disabled:j>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(h4,{className:"w-4 h-4 text-white"})})]})]})}),a.jsx(V4,{printerId:s,isOpen:c,onClose:()=>u(!1)})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function CYe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),s=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function EYe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function AYe(t,e){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const s=new Date(r);s.setHours(0,0,0,0);const o=r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return s.getTime()===i.getTime()?o:s.getTime()===i.getTime()+864e5?`${e("streamOverlay.tomorrow")} ${o}`:r.toLocaleDateString([],{weekday:"short"})+" "+o}function TYe(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function jYe(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};case"medium":default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function PYe(){const{printerId:t}=Nk(),[e]=YR(),{t:n}=Ut(),r=Zt(),i=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>CYe(e),[e]),c=jYe(l.size),{data:u}=et({queryKey:["printer",i],queryFn:()=>ae.getPrinter(i),enabled:i>0}),{data:d}=et({queryKey:["printerStatus",i],queryFn:()=>ae.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3});w.useEffect(()=>{if(!i)return;const b=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,v=new WebSocket(b);return v.onmessage=S=>{try{const k=JSON.parse(S.data);k.type==="printer_status"&&k.printer_id===i&&r.setQueryData(["printerStatus",i],k.status)}catch{}},v.onerror=()=>{},()=>{v.close()}},[i,r]),w.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const h=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const p=d.state==="RUNNING"||d.state==="PAUSE",m=d.progress||0,x=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${s}`;return a.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&a.jsx("img",{src:x,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:h},s),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:a.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:a.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&a.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[a.jsx(Nr,{className:`${c.icon} text-white/70`}),a.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&a.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:d.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&a.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:TYe(d,n)}),l.showProgress&&p&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[a.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),a.jsxs("span",{className:"text-white font-bold",children:[Math.round(m),"%"]})]}),a.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:a.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${m}%`}})})]}),p&&(l.showLayers||l.showEta)&&a.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&d.layer_num!=null&&d.total_layers!=null&&d.total_layers>0&&a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Ja,{className:c.icon}),a.jsxs("span",{className:c.text,children:[a.jsx("span",{className:"text-white",children:d.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Du,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:EYe(d.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(qn,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",AYe(d.remaining_time,n)]})]})]})]}),!p&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function DYe(){const{t}=Ut(),{id:e}=Nk(),{mode:n}=Gm(),{data:r,isLoading:i,error:s}=et({queryKey:["external-link",e],queryFn:()=>ae.getExternalLink(Number(e)),enabled:!!e});return i?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(kn,{className:"w-12 h-12"}),a.jsx("p",{children:t("common.linkNotFound")})]}):a.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const Q9={material:"",subtype:"",brand:"",color_name:"",rgba:"808080FF",label_weight:1e3,core_weight:250,weight_used:0,slicer_filament:"",note:""};function RYe(t){const e={};return t.slicer_filament||(e.slicer_filament="Slicer preset is required"),t.material||(e.material="Material is required"),{isValid:Object.keys(e).length===0,errors:e}}const LYe=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],OYe=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],UR=["Basic","Matte","Silk","Tough","HF","High Flow","Engineering","Galaxy","Glow","Marble","Metal","Rainbow","Sparkle","Wood","Translucent","Transparent","Clear","Lite","Pro","Plus","Max","Super","Ultra","Flex","Soft","Hard","Strong","Impact","Heat Resistant","UV Resistant","ESD","Conductive","Magnetic","Gradient","Dual Color","Tri Color","Multicolor"],Cie=[{name:"Black",hex:"000000"},{name:"White",hex:"FFFFFF"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FFA500"},{name:"Yellow",hex:"FFFF00"},{name:"Green",hex:"00AE42"},{name:"Blue",hex:"0066FF"},{name:"Purple",hex:"8B00FF"},{name:"Pink",hex:"FF69B4"},{name:"Brown",hex:"8B4513"},{name:"Silver",hex:"C0C0C0"}],FYe=[{name:"Dark Red",hex:"8B0000"},{name:"Crimson",hex:"DC143C"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Dark Orange",hex:"FF8C00"},{name:"Peach",hex:"FFDAB9"},{name:"Gold",hex:"FFD700"},{name:"Khaki",hex:"F0E68C"},{name:"Lemon",hex:"FFF44F"},{name:"Lime",hex:"32CD32"},{name:"Forest Green",hex:"228B22"},{name:"Olive",hex:"808000"},{name:"Mint",hex:"98FF98"},{name:"Teal",hex:"008080"},{name:"Navy",hex:"000080"},{name:"Sky Blue",hex:"87CEEB"},{name:"Royal Blue",hex:"4169E1"},{name:"Cyan",hex:"00FFFF"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Magenta",hex:"FF00FF"},{name:"Indigo",hex:"4B0082"},{name:"Lavender",hex:"E6E6FA"},{name:"Plum",hex:"DDA0DD"},{name:"Hot Pink",hex:"FF69B4"},{name:"Rose",hex:"FF007F"},{name:"Blush",hex:"FFB6C1"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Beige",hex:"F5F5DC"},{name:"Maroon",hex:"800000"},{name:"Dark Gray",hex:"404040"},{name:"Light Gray",hex:"D3D3D3"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Bambu Green",hex:"00AE42"},{name:"Jade White",hex:"E8E8E8"},{name:"Titan Gray",hex:"5A5A5A"}],Z9=[...Cie,...FYe],Eie="bambuddy-recent-colors",IYe=8,zYe=[{code:"GFL00",name:"Bambu PLA Basic",displayName:"Bambu PLA Basic",isCustom:!1,allCodes:["GFL00"]},{code:"GFL01",name:"Bambu PLA Matte",displayName:"Bambu PLA Matte",isCustom:!1,allCodes:["GFL01"]},{code:"GFL05",name:"Generic PLA",displayName:"Generic PLA",isCustom:!1,allCodes:["GFL05"]},{code:"GFG00",name:"Bambu PETG Basic",displayName:"Bambu PETG Basic",isCustom:!1,allCodes:["GFG00"]},{code:"GFG05",name:"Generic PETG",displayName:"Generic PETG",isCustom:!1,allCodes:["GFG05"]},{code:"GFB00",name:"Bambu ABS Basic",displayName:"Bambu ABS Basic",isCustom:!1,allCodes:["GFB00"]},{code:"GFB05",name:"Generic ABS",displayName:"Generic ABS",isCustom:!1,allCodes:["GFB05"]},{code:"GFA00",name:"Bambu ASA Basic",displayName:"Bambu ASA Basic",isCustom:!1,allCodes:["GFA00"]},{code:"GFU00",name:"Bambu TPU 95A",displayName:"Bambu TPU 95A",isCustom:!1,allCodes:["GFU00"]},{code:"GFU05",name:"Generic TPU",displayName:"Generic TPU",isCustom:!1,allCodes:["GFU05"]},{code:"GFC00",name:"Bambu PC Basic",displayName:"Bambu PC Basic",isCustom:!1,allCodes:["GFC00"]},{code:"GFN00",name:"Bambu PA Basic",displayName:"Bambu PA Basic",isCustom:!1,allCodes:["GFN00"]},{code:"GFN05",name:"Generic PA",displayName:"Generic PA",isCustom:!1,allCodes:["GFN05"]},{code:"GFS00",name:"Bambu PLA-CF",displayName:"Bambu PLA-CF",isCustom:!1,allCodes:["GFS00"]},{code:"GFT00",name:"Bambu PETG-CF",displayName:"Bambu PETG-CF",isCustom:!1,allCodes:["GFT00"]},{code:"GFNC0",name:"Bambu PA-CF",displayName:"Bambu PA-CF",isCustom:!1,allCodes:["GFNC0"]},{code:"GFV00",name:"Bambu PVA",displayName:"Bambu PVA",isCustom:!1,allCodes:["GFV00"]}];function wk(t){let e=t.replace(/@.*$/,"").trim();e=e.replace(/\(Custom\)/i,"").trim(),e=e.replace(/^[#*]+\s*/,"").trim();const n=["PLA-CF","PETG-CF","ABS-GF","ASA-CF","PA-CF","PAHT-CF","PA6-CF","PA6-GF","PPA-CF","PPA-GF","PET-CF","PPS-CF","PC-CF","PC-ABS","ABS-GF","PETG","PLA","ABS","ASA","PC","PA","TPU","PVA","HIPS","BVOH","PPS","PCTG","PEEK","PEI"];let r="",i=-1;for(const c of n){const u=e.toUpperCase().indexOf(c.toUpperCase());if(u!==-1){r=c,i=u;break}}let s="";i>0&&(s=e.substring(0,i).trim(),s=s.replace(/[-_\s]+$/,""));let o="";i!==-1&&r&&(o=e.substring(i+r.length).trim(),o=o.replace(/^[-_\s]+/,""));let l="";for(const c of UR)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of UR){const u=new RegExp(`\\s+${c}$`,"i");if(u.test(s)){l=c,s=s.replace(u,"").trim();break}}return{brand:s,material:r,variant:l}}function UYe(t,e){const n=new Set(OYe);for(const r of t){const{brand:i}=wk(r.name);i&&i.length>1&&n.add(i)}if(e)for(const r of e)if(r.filament_vendor&&r.filament_vendor.length>1)n.add(r.filament_vendor);else{const{brand:i}=wk(r.name);i&&i.length>1&&n.add(i)}return Array.from(n).sort((r,i)=>r.localeCompare(i))}function BYe(t){const e=t.filter(r=>r.preset_type==="filament");if(e.length===0)return[];const n=new Map;for(const r of e){const i=r.name.replace(/@.*$/,"").trim(),s=n.get(i);if(s)s.allCodes.push(String(r.id));else{const o=r.filament_type||String(r.id);n.set(i,{code:o,name:i,displayName:i,isCustom:!1,allCodes:[o]})}}return Array.from(n.values()).sort((r,i)=>r.displayName.localeCompare(i.displayName))}function $Ye(t,e,n){if(t.length>0){const r=[],i=new Map;for(const s of t)if(s.is_custom){const o=s.name.toUpperCase();(e.size===0||Array.from(e).some(c=>o.includes(c))||!o.includes("@"))&&r.push({code:s.setting_id,name:s.name,displayName:`${s.name} (Custom)`,isCustom:!0,allCodes:[s.setting_id]})}else{const o=s.name.replace(/@.*$/,"").trim(),l=i.get(o);l?l.allCodes.push(s.setting_id):i.set(o,{code:s.setting_id,name:o,displayName:o,isCustom:!1,allCodes:[s.setting_id]})}return[...r,...Array.from(i.values())].sort((s,o)=>s.displayName.localeCompare(o.displayName))}if(n&&n.length>0){const r=BYe(n);if(r.length>0)return r}return zYe}function HYe(t,e){if(!t)return;let n=e.find(r=>r.code===t);if(n||(n=e.find(r=>r.allCodes.includes(t))),!n){const r=t.toLowerCase();n=e.find(i=>i.code.toLowerCase()===r||i.allCodes.some(s=>s.toLowerCase()===r))}return n}function VYe(){try{const t=localStorage.getItem(Eie);if(t)return JSON.parse(t)}catch{}return[]}function GYe(t,e){const n=e.filter(i=>i.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,IYe);try{localStorage.setItem(Eie,JSON.stringify(r))}catch{}return r}function xP(t,e){if(!e.material)return!1;const r=(t.name||"").replace(/^High Flow[_\s]+/i,"").replace(/^Standard[_\s]+/i,"").replace(/^HF[_\s]+/i,"").replace(/^S[_\s]+/i,"").trim(),i=wk(r);return!(!(i.material.toUpperCase()===e.material.toUpperCase())||e.brand&&!(i.brand.toLowerCase().includes(e.brand.toLowerCase())||e.brand.toLowerCase().includes(i.brand.toLowerCase()))||e.subtype&&!(i.variant.toLowerCase().includes(e.subtype.toLowerCase())||e.subtype.toLowerCase().includes(i.variant.toLowerCase())||r.toLowerCase().includes(e.subtype.toLowerCase())))}function qYe({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c}){const{t:u}=Ut(),[d,h]=w.useState(!1),[p,m]=w.useState(!1),[x,y]=w.useState(""),b=w.useRef(null),v=w.useRef(null);w.useEffect(()=>{const N=A=>{b.current&&!b.current.contains(A.target)&&h(!1),v.current&&!v.current.contains(A.target)&&m(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const S=w.useMemo(()=>{if(!i)return l;const N=i.toLowerCase();return l.filter(A=>A.displayName.toLowerCase().includes(N)||A.code.toLowerCase().includes(N))},[l,i]),k=w.useMemo(()=>{if(!x)return c;const N=x.toLowerCase();return c.filter(A=>A.toLowerCase().includes(N))},[c,x]),E=N=>{e("slicer_filament",N.code),s(N.displayName),h(!1);const A=wk(N.name);A.material&&e("material",A.material),A.brand&&e("brand",A.brand),A.variant&&e("subtype",A.variant)};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-3 h-3 animate-spin"})," ",u("inventory.loadingPresets")]}):n?a.jsxs(a.Fragment,{children:[a.jsx(jb,{className:"w-3 h-3 text-bambu-green"})," ",u("inventory.cloudConnected")]}):a.jsxs(a.Fragment,{children:[a.jsx(Hue,{className:"w-3 h-3"})," ",u("inventory.cloudNotConnected")]})}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[u("inventory.slicerPreset")," *"]}),a.jsxs("div",{className:"relative",ref:b,children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:u("inventory.searchPresets"),value:i,onChange:N=>{s(N.target.value),h(!0)},onFocus:()=>{h(!0),s("")}}),d&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:S.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:u("inventory.noPresetsFound")}):S.map(N=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${o?.code===N.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>E(N),children:[a.jsx("span",{className:"truncate",children:N.displayName}),a.jsx("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:N.code})]},N.code))})]}),o&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:[u("inventory.selectedPreset"),": ",a.jsx("span",{className:"font-mono text-bambu-green",children:o.code})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[u("inventory.material")," *"]}),a.jsxs("select",{value:t.material,onChange:N=>e("material",N.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"",children:u("inventory.selectMaterial")}),LYe.map(N=>a.jsx("option",{value:N,children:N},N))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:u("inventory.brand")}),a.jsxs("div",{className:"relative",ref:v,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:u("inventory.searchBrand"),value:p?x:t.brand,onChange:N=>{y(N.target.value),m(!0)},onFocus:()=>{m(!0),y("")}}),a.jsx(tr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),p&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[k.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:u("inventory.noResults")}):k.map(N=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===N?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",N),m(!1),y("")},children:N},N)),x&&!k.includes(x)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("brand",x),m(!1),y("")},children:u("inventory.useCustomBrand",{brand:x})})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:u("inventory.subtype")}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",value:t.subtype,onChange:N=>e("subtype",N.target.value),list:"variant-suggestions",placeholder:"Basic, Matte, Silk...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),a.jsx("datalist",{id:"variant-suggestions",children:UR.map(N=>a.jsx("option",{value:N},N))})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:u("inventory.labelWeight")}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"number",value:t.label_weight,onChange:N=>e("label_weight",parseInt(N.target.value)||0),className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]})]})}function WYe({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:i}){const{t:s}=Ut(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=t.rgba.replace("#","").substring(0,6),h=v=>d.toUpperCase()===v.toUpperCase(),p=(v,S)=>{e("rgba",v.toUpperCase()+"FF"),e("color_name",S),r({name:S,hex:v})},m=w.useMemo(()=>{if(i.length===0)return[];const v=t.brand?.trim(),S=t.material?.toLowerCase().trim(),k=t.subtype?.toLowerCase().trim();if(!v&&!S)return[];const E=v?v.toLowerCase().split(/[\s\-_]+/).filter(M=>M.length>=2):[],N=M=>{if(E.length===0)return!0;const P=M.toLowerCase();return E.some(T=>P.includes(T))},A=S&&k?`${S} ${k}`:"";if(A){const M=i.filter(T=>N(T.manufacturer)&&T.material?.toLowerCase()===A);if(M.length>0)return M.map(T=>({name:T.color_name,hex:T.hex_color.replace("#","").substring(0,6)}));const P=A.replace(/\+$/,"");if(P!==A){const T=i.filter(j=>N(j.manufacturer)&&j.material?.toLowerCase()===P);if(T.length>0)return T.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6)}))}}if(S){const M=i.filter(P=>N(P.manufacturer)&&(!P.material||P.material.toLowerCase().startsWith(S)));if(M.length>0)return M.map(P=>({name:P.color_name,hex:P.hex_color.replace("#","").substring(0,6)}))}return[]},[i,t.brand,t.material,t.subtype]),x=m.length>0,y=w.useMemo(()=>{if(!c)return m;const v=c.toLowerCase();return m.filter(S=>S.name.toLowerCase().includes(v))},[m,c]),b=w.useMemo(()=>c?Z9.filter(v=>v.name.toLowerCase().includes(c.toLowerCase())):o?Z9:Cie,[c,o]);return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"h-10 rounded-lg border border-bambu-dark-tertiary",style:{backgroundColor:`#${d}`}}),n.length>0&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-bambu-gray shrink-0",children:[a.jsx(qn,{className:"w-3 h-3"}),a.jsx("span",{children:s("inventory.recentColors")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(v=>a.jsx("button",{type:"button",onClick:()=>p(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name},v.hex))})]}),a.jsxs("div",{className:"relative",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchColors"),value:c,onChange:v=>u(v.target.value)})]}),x?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:c?s("inventory.searchResults"):`${t.brand}${t.material?` ${t.material}`:""}`}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[y.map(v=>a.jsx("button",{type:"button",onClick:()=>p(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 relative group ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10 shadow-lg text-white",children:v.name})},`${v.hex}-${v.name}`)),y.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:s(c?"inventory.searchResults":o?"inventory.allColors":"inventory.commonColors")}),!c&&a.jsx("button",{type:"button",onClick:()=>l(!o),className:"flex items-center gap-1 hover:text-white transition-colors",children:o?a.jsxs(a.Fragment,{children:[s("inventory.showLess")," ",a.jsx(Kl,{className:"w-3 h-3"})]}):a.jsxs(a.Fragment,{children:[s("inventory.showAll")," ",a.jsx(tr,{className:"w-3 h-3"})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[b.map(v=>a.jsx("button",{type:"button",onClick:()=>p(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 relative group ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10 shadow-lg text-white",children:v.name})},v.hex)),b.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.colorName")}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.colorNamePlaceholder"),value:t.color_name,onChange:v=>e("color_name",v.target.value)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.hexColor")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray",children:"#"}),a.jsx("input",{type:"text",className:"w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green",placeholder:"RRGGBB",value:d.toUpperCase(),onChange:v=>{const S=v.target.value.replace("#","").replace(/[^0-9A-Fa-f]/g,"");S.length<=8&&e("rgba",S.toUpperCase()+(S.length<=6?"FF":""))}})]}),a.jsx("input",{type:"color",className:"w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent",value:`#${d}`,onChange:v=>{const S=v.target.value.replace("#","").toUpperCase();e("rgba",S+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function KYe({catalog:t,value:e,onChange:n}){const{t:r}=Ut(),[i,s]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(null),d=w.useRef(null),h=w.useRef(null);w.useEffect(()=>{const x=y=>{d.current&&!d.current.contains(y.target)&&s(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const p=w.useMemo(()=>{if(!o)return t;const x=o.toLowerCase();return t.filter(y=>y.name.toLowerCase().includes(x)||y.weight.toString().includes(x))},[t,o]),m=w.useMemo(()=>{if(i)return o;if(c){const y=t.find(b=>b.id===c);if(y)return y.name}const x=t.find(y=>y.weight===e);return x?x.name:""},[i,o,c,t,e]);return a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(ofe,{className:"w-3.5 h-3.5 text-bambu-gray"}),r("inventory.coreWeight")]})}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("div",{className:"flex-1 min-w-0 relative",ref:d,children:[a.jsx("input",{ref:h,type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:r("inventory.searchSpoolWeight"),value:m,onFocus:()=>{s(!0),l("")},onChange:x=>{l(x.target.value),s(!0)}}),i&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:p.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:r("inventory.noResults")}):p.map(x=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(c?x.id===c:x.weight===e)?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{u(x.id),n(x.weight),s(!1),l("")},children:[a.jsx("span",{className:"truncate",children:x.name}),a.jsxs("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:[x.weight,"g"]})]},x.id))})]}),a.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a.jsx("input",{type:"number",className:"w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green",value:e,min:0,max:2e3,onChange:x=>{const y=parseInt(x.target.value);!isNaN(y)&&y>=0&&n(y)}}),a.jsx("span",{className:"text-bambu-gray text-sm",children:"g"})]})]})]})}function XYe({formData:t,updateField:e,spoolCatalog:n}){const{t:r}=Ut();return a.jsxs("div",{className:"space-y-4",children:[a.jsx(KYe,{catalog:n,value:t.core_weight,onChange:i=>e("core_weight",i)}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:r("inventory.currentWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:Math.max(0,t.label_weight-t.weight_used),min:0,max:t.label_weight,onChange:i=>{const s=parseInt(i.target.value)||0;e("weight_used",Math.max(0,t.label_weight-s))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:r("inventory.note")}),a.jsx("textarea",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]",placeholder:r("inventory.notePlaceholder"),value:t.note,onChange:i=>e("note",i.target.value)})]})]})}function YYe({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:s}){const{t:o}=Ut(),l=p=>{s(m=>{const x=new Set(m);return x.has(p)?x.delete(p):x.add(p),x})},c=(p,m,x)=>{const y=`${p}:${m}:${x??"null"}`,b=`${p}:${x??"null"}`;r(v=>{const S=new Set(v);if(S.has(y))S.delete(y);else{for(const k of Array.from(S)){const E=k.split(":");`${E[0]}:${E[2]}`===b&&S.delete(k)}S.add(y)}return S})},u=()=>{const p=new Set;for(const{printer:m,calibrations:x}of e){if(!m.connected)continue;const y=x.filter(v=>xP(v,t)),b=new Map;for(const v of y){const S=`${v.extruder_id??"null"}`;b.has(S)||b.set(S,[]),b.get(S).push(v)}for(const[v,S]of b)if(S.length>0){const E=[...S].sort((N,A)=>A.k_value-N.k_value)[0];p.add(`${m.id}:${E.cali_idx}:${v}`)}}r(p)};if(!t.material)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.selectMaterialFirst")})});if(e.length===0)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.noPrintersConfigured")})});const d=e.reduce((p,{printer:m,calibrations:x})=>m.connected?p+x.filter(y=>xP(y,t)).length:p,0),h=(p,m)=>{const x=`${p.id}:${m.cali_idx}:${m.extruder_id??"null"}`,y=n.has(x);return a.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${y?"bg-bambu-green/10 border-bambu-green/30":"bg-bambu-dark border-transparent hover:bg-bambu-dark/80"}`,children:[a.jsx("input",{type:"checkbox",checked:y,onChange:()=>c(String(p.id),m.cali_idx,m.extruder_id),className:"w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("span",{className:`text-sm font-medium ${y?"text-bambu-green":"text-white"}`,children:m.name||m.filament_id})}),a.jsx("div",{className:"flex items-center gap-2 shrink-0",children:a.jsxs("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray",children:["K=",m.k_value.toFixed(3)]})})]},`${m.cali_idx}-${m.extruder_id}`)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:[o("inventory.matchingFilter"),": ",t.brand||o("inventory.anyBrand")," / ",t.material," / ",t.subtype||o("inventory.anyVariant")]}),d>0&&a.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",children:[a.jsx(Jg,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",d,")"]})]}),a.jsx("div",{className:"space-y-3",children:e.map(({printer:p,calibrations:m})=>{const x=i.has(String(p.id)),y=m.filter(E=>xP(E,t)),b=y.length,v=y.some(E=>E.extruder_id!==void 0&&E.extruder_id!==null&&E.extruder_id>0),S=y.filter(E=>E.extruder_id===1),k=y.filter(E=>E.extruder_id===0||E.extruder_id===void 0||E.extruder_id===null);return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>l(String(p.id)),className:"w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[x?a.jsx(tr,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(La,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"font-medium text-white",children:p.name}),b>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:[b," ",o(b!==1?"inventory.matches":"inventory.match")]}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray",children:o("inventory.noMatches")})]}),a.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${p.connected?"bg-green-500/20 text-green-500":"bg-bambu-gray/20 text-bambu-gray"}`,children:p.connected?o("inventory.connected"):o("inventory.offline")})]}),x&&a.jsx("div",{className:"px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary",children:p.connected?b===0?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.noKProfilesMatch")}):v?a.jsxs(a.Fragment,{children:[S.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.leftNozzle")}),a.jsx("div",{className:"space-y-2",children:S.map(E=>h(p,E))})]}),k.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.rightNozzle")}),a.jsx("div",{className:"space-y-2",children:k.map(E=>h(p,E))})]})]}):a.jsx("div",{className:"space-y-2",children:y.map(E=>h(p,E))}):a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.printerOffline")})})]},p.id)})}),n.size>0&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"font-semibold",children:n.size})," ",o("inventory.profilesSelected")]})})]})}function QYe(t){const e=new Date(t);return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}const ZYe={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function JYe({spoolId:t}){const{t:e}=Ut(),n=Zt(),{showToast:r}=hn(),{data:i,isLoading:s}=et({queryKey:["spool-usage",t],queryFn:()=>ae.getSpoolUsageHistory(t)}),o=st({mutationFn:()=>ae.clearSpoolUsageHistory(t),onSuccess:()=>{n.invalidateQueries({queryKey:["spool-usage",t]}),r(e("inventory.historyCleared"),"success")}});return s?a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(it,{className:"w-5 h-5 animate-spin text-bambu-green"})}):!i||i.length===0?a.jsxs("div",{className:"text-center py-4 text-bambu-gray text-sm",children:[a.jsx(qn,{className:"w-5 h-5 mx-auto mb-2 opacity-50"}),e("inventory.noUsageHistory")]}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:e("inventory.usageHistory")}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[a.jsx(en,{className:"w-3 h-3 mr-1"}),e("inventory.clearHistory")]})]}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:i.map(l=>a.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-bambu-gray",children:QYe(l.created_at)}),l.print_name&&a.jsx("span",{className:"text-white ml-2 truncate",title:l.print_name,children:l.print_name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[a.jsxs("span",{className:"text-white font-medium",children:[l.weight_used.toFixed(1),"g"]}),a.jsxs("span",{className:"text-bambu-gray",children:["(",l.percent_used,"%)"]}),a.jsx("span",{className:ZYe[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function eQe({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[]}){const{t:i}=Ut(),s=Zt(),{showToast:o}=hn(),l=!!n,[c,u]=w.useState(Q9),[d,h]=w.useState({}),[p,m]=w.useState("filament"),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[S,k]=w.useState([]),[E,N]=w.useState(""),[A,M]=w.useState([]),[P,T]=w.useState([]),[j,z]=w.useState([]),[F,$]=w.useState([]),[D,H]=w.useState([]),[q,I]=w.useState(new Set),[K,Z]=w.useState(new Set),se=r.length>0?r:D,V=w.useMemo(()=>q.size,[q]);w.useEffect(()=>{$(VYe())},[]),w.useEffect(()=>{t&&((async()=>{v(!0);try{const Ie=await ae.getCloudStatus();if(y(Ie.is_authenticated),Ie.is_authenticated){const G=await ae.getFilamentPresets();k(G)}}catch(Ie){console.error("Failed to fetch cloud presets:",Ie),y(!1)}finally{v(!1)}})(),ae.getSpoolCatalog().then(M).catch(console.error),ae.getColorCatalog().then(z).catch(console.error),ae.getLocalPresets().then(Ie=>T(Ie.filament)).catch(console.error),r.length===0&&(async()=>{try{const Ie=await ae.getPrinters(),G=await Promise.all(Ie.map(ue=>ae.getPrinterStatus(ue.id).catch(()=>null))),Y=[];for(let ue=0;ue<Ie.length;ue++){const B=Ie[ue],Q=G[ue]?.connected??!1;let le=[];if(Q)try{le=(await ae.getKProfiles(B.id)).profiles.map(te=>({cali_idx:te.slot_id,filament_id:te.filament_id,setting_id:te.setting_id||"",name:te.name,k_value:parseFloat(te.k_value)||0,n_coef:parseFloat(te.n_coef)||0,extruder_id:te.extruder_id,nozzle_diameter:te.nozzle_diameter}))}catch{}Y.push({printer:{...B,connected:Q},calibrations:le})}H(Y)}catch(Ie){console.error("Failed to fetch printer calibrations:",Ie)}})())},[t,r.length]);const W=w.useMemo(()=>$Ye(S,new Set,P),[S,P]),ie=w.useMemo(()=>UYe(S,P),[S,P]),J=w.useMemo(()=>HYe(c.slicer_filament,W),[c.slicer_filament,W]);w.useEffect(()=>{if(t){if(n)if(u({material:n.material||"",subtype:n.subtype||"",brand:n.brand||"",color_name:n.color_name||"",rgba:n.rgba||"808080FF",label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,weight_used:n.weight_used||0,slicer_filament:n.slicer_filament||"",note:n.note||""}),N(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const re=new Set;for(const Ie of n.k_profiles)Ie.cali_idx!==null&&Ie.cali_idx!==void 0&&re.add(`${Ie.printer_id}:${Ie.cali_idx}:${Ie.extruder??"null"}`);I(re)}else I(new Set);else u(Q9),N(""),I(new Set);h({}),m("filament")}},[t,n]),w.useEffect(()=>{t&&se.length>0&&Z(new Set(se.map(re=>String(re.printer.id))))},[t,se]);const pe=(re,Ie)=>{u(G=>({...G,[re]:Ie})),d[re]&&h(G=>({...G,[re]:void 0}))},fe=re=>{$(Ie=>GYe(re,Ie))},ve=st({mutationFn:re=>ae.createSpool(re),onSuccess:async re=>{q.size>0&&re?.id&&await de(re.id),await s.invalidateQueries({queryKey:["inventory-spools"]}),o(i("inventory.spoolCreated"),"success"),e()},onError:re=>{o(re.message,"error")}}),Le=st({mutationFn:re=>ae.updateSpool(n.id,re),onSuccess:async()=>{n?.id&&await de(n.id),await s.invalidateQueries({queryKey:["inventory-spools"]}),o(i("inventory.spoolUpdated"),"success"),e()},onError:re=>{o(re.message,"error")}}),de=async re=>{if(q.size===0){try{await ae.saveSpoolKProfiles(re,[])}catch{}return}const Ie=[];for(const G of q){const[Y,ue,B]=G.split(":"),ee=parseInt(Y),Q=parseInt(ue),le=B==="null"?0:parseInt(B),he=se.find(te=>te.printer.id===ee);if(he){const te=he.calibrations.find(U=>U.cali_idx===Q);te&&Ie.push({printer_id:ee,extruder:le,nozzle_diameter:te.nozzle_diameter||"0.4",k_value:te.k_value,name:te.name||null,cali_idx:te.cali_idx,setting_id:te.setting_id||null})}}if(Ie.length>0)try{await ae.saveSpoolKProfiles(re,Ie)}catch(G){console.error("Failed to save K-profiles:",G)}};if(w.useEffect(()=>{if(!t)return;const re=Ie=>{Ie.key==="Escape"&&e()};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[t,e]),!t)return null;const ce=()=>{const re=RYe(c);if(!re.isValid){h(re.errors),(re.errors.slicer_filament||re.errors.material)&&m("filament");return}const Ie=J?.displayName||E||null,G={material:c.material,subtype:c.subtype||null,brand:c.brand||null,color_name:c.color_name||null,rgba:c.rgba||null,label_weight:c.label_weight,core_weight:c.core_weight,weight_used:c.weight_used,slicer_filament:c.slicer_filament||null,slicer_filament_name:Ie,nozzle_temp_min:null,nozzle_temp_max:null,note:c.note||null};l?Le.mutate(G):ve.mutate(G)},Ae=ve.isPending||Le.isPending;return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(l?"inventory.editSpool":"inventory.addSpool")}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("button",{onClick:()=>m("filament"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${p==="filament"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(Pk,{className:"w-4 h-4"}),i("inventory.filamentInfoTab")]}),a.jsxs("button",{onClick:()=>m("pa-profile"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${p==="pa-profile"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(rue,{className:"w-4 h-4"}),i("inventory.paProfileTab"),V>0&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:V})]})]}),a.jsx("div",{className:"p-4 overflow-y-auto flex-1",children:p==="filament"?a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.filamentInfo")}),a.jsx(qYe,{formData:c,updateField:pe,cloudAuthenticated:x,loadingCloudPresets:b,presetInputValue:E,setPresetInputValue:N,selectedPresetOption:J,filamentOptions:W,availableBrands:ie}),d.slicer_filament&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:d.slicer_filament}),d.material&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:d.material})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.color")}),a.jsx(WYe,{formData:c,updateField:pe,recentColors:F,onColorUsed:fe,catalogColors:j})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.additional")}),a.jsx(XYe,{formData:c,updateField:pe,spoolCatalog:A})]}),l&&n&&a.jsx("div",{children:a.jsx(JYe,{spoolId:n.id})})]}):a.jsx(YYe,{formData:c,updateField:pe,printersWithCalibrations:se,selectedProfiles:q,setSelectedProfiles:I,expandedPrinters:K,setExpandedPrinters:Z})}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{onClick:ce,disabled:Ae,children:Ae?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(fs,{className:"w-4 h-4"}),i(l?"common.save":"inventory.addSpool")]})})]})]})]})}function tQe({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:i}){const{t:s}=Ut(),[o,l]=w.useState(n),[c,u]=w.useState(null),d=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(E=>({...E})))},[t,n]),w.useEffect(()=>{if(!t)return;const E=N=>{N.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t,e]),!t)return null;const h=E=>{l(N=>N.map((A,M)=>M===E?{...A,visible:!A.visible}:A))},p=(E,N)=>{N<0||N>=o.length||l(A=>{const M=[...A],[P]=M.splice(E,1);return M.splice(N,0,P),M})},m=(E,N)=>{d.current=N,u(N),E.dataTransfer.effectAllowed="move"},x=(E,N)=>{E.preventDefault(),E.dataTransfer.dropEffect="move";const A=d.current;A!==null&&A!==N&&(p(A,N),d.current=N,u(N))},y=E=>{E.preventDefault()},b=()=>{d.current=null,u(null)},v=()=>{l(r.map(E=>({...E})))},S=()=>{i(o),e()},k=o.filter(E=>E.visible).length;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsx(_t,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:E=>E.stopPropagation(),children:a.jsxs(Nt,{className:"p-6 flex flex-col min-h-0",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:s("inventory.configureColumns")}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:[s("inventory.configureColumnsDesc"),a.jsxs("span",{className:"ml-2 text-bambu-gray/60",children:["(",k," ",s("inventory.of")," ",o.length," ",s("inventory.visible"),")"]})]}),a.jsx("div",{className:"space-y-1 overflow-y-auto flex-1 min-h-0 pr-1",children:o.map((E,N)=>a.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===N?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${E.visible?"":"opacity-50"}`,draggable:!0,onDragStart:A=>m(A,N),onDragOver:A=>x(A,N),onDrop:y,onDragEnd:b,children:[a.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:a.jsx(kh,{className:"w-4 h-4"})}),a.jsx("span",{className:"flex-1 font-medium text-sm text-white",children:E.label}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("button",{onClick:()=>p(N,N-1),disabled:N===0,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveUp"),children:a.jsx(Kl,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>p(N,N+1),disabled:N===o.length-1,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveDown"),children:a.jsx(tr,{className:"w-4 h-4"})})]}),a.jsx("button",{onClick:()=>h(N),className:`p-1.5 rounded transition-colors ${E.visible?"text-bambu-green hover:bg-bambu-green/10":"text-bambu-gray/50 hover:bg-bambu-dark-secondary"}`,title:E.visible?s("inventory.hideColumn"):s("inventory.showColumn"),children:E.visible?a.jsx(Yl,{className:"w-4 h-4"}):a.jsx(W0,{className:"w-4 h-4"})})]},E.id))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs(Me,{variant:"secondary",onClick:v,className:"mr-auto",children:[a.jsx(Po,{className:"w-4 h-4"}),s("inventory.reset")]}),a.jsx(Me,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),a.jsx(Me,{onClick:S,children:s("inventory.applyChanges")})]})]})})})}const Aie="bambuddy-inventory-columns",r1=[{id:"id",label:"#",visible:!0},{id:"added_time",label:"Added",visible:!0},{id:"encode_time",label:"Encoded",visible:!1},{id:"last_used_time",label:"Last Used",visible:!1},{id:"rgba",label:"Color",visible:!0},{id:"material",label:"Material",visible:!0},{id:"subtype",label:"Subtype",visible:!0},{id:"color_name",label:"Color Name",visible:!1},{id:"brand",label:"Brand",visible:!0},{id:"slicer_filament",label:"Slicer Filament",visible:!1},{id:"location",label:"Location",visible:!0},{id:"label_weight",label:"Label",visible:!0},{id:"net",label:"Net",visible:!0},{id:"gross",label:"Gross",visible:!1},{id:"added_full",label:"Full",visible:!1},{id:"used",label:"Used",visible:!1},{id:"printed_total",label:"Printed Total",visible:!1},{id:"printed_since_weight",label:"Printed Since Weight",visible:!1},{id:"note",label:"Note",visible:!1},{id:"pa_k",label:"PA(K)",visible:!0},{id:"tag_id",label:"Tag ID",visible:!1},{id:"data_origin",label:"Data Origin",visible:!1},{id:"tag_type",label:"Linked Tag Type",visible:!1},{id:"remaining",label:"Remaining",visible:!0}];function nQe(){try{const t=localStorage.getItem(Aie);if(t){const e=JSON.parse(t),n=new Set(r1.map(o=>o.id)),r=new Set(e.map(o=>o.id)),i=e.filter(o=>n.has(o.id)),s=r1.filter(o=>!r.has(o.id));return[...i,...s]}}catch{}return r1.map(t=>({...t}))}function rQe(t){try{localStorage.setItem(Aie,JSON.stringify(t))}catch{}}function ju(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const iQe={PLA:"bg-green-500/20 text-green-400",ABS:"bg-red-500/20 text-red-400",PETG:"bg-blue-500/20 text-blue-400",TPU:"bg-purple-500/20 text-purple-400",ASA:"bg-orange-500/20 text-orange-400",PA:"bg-yellow-500/20 text-yellow-400",PC:"bg-cyan-500/20 text-cyan-400",PET:"bg-sky-500/20 text-sky-400"};function yP(t){return t?new Date(t).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"}):"-"}const aQe={id:()=>"#",added_time:()=>"Added",encode_time:()=>"Encoded",last_used_time:()=>"Last Used",rgba:t=>t("inventory.color"),material:t=>t("inventory.material"),subtype:t=>t("inventory.subtype"),color_name:t=>t("inventory.colorName"),brand:t=>t("inventory.brand"),slicer_filament:t=>t("inventory.slicerFilament"),location:()=>"Location",label_weight:t=>t("inventory.labelWeight"),net:t=>t("inventory.net"),gross:()=>"Gross",added_full:()=>"Full",used:t=>t("inventory.weightUsed"),printed_total:()=>"Printed Total",printed_since_weight:()=>"Printed Since Weight",note:t=>t("inventory.note"),pa_k:()=>"PA(K)",tag_id:()=>"Tag ID",data_origin:()=>"Data Origin",tag_type:()=>"Linked Tag Type",remaining:t=>t("inventory.remaining")},sQe={id:({spool:t})=>a.jsx("span",{className:"text-sm font-medium text-white",children:t.id}),added_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:yP(t.created_at)}),encode_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:yP(t.encode_time)}),last_used_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?yP(t.last_used):"Never"}),rgba:({spool:t})=>a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"w-5 h-5 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:t.rgba?`#${t.rgba.substring(0,6)}`:"#808080"},title:t.rgba?`#${t.rgba.substring(0,6)}`:void 0})}),material:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:t.material}),subtype:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.subtype||"-"}),color_name:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:tte(t.color_name,t.rgba)||"-"}),brand:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.brand||"-"}),slicer_filament:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",title:t.slicer_filament||void 0,children:t.slicer_filament_name||t.slicer_filament||"-"}),location:({spool:t,assignmentMap:e})=>{const n=e[t.id];if(!n)return a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"});const r=n.printer_name||`Printer ${n.printer_id}`,i=String.fromCharCode(65+n.ams_id),s=n.tray_id+1;return a.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400",children:[r," ",i,s]})},label_weight:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:ju(t.label_weight)}),net:({remaining:t})=>a.jsx("span",{className:"text-sm text-white",children:ju(t)}),gross:({spool:t,remaining:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:ju(e+t.core_weight)}),added_full:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.added_full==null?"-":t.added_full?"Yes":"No"}),used:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.weight_used>0?ju(t.weight_used):"-"}),printed_total:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),printed_since_weight:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),note:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray max-w-[150px] truncate block",title:t.note||void 0,children:t.note||"-"}),pa_k:({spool:t})=>(t.k_profiles?.length??0)===0?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green",children:"K"}),tag_id:({spool:t})=>{const e=t.tag_uid||t.tray_uuid;return e?a.jsx("span",{className:"text-sm text-bambu-gray font-mono",title:e,children:e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}):a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"})},data_origin:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.data_origin||"-"}),tag_type:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.tag_type||"-"}),remaining:({remaining:t,pct:e})=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${e>50?"bg-bambu-green":e>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(t),"g"]})]})},vP={id:t=>t.id,added_time:t=>t.created_at||"",encode_time:t=>t.encode_time||"",last_used_time:t=>t.last_used||"",material:t=>(t.material||"").toLowerCase(),subtype:t=>(t.subtype||"").toLowerCase(),color_name:t=>(t.color_name||"").toLowerCase(),brand:t=>(t.brand||"").toLowerCase(),slicer_filament:t=>(t.slicer_filament_name||t.slicer_filament||"").toLowerCase(),location:(t,e)=>{const n=e[t.id];return n?`${n.printer_name||""} ${String.fromCharCode(65+n.ams_id)}${n.tray_id+1}`:""},label_weight:t=>t.label_weight,net:t=>Math.max(0,t.label_weight-t.weight_used),gross:t=>Math.max(0,t.label_weight-t.weight_used)+t.core_weight,used:t=>t.weight_used,remaining:t=>t.label_weight>0?Math.max(0,t.label_weight-t.weight_used)/t.label_weight:0,note:t=>(t.note||"").toLowerCase(),data_origin:t=>(t.data_origin||"").toLowerCase(),tag_type:t=>(t.tag_type||"").toLowerCase()},BR="bambuddy-inventory-sort";function oQe(){try{const t=localStorage.getItem(BR);if(t)return JSON.parse(t)}catch{}return null}function lQe(t){try{t?localStorage.setItem(BR,JSON.stringify(t)):localStorage.removeItem(BR)}catch{}}function cQe(){const{t}=Ut(),e=Zt(),{showToast:n}=hn(),[r,i]=w.useState(null),[s,o]=w.useState("active"),[l,c]=w.useState("all"),[u,d]=w.useState(""),[h,p]=w.useState(""),[m,x]=w.useState(""),[y,b]=w.useState("table"),[v,S]=w.useState(oQe),[k,E]=w.useState(nQe),[N,A]=w.useState(!1),[M,P]=w.useState(0),[T,j]=w.useState(()=>{try{const B=localStorage.getItem("bambuddy-inventory-pageSize");if(B){const ee=Number(B);if([15,30,50,100,-1].includes(ee))return ee}}catch{}return 15}),{data:z,isLoading:F}=et({queryKey:["inventory-spools"],queryFn:()=>ae.getSpools(!0),refetchInterval:3e4}),{data:$}=et({queryKey:["spool-assignments"],queryFn:()=>ae.getAssignments(),refetchInterval:3e4}),D=st({mutationFn:B=>ae.deleteSpool(B),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),H=st({mutationFn:B=>ae.archiveSpool(B),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),q=st({mutationFn:B=>ae.restoreSpool(B),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),I=w.useMemo(()=>{if(!z)return null;let B=0,ee=0,Q=0,le=0;const he={};for(const te of z){if(te.archived_at)continue;le++;const U=Math.max(0,te.label_weight-te.weight_used);B+=U,ee+=te.weight_used,(te.label_weight>0?U/te.label_weight*100:0)<20&&Q++;const X=te.material||"Unknown";he[X]||(he[X]={count:0,weight:0}),he[X].count++,he[X].weight+=U}return{totalWeight:B,totalConsumed:ee,lowStock:Q,byMaterial:he,totalSpools:le}},[z]),K=$?.length??0,Z=w.useMemo(()=>{const B={};for(const ee of $||[])B[ee.spool_id]=ee;return B},[$]),se=w.useMemo(()=>I?Object.entries(I.byMaterial).sort((B,ee)=>ee[1].weight-B[1].weight).slice(0,4):[],[I]),V=w.useMemo(()=>{let B=z||[];if(s==="active"?B=B.filter(ee=>!ee.archived_at):B=B.filter(ee=>!!ee.archived_at),l==="used"?B=B.filter(ee=>ee.weight_used>0):l==="new"&&(B=B.filter(ee=>ee.weight_used===0)),u&&(B=B.filter(ee=>ee.material===u)),h&&(B=B.filter(ee=>ee.brand===h)),m){const ee=m.toLowerCase();B=B.filter(Q=>Q.brand?.toLowerCase().includes(ee)||Q.material.toLowerCase().includes(ee)||Q.color_name?.toLowerCase().includes(ee)||Q.subtype?.toLowerCase().includes(ee)||Q.note?.toLowerCase().includes(ee)||Q.slicer_filament_name?.toLowerCase().includes(ee))}return B},[z,s,l,u,h,m]),W=()=>P(0),ie=[...new Set(z?.map(B=>B.material)||[])].sort(),J=[...new Set(z?.map(B=>B.brand).filter(Boolean)||[])].sort(),pe=s!=="active"||l!=="all"||!!u||!!h||!!m,fe=B=>{E(B),rQe(B)},ve=w.useMemo(()=>k.filter(B=>B.visible).map(B=>B.id),[k]),Le=B=>{vP[B]&&(S(ee=>{let Q;return ee?.column===B?Q=ee.direction==="asc"?{column:B,direction:"desc"}:null:Q={column:B,direction:"asc"},lQe(Q),Q}),W())},de=w.useMemo(()=>{if(!v)return V;const B=vP[v.column];return B?[...V].sort((Q,le)=>{const he=B(Q,Z),te=B(le,Z);return he<te?v.direction==="asc"?-1:1:he>te?v.direction==="asc"?1:-1:0}):V},[V,v,Z]),ce=T===-1,Ae=ce?de.length||1:T,re=Math.max(1,Math.ceil(de.length/Ae)),Ie=ce?0:Math.min(M,re-1),G=ce?de:de.slice(Ie*Ae,(Ie+1)*Ae),Y=B=>{j(B),P(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(B))}catch{}},ue=()=>{o("active"),c("all"),d(""),p(""),x(""),W()};return a.jsxs("div",{className:"p-4 md:p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ta,{className:"w-6 h-6 text-bambu-green"}),a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inventory.title")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-9",children:(t("inventory.noSpools").split(".")[0],"")})]}),a.jsxs(Me,{onClick:()=>i({spool:null}),children:[a.jsx(nr,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),I&&!F&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(ta,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalInventory")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:ju(I.totalWeight,!0)}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[I.totalSpools," ",I.totalSpools!==1?t("inventory.spools"):t("inventory.spool")]})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(u4,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalConsumed")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:ju(I.totalConsumed,!0)}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.sinceTracking")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Ja,{className:"w-4 h-4 text-green-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.byMaterial")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:se.map(([B,ee])=>a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${iQe[B]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[B," ",a.jsx("span",{className:"opacity-70",children:ju(ee.weight,!0)})]},B))})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Nr,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.inPrinter")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:K}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.loadedInAms")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(kn,{className:"w-4 h-4 text-yellow-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.lowStock")})]}),a.jsx("div",{className:`text-xl font-bold ${I.lowStock>0?"text-yellow-400":"text-white"}`,children:I.lowStock}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.lowStockThreshold")})]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between",children:[a.jsxs("div",{className:"relative flex-1 max-w-md",children:[a.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50"}),a.jsx("input",{type:"text",value:m,onChange:B=>{x(B.target.value),W()},placeholder:t("inventory.search"),className:"w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),m&&a.jsx("button",{onClick:()=>{x(""),W()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[y==="table"&&a.jsxs("button",{onClick:()=>A(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t("inventory.configureColumns"),children:[a.jsx(Jue,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.columns")})]}),a.jsxs("div",{className:"flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>b("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${y==="table"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Dfe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.table")})]}),a.jsxs("button",{onClick:()=>b("cards"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${y==="cards"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(X0,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.cards")})]})]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("button",{onClick:()=>{o("active"),W()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${s==="active"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(ta,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),a.jsxs("button",{onClick:()=>{o("archived"),W()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${s==="archived"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(As,{className:"w-3.5 h-3.5"}),t("inventory.archived")]})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{c("all"),W()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${l==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsxs("button",{onClick:()=>{c("used"),W()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="used"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),t("inventory.used")]}),a.jsx("button",{onClick:()=>{c("new"),W()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${l==="new"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.new")})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("select",{value:u,onChange:B=>{d(B.target.value),W()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${u?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.material")}),ie.map(B=>a.jsx("option",{value:B,children:B},B))]}),a.jsxs("select",{value:h,onChange:B=>{p(B.target.value),W()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${h?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.brand")}),J.map(B=>a.jsx("option",{value:B,children:B},B))]}),pe&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("button",{onClick:ue,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:[a.jsx(Rt,{className:"w-3.5 h-3.5"}),t("inventory.clearFilters")]})]}),a.jsxs("span",{className:"ml-auto text-xs text-bambu-gray",children:[de.length," ",de.length!==1?t("inventory.spools"):t("inventory.spool")]})]}),F?a.jsx("div",{className:"flex justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):y==="cards"?G.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:G.map(B=>{const ee=Math.max(0,B.label_weight-B.weight_used),Q=B.label_weight>0?ee/B.label_weight*100:0,le=B.rgba?`#${B.rgba.substring(0,6)}`:"#808080";return a.jsxs("div",{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${B.archived_at?"opacity-50":""}`,onClick:()=>i({spool:B}),children:[a.jsx("div",{className:"h-14 flex items-center justify-center",style:{backgroundColor:le},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:tte(B.color_name,B.rgba)||"-"})}),a.jsxs("div",{className:"p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[B.material,B.subtype?` ${B.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:B.brand||"-"})]}),a.jsxs("span",{className:"text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:["#",B.id]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[a.jsx("span",{children:t("inventory.remaining")}),a.jsxs("span",{children:[Math.round(Q),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${Q>50?"bg-bambu-green":Q>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(Q,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(ee),"g"]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[t("inventory.labelWeight"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:ju(B.label_weight)})]}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[t("inventory.weightUsed"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:B.weight_used>0?ju(B.weight_used):"-"})]})]}),B.note&&a.jsx("div",{className:"text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate",title:B.note,children:B.note})]})]},B.id)})}),a.jsx(uQe,{pageIndex:Ie,pageSize:T,totalRows:de.length,totalPages:re,onPageChange:P,onPageSizeChange:Y,t})]}):a.jsx(J9,{hasFilters:pe,onAddSpool:()=>i({spool:null}),t}):G.length>0?a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30",children:[ve.map(B=>{const ee=!!vP[B],Q=v?.column===B;return a.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${B==="remaining"?"min-w-[150px]":""} ${ee?"cursor-pointer hover:text-bambu-green transition-colors":""} ${Q?"text-bambu-green":"text-bambu-gray"}`,onClick:ee?()=>Le(B):void 0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[aQe[B]?.(t)??B,ee&&(Q?v.direction==="asc"?a.jsx(_m,{className:"w-3 h-3"}):a.jsx(Yg,{className:"w-3 h-3"}):a.jsx(i4,{className:"w-3 h-3 opacity-30"}))]})},B)}),a.jsx("th",{className:"text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide",children:t("common.actions")})]})}),a.jsx("tbody",{children:G.map(B=>{const ee=Math.max(0,B.label_weight-B.weight_used),Q=B.label_weight>0?ee/B.label_weight*100:0;return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${B.archived_at?"opacity-50":""}`,onClick:()=>i({spool:B}),children:[ve.map(le=>a.jsx("td",{className:"py-3 px-4",children:sQe[le]?.({spool:B,remaining:ee,pct:Q,assignmentMap:Z})},le)),a.jsx("td",{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:le=>le.stopPropagation(),children:[a.jsx("button",{onClick:()=>i({spool:B}),className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:t("inventory.editSpool"),children:a.jsx(Yf,{className:"w-4 h-4"})}),B.archived_at?a.jsx("button",{onClick:()=>q.mutate(B.id),className:"p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors",title:t("inventory.restore"),children:a.jsx(Po,{className:"w-4 h-4"})}):a.jsx("button",{onClick:()=>H.mutate(B.id),className:"p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors",title:t("inventory.archive"),children:a.jsx(As,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(t("inventory.deleteConfirm"))&&D.mutate(B.id)},className:"p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors",title:t("common.delete"),children:a.jsx(en,{className:"w-4 h-4"})})]})})]},B.id)})})]})}),a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:ce?`${de.length} ${de.length!==1?t("inventory.spools"):t("inventory.spool")}`:a.jsxs(a.Fragment,{children:[t("inventory.showing")," ",Ie*Ae+1," ",t("inventory.to")," ",Math.min((Ie+1)*Ae,de.length)," ",t("inventory.of")," ",de.length," ",t("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:t("inventory.show")}),a.jsxs("select",{value:T,onChange:B=>Y(Number(B.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(B=>a.jsx("option",{value:B,children:B},B)),a.jsx("option",{value:-1,children:t("inventory.all")})]}),!ce&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>P(0),disabled:Ie===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"First page",children:a.jsx(YW,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>P(B=>Math.max(0,B-1)),disabled:Ie===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Tc,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[t("inventory.page")," ",Ie+1," ",t("inventory.of")," ",re]}),a.jsx("button",{onClick:()=>P(B=>Math.min(re-1,B+1)),disabled:Ie>=re-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(La,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>P(re-1),disabled:Ie>=re-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Last page",children:a.jsx(QW,{className:"w-4 h-4"})})]})]})]})]}):a.jsx(J9,{hasFilters:pe,onAddSpool:()=>i({spool:null}),t}),r!==null&&a.jsx(eQe,{isOpen:!0,onClose:()=>i(null),spool:r.spool}),a.jsx(tQe,{isOpen:N,onClose:()=>A(!1),columns:k,defaultColumns:r1,onSave:fe})]})}function uQe({pageIndex:t,pageSize:e,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:s,t:o}){const l=e===-1;if(r<=1&&!l)return null;const c=l?n||1:e;return a.jsxs("div",{className:"flex items-center justify-between pt-2 text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:l?`${n} ${o(n!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[o("inventory.showing")," ",t*c+1," ",o("inventory.to")," ",Math.min((t+1)*c,n)," ",o("inventory.of")," ",n," ",o("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:o("inventory.show")}),a.jsxs("select",{value:e,onChange:u=>s(Number(u.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(u=>a.jsx("option",{value:u,children:u},u)),a.jsx("option",{value:-1,children:o("inventory.all")})]}),!l&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>i(0),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(YW,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(Math.max(0,t-1)),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Tc,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[o("inventory.page")," ",t+1," ",o("inventory.of")," ",r]}),a.jsx("button",{onClick:()=>i(Math.min(r-1,t+1)),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(La,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(r-1),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(QW,{className:"w-4 h-4"})})]})]})]})}function J9({hasFilters:t,onAddSpool:e,t:n}){return a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[a.jsxs("div",{className:"relative mb-6",children:[a.jsx("div",{className:"absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl"}),a.jsxs("div",{className:"relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg",children:[a.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30"}),a.jsx("div",{className:"absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20"}),t?a.jsx(zr,{className:"w-10 h-10 text-bambu-gray/40",strokeWidth:1.5}):a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center",children:a.jsx("div",{className:"w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20"})}),a.jsx("div",{className:"absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md",children:a.jsx("span",{className:"text-white text-lg font-bold leading-none",children:"+"})})]})]})]}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2 text-center",children:t?n("inventory.noSpoolsMatch"):n("inventory.noSpools").split(".")[0]}),a.jsx("p",{className:"text-sm text-bambu-gray text-center max-w-sm mb-6",children:n(t?"inventory.noSpoolsMatchDesc":"inventory.noSpools")}),!t&&a.jsxs(Me,{onClick:e,children:[a.jsx(ta,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const eW=["DEBUG","INFO","WARNING","ERROR"],wP={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},dQe={DEBUG:Mk,INFO:Xs,WARNING:kn,ERROR:Ui};function hQe(){const t=Zt(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[h,p]=w.useState(!1),m=w.useRef(null),{data:x,isLoading:y,refetch:b}=et({queryKey:["application-logs",l,s],queryFn:()=>Og.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:u});w.useEffect(()=>{u||p(!1)},[u]);const v=st({mutationFn:()=>Og.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&m.current&&x?.entries&&(m.current.scrollTop=m.current.scrollHeight)},[x?.entries,e]);const S=M=>{i(P=>{const T=new Set(P);return T.has(M)?T.delete(M):T.add(M),T})},k=M=>{const P=M.split(" ");return P.length>=2?P[1]:M},E=w.useMemo(()=>x?.entries??[],[x?.entries]),N=w.useMemo(()=>[...E].reverse(),[E]),A=({level:M})=>{const P=dQe[M]||Xs;return a.jsx(P,{className:`w-3.5 h-3.5 ${wP[M]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${h?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(Mk,{className:"w-5 h-5"})}),a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?a.jsx(Kl,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(tr,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h?a.jsxs("button",{onClick:M=>{M.stopPropagation(),p(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[a.jsx(pl,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:M=>{M.stopPropagation(),p(!0),b()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[a.jsx(jo,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||E.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[a.jsx(en,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>b(),disabled:y,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:a.jsx(Ir,{className:`w-4 h-4 ${y?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:M=>n(M.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(zr,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange:M=>o(M.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),s&&a.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),eW.map((M,P)=>a.jsx("button",{onClick:()=>c(M),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${P===eW.length-1?"rounded-r":""} ${l===M?`${wP[M]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:M},M))]})]})]}),a.jsx("div",{ref:m,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:E.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No log entries found"}),a.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:N.map((M,P)=>{const T=r.has(P),j=M.message.includes(`
  8310. `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${T?"bg-bambu-dark-secondary/30":""}`,onClick:()=>j&&S(P),children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:k(M.timestamp)}),a.jsx("span",{className:"shrink-0",children:a.jsx(A,{level:M.level})}),a.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:M.logger_name,children:["[",M.logger_name,"]"]}),a.jsx("span",{className:`flex-1 ${wP[M.level]||"text-white/80"} ${!T&&j?"truncate":""}`,children:T?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:M.message}):M.message.split(`
  8311. `)[0]}),j&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:T?a.jsx(Kl,{className:"w-3.5 h-3.5"}):a.jsx(tr,{className:"w-3.5 h-3.5"})})]})},P)})})}),a.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:h?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):a.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function fQe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Ei({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return a.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function tW({percent:t,color:e="bg-bambu-green"}){return a.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function eh({title:t,icon:e,children:n}){return a.jsxs(_t,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(e,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function mQe(){const{t}=Ut(),e=Zt(),[n,r]=w.useState(null),[i,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:h}=et({queryKey:["systemInfo"],queryFn:ae.getSystemInfo,refetchInterval:3e4}),{data:p}=et({queryKey:["debugLogging"],queryFn:Og.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:m}=et({queryKey:["settings"],queryFn:ae.getSettings}),{data:x}=et({queryKey:["library-stats"],queryFn:ae.getLibraryStats}),y=m?.time_format||"system",b=async()=>{l(!0);try{const E=await Og.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],E)}catch(E){console.error("Failed to toggle debug logging:",E)}finally{l(!1)}},v=async()=>{r(null),s(!0);try{await Og.downloadSupportBundle()}catch(E){r(E instanceof Error?E.message:"Failed to download support bundle")}finally{s(!1)}};if(u)return a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return a.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const S=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",k=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return a.jsxs("div",{className:"p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),a.jsxs("button",{onClick:()=>d(),disabled:h,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:[a.jsx(Ir,{className:`w-4 h-4 ${h?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(eh,{title:t("system.application","Application"),icon:Of,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(Ei,{icon:Of,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(Ei,{icon:qn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(Ei,{icon:Of,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(eh,{title:t("support.title","Support & Troubleshooting"),icon:Xde,children:a.jsxs("div",{className:"space-y-4",children:[a.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.")}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(Mk,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[p?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),p?.enabled&&p.duration_seconds!==null&&a.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),a.jsxs("button",{onClick:b,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${p?.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&&a.jsx(it,{className:"w-4 h-4 animate-spin"}),p?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:a.jsx(hi,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),a.jsxs("button",{onClick:v,disabled:i||!p?.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:p?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&a.jsx(it,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!p?.enabled&&a.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:a.jsxs("p",{className:"text-sm text-bambu-gray",children:[a.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),a.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),a.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),a.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),a.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),a.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),a.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),a.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),a.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]}),a.jsxs("li",{children:["• ",t("support.collectItem7","Printer connectivity and firmware versions")]}),a.jsxs("li",{children:["• ",t("support.collectItem8","Integration status (Spoolman, MQTT, HA)")]}),a.jsxs("li",{children:["• ",t("support.collectItem9","Network interfaces (subnets only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem10","Python package versions")]}),a.jsxs("li",{children:["• ",t("support.collectItem11","Database health checks")]}),a.jsxs("li",{children:["• ",t("support.collectItem12","Docker environment details")]})]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),a.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),a.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),a.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),a.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),a.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),a.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].")})]}),a.jsx(hQe,{})]})}),a.jsxs(eh,{title:t("system.database","Database"),icon:kc,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(Ei,{icon:As,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(Ei,{icon:Zg,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(Ei,{icon:ua,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(Ei,{icon:it,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Ei,{icon:Nr,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(Ei,{icon:Pk,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(Ei,{icon:ps,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(Ei,{icon:dl,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[a.jsx(Ei,{icon:qn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(Ei,{icon:As,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(eh,{title:t("system.connectedPrinters","Connected Printers"),icon:Nr,children:[a.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[a.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),a.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?a.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(E=>a.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),a.jsx("span",{className:"font-medium text-white",children:E.name})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[a.jsx("span",{children:E.model}),a.jsx("span",{className:`px-2 py-0.5 rounded ${E.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":E.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:E.state})]})]},E.id))}):a.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),a.jsx(eh,{title:t("system.storage","Storage"),icon:Pb,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),a.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),a.jsx(tW,{percent:c.storage.disk_percent_used,color:S}),a.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),"%)"]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(Ei,{icon:As,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(Ei,{icon:kc,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&a.jsx(Ei,{icon:Ql,label:t("system.fileManagerStorage","File Manager"),value:fQe(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsx(eh,{title:t("system.memory","Memory"),icon:Che,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),a.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),a.jsx(tW,{percent:c.memory.percent_used,color:k}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),a.jsx(eh,{title:t("system.cpu","CPU"),icon:Xw,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Ei,{icon:Xw,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(Ei,{icon:Xw,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(eh,{title:t("system.systemDetails","System Details"),icon:Of,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Ei,{icon:Of,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(Ei,{icon:Xw,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(Ei,{icon:Of,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(Ei,{icon:qn,label:t("system.bootTime","Boot Time"),value:tb(c.system.boot_time,y)})]})})]})}function pQe(){const t=Uc(),{t:e}=Ut(),{login:n}=Rr(),{showToast:r}=hn(),{mode:i}=Gm(),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(!1),[h,p]=w.useState(""),{data:m}=et({queryKey:["advancedAuthStatus"],queryFn:()=>ae.getAdvancedAuthStatus()}),x=st({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:S=>{r(S.message||e("login.loginFailed"),"error")}}),y=st({mutationFn:S=>ae.forgotPassword({email:S}),onSuccess:S=>{r(S.message,"success"),d(!1),p("")},onError:S=>{r(S.message,"error")}}),b=S=>{if(S.preventDefault(),!s||!l){r(e("login.enterCredentials"),"error");return}x.mutate()},v=S=>{if(S.preventDefault(),!h){r("Please enter your email address","error");return}y.mutate(h)};return a.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:i==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:b,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:m?.advanced_auth_enabled?e("login.usernameOrEmail")||"Username or Email":e("login.username")}),a.jsx("input",{id:"username",type:"text",required:!0,value:s,onChange:S=>o(S.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:m?.advanced_auth_enabled?e("login.usernameOrEmailPlaceholder")||"Enter your username or email":e("login.usernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),a.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:S=>c(S.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.passwordPlaceholder"),autoComplete:"current-password"})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:x.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:x.isPending?e("login.signingIn"):e("login.signIn")})}),m?.advanced_auth_enabled&&a.jsx("div",{className:"text-center",children:a.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:a.jsxs(_t,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:[a.jsx(Mn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(r0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{d(!1),p("")},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsx(Nt,{children:m?.advanced_auth_enabled?a.jsxs("form",{onSubmit:v,className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray text-sm",children:e("login.forgotPasswordEmailMessage")||"Enter your email address and we'll send you a new password."}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium text-white mb-2",children:e("login.emailAddress")||"Email Address"}),a.jsx("input",{id:"forgot-email",type:"email",required:!0,value:h,onChange:S=>p(S.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.emailPlaceholder")||"your.email@example.com"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{d(!1),p("")},children:e("login.cancel")||"Cancel"}),a.jsx(Me,{type:"submit",className:"flex-1",disabled:y.isPending,children:y.isPending?e("login.sending")||"Sending...":e("login.sendResetEmail")||"Send Reset Email"})]})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[a.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),a.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[a.jsx("li",{children:e("login.resetStep1")}),a.jsx("li",{children:e("login.resetStep2")}),a.jsx("li",{children:e("login.resetStep3")}),a.jsx("li",{children:e("login.resetStep4")})]})]}),a.jsx(Me,{variant:"secondary",className:"w-full",onClick:()=>d(!1),children:e("login.gotIt")})]})})]})})]})}function gQe(){const t=Uc(),{t:e}=Ut(),{showToast:n}=hn(),{mode:r}=Gm(),{refreshAuth:i}=Rr(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[u,d]=w.useState(""),[h,p]=w.useState(""),m=st({mutationFn:()=>ae.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?u:void 0}),onSuccess:async y=>{await i(),y.auth_enabled?y.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:y=>{n(y.message,"error")}}),x=y=>{if(y.preventDefault(),s&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==h){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}m.mutate()};return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:x,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("input",{id:"auth-enabled",type:"checkbox",checked:s,onChange:y=>o(y.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),a.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),s&&a.jsxs("div",{className:"space-y-4 mt-4",children:[a.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Xs,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),a.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-username",type:"text",value:l,onChange:y=>c(y.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminUsernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-password",type:"password",value:u,onChange:y=>d(y.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]}),u&&a.jsxs("div",{children:[a.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),a.jsx("input",{id:"confirm-password",type:"password",value:h,onChange:y=>p(y.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.confirmPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:m.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:m.isPending?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function bQe(){const t=w.useRef(null),e=w.useRef(null),n=Zt(),[r,i]=w.useState(!1),s=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),h=w.useRef(()=>{}),p=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const k=u.current.shift();k?requestAnimationFrame(()=>{h.current(k),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),m=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const k=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,E=new WebSocket(k);let N=null;E.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),N=window.setInterval(()=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify({type:"ping"}))},3e4)},E.onmessage=A=>{try{const M=JSON.parse(A.data);M.type==="printer_status"&&M.printer_id!==void 0&&M.data?h.current(M):(u.current.push(M),p())}catch{}},E.onclose=A=>{console.log("[WebSocket] Closed",A.code,A.reason),N&&(clearInterval(N),N=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{m()},3e3)},E.onerror=A=>{console.error("[WebSocket] Error",A),E.close()},t.current=E},[p]),x=w.useCallback((S,k)=>{const E=l.current.get(S)||{};l.current.set(S,{...E,...k}),c.current||(c.current=window.setTimeout(()=>{const N=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{N.forEach((A,M)=>{n.setQueryData(["printerStatus",M],P=>{const T={...P,...A};return T.wifi_signal==null&&P?.wifi_signal!=null&&(T.wifi_signal=P.wifi_signal),T})})})},100))},[n]),y=w.useCallback(S=>{s.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const k=Array.from(s.current);s.current.clear(),o.current=null;let E=0;k.forEach(N=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[N]})})},E),E+=500})},3e3)},[n]),b=w.useCallback(S=>{switch(S.type){case"printer_status":S.printer_id!==void 0&&S.data&&x(S.printer_id,S.data);break;case"print_start":S.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",S.printer_id]});break;case"print_complete":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:S.printer_id,printer_name:S.printer_name,message:S.message}}));break;case"spool_auto_assigned":y("inventory-spools"),y("spool-assignments");break;case"spool_usage_logged":y("inventory-spools");break;case"unknown_tag":window.dispatchEvent(new CustomEvent("unknown-tag",{detail:{printer_id:S.printer_id,ams_id:S.ams_id,tray_id:S.tray_id,tag_uid:S.tag_uid,tray_uuid:S.tray_uuid}}));break}},[n,y,x]);w.useEffect(()=>{h.current=b},[b]),w.useEffect(()=>(m(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[m]);const v=w.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:v}}const xQe=new Pce({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function yQe({children:t}){return bQe(),a.jsx(a.Fragment,{children:t})}function vQe({children:t}){const{authEnabled:e,loading:n,user:r}=Rr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?a.jsx(Xg,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function wQe({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Rr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?a.jsx(a.Fragment,{children:t}):a.jsx(Xg,{to:"/",replace:!0}):a.jsx(Xg,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function _Qe({children:t}){const{authEnabled:e,loading:n}=Rr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?a.jsx(Xg,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function SQe(){return a.jsx(gme,{children:a.jsx(Nme,{children:a.jsx(Dce,{client:xQe,children:a.jsx(wme,{children:a.jsx(Jle,{children:a.jsxs(Ele,{children:[a.jsx(Fi,{path:"/setup",element:a.jsx(_Qe,{children:a.jsx(gQe,{})})}),a.jsx(Fi,{path:"/login",element:a.jsx(pQe,{})}),a.jsx(Fi,{path:"/camera/:printerId",element:a.jsx(MYe,{})}),a.jsx(Fi,{path:"/overlay/:printerId",element:a.jsx(PYe,{})}),a.jsxs(Fi,{element:a.jsx(vQe,{children:a.jsx(yQe,{children:a.jsx(Eme,{})})}),children:[a.jsx(Fi,{index:!0,element:a.jsx(d6e,{})}),a.jsx(Fi,{path:"archives",element:a.jsx(hWe,{})}),a.jsx(Fi,{path:"queue",element:a.jsx(QKe,{})}),a.jsx(Fi,{path:"stats",element:a.jsx(fXe,{})}),a.jsx(Fi,{path:"profiles",element:a.jsx(eYe,{})}),a.jsx(Fi,{path:"maintenance",element:a.jsx(aYe,{})}),a.jsx(Fi,{path:"projects",element:a.jsx(oYe,{})}),a.jsx(Fi,{path:"projects/:id",element:a.jsx(mYe,{})}),a.jsx(Fi,{path:"inventory",element:a.jsx(cQe,{})}),a.jsx(Fi,{path:"files",element:a.jsx(_Ye,{})}),a.jsx(Fi,{path:"settings",element:a.jsx(wQe,{children:a.jsx(zXe,{})})}),a.jsx(Fi,{path:"users",element:a.jsx(Xg,{to:"/settings?tab=users",replace:!0})}),a.jsx(Fi,{path:"groups",element:a.jsx(Xg,{to:"/settings?tab=users",replace:!0})}),a.jsx(Fi,{path:"system",element:a.jsx(mQe,{})}),a.jsx(Fi,{path:"external/:id",element:a.jsx(DYe,{})})]})]})})})})})})}Nse.createRoot(document.getElementById("root")).render(a.jsx(w.StrictMode,{children:a.jsx(SQe,{})}));