index-jyNRggdg.js 3.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665
  1. function yae(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Gv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ko(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var gA={exports:{}},zx={};var hU;function vae(){if(hU)return zx;hU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:a}}return zx.Fragment=e,zx.jsx=n,zx.jsxs=n,zx}var fU;function _ae(){return fU||(fU=1,gA.exports=vae()),gA.exports}var s=_ae(),xA={exports:{}},ln={};var mU;function wae(){if(mU)return ln;mU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),m=Symbol.iterator;function p(U){return U===null||typeof U!="object"?null:(U=m&&U[m]||U["@@iterator"],typeof U=="function"?U:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function y(U,G,ee){this.props=U,this.context=G,this.refs=b,this.updater=ee||x}y.prototype.isReactComponent={},y.prototype.setState=function(U,G){if(typeof U!="object"&&typeof U!="function"&&U!=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,U,G,"setState")},y.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function M(){}M.prototype=y.prototype;function S(U,G,ee){this.props=U,this.context=G,this.refs=b,this.updater=ee||x}var A=S.prototype=new M;A.constructor=S,v(A,y.prototype),A.isPureReactComponent=!0;var E=Array.isArray;function k(){}var C={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function T(U,G,ee){var ne=ee.ref;return{$$typeof:t,type:U,key:G,ref:ne!==void 0?ne:null,props:ee}}function P(U,G){return T(U.type,G,U.props)}function F(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function I(U){var G={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(ee){return G[ee]})}var X=/\/+/g;function D(U,G){return typeof U=="object"&&U!==null&&U.key!=null?I(""+U.key):G.toString(36)}function K(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(k,k):(U.status="pending",U.then(function(G){U.status==="pending"&&(U.status="fulfilled",U.value=G)},function(G){U.status==="pending"&&(U.status="rejected",U.reason=G)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function Y(U,G,ee,ne,se){var de=typeof U;(de==="undefined"||de==="boolean")&&(U=null);var he=!1;if(U===null)he=!0;else switch(de){case"bigint":case"string":case"number":he=!0;break;case"object":switch(U.$$typeof){case t:case e:he=!0;break;case d:return he=U._init,Y(he(U._payload),G,ee,ne,se)}}if(he)return se=se(U),he=ne===""?"."+D(U,0):ne,E(se)?(ee="",he!=null&&(ee=he.replace(X,"$&/")+"/"),Y(se,G,ee,"",function(Ne){return Ne})):se!=null&&(F(se)&&(se=P(se,ee+(se.key==null||U&&U.key===se.key?"":(""+se.key).replace(X,"$&/")+"/")+he)),G.push(se)),1;he=0;var Ee=ne===""?".":ne+":";if(E(U))for(var ge=0;ge<U.length;ge++)ne=U[ge],de=Ee+D(ne,ge),he+=Y(ne,G,ee,de,se);else if(ge=p(U),typeof ge=="function")for(U=ge.call(U),ge=0;!(ne=U.next()).done;)ne=ne.value,de=Ee+D(ne,ge++),he+=Y(ne,G,ee,de,se);else if(de==="object"){if(typeof U.then=="function")return Y(K(U),G,ee,ne,se);throw G=String(U),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return he}function q(U,G,ee){if(U==null)return U;var ne=[],se=0;return Y(U,ne,"","",function(de){return G.call(ee,de,se++)}),ne}function Z(U){if(U._status===-1){var G=U._result;G=G(),G.then(function(ee){(U._status===0||U._status===-1)&&(U._status=1,U._result=ee)},function(ee){(U._status===0||U._status===-1)&&(U._status=2,U._result=ee)}),U._status===-1&&(U._status=0,U._result=G)}if(U._status===1)return U._result.default;throw U._result}var re=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},ie={map:q,forEach:function(U,G,ee){q(U,function(){G.apply(this,arguments)},ee)},count:function(U){var G=0;return q(U,function(){G++}),G},toArray:function(U){return q(U,function(G){return G})||[]},only:function(U){if(!F(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return ln.Activity=f,ln.Children=ie,ln.Component=y,ln.Fragment=n,ln.Profiler=i,ln.PureComponent=S,ln.StrictMode=r,ln.Suspense=c,ln.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,ln.__COMPILER_RUNTIME={__proto__:null,c:function(U){return C.H.useMemoCache(U)}},ln.cache=function(U){return function(){return U.apply(null,arguments)}},ln.cacheSignal=function(){return null},ln.cloneElement=function(U,G,ee){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var ne=v({},U.props),se=U.key;if(G!=null)for(de in G.key!==void 0&&(se=""+G.key),G)!R.call(G,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&G.ref===void 0||(ne[de]=G[de]);var de=arguments.length-2;if(de===1)ne.children=ee;else if(1<de){for(var he=Array(de),Ee=0;Ee<de;Ee++)he[Ee]=arguments[Ee+2];ne.children=he}return T(U.type,se,ne)},ln.createContext=function(U){return U={$$typeof:o,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:a,_context:U},U},ln.createElement=function(U,G,ee){var ne,se={},de=null;if(G!=null)for(ne in G.key!==void 0&&(de=""+G.key),G)R.call(G,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(se[ne]=G[ne]);var he=arguments.length-2;if(he===1)se.children=ee;else if(1<he){for(var Ee=Array(he),ge=0;ge<he;ge++)Ee[ge]=arguments[ge+2];se.children=Ee}if(U&&U.defaultProps)for(ne in he=U.defaultProps,he)se[ne]===void 0&&(se[ne]=he[ne]);return T(U,de,se)},ln.createRef=function(){return{current:null}},ln.forwardRef=function(U){return{$$typeof:l,render:U}},ln.isValidElement=F,ln.lazy=function(U){return{$$typeof:d,_payload:{_status:-1,_result:U},_init:Z}},ln.memo=function(U,G){return{$$typeof:u,type:U,compare:G===void 0?null:G}},ln.startTransition=function(U){var G=C.T,ee={};C.T=ee;try{var ne=U(),se=C.S;se!==null&&se(ee,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(k,re)}catch(de){re(de)}finally{G!==null&&ee.types!==null&&(G.types=ee.types),C.T=G}},ln.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},ln.use=function(U){return C.H.use(U)},ln.useActionState=function(U,G,ee){return C.H.useActionState(U,G,ee)},ln.useCallback=function(U,G){return C.H.useCallback(U,G)},ln.useContext=function(U){return C.H.useContext(U)},ln.useDebugValue=function(){},ln.useDeferredValue=function(U,G){return C.H.useDeferredValue(U,G)},ln.useEffect=function(U,G){return C.H.useEffect(U,G)},ln.useEffectEvent=function(U){return C.H.useEffectEvent(U)},ln.useId=function(){return C.H.useId()},ln.useImperativeHandle=function(U,G,ee){return C.H.useImperativeHandle(U,G,ee)},ln.useInsertionEffect=function(U,G){return C.H.useInsertionEffect(U,G)},ln.useLayoutEffect=function(U,G){return C.H.useLayoutEffect(U,G)},ln.useMemo=function(U,G){return C.H.useMemo(U,G)},ln.useOptimistic=function(U,G){return C.H.useOptimistic(U,G)},ln.useReducer=function(U,G,ee){return C.H.useReducer(U,G,ee)},ln.useRef=function(U){return C.H.useRef(U)},ln.useState=function(U){return C.H.useState(U)},ln.useSyncExternalStore=function(U,G,ee){return C.H.useSyncExternalStore(U,G,ee)},ln.useTransition=function(){return C.H.useTransition()},ln.version="19.2.0",ln}var pU;function Ag(){return pU||(pU=1,xA.exports=wae()),xA.exports}var w=Ag();const jr=ko(w),Sae=yae({__proto__:null,default:jr},[w]);var bA={exports:{}},Bx={},yA={exports:{}},vA={};var gU;function Mae(){return gU||(gU=1,(function(t){function e(Y,q){var Z=Y.length;Y.push(q);e:for(;0<Z;){var re=Z-1>>>1,ie=Y[re];if(0<i(ie,q))Y[re]=q,Y[Z]=ie,Z=re;else break e}}function n(Y){return Y.length===0?null:Y[0]}function r(Y){if(Y.length===0)return null;var q=Y[0],Z=Y.pop();if(Z!==q){Y[0]=Z;e:for(var re=0,ie=Y.length,U=ie>>>1;re<U;){var G=2*(re+1)-1,ee=Y[G],ne=G+1,se=Y[ne];if(0>i(ee,Z))ne<ie&&0>i(se,ee)?(Y[re]=se,Y[ne]=Z,re=ne):(Y[re]=ee,Y[G]=Z,re=G);else if(ne<ie&&0>i(se,Z))Y[re]=se,Y[ne]=Z,re=ne;else break e}}return q}function i(Y,q){var Z=Y.sortIndex-q.sortIndex;return Z!==0?Z:Y.id-q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,m=3,p=!1,x=!1,v=!1,b=!1,y=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function A(Y){for(var q=n(u);q!==null;){if(q.callback===null)r(u);else if(q.startTime<=Y)r(u),q.sortIndex=q.expirationTime,e(c,q);else break;q=n(u)}}function E(Y){if(v=!1,A(Y),!x)if(n(c)!==null)x=!0,k||(k=!0,I());else{var q=n(u);q!==null&&K(E,q.startTime-Y)}}var k=!1,C=-1,R=5,T=-1;function P(){return b?!0:!(t.unstable_now()-T<R)}function F(){if(b=!1,k){var Y=t.unstable_now();T=Y;var q=!0;try{e:{x=!1,v&&(v=!1,M(C),C=-1),p=!0;var Z=m;try{t:{for(A(Y),f=n(c);f!==null&&!(f.expirationTime>Y&&P());){var re=f.callback;if(typeof re=="function"){f.callback=null,m=f.priorityLevel;var ie=re(f.expirationTime<=Y);if(Y=t.unstable_now(),typeof ie=="function"){f.callback=ie,A(Y),q=!0;break t}f===n(c)&&r(c),A(Y)}else r(c);f=n(c)}if(f!==null)q=!0;else{var U=n(u);U!==null&&K(E,U.startTime-Y),q=!1}}break e}finally{f=null,m=Z,p=!1}q=void 0}}finally{q?I():k=!1}}}var I;if(typeof S=="function")I=function(){S(F)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,D=X.port2;X.port1.onmessage=F,I=function(){D.postMessage(null)}}else I=function(){y(F,0)};function K(Y,q){C=y(function(){Y(t.unstable_now())},q)}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(Y){Y.callback=null},t.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<Y?Math.floor(1e3/Y):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(Y){switch(m){case 1:case 2:case 3:var q=3;break;default:q=m}var Z=m;m=q;try{return Y()}finally{m=Z}},t.unstable_requestPaint=function(){b=!0},t.unstable_runWithPriority=function(Y,q){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var Z=m;m=Y;try{return q()}finally{m=Z}},t.unstable_scheduleCallback=function(Y,q,Z){var re=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?re+Z:re):Z=re,Y){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=Z+ie,Y={id:d++,callback:q,priorityLevel:Y,startTime:Z,expirationTime:ie,sortIndex:-1},Z>re?(Y.sortIndex=Z,e(u,Y),n(c)===null&&Y===n(u)&&(v?(M(C),C=-1):v=!0,K(E,Z-re))):(Y.sortIndex=ie,e(c,Y),x||p||(x=!0,k||(k=!0,I()))),Y},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(Y){var q=m;return function(){var Z=m;m=q;try{return Y.apply(this,arguments)}finally{m=Z}}}})(vA)),vA}var xU;function Nae(){return xU||(xU=1,yA.exports=Mae()),yA.exports}var _A={exports:{}},ya={};var bU;function Eae(){if(bU)return ya;bU=1;var t=Ag();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ya.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ya.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},ya.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()}},ya.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))},ya.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ya.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),m=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:m,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:m,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ya.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)},ya.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},ya.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)},ya.requestFormReset=function(c){r.d.r(c)},ya.unstable_batchedUpdates=function(c,u){return c(u)},ya.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},ya.useFormStatus=function(){return o.H.useHostTransitionStatus()},ya.version="19.2.0",ya}var yU;function XG(){if(yU)return _A.exports;yU=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(),_A.exports=Eae(),_A.exports}var vU;function Aae(){if(vU)return Bx;vU=1;var t=Nae(),e=Ag(),n=XG();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)g+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var g=h,_=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(_=g.return),h=g.return;while(h)}return g.tag===3?_:null}function o(h){if(h.tag===13){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function l(h){if(h.tag===31){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var g=h.alternate;if(!g){if(g=a(h),g===null)throw Error(r(188));return g!==h?null:h}for(var _=h,N=g;;){var j=_.return;if(j===null)break;var O=j.alternate;if(O===null){if(N=j.return,N!==null){_=N;continue}break}if(j.child===O.child){for(O=j.child;O;){if(O===_)return c(j),h;if(O===N)return c(j),g;O=O.sibling}throw Error(r(188))}if(_.return!==N.return)_=j,N=O;else{for(var J=!1,fe=j.child;fe;){if(fe===_){J=!0,_=j,N=O;break}if(fe===N){J=!0,N=j,_=O;break}fe=fe.sibling}if(!J){for(fe=O.child;fe;){if(fe===_){J=!0,_=O,N=j;break}if(fe===N){J=!0,N=O,_=j;break}fe=fe.sibling}if(!J)throw Error(r(189))}}if(_.alternate!==N)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:g}function d(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h;for(h=h.child;h!==null;){if(g=d(h),g!==null)return g;h=h.sibling}return null}var f=Object.assign,m=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),S=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function I(h){return h===null||typeof h!="object"?null:(h=F&&h[F]||h["@@iterator"],typeof h=="function"?h:null)}var X=Symbol.for("react.client.reference");function D(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===X?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case v:return"Fragment";case y:return"Profiler";case b:return"StrictMode";case E:return"Suspense";case k:return"SuspenseList";case T:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case S:return h.displayName||"Context";case M:return(h._context.displayName||"Context")+".Consumer";case A:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case C:return g=h.displayName||null,g!==null?g:D(h.type)||"Memo";case R:g=h._payload,h=h._init;try{return D(h(g))}catch{}}return null}var K=Array.isArray,Y=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function U(h){return{current:h}}function G(h){0>ie||(h.current=re[ie],re[ie]=null,ie--)}function ee(h,g){ie++,re[ie]=h.current,h.current=g}var ne=U(null),se=U(null),de=U(null),he=U(null);function Ee(h,g){switch(ee(de,g),ee(se,h),ee(ne,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?OF(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=OF(g),h=LF(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}G(ne),ee(ne,h)}function ge(){G(ne),G(se),G(de)}function Ne(h){h.memoizedState!==null&&ee(he,h);var g=ne.current,_=LF(g,h.type);g!==_&&(ee(se,h),ee(ne,_))}function Re(h){se.current===h&&(G(ne),G(se)),he.current===h&&(G(he),Lx._currentValue=Z)}var te,Je;function B(h){if(te===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);te=g&&g[1]||"",Je=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+te+h+Je}var H=!1;function W(h,g){if(!h||H)return"";H=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var N={DetermineComponentFrameRoot:function(){try{if(g){var xt=function(){throw Error()};if(Object.defineProperty(xt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(xt,[])}catch(ot){var it=ot}Reflect.construct(h,[],xt)}else{try{xt.call()}catch(ot){it=ot}h.call(xt.prototype)}}else{try{throw Error()}catch(ot){it=ot}(xt=h())&&typeof xt.catch=="function"&&xt.catch(function(){})}}catch(ot){if(ot&&it&&typeof ot.stack=="string")return[ot.stack,it.stack]}return[null,null]}};N.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var j=Object.getOwnPropertyDescriptor(N.DetermineComponentFrameRoot,"name");j&&j.configurable&&Object.defineProperty(N.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=N.DetermineComponentFrameRoot(),J=O[0],fe=O[1];if(J&&fe){var je=J.split(`
  4. `),tt=fe.split(`
  5. `);for(j=N=0;N<je.length&&!je[N].includes("DetermineComponentFrameRoot");)N++;for(;j<tt.length&&!tt[j].includes("DetermineComponentFrameRoot");)j++;if(N===je.length||j===tt.length)for(N=je.length-1,j=tt.length-1;1<=N&&0<=j&&je[N]!==tt[j];)j--;for(;1<=N&&0<=j;N--,j--)if(je[N]!==tt[j]){if(N!==1||j!==1)do if(N--,j--,0>j||je[N]!==tt[j]){var mt=`
  6. `+je[N].replace(" at new "," at ");return h.displayName&&mt.includes("<anonymous>")&&(mt=mt.replace("<anonymous>",h.displayName)),mt}while(1<=N&&0<=j);break}}}finally{H=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?B(_):""}function z(h,g){switch(h.tag){case 26:case 27:case 5:return B(h.type);case 16:return B("Lazy");case 13:return h.child!==g&&g!==null?B("Suspense Fallback"):B("Suspense");case 19:return B("SuspenseList");case 0:case 15:return W(h.type,!1);case 11:return W(h.type.render,!1);case 1:return W(h.type,!0);case 31:return B("Activity");default:return""}}function V(h){try{var g="",_=null;do g+=z(h,_),_=h,h=h.return;while(h);return g}catch(N){return`
  7. Error generating stack: `+N.message+`
  8. `+N.stack}}var Q=Object.prototype.hasOwnProperty,Te=t.unstable_scheduleCallback,ke=t.unstable_cancelCallback,Ae=t.unstable_shouldYield,$=t.unstable_requestPaint,L=t.unstable_now,oe=t.unstable_getCurrentPriorityLevel,ce=t.unstable_ImmediatePriority,xe=t.unstable_UserBlockingPriority,ve=t.unstable_NormalPriority,_e=t.unstable_LowPriority,Ie=t.unstable_IdlePriority,We=t.log,ht=t.unstable_setDisableYieldValue,qe=null,me=null;function rt(h){if(typeof We=="function"&&ht(h),me&&typeof me.setStrictMode=="function")try{me.setStrictMode(qe,h)}catch{}}var Xe=Math.clz32?Math.clz32:ae,nt=Math.log,ut=Math.LN2;function ae(h){return h>>>=0,h===0?32:31-(nt(h)/ut|0)|0}var $e=256,ye=262144,Be=4194304;function De(h){var g=h&42;if(g!==0)return g;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function we(h,g,_){var N=h.pendingLanes;if(N===0)return 0;var j=0,O=h.suspendedLanes,J=h.pingedLanes;h=h.warmLanes;var fe=N&134217727;return fe!==0?(N=fe&~O,N!==0?j=De(N):(J&=fe,J!==0?j=De(J):_||(_=fe&~h,_!==0&&(j=De(_))))):(fe=N&~O,fe!==0?j=De(fe):J!==0?j=De(J):_||(_=N&~h,_!==0&&(j=De(_)))),j===0?0:g!==0&&g!==j&&(g&O)===0&&(O=j&-j,_=g&-g,O>=_||O===32&&(_&4194048)!==0)?g:j}function Ve(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function dt(h,g){switch(h){case 1:case 2:case 4:case 8:case 64:return g+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return g+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Tt(){var h=Be;return Be<<=1,(Be&62914560)===0&&(Be=4194304),h}function Ct(h){for(var g=[],_=0;31>_;_++)g.push(h);return g}function Xt(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Pt(h,g,_,N,j,O){var J=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var fe=h.entanglements,je=h.expirationTimes,tt=h.hiddenUpdates;for(_=J&~_;0<_;){var mt=31-Xe(_),xt=1<<mt;fe[mt]=0,je[mt]=-1;var it=tt[mt];if(it!==null)for(tt[mt]=null,mt=0;mt<it.length;mt++){var ot=it[mt];ot!==null&&(ot.lane&=-536870913)}_&=~xt}N!==0&&an(h,N,0),O!==0&&j===0&&h.tag!==0&&(h.suspendedLanes|=O&~(J&~g))}function an(h,g,_){h.pendingLanes|=g,h.suspendedLanes&=~g;var N=31-Xe(g);h.entangledLanes|=g,h.entanglements[N]=h.entanglements[N]|1073741824|_&261930}function bn(h,g){var _=h.entangledLanes|=g;for(h=h.entanglements;_;){var N=31-Xe(_),j=1<<N;j&g|h[N]&g&&(h[N]|=g),_&=~j}}function Kn(h,g){var _=g&-g;return _=(_&42)!==0?1:zn(_),(_&(h.suspendedLanes|g))!==0?0:_}function zn(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Vn(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function _r(){var h=q.p;return h!==0?h:(h=window.event,h===void 0?32:aU(h.type))}function $r(h,g){var _=q.p;try{return q.p=h,g()}finally{q.p=_}}var Tr=Math.random().toString(36).slice(2),hr="__reactFiber$"+Tr,bt="__reactProps$"+Tr,Yt="__reactContainer$"+Tr,yn="__reactEvents$"+Tr,ue="__reactListeners$"+Tr,ze="__reactHandles$"+Tr,Ye="__reactResources$"+Tr,Ke="__reactMarker$"+Tr;function Qe(h){delete h[hr],delete h[bt],delete h[yn],delete h[ue],delete h[ze]}function Nt(h){var g=h[hr];if(g)return g;for(var _=h.parentNode;_;){if(g=_[Yt]||_[hr]){if(_=g.alternate,g.child!==null||_!==null&&_.child!==null)for(h=HF(h);h!==null;){if(_=h[hr])return _;h=HF(h)}return g}h=_,_=h.parentNode}return null}function le(h){if(h=h[hr]||h[Yt]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function Se(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Le(h){var g=h[Ye];return g||(g=h[Ye]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function Oe(h){h[Ke]=!0}var Pe=new Set,ct={};function vt(h,g){Et(h,g),Et(h+"Capture",g)}function Et(h,g){for(ct[h]=g,h=0;h<g.length;h++)Pe.add(g[h])}var _t=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]*$"),yt={},be={};function st(h){return Q.call(be,h)?!0:Q.call(yt,h)?!1:_t.test(h)?be[h]=!0:(yt[h]=!0,!1)}function zt(h,g,_){if(st(g))if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(g);return;case"boolean":var N=g.toLowerCase().slice(0,5);if(N!=="data-"&&N!=="aria-"){h.removeAttribute(g);return}}h.setAttribute(g,""+_)}}function Ot(h,g,_){if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(g);return}h.setAttribute(g,""+_)}}function tn(h,g,_,N){if(N===null)h.removeAttribute(_);else{switch(typeof N){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(g,_,""+N)}}function sn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function $t(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Ht(h,g,_){var N=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof N<"u"&&typeof N.get=="function"&&typeof N.set=="function"){var j=N.get,O=N.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return j.call(this)},set:function(J){_=""+J,O.call(this,J)}}),Object.defineProperty(h,g,{enumerable:N.enumerable}),{getValue:function(){return _},setValue:function(J){_=""+J},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function on(h){if(!h._valueTracker){var g=$t(h)?"checked":"value";h._valueTracker=Ht(h,g,""+h[g])}}function cn(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var _=g.getValue(),N="";return h&&(N=$t(h)?h.checked?"true":"false":h.value),h=N,h!==_?(g.setValue(h),!0):!1}function Hr(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var ti=/[\n"\\]/g;function Gn(h){return h.replace(ti,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function Ro(h,g,_,N,j,O,J,fe){h.name="",J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?h.type=J:h.removeAttribute("type"),g!=null?J==="number"?(g===0&&h.value===""||h.value!=g)&&(h.value=""+sn(g)):h.value!==""+sn(g)&&(h.value=""+sn(g)):J!=="submit"&&J!=="reset"||h.removeAttribute("value"),g!=null?Ii(h,J,sn(g)):_!=null?Ii(h,J,sn(_)):N!=null&&h.removeAttribute("value"),j==null&&O!=null&&(h.defaultChecked=!!O),j!=null&&(h.checked=j&&typeof j!="function"&&typeof j!="symbol"),fe!=null&&typeof fe!="function"&&typeof fe!="symbol"&&typeof fe!="boolean"?h.name=""+sn(fe):h.removeAttribute("name")}function Xn(h,g,_,N,j,O,J,fe){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(h.type=O),g!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||g!=null)){on(h);return}_=_!=null?""+sn(_):"",g=g!=null?""+sn(g):_,fe||g===h.value||(h.value=g),h.defaultValue=g}N=N??j,N=typeof N!="function"&&typeof N!="symbol"&&!!N,h.checked=fe?h.checked:!!N,h.defaultChecked=!!N,J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"&&(h.name=J),on(h)}function Ii(h,g,_){g==="number"&&Hr(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function wi(h,g,_,N){if(h=h.options,g){g={};for(var j=0;j<_.length;j++)g["$"+_[j]]=!0;for(_=0;_<h.length;_++)j=g.hasOwnProperty("$"+h[_].value),h[_].selected!==j&&(h[_].selected=j),j&&N&&(h[_].defaultSelected=!0)}else{for(_=""+sn(_),g=null,j=0;j<h.length;j++){if(h[j].value===_){h[j].selected=!0,N&&(h[j].defaultSelected=!0);return}g!==null||h[j].disabled||(g=h[j])}g!==null&&(g.selected=!0)}}function Fi(h,g,_){if(g!=null&&(g=""+sn(g),g!==h.value&&(h.value=g),_==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=_!=null?""+sn(_):""}function na(h,g,_,N){if(g==null){if(N!=null){if(_!=null)throw Error(r(92));if(K(N)){if(1<N.length)throw Error(r(93));N=N[0]}_=N}_==null&&(_=""),g=_}_=sn(g),h.defaultValue=_,N=h.textContent,N===_&&N!==""&&N!==null&&(h.value=N),on(h)}function cl(h,g){if(g){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=g;return}}h.textContent=g}var Yl=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 PL(h,g,_){var N=g.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?N?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":N?h.setProperty(g,_):typeof _!="number"||_===0||Yl.has(g)?g==="float"?h.cssFloat=_:h[g]=(""+_).trim():h[g]=_+"px"}function RL(h,g,_){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,_!=null){for(var N in _)!_.hasOwnProperty(N)||g!=null&&g.hasOwnProperty(N)||(N.indexOf("--")===0?h.setProperty(N,""):N==="float"?h.cssFloat="":h[N]="");for(var j in g)N=g[j],g.hasOwnProperty(j)&&_[j]!==N&&PL(h,j,N)}else for(var O in g)g.hasOwnProperty(O)&&PL(h,O,g[O])}function hN(h){if(h.indexOf("-")===-1)return!1;switch(h){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var pre=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"]]),gre=/^[\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 Ly(h){return gre.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Ql(){}var fN=null;function mN(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var Qf=null,Zf=null;function DL(h){var g=le(h);if(g&&(h=g.stateNode)){var _=h[bt]||null;e:switch(h=g.stateNode,g.type){case"input":if(Ro(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),g=_.name,_.type==="radio"&&g!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Gn(""+g)+'"][type="radio"]'),g=0;g<_.length;g++){var N=_[g];if(N!==h&&N.form===h.form){var j=N[bt]||null;if(!j)throw Error(r(90));Ro(N,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(g=0;g<_.length;g++)N=_[g],N.form===h.form&&cn(N)}break e;case"textarea":Fi(h,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&wi(h,!!_.multiple,g,!1)}}}var pN=!1;function OL(h,g,_){if(pN)return h(g,_);pN=!0;try{var N=h(g);return N}finally{if(pN=!1,(Qf!==null||Zf!==null)&&(Sv(),Qf&&(g=Qf,h=Zf,Zf=Qf=null,DL(g),h)))for(g=0;g<h.length;g++)DL(h[g])}}function Jg(h,g){var _=h.stateNode;if(_===null)return null;var N=_[bt]||null;if(N===null)return null;_=N[g];e:switch(g){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(N=!N.disabled)||(h=h.type,N=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!N;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,g,typeof _));return _}var Zl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),gN=!1;if(Zl)try{var ex={};Object.defineProperty(ex,"passive",{get:function(){gN=!0}}),window.addEventListener("test",ex,ex),window.removeEventListener("test",ex,ex)}catch{gN=!1}var gu=null,xN=null,Iy=null;function LL(){if(Iy)return Iy;var h,g=xN,_=g.length,N,j="value"in gu?gu.value:gu.textContent,O=j.length;for(h=0;h<_&&g[h]===j[h];h++);var J=_-h;for(N=1;N<=J&&g[_-N]===j[O-N];N++);return Iy=j.slice(h,1<N?1-N:void 0)}function Fy(h){var g=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&g===13&&(h=13)):h=g,h===10&&(h=13),32<=h||h===13?h:0}function Uy(){return!0}function IL(){return!1}function Ya(h){function g(_,N,j,O,J){this._reactName=_,this._targetInst=j,this.type=N,this.nativeEvent=O,this.target=J,this.currentTarget=null;for(var fe in h)h.hasOwnProperty(fe)&&(_=h[fe],this[fe]=_?_(O):O[fe]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?Uy:IL,this.isPropagationStopped=IL,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Uy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Uy)},persist:function(){},isPersistent:Uy}),g}var rh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},zy=Ya(rh),tx=f({},rh,{view:0,detail:0}),xre=Ya(tx),bN,yN,nx,By=f({},tx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_N,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==nx&&(nx&&h.type==="mousemove"?(bN=h.screenX-nx.screenX,yN=h.screenY-nx.screenY):yN=bN=0,nx=h),bN)},movementY:function(h){return"movementY"in h?h.movementY:yN}}),FL=Ya(By),bre=f({},By,{dataTransfer:0}),yre=Ya(bre),vre=f({},tx,{relatedTarget:0}),vN=Ya(vre),_re=f({},rh,{animationName:0,elapsedTime:0,pseudoElement:0}),wre=Ya(_re),Sre=f({},rh,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Mre=Ya(Sre),Nre=f({},rh,{data:0}),UL=Ya(Nre),Ere={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Are={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"},Tre={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Cre(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=Tre[h])?!!g[h]:!1}function _N(){return Cre}var kre=f({},tx,{key:function(h){if(h.key){var g=Ere[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=Fy(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Are[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_N,charCode:function(h){return h.type==="keypress"?Fy(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Fy(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),jre=Ya(kre),Pre=f({},By,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),zL=Ya(Pre),Rre=f({},tx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_N}),Dre=Ya(Rre),Ore=f({},rh,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lre=Ya(Ore),Ire=f({},By,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),Fre=Ya(Ire),Ure=f({},rh,{newState:0,oldState:0}),zre=Ya(Ure),Bre=[9,13,27,32],wN=Zl&&"CompositionEvent"in window,rx=null;Zl&&"documentMode"in document&&(rx=document.documentMode);var $re=Zl&&"TextEvent"in window&&!rx,BL=Zl&&(!wN||rx&&8<rx&&11>=rx),$L=" ",HL=!1;function VL(h,g){switch(h){case"keyup":return Bre.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function GL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Jf=!1;function Hre(h,g){switch(h){case"compositionend":return GL(g);case"keypress":return g.which!==32?null:(HL=!0,$L);case"textInput":return h=g.data,h===$L&&HL?null:h;default:return null}}function Vre(h,g){if(Jf)return h==="compositionend"||!wN&&VL(h,g)?(h=LL(),Iy=xN=gu=null,Jf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1<g.char.length)return g.char;if(g.which)return String.fromCharCode(g.which)}return null;case"compositionend":return BL&&g.locale!=="ko"?null:g.data;default:return null}}var Gre={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 WL(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!Gre[h.type]:g==="textarea"}function qL(h,g,_,N){Qf?Zf?Zf.push(N):Zf=[N]:Qf=N,g=kv(g,"onChange"),0<g.length&&(_=new zy("onChange","change",null,_,N),h.push({event:_,listeners:g}))}var ix=null,ax=null;function Wre(h){CF(h,0)}function $y(h){var g=Se(h);if(cn(g))return h}function KL(h,g){if(h==="change")return g}var XL=!1;if(Zl){var SN;if(Zl){var MN="oninput"in document;if(!MN){var YL=document.createElement("div");YL.setAttribute("oninput","return;"),MN=typeof YL.oninput=="function"}SN=MN}else SN=!1;XL=SN&&(!document.documentMode||9<document.documentMode)}function QL(){ix&&(ix.detachEvent("onpropertychange",ZL),ax=ix=null)}function ZL(h){if(h.propertyName==="value"&&$y(ax)){var g=[];qL(g,ax,h,mN(h)),OL(Wre,g)}}function qre(h,g,_){h==="focusin"?(QL(),ix=g,ax=_,ix.attachEvent("onpropertychange",ZL)):h==="focusout"&&QL()}function Kre(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return $y(ax)}function Xre(h,g){if(h==="click")return $y(g)}function Yre(h,g){if(h==="input"||h==="change")return $y(g)}function Qre(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var vs=typeof Object.is=="function"?Object.is:Qre;function sx(h,g){if(vs(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var _=Object.keys(h),N=Object.keys(g);if(_.length!==N.length)return!1;for(N=0;N<_.length;N++){var j=_[N];if(!Q.call(g,j)||!vs(h[j],g[j]))return!1}return!0}function JL(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function eI(h,g){var _=JL(h);h=0;for(var N;_;){if(_.nodeType===3){if(N=h+_.textContent.length,h<=g&&N>=g)return{node:_,offset:g-h};h=N}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=JL(_)}}function tI(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?tI(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function nI(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=Hr(h.document);g instanceof h.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)h=g.contentWindow;else break;g=Hr(h.document)}return g}function NN(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g&&(g==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||g==="textarea"||h.contentEditable==="true")}var Zre=Zl&&"documentMode"in document&&11>=document.documentMode,em=null,EN=null,ox=null,AN=!1;function rI(h,g,_){var N=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;AN||em==null||em!==Hr(N)||(N=em,"selectionStart"in N&&NN(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),ox&&sx(ox,N)||(ox=N,N=kv(EN,"onSelect"),0<N.length&&(g=new zy("onSelect","select",null,g,_),h.push({event:g,listeners:N}),g.target=em)))}function ih(h,g){var _={};return _[h.toLowerCase()]=g.toLowerCase(),_["Webkit"+h]="webkit"+g,_["Moz"+h]="moz"+g,_}var tm={animationend:ih("Animation","AnimationEnd"),animationiteration:ih("Animation","AnimationIteration"),animationstart:ih("Animation","AnimationStart"),transitionrun:ih("Transition","TransitionRun"),transitionstart:ih("Transition","TransitionStart"),transitioncancel:ih("Transition","TransitionCancel"),transitionend:ih("Transition","TransitionEnd")},TN={},iI={};Zl&&(iI=document.createElement("div").style,"AnimationEvent"in window||(delete tm.animationend.animation,delete tm.animationiteration.animation,delete tm.animationstart.animation),"TransitionEvent"in window||delete tm.transitionend.transition);function ah(h){if(TN[h])return TN[h];if(!tm[h])return h;var g=tm[h],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in iI)return TN[h]=g[_];return h}var aI=ah("animationend"),sI=ah("animationiteration"),oI=ah("animationstart"),Jre=ah("transitionrun"),eie=ah("transitionstart"),tie=ah("transitioncancel"),lI=ah("transitionend"),cI=new Map,CN="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(" ");CN.push("scrollEnd");function Do(h,g){cI.set(h,g),vt(g,[h])}var Hy=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Xs=[],nm=0,kN=0;function Vy(){for(var h=nm,g=kN=nm=0;g<h;){var _=Xs[g];Xs[g++]=null;var N=Xs[g];Xs[g++]=null;var j=Xs[g];Xs[g++]=null;var O=Xs[g];if(Xs[g++]=null,N!==null&&j!==null){var J=N.pending;J===null?j.next=j:(j.next=J.next,J.next=j),N.pending=j}O!==0&&uI(_,j,O)}}function Gy(h,g,_,N){Xs[nm++]=h,Xs[nm++]=g,Xs[nm++]=_,Xs[nm++]=N,kN|=N,h.lanes|=N,h=h.alternate,h!==null&&(h.lanes|=N)}function jN(h,g,_,N){return Gy(h,g,_,N),Wy(h)}function sh(h,g){return Gy(h,null,null,g),Wy(h)}function uI(h,g,_){h.lanes|=_;var N=h.alternate;N!==null&&(N.lanes|=_);for(var j=!1,O=h.return;O!==null;)O.childLanes|=_,N=O.alternate,N!==null&&(N.childLanes|=_),O.tag===22&&(h=O.stateNode,h===null||h._visibility&1||(j=!0)),h=O,O=O.return;return h.tag===3?(O=h.stateNode,j&&g!==null&&(j=31-Xe(_),h=O.hiddenUpdates,N=h[j],N===null?h[j]=[g]:N.push(g),g.lane=_|536870912),O):null}function Wy(h){if(50<Cx)throw Cx=0,zE=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var rm={};function nie(h,g,_,N){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=N,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _s(h,g,_,N){return new nie(h,g,_,N)}function PN(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Jl(h,g){var _=h.alternate;return _===null?(_=_s(h.tag,g,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=g,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,g=h.dependencies,_.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function dI(h,g){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=g,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,g=_.dependencies,h.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),h}function qy(h,g,_,N,j,O){var J=0;if(N=h,typeof h=="function")PN(h)&&(J=1);else if(typeof h=="string")J=oae(h,_,ne.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case T:return h=_s(31,_,g,j),h.elementType=T,h.lanes=O,h;case v:return oh(_.children,j,O,g);case b:J=8,j|=24;break;case y:return h=_s(12,_,g,j|2),h.elementType=y,h.lanes=O,h;case E:return h=_s(13,_,g,j),h.elementType=E,h.lanes=O,h;case k:return h=_s(19,_,g,j),h.elementType=k,h.lanes=O,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case S:J=10;break e;case M:J=9;break e;case A:J=11;break e;case C:J=14;break e;case R:J=16,N=null;break e}J=29,_=Error(r(130,h===null?"null":typeof h,"")),N=null}return g=_s(J,_,g,j),g.elementType=h,g.type=N,g.lanes=O,g}function oh(h,g,_,N){return h=_s(7,h,N,g),h.lanes=_,h}function RN(h,g,_){return h=_s(6,h,null,g),h.lanes=_,h}function hI(h){var g=_s(18,null,null,0);return g.stateNode=h,g}function DN(h,g,_){return g=_s(4,h.children!==null?h.children:[],h.key,g),g.lanes=_,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var fI=new WeakMap;function Ys(h,g){if(typeof h=="object"&&h!==null){var _=fI.get(h);return _!==void 0?_:(g={value:h,source:g,stack:V(g)},fI.set(h,g),g)}return{value:h,source:g,stack:V(g)}}var im=[],am=0,Ky=null,lx=0,Qs=[],Zs=0,xu=null,ul=1,dl="";function ec(h,g){im[am++]=lx,im[am++]=Ky,Ky=h,lx=g}function mI(h,g,_){Qs[Zs++]=ul,Qs[Zs++]=dl,Qs[Zs++]=xu,xu=h;var N=ul;h=dl;var j=32-Xe(N)-1;N&=~(1<<j),_+=1;var O=32-Xe(g)+j;if(30<O){var J=j-j%5;O=(N&(1<<J)-1).toString(32),N>>=J,j-=J,ul=1<<32-Xe(g)+j|_<<j|N,dl=O+h}else ul=1<<O|_<<j|N,dl=h}function ON(h){h.return!==null&&(ec(h,1),mI(h,1,0))}function LN(h){for(;h===Ky;)Ky=im[--am],im[am]=null,lx=im[--am],im[am]=null;for(;h===xu;)xu=Qs[--Zs],Qs[Zs]=null,dl=Qs[--Zs],Qs[Zs]=null,ul=Qs[--Zs],Qs[Zs]=null}function pI(h,g){Qs[Zs++]=ul,Qs[Zs++]=dl,Qs[Zs++]=xu,ul=g.id,dl=g.overflow,xu=h}var ra=null,wr=null,jn=!1,bu=null,Js=!1,IN=Error(r(519));function yu(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw cx(Ys(g,h)),IN}function gI(h){var g=h.stateNode,_=h.type,N=h.memoizedProps;switch(g[hr]=h,g[bt]=N,_){case"dialog":Sn("cancel",g),Sn("close",g);break;case"iframe":case"object":case"embed":Sn("load",g);break;case"video":case"audio":for(_=0;_<jx.length;_++)Sn(jx[_],g);break;case"source":Sn("error",g);break;case"img":case"image":case"link":Sn("error",g),Sn("load",g);break;case"details":Sn("toggle",g);break;case"input":Sn("invalid",g),Xn(g,N.value,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name,!0);break;case"select":Sn("invalid",g);break;case"textarea":Sn("invalid",g),na(g,N.value,N.defaultValue,N.children)}_=N.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||N.suppressHydrationWarning===!0||RF(g.textContent,_)?(N.popover!=null&&(Sn("beforetoggle",g),Sn("toggle",g)),N.onScroll!=null&&Sn("scroll",g),N.onScrollEnd!=null&&Sn("scrollend",g),N.onClick!=null&&(g.onclick=Ql),g=!0):g=!1,g||yu(h,!0)}function xI(h){for(ra=h.return;ra;)switch(ra.tag){case 5:case 31:case 13:Js=!1;return;case 27:case 3:Js=!0;return;default:ra=ra.return}}function sm(h){if(h!==ra)return!1;if(!jn)return xI(h),jn=!0,!1;var g=h.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||tA(h.type,h.memoizedProps)),_=!_),_&&wr&&yu(h),xI(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));wr=$F(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));wr=$F(h)}else g===27?(g=wr,Ru(h.type)?(h=sA,sA=null,wr=h):wr=g):wr=ra?to(h.stateNode.nextSibling):null;return!0}function lh(){wr=ra=null,jn=!1}function FN(){var h=bu;return h!==null&&(es===null?es=h:es.push.apply(es,h),bu=null),h}function cx(h){bu===null?bu=[h]:bu.push(h)}var UN=U(null),ch=null,tc=null;function vu(h,g,_){ee(UN,g._currentValue),g._currentValue=_}function nc(h){h._currentValue=UN.current,G(UN)}function zN(h,g,_){for(;h!==null;){var N=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,N!==null&&(N.childLanes|=g)):N!==null&&(N.childLanes&g)!==g&&(N.childLanes|=g),h===_)break;h=h.return}}function BN(h,g,_,N){var j=h.child;for(j!==null&&(j.return=h);j!==null;){var O=j.dependencies;if(O!==null){var J=j.child;O=O.firstContext;e:for(;O!==null;){var fe=O;O=j;for(var je=0;je<g.length;je++)if(fe.context===g[je]){O.lanes|=_,fe=O.alternate,fe!==null&&(fe.lanes|=_),zN(O.return,_,h),N||(J=null);break e}O=fe.next}}else if(j.tag===18){if(J=j.return,J===null)throw Error(r(341));J.lanes|=_,O=J.alternate,O!==null&&(O.lanes|=_),zN(J,_,h),J=null}else J=j.child;if(J!==null)J.return=j;else for(J=j;J!==null;){if(J===h){J=null;break}if(j=J.sibling,j!==null){j.return=J.return,J=j;break}J=J.return}j=J}}function om(h,g,_,N){h=null;for(var j=g,O=!1;j!==null;){if(!O){if((j.flags&524288)!==0)O=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var J=j.alternate;if(J===null)throw Error(r(387));if(J=J.memoizedProps,J!==null){var fe=j.type;vs(j.pendingProps.value,J.value)||(h!==null?h.push(fe):h=[fe])}}else if(j===he.current){if(J=j.alternate,J===null)throw Error(r(387));J.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(h!==null?h.push(Lx):h=[Lx])}j=j.return}h!==null&&BN(g,h,_,N),g.flags|=262144}function Xy(h){for(h=h.firstContext;h!==null;){if(!vs(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function uh(h){ch=h,tc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function ia(h){return bI(ch,h)}function Yy(h,g){return ch===null&&uh(h),bI(h,g)}function bI(h,g){var _=g._currentValue;if(g={context:g,memoizedValue:_,next:null},tc===null){if(h===null)throw Error(r(308));tc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else tc=tc.next=g;return _}var rie=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(_,N){h.push(N)}};this.abort=function(){g.aborted=!0,h.forEach(function(_){return _()})}},iie=t.unstable_scheduleCallback,aie=t.unstable_NormalPriority,oi={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function $N(){return{controller:new rie,data:new Map,refCount:0}}function ux(h){h.refCount--,h.refCount===0&&iie(aie,function(){h.controller.abort()})}var dx=null,HN=0,lm=0,cm=null;function sie(h,g){if(dx===null){var _=dx=[];HN=0,lm=WE(),cm={status:"pending",value:void 0,then:function(N){_.push(N)}}}return HN++,g.then(yI,yI),g}function yI(){if(--HN===0&&dx!==null){cm!==null&&(cm.status="fulfilled");var h=dx;dx=null,lm=0,cm=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function oie(h,g){var _=[],N={status:"pending",value:null,reason:null,then:function(j){_.push(j)}};return h.then(function(){N.status="fulfilled",N.value=g;for(var j=0;j<_.length;j++)(0,_[j])(g)},function(j){for(N.status="rejected",N.reason=j,j=0;j<_.length;j++)(0,_[j])(void 0)}),N}var vI=Y.S;Y.S=function(h,g){rF=L(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&sie(h,g),vI!==null&&vI(h,g)};var dh=U(null);function VN(){var h=dh.current;return h!==null?h:fr.pooledCache}function Qy(h,g){g===null?ee(dh,dh.current):ee(dh,g.pool)}function _I(){var h=VN();return h===null?null:{parent:oi._currentValue,pool:h}}var um=Error(r(460)),GN=Error(r(474)),Zy=Error(r(542)),Jy={then:function(){}};function wI(h){return h=h.status,h==="fulfilled"||h==="rejected"}function SI(h,g,_){switch(_=h[_],_===void 0?h.push(g):_!==g&&(g.then(Ql,Ql),g=_),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,NI(h),h;default:if(typeof g.status=="string")g.then(Ql,Ql);else{if(h=fr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(N){if(g.status==="pending"){var j=g;j.status="fulfilled",j.value=N}},function(N){if(g.status==="pending"){var j=g;j.status="rejected",j.reason=N}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,NI(h),h}throw fh=g,um}}function hh(h){try{var g=h._init;return g(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(fh=_,um):_}}var fh=null;function MI(){if(fh===null)throw Error(r(459));var h=fh;return fh=null,h}function NI(h){if(h===um||h===Zy)throw Error(r(483))}var dm=null,hx=0;function ev(h){var g=hx;return hx+=1,dm===null&&(dm=[]),SI(dm,h,g)}function fx(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function tv(h,g){throw g.$$typeof===m?Error(r(525)):(h=Object.prototype.toString.call(g),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":h)))}function EI(h){function g(Ge,Fe){if(h){var et=Ge.deletions;et===null?(Ge.deletions=[Fe],Ge.flags|=16):et.push(Fe)}}function _(Ge,Fe){if(!h)return null;for(;Fe!==null;)g(Ge,Fe),Fe=Fe.sibling;return null}function N(Ge){for(var Fe=new Map;Ge!==null;)Ge.key!==null?Fe.set(Ge.key,Ge):Fe.set(Ge.index,Ge),Ge=Ge.sibling;return Fe}function j(Ge,Fe){return Ge=Jl(Ge,Fe),Ge.index=0,Ge.sibling=null,Ge}function O(Ge,Fe,et){return Ge.index=et,h?(et=Ge.alternate,et!==null?(et=et.index,et<Fe?(Ge.flags|=67108866,Fe):et):(Ge.flags|=67108866,Fe)):(Ge.flags|=1048576,Fe)}function J(Ge){return h&&Ge.alternate===null&&(Ge.flags|=67108866),Ge}function fe(Ge,Fe,et,gt){return Fe===null||Fe.tag!==6?(Fe=RN(et,Ge.mode,gt),Fe.return=Ge,Fe):(Fe=j(Fe,et),Fe.return=Ge,Fe)}function je(Ge,Fe,et,gt){var Vt=et.type;return Vt===v?mt(Ge,Fe,et.props.children,gt,et.key):Fe!==null&&(Fe.elementType===Vt||typeof Vt=="object"&&Vt!==null&&Vt.$$typeof===R&&hh(Vt)===Fe.type)?(Fe=j(Fe,et.props),fx(Fe,et),Fe.return=Ge,Fe):(Fe=qy(et.type,et.key,et.props,null,Ge.mode,gt),fx(Fe,et),Fe.return=Ge,Fe)}function tt(Ge,Fe,et,gt){return Fe===null||Fe.tag!==4||Fe.stateNode.containerInfo!==et.containerInfo||Fe.stateNode.implementation!==et.implementation?(Fe=DN(et,Ge.mode,gt),Fe.return=Ge,Fe):(Fe=j(Fe,et.children||[]),Fe.return=Ge,Fe)}function mt(Ge,Fe,et,gt,Vt){return Fe===null||Fe.tag!==7?(Fe=oh(et,Ge.mode,gt,Vt),Fe.return=Ge,Fe):(Fe=j(Fe,et),Fe.return=Ge,Fe)}function xt(Ge,Fe,et){if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number"||typeof Fe=="bigint")return Fe=RN(""+Fe,Ge.mode,et),Fe.return=Ge,Fe;if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case p:return et=qy(Fe.type,Fe.key,Fe.props,null,Ge.mode,et),fx(et,Fe),et.return=Ge,et;case x:return Fe=DN(Fe,Ge.mode,et),Fe.return=Ge,Fe;case R:return Fe=hh(Fe),xt(Ge,Fe,et)}if(K(Fe)||I(Fe))return Fe=oh(Fe,Ge.mode,et,null),Fe.return=Ge,Fe;if(typeof Fe.then=="function")return xt(Ge,ev(Fe),et);if(Fe.$$typeof===S)return xt(Ge,Yy(Ge,Fe),et);tv(Ge,Fe)}return null}function it(Ge,Fe,et,gt){var Vt=Fe!==null?Fe.key:null;if(typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint")return Vt!==null?null:fe(Ge,Fe,""+et,gt);if(typeof et=="object"&&et!==null){switch(et.$$typeof){case p:return et.key===Vt?je(Ge,Fe,et,gt):null;case x:return et.key===Vt?tt(Ge,Fe,et,gt):null;case R:return et=hh(et),it(Ge,Fe,et,gt)}if(K(et)||I(et))return Vt!==null?null:mt(Ge,Fe,et,gt,null);if(typeof et.then=="function")return it(Ge,Fe,ev(et),gt);if(et.$$typeof===S)return it(Ge,Fe,Yy(Ge,et),gt);tv(Ge,et)}return null}function ot(Ge,Fe,et,gt,Vt){if(typeof gt=="string"&&gt!==""||typeof gt=="number"||typeof gt=="bigint")return Ge=Ge.get(et)||null,fe(Fe,Ge,""+gt,Vt);if(typeof gt=="object"&&gt!==null){switch(gt.$$typeof){case p:return Ge=Ge.get(gt.key===null?et:gt.key)||null,je(Fe,Ge,gt,Vt);case x:return Ge=Ge.get(gt.key===null?et:gt.key)||null,tt(Fe,Ge,gt,Vt);case R:return gt=hh(gt),ot(Ge,Fe,et,gt,Vt)}if(K(gt)||I(gt))return Ge=Ge.get(et)||null,mt(Fe,Ge,gt,Vt,null);if(typeof gt.then=="function")return ot(Ge,Fe,et,ev(gt),Vt);if(gt.$$typeof===S)return ot(Ge,Fe,et,Yy(Fe,gt),Vt);tv(Fe,gt)}return null}function Ft(Ge,Fe,et,gt){for(var Vt=null,On=null,Bt=Fe,dn=Fe=0,Cn=null;Bt!==null&&dn<et.length;dn++){Bt.index>dn?(Cn=Bt,Bt=null):Cn=Bt.sibling;var Ln=it(Ge,Bt,et[dn],gt);if(Ln===null){Bt===null&&(Bt=Cn);break}h&&Bt&&Ln.alternate===null&&g(Ge,Bt),Fe=O(Ln,Fe,dn),On===null?Vt=Ln:On.sibling=Ln,On=Ln,Bt=Cn}if(dn===et.length)return _(Ge,Bt),jn&&ec(Ge,dn),Vt;if(Bt===null){for(;dn<et.length;dn++)Bt=xt(Ge,et[dn],gt),Bt!==null&&(Fe=O(Bt,Fe,dn),On===null?Vt=Bt:On.sibling=Bt,On=Bt);return jn&&ec(Ge,dn),Vt}for(Bt=N(Bt);dn<et.length;dn++)Cn=ot(Bt,Ge,dn,et[dn],gt),Cn!==null&&(h&&Cn.alternate!==null&&Bt.delete(Cn.key===null?dn:Cn.key),Fe=O(Cn,Fe,dn),On===null?Vt=Cn:On.sibling=Cn,On=Cn);return h&&Bt.forEach(function(Fu){return g(Ge,Fu)}),jn&&ec(Ge,dn),Vt}function Kt(Ge,Fe,et,gt){if(et==null)throw Error(r(151));for(var Vt=null,On=null,Bt=Fe,dn=Fe=0,Cn=null,Ln=et.next();Bt!==null&&!Ln.done;dn++,Ln=et.next()){Bt.index>dn?(Cn=Bt,Bt=null):Cn=Bt.sibling;var Fu=it(Ge,Bt,Ln.value,gt);if(Fu===null){Bt===null&&(Bt=Cn);break}h&&Bt&&Fu.alternate===null&&g(Ge,Bt),Fe=O(Fu,Fe,dn),On===null?Vt=Fu:On.sibling=Fu,On=Fu,Bt=Cn}if(Ln.done)return _(Ge,Bt),jn&&ec(Ge,dn),Vt;if(Bt===null){for(;!Ln.done;dn++,Ln=et.next())Ln=xt(Ge,Ln.value,gt),Ln!==null&&(Fe=O(Ln,Fe,dn),On===null?Vt=Ln:On.sibling=Ln,On=Ln);return jn&&ec(Ge,dn),Vt}for(Bt=N(Bt);!Ln.done;dn++,Ln=et.next())Ln=ot(Bt,Ge,dn,Ln.value,gt),Ln!==null&&(h&&Ln.alternate!==null&&Bt.delete(Ln.key===null?dn:Ln.key),Fe=O(Ln,Fe,dn),On===null?Vt=Ln:On.sibling=Ln,On=Ln);return h&&Bt.forEach(function(bae){return g(Ge,bae)}),jn&&ec(Ge,dn),Vt}function ir(Ge,Fe,et,gt){if(typeof et=="object"&&et!==null&&et.type===v&&et.key===null&&(et=et.props.children),typeof et=="object"&&et!==null){switch(et.$$typeof){case p:e:{for(var Vt=et.key;Fe!==null;){if(Fe.key===Vt){if(Vt=et.type,Vt===v){if(Fe.tag===7){_(Ge,Fe.sibling),gt=j(Fe,et.props.children),gt.return=Ge,Ge=gt;break e}}else if(Fe.elementType===Vt||typeof Vt=="object"&&Vt!==null&&Vt.$$typeof===R&&hh(Vt)===Fe.type){_(Ge,Fe.sibling),gt=j(Fe,et.props),fx(gt,et),gt.return=Ge,Ge=gt;break e}_(Ge,Fe);break}else g(Ge,Fe);Fe=Fe.sibling}et.type===v?(gt=oh(et.props.children,Ge.mode,gt,et.key),gt.return=Ge,Ge=gt):(gt=qy(et.type,et.key,et.props,null,Ge.mode,gt),fx(gt,et),gt.return=Ge,Ge=gt)}return J(Ge);case x:e:{for(Vt=et.key;Fe!==null;){if(Fe.key===Vt)if(Fe.tag===4&&Fe.stateNode.containerInfo===et.containerInfo&&Fe.stateNode.implementation===et.implementation){_(Ge,Fe.sibling),gt=j(Fe,et.children||[]),gt.return=Ge,Ge=gt;break e}else{_(Ge,Fe);break}else g(Ge,Fe);Fe=Fe.sibling}gt=DN(et,Ge.mode,gt),gt.return=Ge,Ge=gt}return J(Ge);case R:return et=hh(et),ir(Ge,Fe,et,gt)}if(K(et))return Ft(Ge,Fe,et,gt);if(I(et)){if(Vt=I(et),typeof Vt!="function")throw Error(r(150));return et=Vt.call(et),Kt(Ge,Fe,et,gt)}if(typeof et.then=="function")return ir(Ge,Fe,ev(et),gt);if(et.$$typeof===S)return ir(Ge,Fe,Yy(Ge,et),gt);tv(Ge,et)}return typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint"?(et=""+et,Fe!==null&&Fe.tag===6?(_(Ge,Fe.sibling),gt=j(Fe,et),gt.return=Ge,Ge=gt):(_(Ge,Fe),gt=RN(et,Ge.mode,gt),gt.return=Ge,Ge=gt),J(Ge)):_(Ge,Fe)}return function(Ge,Fe,et,gt){try{hx=0;var Vt=ir(Ge,Fe,et,gt);return dm=null,Vt}catch(Bt){if(Bt===um||Bt===Zy)throw Bt;var On=_s(29,Bt,null,Ge.mode);return On.lanes=gt,On.return=Ge,On}finally{}}}var mh=EI(!0),AI=EI(!1),_u=!1;function WN(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qN(h,g){h=h.updateQueue,g.updateQueue===h&&(g.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function wu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Su(h,g,_){var N=h.updateQueue;if(N===null)return null;if(N=N.shared,(Bn&2)!==0){var j=N.pending;return j===null?g.next=g:(g.next=j.next,j.next=g),N.pending=g,g=Wy(h),uI(h,null,_),g}return Gy(h,N,g,_),Wy(h)}function mx(h,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var N=g.lanes;N&=h.pendingLanes,_|=N,g.lanes=_,bn(h,_)}}function KN(h,g){var _=h.updateQueue,N=h.alternate;if(N!==null&&(N=N.updateQueue,_===N)){var j=null,O=null;if(_=_.firstBaseUpdate,_!==null){do{var J={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};O===null?j=O=J:O=O.next=J,_=_.next}while(_!==null);O===null?j=O=g:O=O.next=g}else j=O=g;_={baseState:N.baseState,firstBaseUpdate:j,lastBaseUpdate:O,shared:N.shared,callbacks:N.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=g:h.next=g,_.lastBaseUpdate=g}var XN=!1;function px(){if(XN){var h=cm;if(h!==null)throw h}}function gx(h,g,_,N){XN=!1;var j=h.updateQueue;_u=!1;var O=j.firstBaseUpdate,J=j.lastBaseUpdate,fe=j.shared.pending;if(fe!==null){j.shared.pending=null;var je=fe,tt=je.next;je.next=null,J===null?O=tt:J.next=tt,J=je;var mt=h.alternate;mt!==null&&(mt=mt.updateQueue,fe=mt.lastBaseUpdate,fe!==J&&(fe===null?mt.firstBaseUpdate=tt:fe.next=tt,mt.lastBaseUpdate=je))}if(O!==null){var xt=j.baseState;J=0,mt=tt=je=null,fe=O;do{var it=fe.lane&-536870913,ot=it!==fe.lane;if(ot?(Tn&it)===it:(N&it)===it){it!==0&&it===lm&&(XN=!0),mt!==null&&(mt=mt.next={lane:0,tag:fe.tag,payload:fe.payload,callback:null,next:null});e:{var Ft=h,Kt=fe;it=g;var ir=_;switch(Kt.tag){case 1:if(Ft=Kt.payload,typeof Ft=="function"){xt=Ft.call(ir,xt,it);break e}xt=Ft;break e;case 3:Ft.flags=Ft.flags&-65537|128;case 0:if(Ft=Kt.payload,it=typeof Ft=="function"?Ft.call(ir,xt,it):Ft,it==null)break e;xt=f({},xt,it);break e;case 2:_u=!0}}it=fe.callback,it!==null&&(h.flags|=64,ot&&(h.flags|=8192),ot=j.callbacks,ot===null?j.callbacks=[it]:ot.push(it))}else ot={lane:it,tag:fe.tag,payload:fe.payload,callback:fe.callback,next:null},mt===null?(tt=mt=ot,je=xt):mt=mt.next=ot,J|=it;if(fe=fe.next,fe===null){if(fe=j.shared.pending,fe===null)break;ot=fe,fe=ot.next,ot.next=null,j.lastBaseUpdate=ot,j.shared.pending=null}}while(!0);mt===null&&(je=xt),j.baseState=je,j.firstBaseUpdate=tt,j.lastBaseUpdate=mt,O===null&&(j.shared.lanes=0),Tu|=J,h.lanes=J,h.memoizedState=xt}}function TI(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function CI(h,g){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)TI(_[h],g)}var hm=U(null),nv=U(0);function kI(h,g){h=dc,ee(nv,h),ee(hm,g),dc=h|g.baseLanes}function YN(){ee(nv,dc),ee(hm,hm.current)}function QN(){dc=nv.current,G(hm),G(nv)}var ws=U(null),eo=null;function Mu(h){var g=h.alternate;ee(ni,ni.current&1),ee(ws,h),eo===null&&(g===null||hm.current!==null||g.memoizedState!==null)&&(eo=h)}function ZN(h){ee(ni,ni.current),ee(ws,h),eo===null&&(eo=h)}function jI(h){h.tag===22?(ee(ni,ni.current),ee(ws,h),eo===null&&(eo=h)):Nu()}function Nu(){ee(ni,ni.current),ee(ws,ws.current)}function Ss(h){G(ws),eo===h&&(eo=null),G(ni)}var ni=U(0);function rv(h){for(var g=h;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||iA(_)||aA(_)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var rc=0,un=null,nr=null,li=null,iv=!1,fm=!1,ph=!1,av=0,xx=0,mm=null,lie=0;function Vr(){throw Error(r(321))}function JN(h,g){if(g===null)return!1;for(var _=0;_<g.length&&_<h.length;_++)if(!vs(h[_],g[_]))return!1;return!0}function eE(h,g,_,N,j,O){return rc=O,un=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,Y.H=h===null||h.memoizedState===null?m5:pE,ph=!1,O=_(N,j),ph=!1,fm&&(O=RI(g,_,N,j)),PI(h),O}function PI(h){Y.H=vx;var g=nr!==null&&nr.next!==null;if(rc=0,li=nr=un=null,iv=!1,xx=0,mm=null,g)throw Error(r(300));h===null||ci||(h=h.dependencies,h!==null&&Xy(h)&&(ci=!0))}function RI(h,g,_,N){un=h;var j=0;do{if(fm&&(mm=null),xx=0,fm=!1,25<=j)throw Error(r(301));if(j+=1,li=nr=null,h.updateQueue!=null){var O=h.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}Y.H=p5,O=g(_,N)}while(fm);return O}function cie(){var h=Y.H,g=h.useState()[0];return g=typeof g.then=="function"?bx(g):g,h=h.useState()[0],(nr!==null?nr.memoizedState:null)!==h&&(un.flags|=1024),g}function tE(){var h=av!==0;return av=0,h}function nE(h,g,_){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~_}function rE(h){if(iv){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}iv=!1}rc=0,li=nr=un=null,fm=!1,xx=av=0,mm=null}function Da(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return li===null?un.memoizedState=li=h:li=li.next=h,li}function ri(){if(nr===null){var h=un.alternate;h=h!==null?h.memoizedState:null}else h=nr.next;var g=li===null?un.memoizedState:li.next;if(g!==null)li=g,nr=h;else{if(h===null)throw un.alternate===null?Error(r(467)):Error(r(310));nr=h,h={memoizedState:nr.memoizedState,baseState:nr.baseState,baseQueue:nr.baseQueue,queue:nr.queue,next:null},li===null?un.memoizedState=li=h:li=li.next=h}return li}function sv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function bx(h){var g=xx;return xx+=1,mm===null&&(mm=[]),h=SI(mm,h,g),g=un,(li===null?g.memoizedState:li.next)===null&&(g=g.alternate,Y.H=g===null||g.memoizedState===null?m5:pE),h}function ov(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return bx(h);if(h.$$typeof===S)return ia(h)}throw Error(r(438,String(h)))}function iE(h){var g=null,_=un.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var N=un.alternate;N!==null&&(N=N.updateQueue,N!==null&&(N=N.memoCache,N!=null&&(g={data:N.data.map(function(j){return j.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),_===null&&(_=sv(),un.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(h),N=0;N<h;N++)_[N]=P;return g.index++,_}function ic(h,g){return typeof g=="function"?g(h):g}function lv(h){var g=ri();return aE(g,nr,h)}function aE(h,g,_){var N=h.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=_;var j=h.baseQueue,O=N.pending;if(O!==null){if(j!==null){var J=j.next;j.next=O.next,O.next=J}g.baseQueue=j=O,N.pending=null}if(O=h.baseState,j===null)h.memoizedState=O;else{g=j.next;var fe=J=null,je=null,tt=g,mt=!1;do{var xt=tt.lane&-536870913;if(xt!==tt.lane?(Tn&xt)===xt:(rc&xt)===xt){var it=tt.revertLane;if(it===0)je!==null&&(je=je.next={lane:0,revertLane:0,gesture:null,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null}),xt===lm&&(mt=!0);else if((rc&it)===it){tt=tt.next,it===lm&&(mt=!0);continue}else xt={lane:0,revertLane:tt.revertLane,gesture:null,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null},je===null?(fe=je=xt,J=O):je=je.next=xt,un.lanes|=it,Tu|=it;xt=tt.action,ph&&_(O,xt),O=tt.hasEagerState?tt.eagerState:_(O,xt)}else it={lane:xt,revertLane:tt.revertLane,gesture:tt.gesture,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null},je===null?(fe=je=it,J=O):je=je.next=it,un.lanes|=xt,Tu|=xt;tt=tt.next}while(tt!==null&&tt!==g);if(je===null?J=O:je.next=fe,!vs(O,h.memoizedState)&&(ci=!0,mt&&(_=cm,_!==null)))throw _;h.memoizedState=O,h.baseState=J,h.baseQueue=je,N.lastRenderedState=O}return j===null&&(N.lanes=0),[h.memoizedState,N.dispatch]}function sE(h){var g=ri(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var N=_.dispatch,j=_.pending,O=g.memoizedState;if(j!==null){_.pending=null;var J=j=j.next;do O=h(O,J.action),J=J.next;while(J!==j);vs(O,g.memoizedState)||(ci=!0),g.memoizedState=O,g.baseQueue===null&&(g.baseState=O),_.lastRenderedState=O}return[O,N]}function DI(h,g,_){var N=un,j=ri(),O=jn;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=g();var J=!vs((nr||j).memoizedState,_);if(J&&(j.memoizedState=_,ci=!0),j=j.queue,cE(II.bind(null,N,j,h),[h]),j.getSnapshot!==g||J||li!==null&&li.memoizedState.tag&1){if(N.flags|=2048,pm(9,{destroy:void 0},LI.bind(null,N,j,_,g),null),fr===null)throw Error(r(349));O||(rc&127)!==0||OI(N,g,_)}return _}function OI(h,g,_){h.flags|=16384,h={getSnapshot:g,value:_},g=un.updateQueue,g===null?(g=sv(),un.updateQueue=g,g.stores=[h]):(_=g.stores,_===null?g.stores=[h]:_.push(h))}function LI(h,g,_,N){g.value=_,g.getSnapshot=N,FI(g)&&UI(h)}function II(h,g,_){return _(function(){FI(g)&&UI(h)})}function FI(h){var g=h.getSnapshot;h=h.value;try{var _=g();return!vs(h,_)}catch{return!0}}function UI(h){var g=sh(h,2);g!==null&&ts(g,h,2)}function oE(h){var g=Da();if(typeof h=="function"){var _=h;if(h=_(),ph){rt(!0);try{_()}finally{rt(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ic,lastRenderedState:h},g}function zI(h,g,_,N){return h.baseState=_,aE(h,nr,typeof N=="function"?N:ic)}function uie(h,g,_,N,j){if(dv(h))throw Error(r(485));if(h=g.action,h!==null){var O={payload:j,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(J){O.listeners.push(J)}};Y.T!==null?_(!0):O.isTransition=!1,N(O),_=g.pending,_===null?(O.next=g.pending=O,BI(g,O)):(O.next=_.next,g.pending=_.next=O)}}function BI(h,g){var _=g.action,N=g.payload,j=h.state;if(g.isTransition){var O=Y.T,J={};Y.T=J;try{var fe=_(j,N),je=Y.S;je!==null&&je(J,fe),$I(h,g,fe)}catch(tt){lE(h,g,tt)}finally{O!==null&&J.types!==null&&(O.types=J.types),Y.T=O}}else try{O=_(j,N),$I(h,g,O)}catch(tt){lE(h,g,tt)}}function $I(h,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(N){HI(h,g,N)},function(N){return lE(h,g,N)}):HI(h,g,_)}function HI(h,g,_){g.status="fulfilled",g.value=_,VI(g),h.state=_,g=h.pending,g!==null&&(_=g.next,_===g?h.pending=null:(_=_.next,g.next=_,BI(h,_)))}function lE(h,g,_){var N=h.pending;if(h.pending=null,N!==null){N=N.next;do g.status="rejected",g.reason=_,VI(g),g=g.next;while(g!==N)}h.action=null}function VI(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function GI(h,g){return g}function WI(h,g){if(jn){var _=fr.formState;if(_!==null){e:{var N=un;if(jn){if(wr){t:{for(var j=wr,O=Js;j.nodeType!==8;){if(!O){j=null;break t}if(j=to(j.nextSibling),j===null){j=null;break t}}O=j.data,j=O==="F!"||O==="F"?j:null}if(j){wr=to(j.nextSibling),N=j.data==="F!";break e}}yu(N)}N=!1}N&&(g=_[0])}}return _=Da(),_.memoizedState=_.baseState=g,N={pending:null,lanes:0,dispatch:null,lastRenderedReducer:GI,lastRenderedState:g},_.queue=N,_=d5.bind(null,un,N),N.dispatch=_,N=oE(!1),O=mE.bind(null,un,!1,N.queue),N=Da(),j={state:g,dispatch:null,action:h,pending:null},N.queue=j,_=uie.bind(null,un,j,O,_),j.dispatch=_,N.memoizedState=h,[g,_,!1]}function qI(h){var g=ri();return KI(g,nr,h)}function KI(h,g,_){if(g=aE(h,g,GI)[0],h=lv(ic)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var N=bx(g)}catch(J){throw J===um?Zy:J}else N=g;g=ri();var j=g.queue,O=j.dispatch;return _!==g.memoizedState&&(un.flags|=2048,pm(9,{destroy:void 0},die.bind(null,j,_),null)),[N,O,h]}function die(h,g){h.action=g}function XI(h){var g=ri(),_=nr;if(_!==null)return KI(g,_,h);ri(),g=g.memoizedState,_=ri();var N=_.queue.dispatch;return _.memoizedState=h,[g,N,!1]}function pm(h,g,_,N){return h={tag:h,create:_,deps:N,inst:g,next:null},g=un.updateQueue,g===null&&(g=sv(),un.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=h.next=h:(N=_.next,_.next=h,h.next=N,g.lastEffect=h),h}function YI(){return ri().memoizedState}function cv(h,g,_,N){var j=Da();un.flags|=h,j.memoizedState=pm(1|g,{destroy:void 0},_,N===void 0?null:N)}function uv(h,g,_,N){var j=ri();N=N===void 0?null:N;var O=j.memoizedState.inst;nr!==null&&N!==null&&JN(N,nr.memoizedState.deps)?j.memoizedState=pm(g,O,_,N):(un.flags|=h,j.memoizedState=pm(1|g,O,_,N))}function QI(h,g){cv(8390656,8,h,g)}function cE(h,g){uv(2048,8,h,g)}function hie(h){un.flags|=4;var g=un.updateQueue;if(g===null)g=sv(),un.updateQueue=g,g.events=[h];else{var _=g.events;_===null?g.events=[h]:_.push(h)}}function ZI(h){var g=ri().memoizedState;return hie({ref:g,nextImpl:h}),function(){if((Bn&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function JI(h,g){return uv(4,2,h,g)}function e5(h,g){return uv(4,4,h,g)}function t5(h,g){if(typeof g=="function"){h=h();var _=g(h);return function(){typeof _=="function"?_():g(null)}}if(g!=null)return h=h(),g.current=h,function(){g.current=null}}function n5(h,g,_){_=_!=null?_.concat([h]):null,uv(4,4,t5.bind(null,g,h),_)}function uE(){}function r5(h,g){var _=ri();g=g===void 0?null:g;var N=_.memoizedState;return g!==null&&JN(g,N[1])?N[0]:(_.memoizedState=[h,g],h)}function i5(h,g){var _=ri();g=g===void 0?null:g;var N=_.memoizedState;if(g!==null&&JN(g,N[1]))return N[0];if(N=h(),ph){rt(!0);try{h()}finally{rt(!1)}}return _.memoizedState=[N,g],N}function dE(h,g,_){return _===void 0||(rc&1073741824)!==0&&(Tn&261930)===0?h.memoizedState=g:(h.memoizedState=_,h=aF(),un.lanes|=h,Tu|=h,_)}function a5(h,g,_,N){return vs(_,g)?_:hm.current!==null?(h=dE(h,_,N),vs(h,g)||(ci=!0),h):(rc&42)===0||(rc&1073741824)!==0&&(Tn&261930)===0?(ci=!0,h.memoizedState=_):(h=aF(),un.lanes|=h,Tu|=h,g)}function s5(h,g,_,N,j){var O=q.p;q.p=O!==0&&8>O?O:8;var J=Y.T,fe={};Y.T=fe,mE(h,!1,g,_);try{var je=j(),tt=Y.S;if(tt!==null&&tt(fe,je),je!==null&&typeof je=="object"&&typeof je.then=="function"){var mt=oie(je,N);yx(h,g,mt,Es(h))}else yx(h,g,N,Es(h))}catch(xt){yx(h,g,{then:function(){},status:"rejected",reason:xt},Es())}finally{q.p=O,J!==null&&fe.types!==null&&(J.types=fe.types),Y.T=J}}function fie(){}function hE(h,g,_,N){if(h.tag!==5)throw Error(r(476));var j=o5(h).queue;s5(h,j,g,Z,_===null?fie:function(){return l5(h),_(N)})}function o5(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ic,lastRenderedState:Z},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ic,lastRenderedState:_},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function l5(h){var g=o5(h);g.next===null&&(g=h.alternate.memoizedState),yx(h,g.next.queue,{},Es())}function fE(){return ia(Lx)}function c5(){return ri().memoizedState}function u5(){return ri().memoizedState}function mie(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var _=Es();h=wu(_);var N=Su(g,h,_);N!==null&&(ts(N,g,_),mx(N,g,_)),g={cache:$N()},h.payload=g;return}g=g.return}}function pie(h,g,_){var N=Es();_={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},dv(h)?h5(g,_):(_=jN(h,g,_,N),_!==null&&(ts(_,h,N),f5(_,g,N)))}function d5(h,g,_){var N=Es();yx(h,g,_,N)}function yx(h,g,_,N){var j={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(dv(h))h5(g,j);else{var O=h.alternate;if(h.lanes===0&&(O===null||O.lanes===0)&&(O=g.lastRenderedReducer,O!==null))try{var J=g.lastRenderedState,fe=O(J,_);if(j.hasEagerState=!0,j.eagerState=fe,vs(fe,J))return Gy(h,g,j,0),fr===null&&Vy(),!1}catch{}finally{}if(_=jN(h,g,j,N),_!==null)return ts(_,h,N),f5(_,g,N),!0}return!1}function mE(h,g,_,N){if(N={lane:2,revertLane:WE(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},dv(h)){if(g)throw Error(r(479))}else g=jN(h,_,N,2),g!==null&&ts(g,h,2)}function dv(h){var g=h.alternate;return h===un||g!==null&&g===un}function h5(h,g){fm=iv=!0;var _=h.pending;_===null?g.next=g:(g.next=_.next,_.next=g),h.pending=g}function f5(h,g,_){if((_&4194048)!==0){var N=g.lanes;N&=h.pendingLanes,_|=N,g.lanes=_,bn(h,_)}}var vx={readContext:ia,use:ov,useCallback:Vr,useContext:Vr,useEffect:Vr,useImperativeHandle:Vr,useLayoutEffect:Vr,useInsertionEffect:Vr,useMemo:Vr,useReducer:Vr,useRef:Vr,useState:Vr,useDebugValue:Vr,useDeferredValue:Vr,useTransition:Vr,useSyncExternalStore:Vr,useId:Vr,useHostTransitionStatus:Vr,useFormState:Vr,useActionState:Vr,useOptimistic:Vr,useMemoCache:Vr,useCacheRefresh:Vr};vx.useEffectEvent=Vr;var m5={readContext:ia,use:ov,useCallback:function(h,g){return Da().memoizedState=[h,g===void 0?null:g],h},useContext:ia,useEffect:QI,useImperativeHandle:function(h,g,_){_=_!=null?_.concat([h]):null,cv(4194308,4,t5.bind(null,g,h),_)},useLayoutEffect:function(h,g){return cv(4194308,4,h,g)},useInsertionEffect:function(h,g){cv(4,2,h,g)},useMemo:function(h,g){var _=Da();g=g===void 0?null:g;var N=h();if(ph){rt(!0);try{h()}finally{rt(!1)}}return _.memoizedState=[N,g],N},useReducer:function(h,g,_){var N=Da();if(_!==void 0){var j=_(g);if(ph){rt(!0);try{_(g)}finally{rt(!1)}}}else j=g;return N.memoizedState=N.baseState=j,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:j},N.queue=h,h=h.dispatch=pie.bind(null,un,h),[N.memoizedState,h]},useRef:function(h){var g=Da();return h={current:h},g.memoizedState=h},useState:function(h){h=oE(h);var g=h.queue,_=d5.bind(null,un,g);return g.dispatch=_,[h.memoizedState,_]},useDebugValue:uE,useDeferredValue:function(h,g){var _=Da();return dE(_,h,g)},useTransition:function(){var h=oE(!1);return h=s5.bind(null,un,h.queue,!0,!1),Da().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,_){var N=un,j=Da();if(jn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),fr===null)throw Error(r(349));(Tn&127)!==0||OI(N,g,_)}j.memoizedState=_;var O={value:_,getSnapshot:g};return j.queue=O,QI(II.bind(null,N,O,h),[h]),N.flags|=2048,pm(9,{destroy:void 0},LI.bind(null,N,O,_,g),null),_},useId:function(){var h=Da(),g=fr.identifierPrefix;if(jn){var _=dl,N=ul;_=(N&~(1<<32-Xe(N)-1)).toString(32)+_,g="_"+g+"R_"+_,_=av++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=lie++,g="_"+g+"r_"+_.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:fE,useFormState:WI,useActionState:WI,useOptimistic:function(h){var g=Da();g.memoizedState=g.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=mE.bind(null,un,!0,_),_.dispatch=g,[h,g]},useMemoCache:iE,useCacheRefresh:function(){return Da().memoizedState=mie.bind(null,un)},useEffectEvent:function(h){var g=Da(),_={impl:h};return g.memoizedState=_,function(){if((Bn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},pE={readContext:ia,use:ov,useCallback:r5,useContext:ia,useEffect:cE,useImperativeHandle:n5,useInsertionEffect:JI,useLayoutEffect:e5,useMemo:i5,useReducer:lv,useRef:YI,useState:function(){return lv(ic)},useDebugValue:uE,useDeferredValue:function(h,g){var _=ri();return a5(_,nr.memoizedState,h,g)},useTransition:function(){var h=lv(ic)[0],g=ri().memoizedState;return[typeof h=="boolean"?h:bx(h),g]},useSyncExternalStore:DI,useId:c5,useHostTransitionStatus:fE,useFormState:qI,useActionState:qI,useOptimistic:function(h,g){var _=ri();return zI(_,nr,h,g)},useMemoCache:iE,useCacheRefresh:u5};pE.useEffectEvent=ZI;var p5={readContext:ia,use:ov,useCallback:r5,useContext:ia,useEffect:cE,useImperativeHandle:n5,useInsertionEffect:JI,useLayoutEffect:e5,useMemo:i5,useReducer:sE,useRef:YI,useState:function(){return sE(ic)},useDebugValue:uE,useDeferredValue:function(h,g){var _=ri();return nr===null?dE(_,h,g):a5(_,nr.memoizedState,h,g)},useTransition:function(){var h=sE(ic)[0],g=ri().memoizedState;return[typeof h=="boolean"?h:bx(h),g]},useSyncExternalStore:DI,useId:c5,useHostTransitionStatus:fE,useFormState:XI,useActionState:XI,useOptimistic:function(h,g){var _=ri();return nr!==null?zI(_,nr,h,g):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:iE,useCacheRefresh:u5};p5.useEffectEvent=ZI;function gE(h,g,_,N){g=h.memoizedState,_=_(N,g),_=_==null?g:f({},g,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var xE={enqueueSetState:function(h,g,_){h=h._reactInternals;var N=Es(),j=wu(N);j.payload=g,_!=null&&(j.callback=_),g=Su(h,j,N),g!==null&&(ts(g,h,N),mx(g,h,N))},enqueueReplaceState:function(h,g,_){h=h._reactInternals;var N=Es(),j=wu(N);j.tag=1,j.payload=g,_!=null&&(j.callback=_),g=Su(h,j,N),g!==null&&(ts(g,h,N),mx(g,h,N))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var _=Es(),N=wu(_);N.tag=2,g!=null&&(N.callback=g),g=Su(h,N,_),g!==null&&(ts(g,h,_),mx(g,h,_))}};function g5(h,g,_,N,j,O,J){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(N,O,J):g.prototype&&g.prototype.isPureReactComponent?!sx(_,N)||!sx(j,O):!0}function x5(h,g,_,N){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,N),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,N),g.state!==h&&xE.enqueueReplaceState(g,g.state,null)}function gh(h,g){var _=g;if("ref"in g){_={};for(var N in g)N!=="ref"&&(_[N]=g[N])}if(h=h.defaultProps){_===g&&(_=f({},_));for(var j in h)_[j]===void 0&&(_[j]=h[j])}return _}function b5(h){Hy(h)}function y5(h){console.error(h)}function v5(h){Hy(h)}function hv(h,g){try{var _=h.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(N){setTimeout(function(){throw N})}}function _5(h,g,_){try{var N=h.onCaughtError;N(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function bE(h,g,_){return _=wu(_),_.tag=3,_.payload={element:null},_.callback=function(){hv(h,g)},_}function w5(h){return h=wu(h),h.tag=3,h}function S5(h,g,_,N){var j=_.type.getDerivedStateFromError;if(typeof j=="function"){var O=N.value;h.payload=function(){return j(O)},h.callback=function(){_5(g,_,N)}}var J=_.stateNode;J!==null&&typeof J.componentDidCatch=="function"&&(h.callback=function(){_5(g,_,N),typeof j!="function"&&(Cu===null?Cu=new Set([this]):Cu.add(this));var fe=N.stack;this.componentDidCatch(N.value,{componentStack:fe!==null?fe:""})})}function gie(h,g,_,N,j){if(_.flags|=32768,N!==null&&typeof N=="object"&&typeof N.then=="function"){if(g=_.alternate,g!==null&&om(g,_,j,!0),_=ws.current,_!==null){switch(_.tag){case 31:case 13:return eo===null?Mv():_.alternate===null&&Gr===0&&(Gr=3),_.flags&=-257,_.flags|=65536,_.lanes=j,N===Jy?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([N]):g.add(N),HE(h,N,j)),!1;case 22:return _.flags|=65536,N===Jy?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([N])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([N]):_.add(N)),HE(h,N,j)),!1}throw Error(r(435,_.tag))}return HE(h,N,j),Mv(),!1}if(jn)return g=ws.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=j,N!==IN&&(h=Error(r(422),{cause:N}),cx(Ys(h,_)))):(N!==IN&&(g=Error(r(423),{cause:N}),cx(Ys(g,_))),h=h.current.alternate,h.flags|=65536,j&=-j,h.lanes|=j,N=Ys(N,_),j=bE(h.stateNode,N,j),KN(h,j),Gr!==4&&(Gr=2)),!1;var O=Error(r(520),{cause:N});if(O=Ys(O,_),Tx===null?Tx=[O]:Tx.push(O),Gr!==4&&(Gr=2),g===null)return!0;N=Ys(N,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,h=j&-j,_.lanes|=h,h=bE(_.stateNode,N,h),KN(_,h),!1;case 1:if(g=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Cu===null||!Cu.has(O))))return _.flags|=65536,j&=-j,_.lanes|=j,j=w5(j),S5(j,h,_,N),KN(_,j),!1}_=_.return}while(_!==null);return!1}var yE=Error(r(461)),ci=!1;function aa(h,g,_,N){g.child=h===null?AI(g,null,_,N):mh(g,h.child,_,N)}function M5(h,g,_,N,j){_=_.render;var O=g.ref;if("ref"in N){var J={};for(var fe in N)fe!=="ref"&&(J[fe]=N[fe])}else J=N;return uh(g),N=eE(h,g,_,J,O,j),fe=tE(),h!==null&&!ci?(nE(h,g,j),ac(h,g,j)):(jn&&fe&&ON(g),g.flags|=1,aa(h,g,N,j),g.child)}function N5(h,g,_,N,j){if(h===null){var O=_.type;return typeof O=="function"&&!PN(O)&&O.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=O,E5(h,g,O,N,j)):(h=qy(_.type,null,N,g,g.mode,j),h.ref=g.ref,h.return=g,g.child=h)}if(O=h.child,!AE(h,j)){var J=O.memoizedProps;if(_=_.compare,_=_!==null?_:sx,_(J,N)&&h.ref===g.ref)return ac(h,g,j)}return g.flags|=1,h=Jl(O,N),h.ref=g.ref,h.return=g,g.child=h}function E5(h,g,_,N,j){if(h!==null){var O=h.memoizedProps;if(sx(O,N)&&h.ref===g.ref)if(ci=!1,g.pendingProps=N=O,AE(h,j))(h.flags&131072)!==0&&(ci=!0);else return g.lanes=h.lanes,ac(h,g,j)}return vE(h,g,_,N,j)}function A5(h,g,_,N){var j=N.children,O=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),N.mode==="hidden"){if((g.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,h!==null){for(N=g.child=h.child,j=0;N!==null;)j=j|N.lanes|N.childLanes,N=N.sibling;N=j&~O}else N=0,g.child=null;return T5(h,g,O,_,N)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&Qy(g,O!==null?O.cachePool:null),O!==null?kI(g,O):YN(),jI(g);else return N=g.lanes=536870912,T5(h,g,O!==null?O.baseLanes|_:_,_,N)}else O!==null?(Qy(g,O.cachePool),kI(g,O),Nu(),g.memoizedState=null):(h!==null&&Qy(g,null),YN(),Nu());return aa(h,g,j,_),g.child}function _x(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function T5(h,g,_,N,j){var O=VN();return O=O===null?null:{parent:oi._currentValue,pool:O},g.memoizedState={baseLanes:_,cachePool:O},h!==null&&Qy(g,null),YN(),jI(g),h!==null&&om(h,g,N,!0),g.childLanes=j,null}function fv(h,g){return g=pv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function C5(h,g,_){return mh(g,h.child,null,_),h=fv(g,g.pendingProps),h.flags|=2,Ss(g),g.memoizedState=null,h}function xie(h,g,_){var N=g.pendingProps,j=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(jn){if(N.mode==="hidden")return h=fv(g,N),g.lanes=536870912,_x(null,h);if(ZN(g),(h=wr)?(h=BF(h,Js),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:xu!==null?{id:ul,overflow:dl}:null,retryLane:536870912,hydrationErrors:null},_=hI(h),_.return=g,g.child=_,ra=g,wr=null)):h=null,h===null)throw yu(g);return g.lanes=536870912,null}return fv(g,N)}var O=h.memoizedState;if(O!==null){var J=O.dehydrated;if(ZN(g),j)if(g.flags&256)g.flags&=-257,g=C5(h,g,_);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(ci||om(h,g,_,!1),j=(_&h.childLanes)!==0,ci||j){if(N=fr,N!==null&&(J=Kn(N,_),J!==0&&J!==O.retryLane))throw O.retryLane=J,sh(h,J),ts(N,h,J),yE;Mv(),g=C5(h,g,_)}else h=O.treeContext,wr=to(J.nextSibling),ra=g,jn=!0,bu=null,Js=!1,h!==null&&pI(g,h),g=fv(g,N),g.flags|=4096;return g}return h=Jl(h.child,{mode:N.mode,children:N.children}),h.ref=g.ref,g.child=h,h.return=g,h}function mv(h,g){var _=g.ref;if(_===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(g.flags|=4194816)}}function vE(h,g,_,N,j){return uh(g),_=eE(h,g,_,N,void 0,j),N=tE(),h!==null&&!ci?(nE(h,g,j),ac(h,g,j)):(jn&&N&&ON(g),g.flags|=1,aa(h,g,_,j),g.child)}function k5(h,g,_,N,j,O){return uh(g),g.updateQueue=null,_=RI(g,N,_,j),PI(h),N=tE(),h!==null&&!ci?(nE(h,g,O),ac(h,g,O)):(jn&&N&&ON(g),g.flags|=1,aa(h,g,_,O),g.child)}function j5(h,g,_,N,j){if(uh(g),g.stateNode===null){var O=rm,J=_.contextType;typeof J=="object"&&J!==null&&(O=ia(J)),O=new _(N,O),g.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=xE,g.stateNode=O,O._reactInternals=g,O=g.stateNode,O.props=N,O.state=g.memoizedState,O.refs={},WN(g),J=_.contextType,O.context=typeof J=="object"&&J!==null?ia(J):rm,O.state=g.memoizedState,J=_.getDerivedStateFromProps,typeof J=="function"&&(gE(g,_,J,N),O.state=g.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(J=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),J!==O.state&&xE.enqueueReplaceState(O,O.state,null),gx(g,N,O,j),px(),O.state=g.memoizedState),typeof O.componentDidMount=="function"&&(g.flags|=4194308),N=!0}else if(h===null){O=g.stateNode;var fe=g.memoizedProps,je=gh(_,fe);O.props=je;var tt=O.context,mt=_.contextType;J=rm,typeof mt=="object"&&mt!==null&&(J=ia(mt));var xt=_.getDerivedStateFromProps;mt=typeof xt=="function"||typeof O.getSnapshotBeforeUpdate=="function",fe=g.pendingProps!==fe,mt||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(fe||tt!==J)&&x5(g,O,N,J),_u=!1;var it=g.memoizedState;O.state=it,gx(g,N,O,j),px(),tt=g.memoizedState,fe||it!==tt||_u?(typeof xt=="function"&&(gE(g,_,xt,N),tt=g.memoizedState),(je=_u||g5(g,_,je,N,it,tt,J))?(mt||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=N,g.memoizedState=tt),O.props=N,O.state=tt,O.context=J,N=je):(typeof O.componentDidMount=="function"&&(g.flags|=4194308),N=!1)}else{O=g.stateNode,qN(h,g),J=g.memoizedProps,mt=gh(_,J),O.props=mt,xt=g.pendingProps,it=O.context,tt=_.contextType,je=rm,typeof tt=="object"&&tt!==null&&(je=ia(tt)),fe=_.getDerivedStateFromProps,(tt=typeof fe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(J!==xt||it!==je)&&x5(g,O,N,je),_u=!1,it=g.memoizedState,O.state=it,gx(g,N,O,j),px();var ot=g.memoizedState;J!==xt||it!==ot||_u||h!==null&&h.dependencies!==null&&Xy(h.dependencies)?(typeof fe=="function"&&(gE(g,_,fe,N),ot=g.memoizedState),(mt=_u||g5(g,_,mt,N,it,ot,je)||h!==null&&h.dependencies!==null&&Xy(h.dependencies))?(tt||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(N,ot,je),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(N,ot,je)),typeof O.componentDidUpdate=="function"&&(g.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof O.componentDidUpdate!="function"||J===h.memoizedProps&&it===h.memoizedState||(g.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&it===h.memoizedState||(g.flags|=1024),g.memoizedProps=N,g.memoizedState=ot),O.props=N,O.state=ot,O.context=je,N=mt):(typeof O.componentDidUpdate!="function"||J===h.memoizedProps&&it===h.memoizedState||(g.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&it===h.memoizedState||(g.flags|=1024),N=!1)}return O=N,mv(h,g),N=(g.flags&128)!==0,O||N?(O=g.stateNode,_=N&&typeof _.getDerivedStateFromError!="function"?null:O.render(),g.flags|=1,h!==null&&N?(g.child=mh(g,h.child,null,j),g.child=mh(g,null,_,j)):aa(h,g,_,j),g.memoizedState=O.state,h=g.child):h=ac(h,g,j),h}function P5(h,g,_,N){return lh(),g.flags|=256,aa(h,g,_,N),g.child}var _E={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function wE(h){return{baseLanes:h,cachePool:_I()}}function SE(h,g,_){return h=h!==null?h.childLanes&~_:0,g&&(h|=Ns),h}function R5(h,g,_){var N=g.pendingProps,j=!1,O=(g.flags&128)!==0,J;if((J=O)||(J=h!==null&&h.memoizedState===null?!1:(ni.current&2)!==0),J&&(j=!0,g.flags&=-129),J=(g.flags&32)!==0,g.flags&=-33,h===null){if(jn){if(j?Mu(g):Nu(),(h=wr)?(h=BF(h,Js),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:xu!==null?{id:ul,overflow:dl}:null,retryLane:536870912,hydrationErrors:null},_=hI(h),_.return=g,g.child=_,ra=g,wr=null)):h=null,h===null)throw yu(g);return aA(h)?g.lanes=32:g.lanes=536870912,null}var fe=N.children;return N=N.fallback,j?(Nu(),j=g.mode,fe=pv({mode:"hidden",children:fe},j),N=oh(N,j,_,null),fe.return=g,N.return=g,fe.sibling=N,g.child=fe,N=g.child,N.memoizedState=wE(_),N.childLanes=SE(h,J,_),g.memoizedState=_E,_x(null,N)):(Mu(g),ME(g,fe))}var je=h.memoizedState;if(je!==null&&(fe=je.dehydrated,fe!==null)){if(O)g.flags&256?(Mu(g),g.flags&=-257,g=NE(h,g,_)):g.memoizedState!==null?(Nu(),g.child=h.child,g.flags|=128,g=null):(Nu(),fe=N.fallback,j=g.mode,N=pv({mode:"visible",children:N.children},j),fe=oh(fe,j,_,null),fe.flags|=2,N.return=g,fe.return=g,N.sibling=fe,g.child=N,mh(g,h.child,null,_),N=g.child,N.memoizedState=wE(_),N.childLanes=SE(h,J,_),g.memoizedState=_E,g=_x(null,N));else if(Mu(g),aA(fe)){if(J=fe.nextSibling&&fe.nextSibling.dataset,J)var tt=J.dgst;J=tt,N=Error(r(419)),N.stack="",N.digest=J,cx({value:N,source:null,stack:null}),g=NE(h,g,_)}else if(ci||om(h,g,_,!1),J=(_&h.childLanes)!==0,ci||J){if(J=fr,J!==null&&(N=Kn(J,_),N!==0&&N!==je.retryLane))throw je.retryLane=N,sh(h,N),ts(J,h,N),yE;iA(fe)||Mv(),g=NE(h,g,_)}else iA(fe)?(g.flags|=192,g.child=h.child,g=null):(h=je.treeContext,wr=to(fe.nextSibling),ra=g,jn=!0,bu=null,Js=!1,h!==null&&pI(g,h),g=ME(g,N.children),g.flags|=4096);return g}return j?(Nu(),fe=N.fallback,j=g.mode,je=h.child,tt=je.sibling,N=Jl(je,{mode:"hidden",children:N.children}),N.subtreeFlags=je.subtreeFlags&65011712,tt!==null?fe=Jl(tt,fe):(fe=oh(fe,j,_,null),fe.flags|=2),fe.return=g,N.return=g,N.sibling=fe,g.child=N,_x(null,N),N=g.child,fe=h.child.memoizedState,fe===null?fe=wE(_):(j=fe.cachePool,j!==null?(je=oi._currentValue,j=j.parent!==je?{parent:je,pool:je}:j):j=_I(),fe={baseLanes:fe.baseLanes|_,cachePool:j}),N.memoizedState=fe,N.childLanes=SE(h,J,_),g.memoizedState=_E,_x(h.child,N)):(Mu(g),_=h.child,h=_.sibling,_=Jl(_,{mode:"visible",children:N.children}),_.return=g,_.sibling=null,h!==null&&(J=g.deletions,J===null?(g.deletions=[h],g.flags|=16):J.push(h)),g.child=_,g.memoizedState=null,_)}function ME(h,g){return g=pv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function pv(h,g){return h=_s(22,h,null,g),h.lanes=0,h}function NE(h,g,_){return mh(g,h.child,null,_),h=ME(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function D5(h,g,_){h.lanes|=g;var N=h.alternate;N!==null&&(N.lanes|=g),zN(h.return,g,_)}function EE(h,g,_,N,j,O){var J=h.memoizedState;J===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:N,tail:_,tailMode:j,treeForkCount:O}:(J.isBackwards=g,J.rendering=null,J.renderingStartTime=0,J.last=N,J.tail=_,J.tailMode=j,J.treeForkCount=O)}function O5(h,g,_){var N=g.pendingProps,j=N.revealOrder,O=N.tail;N=N.children;var J=ni.current,fe=(J&2)!==0;if(fe?(J=J&1|2,g.flags|=128):J&=1,ee(ni,J),aa(h,g,N,_),N=jn?lx:0,!fe&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&D5(h,_,g);else if(h.tag===19)D5(h,_,g);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===g)break e;for(;h.sibling===null;){if(h.return===null||h.return===g)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(j){case"forwards":for(_=g.child,j=null;_!==null;)h=_.alternate,h!==null&&rv(h)===null&&(j=_),_=_.sibling;_=j,_===null?(j=g.child,g.child=null):(j=_.sibling,_.sibling=null),EE(g,!1,j,_,O,N);break;case"backwards":case"unstable_legacy-backwards":for(_=null,j=g.child,g.child=null;j!==null;){if(h=j.alternate,h!==null&&rv(h)===null){g.child=j;break}h=j.sibling,j.sibling=_,_=j,j=h}EE(g,!0,_,null,O,N);break;case"together":EE(g,!1,null,null,void 0,N);break;default:g.memoizedState=null}return g.child}function ac(h,g,_){if(h!==null&&(g.dependencies=h.dependencies),Tu|=g.lanes,(_&g.childLanes)===0)if(h!==null){if(om(h,g,_,!1),(_&g.childLanes)===0)return null}else return null;if(h!==null&&g.child!==h.child)throw Error(r(153));if(g.child!==null){for(h=g.child,_=Jl(h,h.pendingProps),g.child=_,_.return=g;h.sibling!==null;)h=h.sibling,_=_.sibling=Jl(h,h.pendingProps),_.return=g;_.sibling=null}return g.child}function AE(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&Xy(h)))}function bie(h,g,_){switch(g.tag){case 3:Ee(g,g.stateNode.containerInfo),vu(g,oi,h.memoizedState.cache),lh();break;case 27:case 5:Ne(g);break;case 4:Ee(g,g.stateNode.containerInfo);break;case 10:vu(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,ZN(g),null;break;case 13:var N=g.memoizedState;if(N!==null)return N.dehydrated!==null?(Mu(g),g.flags|=128,null):(_&g.child.childLanes)!==0?R5(h,g,_):(Mu(g),h=ac(h,g,_),h!==null?h.sibling:null);Mu(g);break;case 19:var j=(h.flags&128)!==0;if(N=(_&g.childLanes)!==0,N||(om(h,g,_,!1),N=(_&g.childLanes)!==0),j){if(N)return O5(h,g,_);g.flags|=128}if(j=g.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),ee(ni,ni.current),N)break;return null;case 22:return g.lanes=0,A5(h,g,_,g.pendingProps);case 24:vu(g,oi,h.memoizedState.cache)}return ac(h,g,_)}function L5(h,g,_){if(h!==null)if(h.memoizedProps!==g.pendingProps)ci=!0;else{if(!AE(h,_)&&(g.flags&128)===0)return ci=!1,bie(h,g,_);ci=(h.flags&131072)!==0}else ci=!1,jn&&(g.flags&1048576)!==0&&mI(g,lx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var N=g.pendingProps;if(h=hh(g.elementType),g.type=h,typeof h=="function")PN(h)?(N=gh(h,N),g.tag=1,g=j5(null,g,h,N,_)):(g.tag=0,g=vE(null,g,h,N,_));else{if(h!=null){var j=h.$$typeof;if(j===A){g.tag=11,g=M5(null,g,h,N,_);break e}else if(j===C){g.tag=14,g=N5(null,g,h,N,_);break e}}throw g=D(h)||h,Error(r(306,g,""))}}return g;case 0:return vE(h,g,g.type,g.pendingProps,_);case 1:return N=g.type,j=gh(N,g.pendingProps),j5(h,g,N,j,_);case 3:e:{if(Ee(g,g.stateNode.containerInfo),h===null)throw Error(r(387));N=g.pendingProps;var O=g.memoizedState;j=O.element,qN(h,g),gx(g,N,null,_);var J=g.memoizedState;if(N=J.cache,vu(g,oi,N),N!==O.cache&&BN(g,[oi],_,!0),px(),N=J.element,O.isDehydrated)if(O={element:N,isDehydrated:!1,cache:J.cache},g.updateQueue.baseState=O,g.memoizedState=O,g.flags&256){g=P5(h,g,N,_);break e}else if(N!==j){j=Ys(Error(r(424)),g),cx(j),g=P5(h,g,N,_);break e}else{switch(h=g.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(wr=to(h.firstChild),ra=g,jn=!0,bu=null,Js=!0,_=AI(g,null,N,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(lh(),N===j){g=ac(h,g,_);break e}aa(h,g,N,_)}g=g.child}return g;case 26:return mv(h,g),h===null?(_=qF(g.type,null,g.pendingProps,null))?g.memoizedState=_:jn||(_=g.type,h=g.pendingProps,N=jv(de.current).createElement(_),N[hr]=g,N[bt]=h,sa(N,_,h),Oe(N),g.stateNode=N):g.memoizedState=qF(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Ne(g),h===null&&jn&&(N=g.stateNode=VF(g.type,g.pendingProps,de.current),ra=g,Js=!0,j=wr,Ru(g.type)?(sA=j,wr=to(N.firstChild)):wr=j),aa(h,g,g.pendingProps.children,_),mv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&jn&&((j=N=wr)&&(N=Kie(N,g.type,g.pendingProps,Js),N!==null?(g.stateNode=N,ra=g,wr=to(N.firstChild),Js=!1,j=!0):j=!1),j||yu(g)),Ne(g),j=g.type,O=g.pendingProps,J=h!==null?h.memoizedProps:null,N=O.children,tA(j,O)?N=null:J!==null&&tA(j,J)&&(g.flags|=32),g.memoizedState!==null&&(j=eE(h,g,cie,null,null,_),Lx._currentValue=j),mv(h,g),aa(h,g,N,_),g.child;case 6:return h===null&&jn&&((h=_=wr)&&(_=Xie(_,g.pendingProps,Js),_!==null?(g.stateNode=_,ra=g,wr=null,h=!0):h=!1),h||yu(g)),null;case 13:return R5(h,g,_);case 4:return Ee(g,g.stateNode.containerInfo),N=g.pendingProps,h===null?g.child=mh(g,null,N,_):aa(h,g,N,_),g.child;case 11:return M5(h,g,g.type,g.pendingProps,_);case 7:return aa(h,g,g.pendingProps,_),g.child;case 8:return aa(h,g,g.pendingProps.children,_),g.child;case 12:return aa(h,g,g.pendingProps.children,_),g.child;case 10:return N=g.pendingProps,vu(g,g.type,N.value),aa(h,g,N.children,_),g.child;case 9:return j=g.type._context,N=g.pendingProps.children,uh(g),j=ia(j),N=N(j),g.flags|=1,aa(h,g,N,_),g.child;case 14:return N5(h,g,g.type,g.pendingProps,_);case 15:return E5(h,g,g.type,g.pendingProps,_);case 19:return O5(h,g,_);case 31:return xie(h,g,_);case 22:return A5(h,g,_,g.pendingProps);case 24:return uh(g),N=ia(oi),h===null?(j=VN(),j===null&&(j=fr,O=$N(),j.pooledCache=O,O.refCount++,O!==null&&(j.pooledCacheLanes|=_),j=O),g.memoizedState={parent:N,cache:j},WN(g),vu(g,oi,j)):((h.lanes&_)!==0&&(qN(h,g),gx(g,null,null,_),px()),j=h.memoizedState,O=g.memoizedState,j.parent!==N?(j={parent:N,cache:N},g.memoizedState=j,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=j),vu(g,oi,N)):(N=O.cache,vu(g,oi,N),N!==j.cache&&BN(g,[oi],_,!0))),aa(h,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function sc(h){h.flags|=4}function TE(h,g,_,N,j){if((g=(h.mode&32)!==0)&&(g=!1),g){if(h.flags|=16777216,(j&335544128)===j)if(h.stateNode.complete)h.flags|=8192;else if(cF())h.flags|=8192;else throw fh=Jy,GN}else h.flags&=-16777217}function I5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!ZF(g))if(cF())h.flags|=8192;else throw fh=Jy,GN}function gv(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?Tt():536870912,h.lanes|=g,ym|=g)}function wx(h,g){if(!jn)switch(h.tailMode){case"hidden":g=h.tail;for(var _=null;g!==null;)g.alternate!==null&&(_=g),g=g.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var N=null;_!==null;)_.alternate!==null&&(N=_),_=_.sibling;N===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:N.sibling=null}}function Sr(h){var g=h.alternate!==null&&h.alternate.child===h.child,_=0,N=0;if(g)for(var j=h.child;j!==null;)_|=j.lanes|j.childLanes,N|=j.subtreeFlags&65011712,N|=j.flags&65011712,j.return=h,j=j.sibling;else for(j=h.child;j!==null;)_|=j.lanes|j.childLanes,N|=j.subtreeFlags,N|=j.flags,j.return=h,j=j.sibling;return h.subtreeFlags|=N,h.childLanes=_,g}function yie(h,g,_){var N=g.pendingProps;switch(LN(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sr(g),null;case 1:return Sr(g),null;case 3:return _=g.stateNode,N=null,h!==null&&(N=h.memoizedState.cache),g.memoizedState.cache!==N&&(g.flags|=2048),nc(oi),ge(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(sm(g)?sc(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,FN())),Sr(g),null;case 26:var j=g.type,O=g.memoizedState;return h===null?(sc(g),O!==null?(Sr(g),I5(g,O)):(Sr(g),TE(g,j,null,N,_))):O?O!==h.memoizedState?(sc(g),Sr(g),I5(g,O)):(Sr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==N&&sc(g),Sr(g),TE(g,j,h,N,_)),null;case 27:if(Re(g),_=de.current,j=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&sc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Sr(g),null}h=ne.current,sm(g)?gI(g):(h=VF(j,N,_),g.stateNode=h,sc(g))}return Sr(g),null;case 5:if(Re(g),j=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&sc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Sr(g),null}if(O=ne.current,sm(g))gI(g);else{var J=jv(de.current);switch(O){case 1:O=J.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:O=J.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":O=J.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":O=J.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":O=J.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof N.is=="string"?J.createElement("select",{is:N.is}):J.createElement("select"),N.multiple?O.multiple=!0:N.size&&(O.size=N.size);break;default:O=typeof N.is=="string"?J.createElement(j,{is:N.is}):J.createElement(j)}}O[hr]=g,O[bt]=N;e:for(J=g.child;J!==null;){if(J.tag===5||J.tag===6)O.appendChild(J.stateNode);else if(J.tag!==4&&J.tag!==27&&J.child!==null){J.child.return=J,J=J.child;continue}if(J===g)break e;for(;J.sibling===null;){if(J.return===null||J.return===g)break e;J=J.return}J.sibling.return=J.return,J=J.sibling}g.stateNode=O;e:switch(sa(O,j,N),j){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&sc(g)}}return Sr(g),TE(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,_),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==N&&sc(g);else{if(typeof N!="string"&&g.stateNode===null)throw Error(r(166));if(h=de.current,sm(g)){if(h=g.stateNode,_=g.memoizedProps,N=null,j=ra,j!==null)switch(j.tag){case 27:case 5:N=j.memoizedProps}h[hr]=g,h=!!(h.nodeValue===_||N!==null&&N.suppressHydrationWarning===!0||RF(h.nodeValue,_)),h||yu(g,!0)}else h=jv(h).createTextNode(N),h[hr]=g,g.stateNode=h}return Sr(g),null;case 31:if(_=g.memoizedState,h===null||h.memoizedState!==null){if(N=sm(g),_!==null){if(h===null){if(!N)throw Error(r(318));if(h=g.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[hr]=g}else lh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Sr(g),h=!1}else _=FN(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return g.flags&256?(Ss(g),g):(Ss(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Sr(g),null;case 13:if(N=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(j=sm(g),N!==null&&N.dehydrated!==null){if(h===null){if(!j)throw Error(r(318));if(j=g.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[hr]=g}else lh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Sr(g),j=!1}else j=FN(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=j),j=!0;if(!j)return g.flags&256?(Ss(g),g):(Ss(g),null)}return Ss(g),(g.flags&128)!==0?(g.lanes=_,g):(_=N!==null,h=h!==null&&h.memoizedState!==null,_&&(N=g.child,j=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(j=N.alternate.memoizedState.cachePool.pool),O=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(O=N.memoizedState.cachePool.pool),O!==j&&(N.flags|=2048)),_!==h&&_&&(g.child.flags|=8192),gv(g,g.updateQueue),Sr(g),null);case 4:return ge(),h===null&&YE(g.stateNode.containerInfo),Sr(g),null;case 10:return nc(g.type),Sr(g),null;case 19:if(G(ni),N=g.memoizedState,N===null)return Sr(g),null;if(j=(g.flags&128)!==0,O=N.rendering,O===null)if(j)wx(N,!1);else{if(Gr!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(O=rv(h),O!==null){for(g.flags|=128,wx(N,!1),h=O.updateQueue,g.updateQueue=h,gv(g,h),g.subtreeFlags=0,h=_,_=g.child;_!==null;)dI(_,h),_=_.sibling;return ee(ni,ni.current&1|2),jn&&ec(g,N.treeForkCount),g.child}h=h.sibling}N.tail!==null&&L()>_v&&(g.flags|=128,j=!0,wx(N,!1),g.lanes=4194304)}else{if(!j)if(h=rv(O),h!==null){if(g.flags|=128,j=!0,h=h.updateQueue,g.updateQueue=h,gv(g,h),wx(N,!0),N.tail===null&&N.tailMode==="hidden"&&!O.alternate&&!jn)return Sr(g),null}else 2*L()-N.renderingStartTime>_v&&_!==536870912&&(g.flags|=128,j=!0,wx(N,!1),g.lanes=4194304);N.isBackwards?(O.sibling=g.child,g.child=O):(h=N.last,h!==null?h.sibling=O:g.child=O,N.last=O)}return N.tail!==null?(h=N.tail,N.rendering=h,N.tail=h.sibling,N.renderingStartTime=L(),h.sibling=null,_=ni.current,ee(ni,j?_&1|2:_&1),jn&&ec(g,N.treeForkCount),h):(Sr(g),null);case 22:case 23:return Ss(g),QN(),N=g.memoizedState!==null,h!==null?h.memoizedState!==null!==N&&(g.flags|=8192):N&&(g.flags|=8192),N?(_&536870912)!==0&&(g.flags&128)===0&&(Sr(g),g.subtreeFlags&6&&(g.flags|=8192)):Sr(g),_=g.updateQueue,_!==null&&gv(g,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),N=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(N=g.memoizedState.cachePool.pool),N!==_&&(g.flags|=2048),h!==null&&G(dh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),g.memoizedState.cache!==_&&(g.flags|=2048),nc(oi),Sr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function vie(h,g){switch(LN(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return nc(oi),ge(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return Re(g),null;case 31:if(g.memoizedState!==null){if(Ss(g),g.alternate===null)throw Error(r(340));lh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 13:if(Ss(g),h=g.memoizedState,h!==null&&h.dehydrated!==null){if(g.alternate===null)throw Error(r(340));lh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return G(ni),null;case 4:return ge(),null;case 10:return nc(g.type),null;case 22:case 23:return Ss(g),QN(),h!==null&&G(dh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return nc(oi),null;case 25:return null;default:return null}}function F5(h,g){switch(LN(g),g.tag){case 3:nc(oi),ge();break;case 26:case 27:case 5:Re(g);break;case 4:ge();break;case 31:g.memoizedState!==null&&Ss(g);break;case 13:Ss(g);break;case 19:G(ni);break;case 10:nc(g.type);break;case 22:case 23:Ss(g),QN(),h!==null&&G(dh);break;case 24:nc(oi)}}function Sx(h,g){try{var _=g.updateQueue,N=_!==null?_.lastEffect:null;if(N!==null){var j=N.next;_=j;do{if((_.tag&h)===h){N=void 0;var O=_.create,J=_.inst;N=O(),J.destroy=N}_=_.next}while(_!==j)}}catch(fe){Qn(g,g.return,fe)}}function Eu(h,g,_){try{var N=g.updateQueue,j=N!==null?N.lastEffect:null;if(j!==null){var O=j.next;N=O;do{if((N.tag&h)===h){var J=N.inst,fe=J.destroy;if(fe!==void 0){J.destroy=void 0,j=g;var je=_,tt=fe;try{tt()}catch(mt){Qn(j,je,mt)}}}N=N.next}while(N!==O)}}catch(mt){Qn(g,g.return,mt)}}function U5(h){var g=h.updateQueue;if(g!==null){var _=h.stateNode;try{CI(g,_)}catch(N){Qn(h,h.return,N)}}}function z5(h,g,_){_.props=gh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(N){Qn(h,g,N)}}function Mx(h,g){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var N=h.stateNode;break;case 30:N=h.stateNode;break;default:N=h.stateNode}typeof _=="function"?h.refCleanup=_(N):_.current=N}}catch(j){Qn(h,g,j)}}function hl(h,g){var _=h.ref,N=h.refCleanup;if(_!==null)if(typeof N=="function")try{N()}catch(j){Qn(h,g,j)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(j){Qn(h,g,j)}else _.current=null}function B5(h){var g=h.type,_=h.memoizedProps,N=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":_.autoFocus&&N.focus();break e;case"img":_.src?N.src=_.src:_.srcSet&&(N.srcset=_.srcSet)}}catch(j){Qn(h,h.return,j)}}function CE(h,g,_){try{var N=h.stateNode;$ie(N,h.type,_,g),N[bt]=g}catch(j){Qn(h,h.return,j)}}function $5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Ru(h.type)||h.tag===4}function kE(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||$5(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&Ru(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function jE(h,g,_){var N=h.tag;if(N===5||N===6)h=h.stateNode,g?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,g):(g=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,g.appendChild(h),_=_._reactRootContainer,_!=null||g.onclick!==null||(g.onclick=Ql));else if(N!==4&&(N===27&&Ru(h.type)&&(_=h.stateNode,g=null),h=h.child,h!==null))for(jE(h,g,_),h=h.sibling;h!==null;)jE(h,g,_),h=h.sibling}function xv(h,g,_){var N=h.tag;if(N===5||N===6)h=h.stateNode,g?_.insertBefore(h,g):_.appendChild(h);else if(N!==4&&(N===27&&Ru(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(xv(h,g,_),h=h.sibling;h!==null;)xv(h,g,_),h=h.sibling}function H5(h){var g=h.stateNode,_=h.memoizedProps;try{for(var N=h.type,j=g.attributes;j.length;)g.removeAttributeNode(j[0]);sa(g,N,_),g[hr]=h,g[bt]=_}catch(O){Qn(h,h.return,O)}}var oc=!1,ui=!1,PE=!1,V5=typeof WeakSet=="function"?WeakSet:Set,Ui=null;function _ie(h,g){if(h=h.containerInfo,JE=Fv,h=nI(h),NN(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var N=_.getSelection&&_.getSelection();if(N&&N.rangeCount!==0){_=N.anchorNode;var j=N.anchorOffset,O=N.focusNode;N=N.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var J=0,fe=-1,je=-1,tt=0,mt=0,xt=h,it=null;t:for(;;){for(var ot;xt!==_||j!==0&&xt.nodeType!==3||(fe=J+j),xt!==O||N!==0&&xt.nodeType!==3||(je=J+N),xt.nodeType===3&&(J+=xt.nodeValue.length),(ot=xt.firstChild)!==null;)it=xt,xt=ot;for(;;){if(xt===h)break t;if(it===_&&++tt===j&&(fe=J),it===O&&++mt===N&&(je=J),(ot=xt.nextSibling)!==null)break;xt=it,it=xt.parentNode}xt=ot}_=fe===-1||je===-1?null:{start:fe,end:je}}else _=null}_=_||{start:0,end:0}}else _=null;for(eA={focusedElem:h,selectionRange:_},Fv=!1,Ui=g;Ui!==null;)if(g=Ui,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,Ui=h;else for(;Ui!==null;){switch(g=Ui,O=g.alternate,h=g.flags,g.tag){case 0:if((h&4)!==0&&(h=g.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)j=h[_],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&O!==null){h=void 0,_=g,j=O.memoizedProps,O=O.memoizedState,N=_.stateNode;try{var Ft=gh(_.type,j);h=N.getSnapshotBeforeUpdate(Ft,O),N.__reactInternalSnapshotBeforeUpdate=h}catch(Kt){Qn(_,_.return,Kt)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,_=h.nodeType,_===9)rA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":rA(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=g.sibling,h!==null){h.return=g.return,Ui=h;break}Ui=g.return}}function G5(h,g,_){var N=_.flags;switch(_.tag){case 0:case 11:case 15:cc(h,_),N&4&&Sx(5,_);break;case 1:if(cc(h,_),N&4)if(h=_.stateNode,g===null)try{h.componentDidMount()}catch(J){Qn(_,_.return,J)}else{var j=gh(_.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(j,g,h.__reactInternalSnapshotBeforeUpdate)}catch(J){Qn(_,_.return,J)}}N&64&&U5(_),N&512&&Mx(_,_.return);break;case 3:if(cc(h,_),N&64&&(h=_.updateQueue,h!==null)){if(g=null,_.child!==null)switch(_.child.tag){case 27:case 5:g=_.child.stateNode;break;case 1:g=_.child.stateNode}try{CI(h,g)}catch(J){Qn(_,_.return,J)}}break;case 27:g===null&&N&4&&H5(_);case 26:case 5:cc(h,_),g===null&&N&4&&B5(_),N&512&&Mx(_,_.return);break;case 12:cc(h,_);break;case 31:cc(h,_),N&4&&K5(h,_);break;case 13:cc(h,_),N&4&&X5(h,_),N&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=kie.bind(null,_),Yie(h,_))));break;case 22:if(N=_.memoizedState!==null||oc,!N){g=g!==null&&g.memoizedState!==null||ui,j=oc;var O=ui;oc=N,(ui=g)&&!O?uc(h,_,(_.subtreeFlags&8772)!==0):cc(h,_),oc=j,ui=O}break;case 30:break;default:cc(h,_)}}function W5(h){var g=h.alternate;g!==null&&(h.alternate=null,W5(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&Qe(g)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Cr=null,Qa=!1;function lc(h,g,_){for(_=_.child;_!==null;)q5(h,g,_),_=_.sibling}function q5(h,g,_){if(me&&typeof me.onCommitFiberUnmount=="function")try{me.onCommitFiberUnmount(qe,_)}catch{}switch(_.tag){case 26:ui||hl(_,g),lc(h,g,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:ui||hl(_,g);var N=Cr,j=Qa;Ru(_.type)&&(Cr=_.stateNode,Qa=!1),lc(h,g,_),Rx(_.stateNode),Cr=N,Qa=j;break;case 5:ui||hl(_,g);case 6:if(N=Cr,j=Qa,Cr=null,lc(h,g,_),Cr=N,Qa=j,Cr!==null)if(Qa)try{(Cr.nodeType===9?Cr.body:Cr.nodeName==="HTML"?Cr.ownerDocument.body:Cr).removeChild(_.stateNode)}catch(O){Qn(_,g,O)}else try{Cr.removeChild(_.stateNode)}catch(O){Qn(_,g,O)}break;case 18:Cr!==null&&(Qa?(h=Cr,UF(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Am(h)):UF(Cr,_.stateNode));break;case 4:N=Cr,j=Qa,Cr=_.stateNode.containerInfo,Qa=!0,lc(h,g,_),Cr=N,Qa=j;break;case 0:case 11:case 14:case 15:Eu(2,_,g),ui||Eu(4,_,g),lc(h,g,_);break;case 1:ui||(hl(_,g),N=_.stateNode,typeof N.componentWillUnmount=="function"&&z5(_,g,N)),lc(h,g,_);break;case 21:lc(h,g,_);break;case 22:ui=(N=ui)||_.memoizedState!==null,lc(h,g,_),ui=N;break;default:lc(h,g,_)}}function K5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Am(h)}catch(_){Qn(g,g.return,_)}}}function X5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Am(h)}catch(_){Qn(g,g.return,_)}}function wie(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new V5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new V5),g;default:throw Error(r(435,h.tag))}}function bv(h,g){var _=wie(h);g.forEach(function(N){if(!_.has(N)){_.add(N);var j=jie.bind(null,h,N);N.then(j,j)}})}function Za(h,g){var _=g.deletions;if(_!==null)for(var N=0;N<_.length;N++){var j=_[N],O=h,J=g,fe=J;e:for(;fe!==null;){switch(fe.tag){case 27:if(Ru(fe.type)){Cr=fe.stateNode,Qa=!1;break e}break;case 5:Cr=fe.stateNode,Qa=!1;break e;case 3:case 4:Cr=fe.stateNode.containerInfo,Qa=!0;break e}fe=fe.return}if(Cr===null)throw Error(r(160));q5(O,J,j),Cr=null,Qa=!1,O=j.alternate,O!==null&&(O.return=null),j.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)Y5(g,h),g=g.sibling}var Oo=null;function Y5(h,g){var _=h.alternate,N=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Za(g,h),Ja(h),N&4&&(Eu(3,h,h.return),Sx(3,h),Eu(5,h,h.return));break;case 1:Za(g,h),Ja(h),N&512&&(ui||_===null||hl(_,_.return)),N&64&&oc&&(h=h.updateQueue,h!==null&&(N=h.callbacks,N!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?N:_.concat(N))));break;case 26:var j=Oo;if(Za(g,h),Ja(h),N&512&&(ui||_===null||hl(_,_.return)),N&4){var O=_!==null?_.memoizedState:null;if(N=h.memoizedState,_===null)if(N===null)if(h.stateNode===null){e:{N=h.type,_=h.memoizedProps,j=j.ownerDocument||j;t:switch(N){case"title":O=j.getElementsByTagName("title")[0],(!O||O[Ke]||O[hr]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=j.createElement(N),j.head.insertBefore(O,j.querySelector("head > title"))),sa(O,N,_),O[hr]=h,Oe(O),N=O;break e;case"link":var J=YF("link","href",j).get(N+(_.href||""));if(J){for(var fe=0;fe<J.length;fe++)if(O=J[fe],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)){J.splice(fe,1);break t}}O=j.createElement(N),sa(O,N,_),j.head.appendChild(O);break;case"meta":if(J=YF("meta","content",j).get(N+(_.content||""))){for(fe=0;fe<J.length;fe++)if(O=J[fe],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)){J.splice(fe,1);break t}}O=j.createElement(N),sa(O,N,_),j.head.appendChild(O);break;default:throw Error(r(468,N))}O[hr]=h,Oe(O),N=O}h.stateNode=N}else QF(j,h.type,h.stateNode);else h.stateNode=XF(j,N,h.memoizedProps);else O!==N?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,N===null?QF(j,h.type,h.stateNode):XF(j,N,h.memoizedProps)):N===null&&h.stateNode!==null&&CE(h,h.memoizedProps,_.memoizedProps)}break;case 27:Za(g,h),Ja(h),N&512&&(ui||_===null||hl(_,_.return)),_!==null&&N&4&&CE(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Za(g,h),Ja(h),N&512&&(ui||_===null||hl(_,_.return)),h.flags&32){j=h.stateNode;try{cl(j,"")}catch(Ft){Qn(h,h.return,Ft)}}N&4&&h.stateNode!=null&&(j=h.memoizedProps,CE(h,j,_!==null?_.memoizedProps:j)),N&1024&&(PE=!0);break;case 6:if(Za(g,h),Ja(h),N&4){if(h.stateNode===null)throw Error(r(162));N=h.memoizedProps,_=h.stateNode;try{_.nodeValue=N}catch(Ft){Qn(h,h.return,Ft)}}break;case 3:if(Dv=null,j=Oo,Oo=Pv(g.containerInfo),Za(g,h),Oo=j,Ja(h),N&4&&_!==null&&_.memoizedState.isDehydrated)try{Am(g.containerInfo)}catch(Ft){Qn(h,h.return,Ft)}PE&&(PE=!1,Q5(h));break;case 4:N=Oo,Oo=Pv(h.stateNode.containerInfo),Za(g,h),Ja(h),Oo=N;break;case 12:Za(g,h),Ja(h);break;case 31:Za(g,h),Ja(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,bv(h,N)));break;case 13:Za(g,h),Ja(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(vv=L()),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,bv(h,N)));break;case 22:j=h.memoizedState!==null;var je=_!==null&&_.memoizedState!==null,tt=oc,mt=ui;if(oc=tt||j,ui=mt||je,Za(g,h),ui=mt,oc=tt,Ja(h),N&8192)e:for(g=h.stateNode,g._visibility=j?g._visibility&-2:g._visibility|1,j&&(_===null||je||oc||ui||xh(h)),_=null,g=h;;){if(g.tag===5||g.tag===26){if(_===null){je=_=g;try{if(O=je.stateNode,j)J=O.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none";else{fe=je.stateNode;var xt=je.memoizedProps.style,it=xt!=null&&xt.hasOwnProperty("display")?xt.display:null;fe.style.display=it==null||typeof it=="boolean"?"":(""+it).trim()}}catch(Ft){Qn(je,je.return,Ft)}}}else if(g.tag===6){if(_===null){je=g;try{je.stateNode.nodeValue=j?"":je.memoizedProps}catch(Ft){Qn(je,je.return,Ft)}}}else if(g.tag===18){if(_===null){je=g;try{var ot=je.stateNode;j?zF(ot,!0):zF(je.stateNode,!1)}catch(Ft){Qn(je,je.return,Ft)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===h)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break e;for(;g.sibling===null;){if(g.return===null||g.return===h)break e;_===g&&(_=null),g=g.return}_===g&&(_=null),g.sibling.return=g.return,g=g.sibling}N&4&&(N=h.updateQueue,N!==null&&(_=N.retryQueue,_!==null&&(N.retryQueue=null,bv(h,_))));break;case 19:Za(g,h),Ja(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,bv(h,N)));break;case 30:break;case 21:break;default:Za(g,h),Ja(h)}}function Ja(h){var g=h.flags;if(g&2){try{for(var _,N=h.return;N!==null;){if($5(N)){_=N;break}N=N.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var j=_.stateNode,O=kE(h);xv(h,O,j);break;case 5:var J=_.stateNode;_.flags&32&&(cl(J,""),_.flags&=-33);var fe=kE(h);xv(h,fe,J);break;case 3:case 4:var je=_.stateNode.containerInfo,tt=kE(h);jE(h,tt,je);break;default:throw Error(r(161))}}catch(mt){Qn(h,h.return,mt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function Q5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;Q5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function cc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)G5(h,g.alternate,g),g=g.sibling}function xh(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:Eu(4,g,g.return),xh(g);break;case 1:hl(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&z5(g,g.return,_),xh(g);break;case 27:Rx(g.stateNode);case 26:case 5:hl(g,g.return),xh(g);break;case 22:g.memoizedState===null&&xh(g);break;case 30:xh(g);break;default:xh(g)}h=h.sibling}}function uc(h,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var N=g.alternate,j=h,O=g,J=O.flags;switch(O.tag){case 0:case 11:case 15:uc(j,O,_),Sx(4,O);break;case 1:if(uc(j,O,_),N=O,j=N.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(tt){Qn(N,N.return,tt)}if(N=O,j=N.updateQueue,j!==null){var fe=N.stateNode;try{var je=j.shared.hiddenCallbacks;if(je!==null)for(j.shared.hiddenCallbacks=null,j=0;j<je.length;j++)TI(je[j],fe)}catch(tt){Qn(N,N.return,tt)}}_&&J&64&&U5(O),Mx(O,O.return);break;case 27:H5(O);case 26:case 5:uc(j,O,_),_&&N===null&&J&4&&B5(O),Mx(O,O.return);break;case 12:uc(j,O,_);break;case 31:uc(j,O,_),_&&J&4&&K5(j,O);break;case 13:uc(j,O,_),_&&J&4&&X5(j,O);break;case 22:O.memoizedState===null&&uc(j,O,_),Mx(O,O.return);break;case 30:break;default:uc(j,O,_)}g=g.sibling}}function RE(h,g){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&ux(_))}function DE(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&ux(h))}function Lo(h,g,_,N){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)Z5(h,g,_,N),g=g.sibling}function Z5(h,g,_,N){var j=g.flags;switch(g.tag){case 0:case 11:case 15:Lo(h,g,_,N),j&2048&&Sx(9,g);break;case 1:Lo(h,g,_,N);break;case 3:Lo(h,g,_,N),j&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&ux(h)));break;case 12:if(j&2048){Lo(h,g,_,N),h=g.stateNode;try{var O=g.memoizedProps,J=O.id,fe=O.onPostCommit;typeof fe=="function"&&fe(J,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(je){Qn(g,g.return,je)}}else Lo(h,g,_,N);break;case 31:Lo(h,g,_,N);break;case 13:Lo(h,g,_,N);break;case 23:break;case 22:O=g.stateNode,J=g.alternate,g.memoizedState!==null?O._visibility&2?Lo(h,g,_,N):Nx(h,g):O._visibility&2?Lo(h,g,_,N):(O._visibility|=2,gm(h,g,_,N,(g.subtreeFlags&10256)!==0||!1)),j&2048&&RE(J,g);break;case 24:Lo(h,g,_,N),j&2048&&DE(g.alternate,g);break;default:Lo(h,g,_,N)}}function gm(h,g,_,N,j){for(j=j&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var O=h,J=g,fe=_,je=N,tt=J.flags;switch(J.tag){case 0:case 11:case 15:gm(O,J,fe,je,j),Sx(8,J);break;case 23:break;case 22:var mt=J.stateNode;J.memoizedState!==null?mt._visibility&2?gm(O,J,fe,je,j):Nx(O,J):(mt._visibility|=2,gm(O,J,fe,je,j)),j&&tt&2048&&RE(J.alternate,J);break;case 24:gm(O,J,fe,je,j),j&&tt&2048&&DE(J.alternate,J);break;default:gm(O,J,fe,je,j)}g=g.sibling}}function Nx(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=h,N=g,j=N.flags;switch(N.tag){case 22:Nx(_,N),j&2048&&RE(N.alternate,N);break;case 24:Nx(_,N),j&2048&&DE(N.alternate,N);break;default:Nx(_,N)}g=g.sibling}}var Ex=8192;function xm(h,g,_){if(h.subtreeFlags&Ex)for(h=h.child;h!==null;)J5(h,g,_),h=h.sibling}function J5(h,g,_){switch(h.tag){case 26:xm(h,g,_),h.flags&Ex&&h.memoizedState!==null&&lae(_,Oo,h.memoizedState,h.memoizedProps);break;case 5:xm(h,g,_);break;case 3:case 4:var N=Oo;Oo=Pv(h.stateNode.containerInfo),xm(h,g,_),Oo=N;break;case 22:h.memoizedState===null&&(N=h.alternate,N!==null&&N.memoizedState!==null?(N=Ex,Ex=16777216,xm(h,g,_),Ex=N):xm(h,g,_));break;default:xm(h,g,_)}}function eF(h){var g=h.alternate;if(g!==null&&(h=g.child,h!==null)){g.child=null;do g=h.sibling,h.sibling=null,h=g;while(h!==null)}}function Ax(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var N=g[_];Ui=N,nF(N,h)}eF(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)tF(h),h=h.sibling}function tF(h){switch(h.tag){case 0:case 11:case 15:Ax(h),h.flags&2048&&Eu(9,h,h.return);break;case 3:Ax(h);break;case 12:Ax(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,yv(h)):Ax(h);break;default:Ax(h)}}function yv(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var N=g[_];Ui=N,nF(N,h)}eF(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:Eu(8,g,g.return),yv(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,yv(g));break;default:yv(g)}h=h.sibling}}function nF(h,g){for(;Ui!==null;){var _=Ui;switch(_.tag){case 0:case 11:case 15:Eu(8,_,g);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var N=_.memoizedState.cachePool.pool;N!=null&&N.refCount++}break;case 24:ux(_.memoizedState.cache)}if(N=_.child,N!==null)N.return=_,Ui=N;else e:for(_=h;Ui!==null;){N=Ui;var j=N.sibling,O=N.return;if(W5(N),N===_){Ui=null;break e}if(j!==null){j.return=O,Ui=j;break e}Ui=O}}}var Sie={getCacheForType:function(h){var g=ia(oi),_=g.data.get(h);return _===void 0&&(_=h(),g.data.set(h,_)),_},cacheSignal:function(){return ia(oi).controller.signal}},Mie=typeof WeakMap=="function"?WeakMap:Map,Bn=0,fr=null,wn=null,Tn=0,Yn=0,Ms=null,Au=!1,bm=!1,OE=!1,dc=0,Gr=0,Tu=0,bh=0,LE=0,Ns=0,ym=0,Tx=null,es=null,IE=!1,vv=0,rF=0,_v=1/0,wv=null,Cu=null,Si=0,ku=null,vm=null,hc=0,FE=0,UE=null,iF=null,Cx=0,zE=null;function Es(){return(Bn&2)!==0&&Tn!==0?Tn&-Tn:Y.T!==null?WE():_r()}function aF(){if(Ns===0)if((Tn&536870912)===0||jn){var h=ye;ye<<=1,(ye&3932160)===0&&(ye=262144),Ns=h}else Ns=536870912;return h=ws.current,h!==null&&(h.flags|=32),Ns}function ts(h,g,_){(h===fr&&(Yn===2||Yn===9)||h.cancelPendingCommit!==null)&&(_m(h,0),ju(h,Tn,Ns,!1)),Xt(h,_),((Bn&2)===0||h!==fr)&&(h===fr&&((Bn&2)===0&&(bh|=_),Gr===4&&ju(h,Tn,Ns,!1)),fl(h))}function sF(h,g,_){if((Bn&6)!==0)throw Error(r(327));var N=!_&&(g&127)===0&&(g&h.expiredLanes)===0||Ve(h,g),j=N?Aie(h,g):$E(h,g,!0),O=N;do{if(j===0){bm&&!N&&ju(h,g,0,!1);break}else{if(_=h.current.alternate,O&&!Nie(_)){j=$E(h,g,!1),O=!1;continue}if(j===2){if(O=g,h.errorRecoveryDisabledLanes&O)var J=0;else J=h.pendingLanes&-536870913,J=J!==0?J:J&536870912?536870912:0;if(J!==0){g=J;e:{var fe=h;j=Tx;var je=fe.current.memoizedState.isDehydrated;if(je&&(_m(fe,J).flags|=256),J=$E(fe,J,!1),J!==2){if(OE&&!je){fe.errorRecoveryDisabledLanes|=O,bh|=O,j=4;break e}O=es,es=j,O!==null&&(es===null?es=O:es.push.apply(es,O))}j=J}if(O=!1,j!==2)continue}}if(j===1){_m(h,0),ju(h,g,0,!0);break}e:{switch(N=h,O=j,O){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:ju(N,g,Ns,!Au);break e;case 2:es=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(j=vv+300-L(),10<j)){if(ju(N,g,Ns,!Au),we(N,0,!0)!==0)break e;hc=g,N.timeoutHandle=IF(oF.bind(null,N,_,es,wv,IE,g,Ns,bh,ym,Au,O,"Throttled",-0,0),j);break e}oF(N,_,es,wv,IE,g,Ns,bh,ym,Au,O,null,-0,0)}}break}while(!0);fl(h)}function oF(h,g,_,N,j,O,J,fe,je,tt,mt,xt,it,ot){if(h.timeoutHandle=-1,xt=g.subtreeFlags,xt&8192||(xt&16785408)===16785408){xt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ql},J5(g,O,xt);var Ft=(O&62914560)===O?vv-L():(O&4194048)===O?rF-L():0;if(Ft=cae(xt,Ft),Ft!==null){hc=O,h.cancelPendingCommit=Ft(pF.bind(null,h,g,O,_,N,j,J,fe,je,mt,xt,null,it,ot)),ju(h,O,J,!tt);return}}pF(h,g,O,_,N,j,J,fe,je)}function Nie(h){for(var g=h;;){var _=g.tag;if((_===0||_===11||_===15)&&g.flags&16384&&(_=g.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var N=0;N<_.length;N++){var j=_[N],O=j.getSnapshot;j=j.value;try{if(!vs(O(),j))return!1}catch{return!1}}if(_=g.child,g.subtreeFlags&16384&&_!==null)_.return=g,g=_;else{if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function ju(h,g,_,N){g&=~LE,g&=~bh,h.suspendedLanes|=g,h.pingedLanes&=~g,N&&(h.warmLanes|=g),N=h.expirationTimes;for(var j=g;0<j;){var O=31-Xe(j),J=1<<O;N[O]=-1,j&=~J}_!==0&&an(h,_,g)}function Sv(){return(Bn&6)===0?(kx(0),!1):!0}function BE(){if(wn!==null){if(Yn===0)var h=wn.return;else h=wn,tc=ch=null,rE(h),dm=null,hx=0,h=wn;for(;h!==null;)F5(h.alternate,h),h=h.return;wn=null}}function _m(h,g){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Gie(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),hc=0,BE(),fr=h,wn=_=Jl(h.current,null),Tn=g,Yn=0,Ms=null,Au=!1,bm=Ve(h,g),OE=!1,ym=Ns=LE=bh=Tu=Gr=0,es=Tx=null,IE=!1,(g&8)!==0&&(g|=g&32);var N=h.entangledLanes;if(N!==0)for(h=h.entanglements,N&=g;0<N;){var j=31-Xe(N),O=1<<j;g|=h[j],N&=~O}return dc=g,Vy(),_}function lF(h,g){un=null,Y.H=vx,g===um||g===Zy?(g=MI(),Yn=3):g===GN?(g=MI(),Yn=4):Yn=g===yE?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Ms=g,wn===null&&(Gr=1,hv(h,Ys(g,h.current)))}function cF(){var h=ws.current;return h===null?!0:(Tn&4194048)===Tn?eo===null:(Tn&62914560)===Tn||(Tn&536870912)!==0?h===eo:!1}function uF(){var h=Y.H;return Y.H=vx,h===null?vx:h}function dF(){var h=Y.A;return Y.A=Sie,h}function Mv(){Gr=4,Au||(Tn&4194048)!==Tn&&ws.current!==null||(bm=!0),(Tu&134217727)===0&&(bh&134217727)===0||fr===null||ju(fr,Tn,Ns,!1)}function $E(h,g,_){var N=Bn;Bn|=2;var j=uF(),O=dF();(fr!==h||Tn!==g)&&(wv=null,_m(h,g)),g=!1;var J=Gr;e:do try{if(Yn!==0&&wn!==null){var fe=wn,je=Ms;switch(Yn){case 8:BE(),J=6;break e;case 3:case 2:case 9:case 6:ws.current===null&&(g=!0);var tt=Yn;if(Yn=0,Ms=null,wm(h,fe,je,tt),_&&bm){J=0;break e}break;default:tt=Yn,Yn=0,Ms=null,wm(h,fe,je,tt)}}Eie(),J=Gr;break}catch(mt){lF(h,mt)}while(!0);return g&&h.shellSuspendCounter++,tc=ch=null,Bn=N,Y.H=j,Y.A=O,wn===null&&(fr=null,Tn=0,Vy()),J}function Eie(){for(;wn!==null;)hF(wn)}function Aie(h,g){var _=Bn;Bn|=2;var N=uF(),j=dF();fr!==h||Tn!==g?(wv=null,_v=L()+500,_m(h,g)):bm=Ve(h,g);e:do try{if(Yn!==0&&wn!==null){g=wn;var O=Ms;t:switch(Yn){case 1:Yn=0,Ms=null,wm(h,g,O,1);break;case 2:case 9:if(wI(O)){Yn=0,Ms=null,fF(g);break}g=function(){Yn!==2&&Yn!==9||fr!==h||(Yn=7),fl(h)},O.then(g,g);break e;case 3:Yn=7;break e;case 4:Yn=5;break e;case 7:wI(O)?(Yn=0,Ms=null,fF(g)):(Yn=0,Ms=null,wm(h,g,O,7));break;case 5:var J=null;switch(wn.tag){case 26:J=wn.memoizedState;case 5:case 27:var fe=wn;if(J?ZF(J):fe.stateNode.complete){Yn=0,Ms=null;var je=fe.sibling;if(je!==null)wn=je;else{var tt=fe.return;tt!==null?(wn=tt,Nv(tt)):wn=null}break t}}Yn=0,Ms=null,wm(h,g,O,5);break;case 6:Yn=0,Ms=null,wm(h,g,O,6);break;case 8:BE(),Gr=6;break e;default:throw Error(r(462))}}Tie();break}catch(mt){lF(h,mt)}while(!0);return tc=ch=null,Y.H=N,Y.A=j,Bn=_,wn!==null?0:(fr=null,Tn=0,Vy(),Gr)}function Tie(){for(;wn!==null&&!Ae();)hF(wn)}function hF(h){var g=L5(h.alternate,h,dc);h.memoizedProps=h.pendingProps,g===null?Nv(h):wn=g}function fF(h){var g=h,_=g.alternate;switch(g.tag){case 15:case 0:g=k5(_,g,g.pendingProps,g.type,void 0,Tn);break;case 11:g=k5(_,g,g.pendingProps,g.type.render,g.ref,Tn);break;case 5:rE(g);default:F5(_,g),g=wn=dI(g,dc),g=L5(_,g,dc)}h.memoizedProps=h.pendingProps,g===null?Nv(h):wn=g}function wm(h,g,_,N){tc=ch=null,rE(g),dm=null,hx=0;var j=g.return;try{if(gie(h,j,g,_,Tn)){Gr=1,hv(h,Ys(_,h.current)),wn=null;return}}catch(O){if(j!==null)throw wn=j,O;Gr=1,hv(h,Ys(_,h.current)),wn=null;return}g.flags&32768?(jn||N===1?h=!0:bm||(Tn&536870912)!==0?h=!1:(Au=h=!0,(N===2||N===9||N===3||N===6)&&(N=ws.current,N!==null&&N.tag===13&&(N.flags|=16384))),mF(g,h)):Nv(g)}function Nv(h){var g=h;do{if((g.flags&32768)!==0){mF(g,Au);return}h=g.return;var _=yie(g.alternate,g,dc);if(_!==null){wn=_;return}if(g=g.sibling,g!==null){wn=g;return}wn=g=h}while(g!==null);Gr===0&&(Gr=5)}function mF(h,g){do{var _=vie(h.alternate,h);if(_!==null){_.flags&=32767,wn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!g&&(h=h.sibling,h!==null)){wn=h;return}wn=h=_}while(h!==null);Gr=6,wn=null}function pF(h,g,_,N,j,O,J,fe,je){h.cancelPendingCommit=null;do Ev();while(Si!==0);if((Bn&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(O=g.lanes|g.childLanes,O|=kN,Pt(h,_,O,J,fe,je),h===fr&&(wn=fr=null,Tn=0),vm=g,ku=h,hc=_,FE=O,UE=j,iF=N,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Pie(ve,function(){return vF(),null})):(h.callbackNode=null,h.callbackPriority=0),N=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||N){N=Y.T,Y.T=null,j=q.p,q.p=2,J=Bn,Bn|=4;try{_ie(h,g,_)}finally{Bn=J,q.p=j,Y.T=N}}Si=1,gF(),xF(),bF()}}function gF(){if(Si===1){Si=0;var h=ku,g=vm,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=Y.T,Y.T=null;var N=q.p;q.p=2;var j=Bn;Bn|=4;try{Y5(g,h);var O=eA,J=nI(h.containerInfo),fe=O.focusedElem,je=O.selectionRange;if(J!==fe&&fe&&fe.ownerDocument&&tI(fe.ownerDocument.documentElement,fe)){if(je!==null&&NN(fe)){var tt=je.start,mt=je.end;if(mt===void 0&&(mt=tt),"selectionStart"in fe)fe.selectionStart=tt,fe.selectionEnd=Math.min(mt,fe.value.length);else{var xt=fe.ownerDocument||document,it=xt&&xt.defaultView||window;if(it.getSelection){var ot=it.getSelection(),Ft=fe.textContent.length,Kt=Math.min(je.start,Ft),ir=je.end===void 0?Kt:Math.min(je.end,Ft);!ot.extend&&Kt>ir&&(J=ir,ir=Kt,Kt=J);var Ge=eI(fe,Kt),Fe=eI(fe,ir);if(Ge&&Fe&&(ot.rangeCount!==1||ot.anchorNode!==Ge.node||ot.anchorOffset!==Ge.offset||ot.focusNode!==Fe.node||ot.focusOffset!==Fe.offset)){var et=xt.createRange();et.setStart(Ge.node,Ge.offset),ot.removeAllRanges(),Kt>ir?(ot.addRange(et),ot.extend(Fe.node,Fe.offset)):(et.setEnd(Fe.node,Fe.offset),ot.addRange(et))}}}}for(xt=[],ot=fe;ot=ot.parentNode;)ot.nodeType===1&&xt.push({element:ot,left:ot.scrollLeft,top:ot.scrollTop});for(typeof fe.focus=="function"&&fe.focus(),fe=0;fe<xt.length;fe++){var gt=xt[fe];gt.element.scrollLeft=gt.left,gt.element.scrollTop=gt.top}}Fv=!!JE,eA=JE=null}finally{Bn=j,q.p=N,Y.T=_}}h.current=g,Si=2}}function xF(){if(Si===2){Si=0;var h=ku,g=vm,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=Y.T,Y.T=null;var N=q.p;q.p=2;var j=Bn;Bn|=4;try{G5(h,g.alternate,g)}finally{Bn=j,q.p=N,Y.T=_}}Si=3}}function bF(){if(Si===4||Si===3){Si=0,$();var h=ku,g=vm,_=hc,N=iF;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?Si=5:(Si=0,vm=ku=null,yF(h,h.pendingLanes));var j=h.pendingLanes;if(j===0&&(Cu=null),Vn(_),g=g.stateNode,me&&typeof me.onCommitFiberRoot=="function")try{me.onCommitFiberRoot(qe,g,void 0,(g.current.flags&128)===128)}catch{}if(N!==null){g=Y.T,j=q.p,q.p=2,Y.T=null;try{for(var O=h.onRecoverableError,J=0;J<N.length;J++){var fe=N[J];O(fe.value,{componentStack:fe.stack})}}finally{Y.T=g,q.p=j}}(hc&3)!==0&&Ev(),fl(h),j=h.pendingLanes,(_&261930)!==0&&(j&42)!==0?h===zE?Cx++:(Cx=0,zE=h):Cx=0,kx(0)}}function yF(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,ux(g)))}function Ev(){return gF(),xF(),bF(),vF()}function vF(){if(Si!==5)return!1;var h=ku,g=FE;FE=0;var _=Vn(hc),N=Y.T,j=q.p;try{q.p=32>_?32:_,Y.T=null,_=UE,UE=null;var O=ku,J=hc;if(Si=0,vm=ku=null,hc=0,(Bn&6)!==0)throw Error(r(331));var fe=Bn;if(Bn|=4,tF(O.current),Z5(O,O.current,J,_),Bn=fe,kx(0,!1),me&&typeof me.onPostCommitFiberRoot=="function")try{me.onPostCommitFiberRoot(qe,O)}catch{}return!0}finally{q.p=j,Y.T=N,yF(h,g)}}function _F(h,g,_){g=Ys(_,g),g=bE(h.stateNode,g,2),h=Su(h,g,2),h!==null&&(Xt(h,2),fl(h))}function Qn(h,g,_){if(h.tag===3)_F(h,h,_);else for(;g!==null;){if(g.tag===3){_F(g,h,_);break}else if(g.tag===1){var N=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(Cu===null||!Cu.has(N))){h=Ys(_,h),_=w5(2),N=Su(g,_,2),N!==null&&(S5(_,N,g,h),Xt(N,2),fl(N));break}}g=g.return}}function HE(h,g,_){var N=h.pingCache;if(N===null){N=h.pingCache=new Mie;var j=new Set;N.set(g,j)}else j=N.get(g),j===void 0&&(j=new Set,N.set(g,j));j.has(_)||(OE=!0,j.add(_),h=Cie.bind(null,h,g,_),g.then(h,h))}function Cie(h,g,_){var N=h.pingCache;N!==null&&N.delete(g),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,fr===h&&(Tn&_)===_&&(Gr===4||Gr===3&&(Tn&62914560)===Tn&&300>L()-vv?(Bn&2)===0&&_m(h,0):LE|=_,ym===Tn&&(ym=0)),fl(h)}function wF(h,g){g===0&&(g=Tt()),h=sh(h,g),h!==null&&(Xt(h,g),fl(h))}function kie(h){var g=h.memoizedState,_=0;g!==null&&(_=g.retryLane),wF(h,_)}function jie(h,g){var _=0;switch(h.tag){case 31:case 13:var N=h.stateNode,j=h.memoizedState;j!==null&&(_=j.retryLane);break;case 19:N=h.stateNode;break;case 22:N=h.stateNode._retryCache;break;default:throw Error(r(314))}N!==null&&N.delete(g),wF(h,_)}function Pie(h,g){return Te(h,g)}var Av=null,Sm=null,VE=!1,Tv=!1,GE=!1,Pu=0;function fl(h){h!==Sm&&h.next===null&&(Sm===null?Av=Sm=h:Sm=Sm.next=h),Tv=!0,VE||(VE=!0,Die())}function kx(h,g){if(!GE&&Tv){GE=!0;do for(var _=!1,N=Av;N!==null;){if(h!==0){var j=N.pendingLanes;if(j===0)var O=0;else{var J=N.suspendedLanes,fe=N.pingedLanes;O=(1<<31-Xe(42|h)+1)-1,O&=j&~(J&~fe),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,EF(N,O))}else O=Tn,O=we(N,N===fr?O:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(O&3)===0||Ve(N,O)||(_=!0,EF(N,O));N=N.next}while(_);GE=!1}}function Rie(){SF()}function SF(){Tv=VE=!1;var h=0;Pu!==0&&Vie()&&(h=Pu);for(var g=L(),_=null,N=Av;N!==null;){var j=N.next,O=MF(N,g);O===0?(N.next=null,_===null?Av=j:_.next=j,j===null&&(Sm=_)):(_=N,(h!==0||(O&3)!==0)&&(Tv=!0)),N=j}Si!==0&&Si!==5||kx(h),Pu!==0&&(Pu=0)}function MF(h,g){for(var _=h.suspendedLanes,N=h.pingedLanes,j=h.expirationTimes,O=h.pendingLanes&-62914561;0<O;){var J=31-Xe(O),fe=1<<J,je=j[J];je===-1?((fe&_)===0||(fe&N)!==0)&&(j[J]=dt(fe,g)):je<=g&&(h.expiredLanes|=fe),O&=~fe}if(g=fr,_=Tn,_=we(h,h===g?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N=h.callbackNode,_===0||h===g&&(Yn===2||Yn===9)||h.cancelPendingCommit!==null)return N!==null&&N!==null&&ke(N),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Ve(h,_)){if(g=_&-_,g===h.callbackPriority)return g;switch(N!==null&&ke(N),Vn(_)){case 2:case 8:_=xe;break;case 32:_=ve;break;case 268435456:_=Ie;break;default:_=ve}return N=NF.bind(null,h),_=Te(_,N),h.callbackPriority=g,h.callbackNode=_,g}return N!==null&&N!==null&&ke(N),h.callbackPriority=2,h.callbackNode=null,2}function NF(h,g){if(Si!==0&&Si!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Ev()&&h.callbackNode!==_)return null;var N=Tn;return N=we(h,h===fr?N:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N===0?null:(sF(h,N,g),MF(h,L()),h.callbackNode!=null&&h.callbackNode===_?NF.bind(null,h):null)}function EF(h,g){if(Ev())return null;sF(h,g,!0)}function Die(){Wie(function(){(Bn&6)!==0?Te(ce,Rie):SF()})}function WE(){if(Pu===0){var h=lm;h===0&&(h=$e,$e<<=1,($e&261888)===0&&($e=256)),Pu=h}return Pu}function AF(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:Ly(""+h)}function TF(h,g){var _=g.ownerDocument.createElement("input");return _.name=g.name,_.value=g.value,h.id&&_.setAttribute("form",h.id),g.parentNode.insertBefore(_,g),h=new FormData(h),_.parentNode.removeChild(_),h}function Oie(h,g,_,N,j){if(g==="submit"&&_&&_.stateNode===j){var O=AF((j[bt]||null).action),J=N.submitter;J&&(g=(g=J[bt]||null)?AF(g.formAction):J.getAttribute("formAction"),g!==null&&(O=g,J=null));var fe=new zy("action","action",null,N,j);h.push({event:fe,listeners:[{instance:null,listener:function(){if(N.defaultPrevented){if(Pu!==0){var je=J?TF(j,J):new FormData(j);hE(_,{pending:!0,data:je,method:j.method,action:O},null,je)}}else typeof O=="function"&&(fe.preventDefault(),je=J?TF(j,J):new FormData(j),hE(_,{pending:!0,data:je,method:j.method,action:O},O,je))},currentTarget:j}]})}}for(var qE=0;qE<CN.length;qE++){var KE=CN[qE],Lie=KE.toLowerCase(),Iie=KE[0].toUpperCase()+KE.slice(1);Do(Lie,"on"+Iie)}Do(aI,"onAnimationEnd"),Do(sI,"onAnimationIteration"),Do(oI,"onAnimationStart"),Do("dblclick","onDoubleClick"),Do("focusin","onFocus"),Do("focusout","onBlur"),Do(Jre,"onTransitionRun"),Do(eie,"onTransitionStart"),Do(tie,"onTransitionCancel"),Do(lI,"onTransitionEnd"),Et("onMouseEnter",["mouseout","mouseover"]),Et("onMouseLeave",["mouseout","mouseover"]),Et("onPointerEnter",["pointerout","pointerover"]),Et("onPointerLeave",["pointerout","pointerover"]),vt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),vt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),vt("onBeforeInput",["compositionend","keypress","textInput","paste"]),vt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),vt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),vt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var jx="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(" "),Fie=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(jx));function CF(h,g){g=(g&4)!==0;for(var _=0;_<h.length;_++){var N=h[_],j=N.event;N=N.listeners;e:{var O=void 0;if(g)for(var J=N.length-1;0<=J;J--){var fe=N[J],je=fe.instance,tt=fe.currentTarget;if(fe=fe.listener,je!==O&&j.isPropagationStopped())break e;O=fe,j.currentTarget=tt;try{O(j)}catch(mt){Hy(mt)}j.currentTarget=null,O=je}else for(J=0;J<N.length;J++){if(fe=N[J],je=fe.instance,tt=fe.currentTarget,fe=fe.listener,je!==O&&j.isPropagationStopped())break e;O=fe,j.currentTarget=tt;try{O(j)}catch(mt){Hy(mt)}j.currentTarget=null,O=je}}}}function Sn(h,g){var _=g[yn];_===void 0&&(_=g[yn]=new Set);var N=h+"__bubble";_.has(N)||(kF(g,h,2,!1),_.add(N))}function XE(h,g,_){var N=0;g&&(N|=4),kF(_,h,N,g)}var Cv="_reactListening"+Math.random().toString(36).slice(2);function YE(h){if(!h[Cv]){h[Cv]=!0,Pe.forEach(function(_){_!=="selectionchange"&&(Fie.has(_)||XE(_,!1,h),XE(_,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[Cv]||(g[Cv]=!0,XE("selectionchange",!1,g))}}function kF(h,g,_,N){switch(aU(g)){case 2:var j=hae;break;case 8:j=fae;break;default:j=dA}_=j.bind(null,g,_,h),j=void 0,!gN||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(j=!0),N?j!==void 0?h.addEventListener(g,_,{capture:!0,passive:j}):h.addEventListener(g,_,!0):j!==void 0?h.addEventListener(g,_,{passive:j}):h.addEventListener(g,_,!1)}function QE(h,g,_,N,j){var O=N;if((g&1)===0&&(g&2)===0&&N!==null)e:for(;;){if(N===null)return;var J=N.tag;if(J===3||J===4){var fe=N.stateNode.containerInfo;if(fe===j)break;if(J===4)for(J=N.return;J!==null;){var je=J.tag;if((je===3||je===4)&&J.stateNode.containerInfo===j)return;J=J.return}for(;fe!==null;){if(J=Nt(fe),J===null)return;if(je=J.tag,je===5||je===6||je===26||je===27){N=O=J;continue e}fe=fe.parentNode}}N=N.return}OL(function(){var tt=O,mt=mN(_),xt=[];e:{var it=cI.get(h);if(it!==void 0){var ot=zy,Ft=h;switch(h){case"keypress":if(Fy(_)===0)break e;case"keydown":case"keyup":ot=jre;break;case"focusin":Ft="focus",ot=vN;break;case"focusout":Ft="blur",ot=vN;break;case"beforeblur":case"afterblur":ot=vN;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ot=FL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ot=yre;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ot=Dre;break;case aI:case sI:case oI:ot=wre;break;case lI:ot=Lre;break;case"scroll":case"scrollend":ot=xre;break;case"wheel":ot=Fre;break;case"copy":case"cut":case"paste":ot=Mre;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ot=zL;break;case"toggle":case"beforetoggle":ot=zre}var Kt=(g&4)!==0,ir=!Kt&&(h==="scroll"||h==="scrollend"),Ge=Kt?it!==null?it+"Capture":null:it;Kt=[];for(var Fe=tt,et;Fe!==null;){var gt=Fe;if(et=gt.stateNode,gt=gt.tag,gt!==5&&gt!==26&&gt!==27||et===null||Ge===null||(gt=Jg(Fe,Ge),gt!=null&&Kt.push(Px(Fe,gt,et))),ir)break;Fe=Fe.return}0<Kt.length&&(it=new ot(it,Ft,null,_,mt),xt.push({event:it,listeners:Kt}))}}if((g&7)===0){e:{if(it=h==="mouseover"||h==="pointerover",ot=h==="mouseout"||h==="pointerout",it&&_!==fN&&(Ft=_.relatedTarget||_.fromElement)&&(Nt(Ft)||Ft[Yt]))break e;if((ot||it)&&(it=mt.window===mt?mt:(it=mt.ownerDocument)?it.defaultView||it.parentWindow:window,ot?(Ft=_.relatedTarget||_.toElement,ot=tt,Ft=Ft?Nt(Ft):null,Ft!==null&&(ir=a(Ft),Kt=Ft.tag,Ft!==ir||Kt!==5&&Kt!==27&&Kt!==6)&&(Ft=null)):(ot=null,Ft=tt),ot!==Ft)){if(Kt=FL,gt="onMouseLeave",Ge="onMouseEnter",Fe="mouse",(h==="pointerout"||h==="pointerover")&&(Kt=zL,gt="onPointerLeave",Ge="onPointerEnter",Fe="pointer"),ir=ot==null?it:Se(ot),et=Ft==null?it:Se(Ft),it=new Kt(gt,Fe+"leave",ot,_,mt),it.target=ir,it.relatedTarget=et,gt=null,Nt(mt)===tt&&(Kt=new Kt(Ge,Fe+"enter",Ft,_,mt),Kt.target=et,Kt.relatedTarget=ir,gt=Kt),ir=gt,ot&&Ft)t:{for(Kt=Uie,Ge=ot,Fe=Ft,et=0,gt=Ge;gt;gt=Kt(gt))et++;gt=0;for(var Vt=Fe;Vt;Vt=Kt(Vt))gt++;for(;0<et-gt;)Ge=Kt(Ge),et--;for(;0<gt-et;)Fe=Kt(Fe),gt--;for(;et--;){if(Ge===Fe||Fe!==null&&Ge===Fe.alternate){Kt=Ge;break t}Ge=Kt(Ge),Fe=Kt(Fe)}Kt=null}else Kt=null;ot!==null&&jF(xt,it,ot,Kt,!1),Ft!==null&&ir!==null&&jF(xt,ir,Ft,Kt,!0)}}e:{if(it=tt?Se(tt):window,ot=it.nodeName&&it.nodeName.toLowerCase(),ot==="select"||ot==="input"&&it.type==="file")var On=KL;else if(WL(it))if(XL)On=Yre;else{On=Kre;var Bt=qre}else ot=it.nodeName,!ot||ot.toLowerCase()!=="input"||it.type!=="checkbox"&&it.type!=="radio"?tt&&hN(tt.elementType)&&(On=KL):On=Xre;if(On&&(On=On(h,tt))){qL(xt,On,_,mt);break e}Bt&&Bt(h,it,tt),h==="focusout"&&tt&&it.type==="number"&&tt.memoizedProps.value!=null&&Ii(it,"number",it.value)}switch(Bt=tt?Se(tt):window,h){case"focusin":(WL(Bt)||Bt.contentEditable==="true")&&(em=Bt,EN=tt,ox=null);break;case"focusout":ox=EN=em=null;break;case"mousedown":AN=!0;break;case"contextmenu":case"mouseup":case"dragend":AN=!1,rI(xt,_,mt);break;case"selectionchange":if(Zre)break;case"keydown":case"keyup":rI(xt,_,mt)}var dn;if(wN)e:{switch(h){case"compositionstart":var Cn="onCompositionStart";break e;case"compositionend":Cn="onCompositionEnd";break e;case"compositionupdate":Cn="onCompositionUpdate";break e}Cn=void 0}else Jf?VL(h,_)&&(Cn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(Cn="onCompositionStart");Cn&&(BL&&_.locale!=="ko"&&(Jf||Cn!=="onCompositionStart"?Cn==="onCompositionEnd"&&Jf&&(dn=LL()):(gu=mt,xN="value"in gu?gu.value:gu.textContent,Jf=!0)),Bt=kv(tt,Cn),0<Bt.length&&(Cn=new UL(Cn,h,null,_,mt),xt.push({event:Cn,listeners:Bt}),dn?Cn.data=dn:(dn=GL(_),dn!==null&&(Cn.data=dn)))),(dn=$re?Hre(h,_):Vre(h,_))&&(Cn=kv(tt,"onBeforeInput"),0<Cn.length&&(Bt=new UL("onBeforeInput","beforeinput",null,_,mt),xt.push({event:Bt,listeners:Cn}),Bt.data=dn)),Oie(xt,h,tt,_,mt)}CF(xt,g)})}function Px(h,g,_){return{instance:h,listener:g,currentTarget:_}}function kv(h,g){for(var _=g+"Capture",N=[];h!==null;){var j=h,O=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||O===null||(j=Jg(h,_),j!=null&&N.unshift(Px(h,j,O)),j=Jg(h,g),j!=null&&N.push(Px(h,j,O))),h.tag===3)return N;h=h.return}return[]}function Uie(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function jF(h,g,_,N,j){for(var O=g._reactName,J=[];_!==null&&_!==N;){var fe=_,je=fe.alternate,tt=fe.stateNode;if(fe=fe.tag,je!==null&&je===N)break;fe!==5&&fe!==26&&fe!==27||tt===null||(je=tt,j?(tt=Jg(_,O),tt!=null&&J.unshift(Px(_,tt,je))):j||(tt=Jg(_,O),tt!=null&&J.push(Px(_,tt,je)))),_=_.return}J.length!==0&&h.push({event:g,listeners:J})}var zie=/\r\n?/g,Bie=/\u0000|\uFFFD/g;function PF(h){return(typeof h=="string"?h:""+h).replace(zie,`
  9. `).replace(Bie,"")}function RF(h,g){return g=PF(g),PF(h)===g}function rr(h,g,_,N,j,O){switch(_){case"children":typeof N=="string"?g==="body"||g==="textarea"&&N===""||cl(h,N):(typeof N=="number"||typeof N=="bigint")&&g!=="body"&&cl(h,""+N);break;case"className":Ot(h,"class",N);break;case"tabIndex":Ot(h,"tabindex",N);break;case"dir":case"role":case"viewBox":case"width":case"height":Ot(h,_,N);break;case"style":RL(h,N,O);break;case"data":if(g!=="object"){Ot(h,"data",N);break}case"src":case"href":if(N===""&&(g!=="a"||_!=="href")){h.removeAttribute(_);break}if(N==null||typeof N=="function"||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(_);break}N=Ly(""+N),h.setAttribute(_,N);break;case"action":case"formAction":if(typeof N=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof O=="function"&&(_==="formAction"?(g!=="input"&&rr(h,g,"name",j.name,j,null),rr(h,g,"formEncType",j.formEncType,j,null),rr(h,g,"formMethod",j.formMethod,j,null),rr(h,g,"formTarget",j.formTarget,j,null)):(rr(h,g,"encType",j.encType,j,null),rr(h,g,"method",j.method,j,null),rr(h,g,"target",j.target,j,null)));if(N==null||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(_);break}N=Ly(""+N),h.setAttribute(_,N);break;case"onClick":N!=null&&(h.onclick=Ql);break;case"onScroll":N!=null&&Sn("scroll",h);break;case"onScrollEnd":N!=null&&Sn("scrollend",h);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=N&&typeof N!="function"&&typeof N!="symbol";break;case"muted":h.muted=N&&typeof N!="function"&&typeof N!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(N==null||typeof N=="function"||typeof N=="boolean"||typeof N=="symbol"){h.removeAttribute("xlink:href");break}_=Ly(""+N),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,""+N):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":N&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":N===!0?h.setAttribute(_,""):N!==!1&&N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(_,N):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":N!=null&&typeof N!="function"&&typeof N!="symbol"&&!isNaN(N)&&1<=N?h.setAttribute(_,N):h.removeAttribute(_);break;case"rowSpan":case"start":N==null||typeof N=="function"||typeof N=="symbol"||isNaN(N)?h.removeAttribute(_):h.setAttribute(_,N);break;case"popover":Sn("beforetoggle",h),Sn("toggle",h),zt(h,"popover",N);break;case"xlinkActuate":tn(h,"http://www.w3.org/1999/xlink","xlink:actuate",N);break;case"xlinkArcrole":tn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",N);break;case"xlinkRole":tn(h,"http://www.w3.org/1999/xlink","xlink:role",N);break;case"xlinkShow":tn(h,"http://www.w3.org/1999/xlink","xlink:show",N);break;case"xlinkTitle":tn(h,"http://www.w3.org/1999/xlink","xlink:title",N);break;case"xlinkType":tn(h,"http://www.w3.org/1999/xlink","xlink:type",N);break;case"xmlBase":tn(h,"http://www.w3.org/XML/1998/namespace","xml:base",N);break;case"xmlLang":tn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",N);break;case"xmlSpace":tn(h,"http://www.w3.org/XML/1998/namespace","xml:space",N);break;case"is":zt(h,"is",N);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=pre.get(_)||_,zt(h,_,N))}}function ZE(h,g,_,N,j,O){switch(_){case"style":RL(h,N,O);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof N=="string"?cl(h,N):(typeof N=="number"||typeof N=="bigint")&&cl(h,""+N);break;case"onScroll":N!=null&&Sn("scroll",h);break;case"onScrollEnd":N!=null&&Sn("scrollend",h);break;case"onClick":N!=null&&(h.onclick=Ql);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ct.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(j=_.endsWith("Capture"),g=_.slice(2,j?_.length-7:void 0),O=h[bt]||null,O=O!=null?O[_]:null,typeof O=="function"&&h.removeEventListener(g,O,j),typeof N=="function")){typeof O!="function"&&O!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(g,N,j);break e}_ in h?h[_]=N:N===!0?h.setAttribute(_,""):zt(h,_,N)}}}function sa(h,g,_){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Sn("error",h),Sn("load",h);var N=!1,j=!1,O;for(O in _)if(_.hasOwnProperty(O)){var J=_[O];if(J!=null)switch(O){case"src":N=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:rr(h,g,O,J,_,null)}}j&&rr(h,g,"srcSet",_.srcSet,_,null),N&&rr(h,g,"src",_.src,_,null);return;case"input":Sn("invalid",h);var fe=O=J=j=null,je=null,tt=null;for(N in _)if(_.hasOwnProperty(N)){var mt=_[N];if(mt!=null)switch(N){case"name":j=mt;break;case"type":J=mt;break;case"checked":je=mt;break;case"defaultChecked":tt=mt;break;case"value":O=mt;break;case"defaultValue":fe=mt;break;case"children":case"dangerouslySetInnerHTML":if(mt!=null)throw Error(r(137,g));break;default:rr(h,g,N,mt,_,null)}}Xn(h,O,fe,je,tt,J,j,!1);return;case"select":Sn("invalid",h),N=J=O=null;for(j in _)if(_.hasOwnProperty(j)&&(fe=_[j],fe!=null))switch(j){case"value":O=fe;break;case"defaultValue":J=fe;break;case"multiple":N=fe;default:rr(h,g,j,fe,_,null)}g=O,_=J,h.multiple=!!N,g!=null?wi(h,!!N,g,!1):_!=null&&wi(h,!!N,_,!0);return;case"textarea":Sn("invalid",h),O=j=N=null;for(J in _)if(_.hasOwnProperty(J)&&(fe=_[J],fe!=null))switch(J){case"value":N=fe;break;case"defaultValue":j=fe;break;case"children":O=fe;break;case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(91));break;default:rr(h,g,J,fe,_,null)}na(h,N,j,O);return;case"option":for(je in _)if(_.hasOwnProperty(je)&&(N=_[je],N!=null))switch(je){case"selected":h.selected=N&&typeof N!="function"&&typeof N!="symbol";break;default:rr(h,g,je,N,_,null)}return;case"dialog":Sn("beforetoggle",h),Sn("toggle",h),Sn("cancel",h),Sn("close",h);break;case"iframe":case"object":Sn("load",h);break;case"video":case"audio":for(N=0;N<jx.length;N++)Sn(jx[N],h);break;case"image":Sn("error",h),Sn("load",h);break;case"details":Sn("toggle",h);break;case"embed":case"source":case"link":Sn("error",h),Sn("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(tt in _)if(_.hasOwnProperty(tt)&&(N=_[tt],N!=null))switch(tt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:rr(h,g,tt,N,_,null)}return;default:if(hN(g)){for(mt in _)_.hasOwnProperty(mt)&&(N=_[mt],N!==void 0&&ZE(h,g,mt,N,_,void 0));return}}for(fe in _)_.hasOwnProperty(fe)&&(N=_[fe],N!=null&&rr(h,g,fe,N,_,null))}function $ie(h,g,_,N){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,O=null,J=null,fe=null,je=null,tt=null,mt=null;for(ot in _){var xt=_[ot];if(_.hasOwnProperty(ot)&&xt!=null)switch(ot){case"checked":break;case"value":break;case"defaultValue":je=xt;default:N.hasOwnProperty(ot)||rr(h,g,ot,null,N,xt)}}for(var it in N){var ot=N[it];if(xt=_[it],N.hasOwnProperty(it)&&(ot!=null||xt!=null))switch(it){case"type":O=ot;break;case"name":j=ot;break;case"checked":tt=ot;break;case"defaultChecked":mt=ot;break;case"value":J=ot;break;case"defaultValue":fe=ot;break;case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,g));break;default:ot!==xt&&rr(h,g,it,ot,N,xt)}}Ro(h,J,fe,je,tt,mt,O,j);return;case"select":ot=J=fe=it=null;for(O in _)if(je=_[O],_.hasOwnProperty(O)&&je!=null)switch(O){case"value":break;case"multiple":ot=je;default:N.hasOwnProperty(O)||rr(h,g,O,null,N,je)}for(j in N)if(O=N[j],je=_[j],N.hasOwnProperty(j)&&(O!=null||je!=null))switch(j){case"value":it=O;break;case"defaultValue":fe=O;break;case"multiple":J=O;default:O!==je&&rr(h,g,j,O,N,je)}g=fe,_=J,N=ot,it!=null?wi(h,!!_,it,!1):!!N!=!!_&&(g!=null?wi(h,!!_,g,!0):wi(h,!!_,_?[]:"",!1));return;case"textarea":ot=it=null;for(fe in _)if(j=_[fe],_.hasOwnProperty(fe)&&j!=null&&!N.hasOwnProperty(fe))switch(fe){case"value":break;case"children":break;default:rr(h,g,fe,null,N,j)}for(J in N)if(j=N[J],O=_[J],N.hasOwnProperty(J)&&(j!=null||O!=null))switch(J){case"value":it=j;break;case"defaultValue":ot=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==O&&rr(h,g,J,j,N,O)}Fi(h,it,ot);return;case"option":for(var Ft in _)if(it=_[Ft],_.hasOwnProperty(Ft)&&it!=null&&!N.hasOwnProperty(Ft))switch(Ft){case"selected":h.selected=!1;break;default:rr(h,g,Ft,null,N,it)}for(je in N)if(it=N[je],ot=_[je],N.hasOwnProperty(je)&&it!==ot&&(it!=null||ot!=null))switch(je){case"selected":h.selected=it&&typeof it!="function"&&typeof it!="symbol";break;default:rr(h,g,je,it,N,ot)}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 Kt in _)it=_[Kt],_.hasOwnProperty(Kt)&&it!=null&&!N.hasOwnProperty(Kt)&&rr(h,g,Kt,null,N,it);for(tt in N)if(it=N[tt],ot=_[tt],N.hasOwnProperty(tt)&&it!==ot&&(it!=null||ot!=null))switch(tt){case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(r(137,g));break;default:rr(h,g,tt,it,N,ot)}return;default:if(hN(g)){for(var ir in _)it=_[ir],_.hasOwnProperty(ir)&&it!==void 0&&!N.hasOwnProperty(ir)&&ZE(h,g,ir,void 0,N,it);for(mt in N)it=N[mt],ot=_[mt],!N.hasOwnProperty(mt)||it===ot||it===void 0&&ot===void 0||ZE(h,g,mt,it,N,ot);return}}for(var Ge in _)it=_[Ge],_.hasOwnProperty(Ge)&&it!=null&&!N.hasOwnProperty(Ge)&&rr(h,g,Ge,null,N,it);for(xt in N)it=N[xt],ot=_[xt],!N.hasOwnProperty(xt)||it===ot||it==null&&ot==null||rr(h,g,xt,it,N,ot)}function DF(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Hie(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,_=performance.getEntriesByType("resource"),N=0;N<_.length;N++){var j=_[N],O=j.transferSize,J=j.initiatorType,fe=j.duration;if(O&&fe&&DF(J)){for(J=0,fe=j.responseEnd,N+=1;N<_.length;N++){var je=_[N],tt=je.startTime;if(tt>fe)break;var mt=je.transferSize,xt=je.initiatorType;mt&&DF(xt)&&(je=je.responseEnd,J+=mt*(je<fe?1:(fe-tt)/(je-tt)))}if(--N,g+=8*(O+J)/(j.duration/1e3),h++,10<h)break}}if(0<h)return g/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var JE=null,eA=null;function jv(h){return h.nodeType===9?h:h.ownerDocument}function OF(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function LF(h,g){if(h===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&g==="foreignObject"?0:h}function tA(h,g){return h==="textarea"||h==="noscript"||typeof g.children=="string"||typeof g.children=="number"||typeof g.children=="bigint"||typeof g.dangerouslySetInnerHTML=="object"&&g.dangerouslySetInnerHTML!==null&&g.dangerouslySetInnerHTML.__html!=null}var nA=null;function Vie(){var h=window.event;return h&&h.type==="popstate"?h===nA?!1:(nA=h,!0):(nA=null,!1)}var IF=typeof setTimeout=="function"?setTimeout:void 0,Gie=typeof clearTimeout=="function"?clearTimeout:void 0,FF=typeof Promise=="function"?Promise:void 0,Wie=typeof queueMicrotask=="function"?queueMicrotask:typeof FF<"u"?function(h){return FF.resolve(null).then(h).catch(qie)}:IF;function qie(h){setTimeout(function(){throw h})}function Ru(h){return h==="head"}function UF(h,g){var _=g,N=0;do{var j=_.nextSibling;if(h.removeChild(_),j&&j.nodeType===8)if(_=j.data,_==="/$"||_==="/&"){if(N===0){h.removeChild(j),Am(g);return}N--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")N++;else if(_==="html")Rx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Rx(_);for(var O=_.firstChild;O;){var J=O.nextSibling,fe=O.nodeName;O[Ke]||fe==="SCRIPT"||fe==="STYLE"||fe==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=J}}else _==="body"&&Rx(h.ownerDocument.body);_=j}while(_);Am(g)}function zF(h,g){var _=h;h=0;do{var N=_.nextSibling;if(_.nodeType===1?g?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(g?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),N&&N.nodeType===8)if(_=N.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=N}while(_)}function rA(h){var g=h.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var _=g;switch(g=g.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":rA(_),Qe(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Kie(h,g,_,N){for(;h.nodeType===1;){var j=_;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!N&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(N){if(!h[Ke])switch(g){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(O=h.getAttribute("rel"),O==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(O!==j.rel||h.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||h.getAttribute("title")!==(j.title==null?null:j.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(O=h.getAttribute("src"),(O!==(j.src==null?null:j.src)||h.getAttribute("type")!==(j.type==null?null:j.type)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&O&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var O=j.name==null?null:""+j.name;if(j.type==="hidden"&&h.getAttribute("name")===O)return h}else return h;if(h=to(h.nextSibling),h===null)break}return null}function Xie(h,g,_){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=to(h.nextSibling),h===null))return null;return h}function BF(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=to(h.nextSibling),h===null))return null;return h}function iA(h){return h.data==="$?"||h.data==="$~"}function aA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Yie(h,g){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||_.readyState!=="loading")g();else{var N=function(){g(),_.removeEventListener("DOMContentLoaded",N)};_.addEventListener("DOMContentLoaded",N),h._reactRetry=N}}function to(h){for(;h!=null;h=h.nextSibling){var g=h.nodeType;if(g===1||g===3)break;if(g===8){if(g=h.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return h}var sA=null;function $F(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(g===0)return to(h.nextSibling);g--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||g++}h=h.nextSibling}return null}function HF(h){h=h.previousSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(g===0)return h;g--}else _!=="/$"&&_!=="/&"||g++}h=h.previousSibling}return null}function VF(h,g,_){switch(g=jv(_),h){case"html":if(h=g.documentElement,!h)throw Error(r(452));return h;case"head":if(h=g.head,!h)throw Error(r(453));return h;case"body":if(h=g.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Rx(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);Qe(h)}var no=new Map,GF=new Set;function Pv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var fc=q.d;q.d={f:Qie,r:Zie,D:Jie,C:eae,L:tae,m:nae,X:iae,S:rae,M:aae};function Qie(){var h=fc.f(),g=Sv();return h||g}function Zie(h){var g=le(h);g!==null&&g.tag===5&&g.type==="form"?l5(g):fc.r(h)}var Mm=typeof document>"u"?null:document;function WF(h,g,_){var N=Mm;if(N&&typeof g=="string"&&g){var j=Gn(g);j='link[rel="'+h+'"][href="'+j+'"]',typeof _=="string"&&(j+='[crossorigin="'+_+'"]'),GF.has(j)||(GF.add(j),h={rel:h,crossOrigin:_,href:g},N.querySelector(j)===null&&(g=N.createElement("link"),sa(g,"link",h),Oe(g),N.head.appendChild(g)))}}function Jie(h){fc.D(h),WF("dns-prefetch",h,null)}function eae(h,g){fc.C(h,g),WF("preconnect",h,g)}function tae(h,g,_){fc.L(h,g,_);var N=Mm;if(N&&h&&g){var j='link[rel="preload"][as="'+Gn(g)+'"]';g==="image"&&_&&_.imageSrcSet?(j+='[imagesrcset="'+Gn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(j+='[imagesizes="'+Gn(_.imageSizes)+'"]')):j+='[href="'+Gn(h)+'"]';var O=j;switch(g){case"style":O=Nm(h);break;case"script":O=Em(h)}no.has(O)||(h=f({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:h,as:g},_),no.set(O,h),N.querySelector(j)!==null||g==="style"&&N.querySelector(Dx(O))||g==="script"&&N.querySelector(Ox(O))||(g=N.createElement("link"),sa(g,"link",h),Oe(g),N.head.appendChild(g)))}}function nae(h,g){fc.m(h,g);var _=Mm;if(_&&h){var N=g&&typeof g.as=="string"?g.as:"script",j='link[rel="modulepreload"][as="'+Gn(N)+'"][href="'+Gn(h)+'"]',O=j;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=Em(h)}if(!no.has(O)&&(h=f({rel:"modulepreload",href:h},g),no.set(O,h),_.querySelector(j)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Ox(O)))return}N=_.createElement("link"),sa(N,"link",h),Oe(N),_.head.appendChild(N)}}}function rae(h,g,_){fc.S(h,g,_);var N=Mm;if(N&&h){var j=Le(N).hoistableStyles,O=Nm(h);g=g||"default";var J=j.get(O);if(!J){var fe={loading:0,preload:null};if(J=N.querySelector(Dx(O)))fe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},_),(_=no.get(O))&&oA(h,_);var je=J=N.createElement("link");Oe(je),sa(je,"link",h),je._p=new Promise(function(tt,mt){je.onload=tt,je.onerror=mt}),je.addEventListener("load",function(){fe.loading|=1}),je.addEventListener("error",function(){fe.loading|=2}),fe.loading|=4,Rv(J,g,N)}J={type:"stylesheet",instance:J,count:1,state:fe},j.set(O,J)}}}function iae(h,g){fc.X(h,g);var _=Mm;if(_&&h){var N=Le(_).hoistableScripts,j=Em(h),O=N.get(j);O||(O=_.querySelector(Ox(j)),O||(h=f({src:h,async:!0},g),(g=no.get(j))&&lA(h,g),O=_.createElement("script"),Oe(O),sa(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},N.set(j,O))}}function aae(h,g){fc.M(h,g);var _=Mm;if(_&&h){var N=Le(_).hoistableScripts,j=Em(h),O=N.get(j);O||(O=_.querySelector(Ox(j)),O||(h=f({src:h,async:!0,type:"module"},g),(g=no.get(j))&&lA(h,g),O=_.createElement("script"),Oe(O),sa(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},N.set(j,O))}}function qF(h,g,_,N){var j=(j=de.current)?Pv(j):null;if(!j)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(g=Nm(_.href),_=Le(j).hoistableStyles,N=_.get(g),N||(N={type:"style",instance:null,count:0,state:null},_.set(g,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Nm(_.href);var O=Le(j).hoistableStyles,J=O.get(h);if(J||(j=j.ownerDocument||j,J={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(h,J),(O=j.querySelector(Dx(h)))&&!O._p&&(J.instance=O,J.state.loading=5),no.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},no.set(h,_),O||sae(j,h,_,J.state))),g&&N===null)throw Error(r(528,""));return J}if(g&&N!==null)throw Error(r(529,""));return null;case"script":return g=_.async,_=_.src,typeof _=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=Em(_),_=Le(j).hoistableScripts,N=_.get(g),N||(N={type:"script",instance:null,count:0,state:null},_.set(g,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Nm(h){return'href="'+Gn(h)+'"'}function Dx(h){return'link[rel="stylesheet"]['+h+"]"}function KF(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function sae(h,g,_,N){h.querySelector('link[rel="preload"][as="style"]['+g+"]")?N.loading=1:(g=h.createElement("link"),N.preload=g,g.addEventListener("load",function(){return N.loading|=1}),g.addEventListener("error",function(){return N.loading|=2}),sa(g,"link",_),Oe(g),h.head.appendChild(g))}function Em(h){return'[src="'+Gn(h)+'"]'}function Ox(h){return"script[async]"+h}function XF(h,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var N=h.querySelector('style[data-href~="'+Gn(_.href)+'"]');if(N)return g.instance=N,Oe(N),N;var j=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return N=(h.ownerDocument||h).createElement("style"),Oe(N),sa(N,"style",j),Rv(N,_.precedence,h),g.instance=N;case"stylesheet":j=Nm(_.href);var O=h.querySelector(Dx(j));if(O)return g.state.loading|=4,g.instance=O,Oe(O),O;N=KF(_),(j=no.get(j))&&oA(N,j),O=(h.ownerDocument||h).createElement("link"),Oe(O);var J=O;return J._p=new Promise(function(fe,je){J.onload=fe,J.onerror=je}),sa(O,"link",N),g.state.loading|=4,Rv(O,_.precedence,h),g.instance=O;case"script":return O=Em(_.src),(j=h.querySelector(Ox(O)))?(g.instance=j,Oe(j),j):(N=_,(j=no.get(O))&&(N=f({},_),lA(N,j)),h=h.ownerDocument||h,j=h.createElement("script"),Oe(j),sa(j,"link",N),h.head.appendChild(j),g.instance=j);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(N=g.instance,g.state.loading|=4,Rv(N,_.precedence,h));return g.instance}function Rv(h,g,_){for(var N=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=N.length?N[N.length-1]:null,O=j,J=0;J<N.length;J++){var fe=N[J];if(fe.dataset.precedence===g)O=fe;else if(O!==j)break}O?O.parentNode.insertBefore(h,O.nextSibling):(g=_.nodeType===9?_.head:_,g.insertBefore(h,g.firstChild))}function oA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function lA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var Dv=null;function YF(h,g,_){if(Dv===null){var N=new Map,j=Dv=new Map;j.set(_,N)}else j=Dv,N=j.get(_),N||(N=new Map,j.set(_,N));if(N.has(h))return N;for(N.set(h,null),_=_.getElementsByTagName(h),j=0;j<_.length;j++){var O=_[j];if(!(O[Ke]||O[hr]||h==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var J=O.getAttribute(g)||"";J=h+J;var fe=N.get(J);fe?fe.push(O):N.set(J,[O])}}return N}function QF(h,g,_){h=h.ownerDocument||h,h.head.insertBefore(_,g==="title"?h.querySelector("head > title"):null)}function oae(h,g,_){if(_===1||g.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof g.precedence!="string"||typeof g.href!="string"||g.href==="")break;return!0;case"link":if(typeof g.rel!="string"||typeof g.href!="string"||g.href===""||g.onLoad||g.onError)break;switch(g.rel){case"stylesheet":return h=g.disabled,typeof g.precedence=="string"&&h==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 ZF(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function lae(h,g,_,N){if(_.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var j=Nm(N.href),O=g.querySelector(Dx(j));if(O){g=O._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=Ov.bind(h),g.then(h,h)),_.state.loading|=4,_.instance=O,Oe(O);return}O=g.ownerDocument||g,N=KF(N),(j=no.get(j))&&oA(N,j),O=O.createElement("link"),Oe(O);var J=O;J._p=new Promise(function(fe,je){J.onload=fe,J.onerror=je}),sa(O,"link",N),_.instance=O}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,g),(g=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=Ov.bind(h),g.addEventListener("load",_),g.addEventListener("error",_))}}var cA=0;function cae(h,g){return h.stylesheets&&h.count===0&&Iv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var N=setTimeout(function(){if(h.stylesheets&&Iv(h,h.stylesheets),h.unsuspend){var O=h.unsuspend;h.unsuspend=null,O()}},6e4+g);0<h.imgBytes&&cA===0&&(cA=62500*Hie());var j=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&Iv(h,h.stylesheets),h.unsuspend)){var O=h.unsuspend;h.unsuspend=null,O()}},(h.imgBytes>cA?50:800)+g);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(N),clearTimeout(j)}}:null}function Ov(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Iv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var Lv=null;function Iv(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,Lv=new Map,g.forEach(uae,h),Lv=null,Ov.call(h))}function uae(h,g){if(!(g.state.loading&4)){var _=Lv.get(h);if(_)var N=_.get(null);else{_=new Map,Lv.set(h,_);for(var j=h.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<j.length;O++){var J=j[O];(J.nodeName==="LINK"||J.getAttribute("media")!=="not all")&&(_.set(J.dataset.precedence,J),N=J)}N&&_.set(null,N)}j=g.instance,J=j.getAttribute("data-precedence"),O=_.get(J)||N,O===N&&_.set(null,j),_.set(J,j),this.count++,N=Ov.bind(this),j.addEventListener("load",N),j.addEventListener("error",N),O?O.parentNode.insertBefore(j,O.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(j,h.firstChild)),g.state.loading|=4}}var Lx={$$typeof:S,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function dae(h,g,_,N,j,O,J,fe,je){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ct(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ct(0),this.hiddenUpdates=Ct(null),this.identifierPrefix=N,this.onUncaughtError=j,this.onCaughtError=O,this.onRecoverableError=J,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=je,this.incompleteTransitions=new Map}function JF(h,g,_,N,j,O,J,fe,je,tt,mt,xt){return h=new dae(h,g,_,J,je,tt,mt,xt,fe),g=1,O===!0&&(g|=24),O=_s(3,null,null,g),h.current=O,O.stateNode=h,g=$N(),g.refCount++,h.pooledCache=g,g.refCount++,O.memoizedState={element:N,isDehydrated:_,cache:g},WN(O),h}function eU(h){return h?(h=rm,h):rm}function tU(h,g,_,N,j,O){j=eU(j),N.context===null?N.context=j:N.pendingContext=j,N=wu(g),N.payload={element:_},O=O===void 0?null:O,O!==null&&(N.callback=O),_=Su(h,N,g),_!==null&&(ts(_,h,g),mx(_,h,g))}function nU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<g?_:g}}function uA(h,g){nU(h,g),(h=h.alternate)&&nU(h,g)}function rU(h){if(h.tag===13||h.tag===31){var g=sh(h,67108864);g!==null&&ts(g,h,67108864),uA(h,67108864)}}function iU(h){if(h.tag===13||h.tag===31){var g=Es();g=zn(g);var _=sh(h,g);_!==null&&ts(_,h,g),uA(h,g)}}var Fv=!0;function hae(h,g,_,N){var j=Y.T;Y.T=null;var O=q.p;try{q.p=2,dA(h,g,_,N)}finally{q.p=O,Y.T=j}}function fae(h,g,_,N){var j=Y.T;Y.T=null;var O=q.p;try{q.p=8,dA(h,g,_,N)}finally{q.p=O,Y.T=j}}function dA(h,g,_,N){if(Fv){var j=hA(N);if(j===null)QE(h,g,N,Uv,_),sU(h,N);else if(pae(j,h,g,_,N))N.stopPropagation();else if(sU(h,N),g&4&&-1<mae.indexOf(h)){for(;j!==null;){var O=le(j);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var J=De(O.pendingLanes);if(J!==0){var fe=O;for(fe.pendingLanes|=2,fe.entangledLanes|=2;J;){var je=1<<31-Xe(J);fe.entanglements[1]|=je,J&=~je}fl(O),(Bn&6)===0&&(_v=L()+500,kx(0))}}break;case 31:case 13:fe=sh(O,2),fe!==null&&ts(fe,O,2),Sv(),uA(O,2)}if(O=hA(N),O===null&&QE(h,g,N,Uv,_),O===j)break;j=O}j!==null&&N.stopPropagation()}else QE(h,g,N,null,_)}}function hA(h){return h=mN(h),fA(h)}var Uv=null;function fA(h){if(Uv=null,h=Nt(h),h!==null){var g=a(h);if(g===null)h=null;else{var _=g.tag;if(_===13){if(h=o(g),h!==null)return h;h=null}else if(_===31){if(h=l(g),h!==null)return h;h=null}else if(_===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;h=null}else g!==h&&(h=null)}}return Uv=h,null}function aU(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(oe()){case ce:return 2;case xe:return 8;case ve:case _e:return 32;case Ie:return 268435456;default:return 32}default:return 32}}var mA=!1,Du=null,Ou=null,Lu=null,Ix=new Map,Fx=new Map,Iu=[],mae="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 sU(h,g){switch(h){case"focusin":case"focusout":Du=null;break;case"dragenter":case"dragleave":Ou=null;break;case"mouseover":case"mouseout":Lu=null;break;case"pointerover":case"pointerout":Ix.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fx.delete(g.pointerId)}}function Ux(h,g,_,N,j,O){return h===null||h.nativeEvent!==O?(h={blockedOn:g,domEventName:_,eventSystemFlags:N,nativeEvent:O,targetContainers:[j]},g!==null&&(g=le(g),g!==null&&rU(g)),h):(h.eventSystemFlags|=N,g=h.targetContainers,j!==null&&g.indexOf(j)===-1&&g.push(j),h)}function pae(h,g,_,N,j){switch(g){case"focusin":return Du=Ux(Du,h,g,_,N,j),!0;case"dragenter":return Ou=Ux(Ou,h,g,_,N,j),!0;case"mouseover":return Lu=Ux(Lu,h,g,_,N,j),!0;case"pointerover":var O=j.pointerId;return Ix.set(O,Ux(Ix.get(O)||null,h,g,_,N,j)),!0;case"gotpointercapture":return O=j.pointerId,Fx.set(O,Ux(Fx.get(O)||null,h,g,_,N,j)),!0}return!1}function oU(h){var g=Nt(h.target);if(g!==null){var _=a(g);if(_!==null){if(g=_.tag,g===13){if(g=o(_),g!==null){h.blockedOn=g,$r(h.priority,function(){iU(_)});return}}else if(g===31){if(g=l(_),g!==null){h.blockedOn=g,$r(h.priority,function(){iU(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function zv(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var _=hA(h.nativeEvent);if(_===null){_=h.nativeEvent;var N=new _.constructor(_.type,_);fN=N,_.target.dispatchEvent(N),fN=null}else return g=le(_),g!==null&&rU(g),h.blockedOn=_,!1;g.shift()}return!0}function lU(h,g,_){zv(h)&&_.delete(g)}function gae(){mA=!1,Du!==null&&zv(Du)&&(Du=null),Ou!==null&&zv(Ou)&&(Ou=null),Lu!==null&&zv(Lu)&&(Lu=null),Ix.forEach(lU),Fx.forEach(lU)}function Bv(h,g){h.blockedOn===g&&(h.blockedOn=null,mA||(mA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,gae)))}var $v=null;function cU(h){$v!==h&&($v=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){$v===h&&($v=null);for(var g=0;g<h.length;g+=3){var _=h[g],N=h[g+1],j=h[g+2];if(typeof N!="function"){if(fA(N||_)===null)continue;break}var O=le(_);O!==null&&(h.splice(g,3),g-=3,hE(O,{pending:!0,data:j,method:_.method,action:N},N,j))}}))}function Am(h){function g(je){return Bv(je,h)}Du!==null&&Bv(Du,h),Ou!==null&&Bv(Ou,h),Lu!==null&&Bv(Lu,h),Ix.forEach(g),Fx.forEach(g);for(var _=0;_<Iu.length;_++){var N=Iu[_];N.blockedOn===h&&(N.blockedOn=null)}for(;0<Iu.length&&(_=Iu[0],_.blockedOn===null);)oU(_),_.blockedOn===null&&Iu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(N=0;N<_.length;N+=3){var j=_[N],O=_[N+1],J=j[bt]||null;if(typeof O=="function")J||cU(_);else if(J){var fe=null;if(O&&O.hasAttribute("formAction")){if(j=O,J=O[bt]||null)fe=J.formAction;else if(fA(j)!==null)continue}else fe=J.action;typeof fe=="function"?_[N+1]=fe:(_.splice(N,3),N-=3),cU(_)}}}function uU(){function h(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(J){return j=J})},focusReset:"manual",scroll:"manual"})}function g(){j!==null&&(j(),j=null),N||setTimeout(_,20)}function _(){if(!N&&!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 N=!1,j=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(_,100),function(){N=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),j!==null&&(j(),j=null)}}}function pA(h){this._internalRoot=h}Hv.prototype.render=pA.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,N=Es();tU(_,N,h,g,null,null)},Hv.prototype.unmount=pA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;tU(h.current,2,null,h,null,null),Sv(),g[Yt]=null}};function Hv(h){this._internalRoot=h}Hv.prototype.unstable_scheduleHydration=function(h){if(h){var g=_r();h={blockedOn:null,target:h,priority:g};for(var _=0;_<Iu.length&&g!==0&&g<Iu[_].priority;_++);Iu.splice(_,0,h),_===0&&oU(h)}};var dU=e.version;if(dU!=="19.2.0")throw Error(r(527,dU,"19.2.0"));q.findDOMNode=function(h){var g=h._reactInternals;if(g===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(g),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var xae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Vv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vv.isDisabled&&Vv.supportsFiber)try{qe=Vv.inject(xae),me=Vv}catch{}}return Bx.createRoot=function(h,g){if(!i(h))throw Error(r(299));var _=!1,N="",j=b5,O=y5,J=v5;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(N=g.identifierPrefix),g.onUncaughtError!==void 0&&(j=g.onUncaughtError),g.onCaughtError!==void 0&&(O=g.onCaughtError),g.onRecoverableError!==void 0&&(J=g.onRecoverableError)),g=JF(h,1,!1,null,null,_,N,null,j,O,J,uU),h[Yt]=g.current,YE(h),new pA(g)},Bx.hydrateRoot=function(h,g,_){if(!i(h))throw Error(r(299));var N=!1,j="",O=b5,J=y5,fe=v5,je=null;return _!=null&&(_.unstable_strictMode===!0&&(N=!0),_.identifierPrefix!==void 0&&(j=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(J=_.onCaughtError),_.onRecoverableError!==void 0&&(fe=_.onRecoverableError),_.formState!==void 0&&(je=_.formState)),g=JF(h,1,!0,g,_??null,N,j,je,O,J,fe,uU),g.context=eU(null),_=g.current,N=Es(),N=zn(N),j=wu(N),j.callback=null,Su(_,j,N),_=N,g.current.lanes=_,Xt(g,_),fl(g),h[Yt]=g.current,YE(h),new Hv(g)},Bx.version="19.2.0",Bx}var _U;function Tae(){if(_U)return bA.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(),bA.exports=Aae(),bA.exports}var Cae=Tae();const Zt=t=>typeof t=="string",$x=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},wU=t=>t==null?"":""+t,kae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},jae=/###/g,SU=t=>t&&t.indexOf("###")>-1?t.replace(jae,"."):t,MU=t=>!t||Zt(t),kb=(t,e,n)=>{const r=Zt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(MU(t))return{};const a=SU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return MU(t)?{}:{obj:t,k:SU(r[i])}},NU=(t,e,n)=>{const{obj:r,k:i}=kb(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],o=e.slice(0,e.length-1),l=kb(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=kb(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},Pae=(t,e,n,r)=>{const{obj:i,k:a}=kb(t,e,Object);i[a]=i[a]||[],i[a].push(n)},rw=(t,e)=>{const{obj:n,k:r}=kb(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Rae=(t,e,n)=>{const r=rw(t,n);return r!==void 0?r:rw(e,n)},YG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Zt(t[r])||t[r]instanceof String||Zt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):YG(t[r],e[r],n):t[r]=e[r]);return t},Tm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Dae={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Oae=t=>Zt(t)?t.replace(/[&<>"'\/]/g,e=>Dae[e]):t;class Lae{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 Iae=[" ",",","?","!",";"],Fae=new Lae(20),Uae=(t,e,n)=>{e=e||"",n=n||"";const r=Iae.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Fae.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let a=!i.test(t);if(!a){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(a=!0)}return a},Sj=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=o}return i},e0=t=>t?.replace("_","-"),zae={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 iw{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||zae,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:(Zt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new iw(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new iw(this.logger,e)}}var Nl=new iw;let w2=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i.apply(i,[e,...n])})}};class EU extends w2{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):Zt(r)&&a?l.push(...r.split(a)):l.push(r)));const c=rw(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!Zt(r)?c:Sj(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const o=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),NU(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(Zt(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,o={silent:!1,skipCopy:!1}){let l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=rw(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?YG(c,r,a):c={...c,...r},NU(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 QG={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const ZG=Symbol("i18next/PATH_KEY");function Bae(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===ZG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Mj(t,e){const{[ZG]:n}=t(Bae());return n.join(e?.keySeparator??".")}const AU={},wA=t=>!Zt(t)&&typeof t!="boolean"&&typeof t!="number";class aw extends w2{constructor(e,n={}){super(),kae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Nl.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=wA(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Uae(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:Zt(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:Zt(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=Mj(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const p=this.resolve(e,i);let x=p?.res;const v=p?.usedKey||l,b=p?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],M=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!Zt(i.count),E=aw.hasDefaultValue(i),k=A?this.pluralResolver.getSuffix(f,i.count,i):"",C=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",R=A&&!i.ordinal&&i.count===0,T=R&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${C}`]||i.defaultValue;let P=x;S&&!x&&E&&(P=T);const F=wA(P),I=Object.prototype.toString.apply(P);if(S&&P&&F&&y.indexOf(I)<0&&!(Zt(M)&&Array.isArray(P))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const X=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,P,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(p.res=X,p.usedParams=this.getUsedParamsDetails(i),p):X}if(o){const X=Array.isArray(P),D=X?[]:{},K=X?b:v;for(const Y in P)if(Object.prototype.hasOwnProperty.call(P,Y)){const q=`${K}${o}${Y}`;E&&!x?D[Y]=this.translate(q,{...i,defaultValue:wA(T)?T[Y]:void 0,joinArrays:!1,ns:c}):D[Y]=this.translate(q,{...i,joinArrays:!1,ns:c}),D[Y]===q&&(D[Y]=P[Y])}x=D}}else if(S&&Zt(M)&&Array.isArray(x))x=x.join(M),x&&(x=this.extendTranslation(x,e,i,r));else{let X=!1,D=!1;!this.isValidLookup(x)&&E&&(X=!0,x=T),this.isValidLookup(x)||(D=!0,x=l);const Y=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&D?void 0:x,q=E&&T!==x&&this.options.updateMissing;if(D||X||q){if(this.logger.log(q?"updateKey":"missingKey",f,u,l,q?T:x),o){const U=this.resolve(l,{...i,keySeparator:!1});U&&U.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Z=[];const re=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&re&&re[0])for(let U=0;U<re.length;U++)Z.push(re[U]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(i.lng||this.language):Z.push(i.lng||this.language);const ie=(U,G,ee)=>{const ne=E&&ee!==x?ee:Y;this.options.missingKeyHandler?this.options.missingKeyHandler(U,u,G,ne,q,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(U,u,G,ne,q,i),this.emit("missingKey",U,u,G,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?Z.forEach(U=>{const G=this.pluralResolver.getSuffixes(U,i);R&&i[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(ee=>{ie([U],l+ee,i[`defaultValue${ee}`]||T)})}):ie(Z,l,T))}x=this.extendTranslation(x,e,i,p,r),D&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(D||X)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,X?x:void 0,i))}return a?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=Zt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!Zt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),m=f&&f.length;u<m&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=Zt(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=QG.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,o,l;return Zt(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!Zt(n.count),p=m&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(Zt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!AU[`${v[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(AU[`${v[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${v.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!!!")),v.forEach(y=>{if(this.isValidLookup(r))return;o=y;const M=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,d,y,b,n);else{let A;m&&(A=this.pluralResolver.getSuffix(y,n.count,n));const E=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&A.indexOf(k)===0&&M.push(d+A.replace(k,this.options.pluralSeparator)),M.push(d+A),p&&M.push(d+E)),x){const C=`${d}${this.options.contextSeparator||"_"}${n.context}`;M.push(C),m&&(n.ordinal&&A.indexOf(k)===0&&M.push(C+A.replace(k,this.options.pluralSeparator)),M.push(C+A),p&&M.push(C+E))}}let S;for(;S=M.pop();)this.isValidLookup(r)||(a=S,r=this.getResource(y,b,S,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:o,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Zt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class TU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Nl.create("languageUtils")}getScriptPartFromCode(e){if(e=e0(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=e0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Zt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(o=>{if(o===a)return o;if(!(o.indexOf("-")<0&&a.indexOf("-")<0)&&(o.indexOf("-")>0&&a.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===a||o.indexOf(a)===0&&a.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Zt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],a=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return Zt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):Zt(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const CU={zero:0,one:1,two:2,few:3,many:4,other:5},kU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class $ae{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Nl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=e0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),kU;if(!e.match(/-|_/))return kU;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[a]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,a)=>CU[i]-CU[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const jU=(t,e,n,r=".",i=!0)=>{let a=Rae(t,e,n);return!a&&i&&Zt(n)&&(a=Sj(t,n,r),a===void 0&&(a=Sj(e,n,r))),a},SA=t=>t.replace(/\$/g,"$$$$");class Hae{constructor(e={}){this.logger=Nl.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:y,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:Oae,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Tm(a):o||"{{",this.suffix=l?Tm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?Tm(m):p||Tm("$t("),this.nestingSuffix=x?Tm(x):v||Tm(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=y||1e3,this.alwaysFormat=M!==void 0?M:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let a,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=p=>{if(p.indexOf(this.formatSeparator)<0){const y=jU(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...i,...n,interpolationkey:p}):y}const x=p.split(this.formatSeparator),v=x.shift().trim(),b=x.join(this.formatSeparator).trim();return this.format(jU(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>SA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?SA(this.escape(p)):SA(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const x=a[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const b=d(e,a,i);o=Zt(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!Zt(o)&&!this.useRawValueToEscape&&(o=wU(o));const v=p.safeValue(o);if(e=e.replace(a[0],v),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=a[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let m=`{${f[1]}`;c=f[0],m=this.interpolate(m,o);const p=m.match(/'/g),x=m.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!Zt(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),a=n(l.call(this,i[1].trim(),o),o),a&&i[0]===e&&!Zt(a))return a;Zt(a)||(a=wU(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const Vae=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}},PU=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const o=r+JSON.stringify(a);let l=e[o];return l||(l=t(e0(r),i),e[o]=l),l(n)}},Gae=t=>(e,n,r)=>t(e0(n),r)(e);class Wae{constructor(e={}){this.logger=Nl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?PU:Gae;this.formats={number:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a});return l=>o.format(l)}),currency:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>o.format(l)}),datetime:r((i,a)=>{const o=new Intl.DateTimeFormat(i,{...a});return l=>o.format(l)}),relativetime:r((i,a)=>{const o=new Intl.RelativeTimeFormat(i,{...a});return l=>o.format(l,a.range||"day")}),list:r((i,a)=>{const o=new Intl.ListFormat(i,{...a});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=PU(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:u,formatOptions:d}=Vae(c);if(this.formats[u]){let f=l;try{const m=i?.formatParams?.[i.interpolationkey]||{},p=m.locale||m.lng||i.locale||i.lng||r;f=this.formats[u](l,p,{...d,...i,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const qae=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Kae extends w2{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Nl.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const m=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,d=!1,o[m]===void 0&&(o[m]=!0),a[m]===void 0&&(a[m]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],o=i[1];n&&this.emit("failedLoading",a,o,n),!n&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{Pae(c.loaded,[a],o),qae(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:o});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,o)},a);return}o(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(e,n,l)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Zt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Zt(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,a,o={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const RU=()=>({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]),Zt(t[1])&&(e.defaultValue=t[1]),Zt(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}),DU=t=>(Zt(t.ns)&&(t.ns=[t.ns]),Zt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Zt(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),Wv=()=>{},Xae=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class jb extends w2{constructor(e={},n){if(super(),this.options=DU(e),this.services={},this.logger=Nl,this.modules={external:[]},Xae(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&&(Zt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=RU();this.options={...r,...this.options,...DU(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?Nl.init(i(this.modules.logger),this.options):Nl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Wae;const d=new TU(this.options);this.store=new EU(this.options.resources,this.options);const f=this.services;f.logger=Nl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new $ae(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Hae(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Kae(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new aw(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Wv),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=$x(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=Wv){let r=n;const i=Zt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(l=>o(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=$x();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=Wv),this.services.backendConnector.reload(e,n,a=>{i.resolve(),r(a)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&QG.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=$x();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=Zt(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Zt(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{a(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(a,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([a,o].concat(l)):c={...o},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(a)?d=a.map(f=>(typeof f=="function"&&(f=Mj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Mj(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return Zt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(a,e)))}loadNamespaces(e,n){const r=$x();return this.options.ns?(Zt(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=$x();Zt(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return a.length?(this.options.preload=i.concat(a),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new TU(RU());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 jb(e,n);return r.createInstance=jb.createInstance,r}cloneInstance(e={},n=Wv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new jb(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new EU(l,i),a.services.resourceStore=a.store}return a.translator=new aw(a.services,i),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Xa=jb.createInstance();Xa.createInstance;Xa.dir;Xa.init;Xa.loadResources;Xa.reloadResources;Xa.use;Xa.changeLanguage;Xa.getFixedT;Xa.t;Xa.exists;Xa.setDefaultNamespace;Xa.hasLoadedNamespace;Xa.loadNamespaces;Xa.loadLanguages;const Yae=(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);gf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},OU={},JG=(t,e,n,r)=>{gf(n)&&OU[n]||(gf(n)&&(OU[n]=new Date),Yae(t,e,n,r))},eW=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Nj=(t,e,n)=>{t.loadNamespaces(e,eW(t,n))},LU=(t,e,n,r)=>{if(gf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Nj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,eW(t,r))},Qae=(t,e,n={})=>!e.languages||!e.languages.length?(JG(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}}),gf=t=>typeof t=="string",Zae=t=>typeof t=="object"&&t!==null,Jae=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ese={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},tse=t=>ese[t],nse=t=>t.replace(Jae,tse);let Ej={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:nse};const rse=(t={})=>{Ej={...Ej,...t}},ise=()=>Ej;let tW;const ase=t=>{tW=t},sse=()=>tW,ose={type:"3rdParty",init(t){rse(t.options.react),ase(t)}},lse=w.createContext();class cse{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var MA={exports:{}},NA={};var IU;function use(){if(IU)return NA;IU=1;var t=Ag();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,m){var p=m(),x=r({inst:{value:p,getSnapshot:m}}),v=x[0].inst,b=x[1];return a(function(){v.value=p,v.getSnapshot=m,c(v)&&b({inst:v})},[f,p,m]),i(function(){return c(v)&&b({inst:v}),f(function(){c(v)&&b({inst:v})})},[f]),o(p),p}function c(f){var m=f.getSnapshot;f=f.value;try{var p=m();return!n(f,p)}catch{return!0}}function u(f,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return NA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,NA}var FU;function nW(){return FU||(FU=1,MA.exports=use()),MA.exports}var UR=nW();const dse=(t,e)=>gf(e)?e:Zae(e)&&gf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,hse={t:dse,ready:!1},fse=()=>()=>{},Tg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(lse)||{},a=n||r||sse();a&&!a.reportNamespaces&&(a.reportNamespaces=new cse),a||JG(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...ise(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=gf(u)?[u]:u||["translation"],f=w.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const m=w.useRef(0),p=w.useCallback(T=>{if(!a)return fse;const{bindI18n:P,bindI18nStore:F}=o,I=()=>{m.current+=1,T()};return P&&a.on(P,I),F&&a.store.on(F,I),()=>{P&&P.split(" ").forEach(X=>a.off(X,I)),F&&F.split(" ").forEach(X=>a.store.off(X,I))}},[a,o]),x=w.useRef(),v=w.useCallback(()=>{if(!a)return hse;const T=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(K=>Qae(K,a,o)),P=e.lng||a.language,F=m.current,I=x.current;if(I&&I.ready===T&&I.lng===P&&I.keyPrefix===c&&I.revision===F)return I;const D={t:a.getFixedT(P,o.nsMode==="fallback"?f:f[0],c),ready:T,lng:P,keyPrefix:c,revision:F};return x.current=D,D},[a,f,c,o,e.lng]),[b,y]=w.useState(0),{t:M,ready:S}=UR.useSyncExternalStore(p,v,v);w.useEffect(()=>{if(a&&!S&&!l){const T=()=>y(P=>P+1);e.lng?LU(a,e.lng,f,T):Nj(a,f,T)}},[a,e.lng,f,S,l,b]);const A=a||{},E=w.useRef(null),k=w.useRef(),C=T=>{const P=Object.getOwnPropertyDescriptors(T);P.__original&&delete P.__original;const F=Object.create(Object.getPrototypeOf(T),P);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:T,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},R=w.useMemo(()=>{const T=A,P=T?.language;let F=T;T&&(E.current&&E.current.__original===T?k.current!==P?(F=C(T),E.current=F,k.current=P):F=E.current:(F=C(T),E.current=F,k.current=P));const I=[M,F,S];return I.t=M,I.i18n=F,I.ready=S,I},[M,A,S,A.resolvedLanguage,A.language,A.languages]);if(a&&l&&!S)throw new Promise(T=>{const P=()=>T();e.lng?LU(a,e.lng,f,P):Nj(a,f,P)});return R},{slice:mse,forEach:pse}=[];function gse(t){return pse.call(mse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function xse(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 UU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,bse=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!UU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!UU.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(a+="; Partitioned"),a},zU={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=bse(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 yse={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return zU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&zU.create(n,t,r,i,a)}},vse={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(n=a[o].substring(l+1))}}return n}},_se={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const o=a.split("&");for(let l=0;l<o.length;l++){const c=o[l].indexOf("=");c>0&&o[l].substring(0,c)===e&&(r=o[l].substring(c+1))}}if(r)return r;if(!r&&n>-1){const o=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(o)?o[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let Cm=null;const BU=()=>{if(Cm!==null)return Cm;try{if(Cm=typeof window<"u"&&window.localStorage!==null,!Cm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Cm=!1}return Cm};var wse={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&BU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&BU()&&window.localStorage.setItem(n,t)}};let km=null;const $U=()=>{if(km!==null)return km;try{if(km=typeof window<"u"&&window.sessionStorage!==null,!km)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{km=!1}return km};var Sse={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&$U())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&$U()&&window.sessionStorage.setItem(n,t)}},Mse={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Nse={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}},Ese={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}},Ase={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 rW=!1;try{document.cookie,rW=!0}catch{}const iW=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];rW||iW.splice(1,1);const Tse=()=>({order:iW,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class aW{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=gse(n,this.options||{},Tse()),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(yse),this.addDetector(vse),this.addDetector(wse),this.addDetector(Sse),this.addDetector(Mse),this.addDetector(Nse),this.addDetector(Ese),this.addDetector(Ase),this.addDetector(_se)}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&&!xse(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)}))}}aW.type="languageDetector";const Cse={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",files:"File Manager",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app, which versions and printer models are in use. This helps prioritize bug fixes and new features.",telemetryInfoCollected:"What we collect:",telemetryInfoItem1:"A random installation ID (not linked to you or your hardware)",telemetryInfoItem2:"The app version you're running",telemetryInfoItem3:"Printer model types (e.g., X1C, P1S) - not names or serial numbers",telemetryInfoItem4:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"Your IP address is hashed and cannot be reversed",telemetryInfoNotItem2:"Printer names, serial numbers, or access codes",telemetryInfoNotItem3:"Print history, filenames, or any personal content",telemetryInfoNotItem4:"Any information that could identify you",telemetryInfoFooter:"You can disable telemetry at any time. The installation ID is randomly generated and cannot be traced back to you.",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},kse={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",files:"Dateimanager",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},jse={en:{translation:Cse},de:{translation:kse}};Xa.use(aW).use(ose).init({resources:jse,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const HU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var VU="popstate";function Pse(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return Aj("",{pathname:a,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:t0(i)}return Dse(e,n,null,t)}function Rr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Hs(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Rse(){return Math.random().toString(36).substring(2,10)}function GU(t,e){return{usr:t.state,key:t.key,idx:e}}function Aj(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Cg(e):e,state:n,key:e&&e.key||r||Rse()}}function t0({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Cg(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 Dse(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function f(){l="POP";let b=d(),y=b==null?null:b-u;u=b,c&&c({action:l,location:v.location,delta:y})}function m(b,y){l="PUSH";let M=Aj(v.location,b,y);u=d()+1;let S=GU(M,u),A=v.createHref(M);try{o.pushState(S,"",A)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;i.location.assign(A)}a&&c&&c({action:l,location:v.location,delta:1})}function p(b,y){l="REPLACE";let M=Aj(v.location,b,y);u=d();let S=GU(M,u),A=v.createHref(M);o.replaceState(S,"",A),a&&c&&c({action:l,location:v.location,delta:0})}function x(b){return Ose(b)}let v={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(VU,f),c=b,()=>{i.removeEventListener(VU,f),c=null}},createHref(b){return e(i,b)},createURL:x,encodeLocation(b){let y=x(b);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:m,replace:p,go(b){return o.go(b)}};return v}function Ose(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Rr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:t0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function sW(t,e,n="/"){return Lse(t,e,n,!1)}function Lse(t,e,n,r){let i=typeof e=="string"?Cg(e):e,a=Zc(i.pathname||"/",n);if(a==null)return null;let o=oW(t);Ise(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Kse(a);l=Wse(o[c],u,r)}return l}function oW(t,e=[],n=[],r="",i=!1){let a=(o,l,c=i,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;Rr(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=Vc([r,d.relativePath]),m=n.concat(d);o.children&&o.children.length>0&&(Rr(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),oW(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:Vse(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of lW(o.path))a(o,l,!0,c)}),e}function lW(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let o=lW(r.join("/")),l=[];return l.push(...o.map(c=>c===""?a:[a,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function Ise(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Gse(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Fse=/^:[\w-]+$/,Use=3,zse=2,Bse=1,$se=10,Hse=-2,WU=t=>t==="*";function Vse(t,e){let n=t.split("/"),r=n.length;return n.some(WU)&&(r+=Hse),e&&(r+=zse),n.filter(i=>!WU(i)).reduce((i,a)=>i+(Fse.test(a)?Use:a===""?Bse:$se),r)}function Gse(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 Wse(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=sw({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=sw({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Vc([a,f.pathname]),pathnameBase:Jse(Vc([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=Vc([a,f.pathnameBase]))}return o}function sw(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=qse(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},m)=>{if(d==="*"){let x=l[m]||"";o=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[m];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function qse(t,e=!1,n=!0){Hs(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 Kse(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Hs(!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 Zc(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 Xse=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yse=t=>Xse.test(t);function Qse(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Cg(t):t,a;if(n)if(Yse(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Hs(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=qU(n.substring(1),"/"):a=qU(n,e)}else a=e;return{pathname:a,search:eoe(r),hash:toe(i)}}function qU(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 EA(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 Zse(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function zR(t){let e=Zse(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function BR(t,e,n,r=!1){let i;typeof t=="string"?i=Cg(t):(i={...t},Rr(!i.pathname||!i.pathname.includes("?"),EA("?","pathname","search",i)),Rr(!i.pathname||!i.pathname.includes("#"),EA("#","pathname","hash",i)),Rr(!i.search||!i.search.includes("#"),EA("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),f-=1;i.pathname=m.join("/")}l=f>=0?e[f]:"/"}let c=Qse(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Vc=t=>t.join("/").replace(/\/\/+/g,"/"),Jse=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),eoe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,toe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function noe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var cW=["POST","PUT","PATCH","DELETE"];new Set(cW);var roe=["GET",...cW];new Set(roe);var kg=w.createContext(null);kg.displayName="DataRouter";var S2=w.createContext(null);S2.displayName="DataRouterState";w.createContext(!1);var uW=w.createContext({isTransitioning:!1});uW.displayName="ViewTransition";var ioe=w.createContext(new Map);ioe.displayName="Fetchers";var aoe=w.createContext(null);aoe.displayName="Await";var al=w.createContext(null);al.displayName="Navigation";var q0=w.createContext(null);q0.displayName="Location";var jo=w.createContext({outlet:null,matches:[],isDataRoute:!1});jo.displayName="Route";var $R=w.createContext(null);$R.displayName="RouteError";function soe(t,{relative:e}={}){Rr(jg(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(al),{hash:i,pathname:a,search:o}=K0(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Vc([n,a])),r.createHref({pathname:l,search:o,hash:i})}function jg(){return w.useContext(q0)!=null}function Gl(){return Rr(jg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(q0).location}var dW="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function hW(t){w.useContext(al).static||w.useLayoutEffect(t)}function sl(){let{isDataRoute:t}=w.useContext(jo);return t?_oe():ooe()}function ooe(){Rr(jg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(kg),{basename:e,navigator:n}=w.useContext(al),{matches:r}=w.useContext(jo),{pathname:i}=Gl(),a=JSON.stringify(zR(r)),o=w.useRef(!1);return hW(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(Hs(o.current,dW),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=BR(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Vc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var loe=w.createContext(null);function coe(t){let e=w.useContext(jo).outlet;return w.useMemo(()=>e&&w.createElement(loe.Provider,{value:t},e),[e,t])}function HR(){let{matches:t}=w.useContext(jo),e=t[t.length-1];return e?e.params:{}}function K0(t,{relative:e}={}){let{matches:n}=w.useContext(jo),{pathname:r}=Gl(),i=JSON.stringify(zR(n));return w.useMemo(()=>BR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function uoe(t,e){return fW(t,e)}function fW(t,e,n,r,i){Rr(jg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=w.useContext(al),{matches:o}=w.useContext(jo),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let M=f&&f.path||"";mW(u,!f||M.endsWith("*")||M.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${M}">) 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="${M}"> to <Route path="${M==="/"?"*":`${M}/*`}">.`)}let m=Gl(),p;if(e){let M=typeof e=="string"?Cg(e):e;Rr(d==="/"||M.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 "${M.pathname}" was given in the \`location\` prop.`),p=M}else p=m;let x=p.pathname||"/",v=x;if(d!=="/"){let M=d.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(M.length).join("/")}let b=sW(t,{pathname:v});Hs(f||b!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Hs(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=poe(b&&b.map(M=>Object.assign({},M,{params:Object.assign({},c,M.params),pathname:Vc([d,a.encodeLocation?a.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?d:Vc([d,a.encodeLocation?a.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),o,n,r,i);return e&&y?w.createElement(q0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},y):y}function doe(){let t=voe(),e=noe(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:a},"ErrorBoundary")," or"," ",w.createElement("code",{style:a},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},e),n?w.createElement("pre",{style:i},n):null,o)}var hoe=w.createElement(doe,null),foe=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(){return this.state.error!==void 0?w.createElement(jo.Provider,{value:this.props.routeContext},w.createElement($R.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function moe({routeContext:t,match:e,children:n}){let r=w.useContext(kg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(jo.Provider,{value:t},n)}function poe(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,o=n?.errors;if(o!=null){let d=a.findIndex(f=>f.route.id&&o?.[f.route.id]!==void 0);Rr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:m,errors:p}=n,x=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,m)=>{let p,x=!1,v=null,b=null;n&&(p=o&&f.route.id?o[f.route.id]:void 0,v=f.route.errorElement||hoe,l&&(c<0&&m===0?(mW("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,b=null):c===m&&(x=!0,b=f.route.hydrateFallbackElement||null)));let y=e.concat(a.slice(0,m+1)),M=()=>{let S;return p?S=v:x?S=b:f.route.Component?S=w.createElement(f.route.Component,null):f.route.element?S=f.route.element:S=d,w.createElement(moe,{match:f,routeContext:{outlet:d,matches:y,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(foe,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:M(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:u}):M()},null)}function VR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function goe(t){let e=w.useContext(kg);return Rr(e,VR(t)),e}function xoe(t){let e=w.useContext(S2);return Rr(e,VR(t)),e}function boe(t){let e=w.useContext(jo);return Rr(e,VR(t)),e}function GR(t){let e=boe(t),n=e.matches[e.matches.length-1];return Rr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function yoe(){return GR("useRouteId")}function voe(){let t=w.useContext($R),e=xoe("useRouteError"),n=GR("useRouteError");return t!==void 0?t:e.errors?.[n]}function _oe(){let{router:t}=goe("useNavigate"),e=GR("useNavigate"),n=w.useRef(!1);return hW(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{Hs(n.current,dW),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var KU={};function mW(t,e,n){!e&&!KU[t]&&(KU[t]=!0,Hs(!1,n))}w.memo(woe);function woe({routes:t,future:e,state:n,unstable_onError:r}){return fW(t,void 0,n,r,e)}function ow({to:t,replace:e,state:n,relative:r}){Rr(jg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(al);Hs(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=w.useContext(jo),{pathname:o}=Gl(),l=sl(),c=BR(t,zR(a),o,r==="path"),u=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function Soe(t){return coe(t.context)}function $i(t){Rr(!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 Moe({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){Rr(!jg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let o=t.replace(/^\/*/,"/"),l=w.useMemo(()=>({basename:o,navigator:i,static:a,future:{}}),[o,i,a]);typeof n=="string"&&(n=Cg(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:m="default"}=n,p=w.useMemo(()=>{let x=Zc(c,o);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:m},navigationType:r}},[o,c,u,d,f,m,r]);return Hs(p!=null,`<Router basename="${o}"> is not able to match the URL "${c}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:w.createElement(al.Provider,{value:l},w.createElement(q0.Provider,{children:e,value:p}))}function Noe({children:t,location:e}){return uoe(Tj(t),e)}function Tj(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let a=[...e,i];if(r.type===w.Fragment){n.push.apply(n,Tj(r.props.children,a));return}Rr(r.type===$i,`[${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>`),Rr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Tj(r.props.children,a)),n.push(o)}),n}var k1="get",j1="application/x-www-form-urlencoded";function M2(t){return t!=null&&typeof t.tagName=="string"}function Eoe(t){return M2(t)&&t.tagName.toLowerCase()==="button"}function Aoe(t){return M2(t)&&t.tagName.toLowerCase()==="form"}function Toe(t){return M2(t)&&t.tagName.toLowerCase()==="input"}function Coe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function koe(t,e){return t.button===0&&(!e||e==="_self")&&!Coe(t)}function Cj(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 joe(t,e){let n=Cj(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var qv=null;function Poe(){if(qv===null)try{new FormData(document.createElement("form"),0),qv=!1}catch{qv=!0}return qv}var Roe=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function AA(t){return t!=null&&!Roe.has(t)?(Hs(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${j1}"`),null):t}function Doe(t,e){let n,r,i,a,o;if(Aoe(t)){let l=t.getAttribute("action");r=l?Zc(l,e):null,n=t.getAttribute("method")||k1,i=AA(t.getAttribute("enctype"))||j1,a=new FormData(t)}else if(Eoe(t)||Toe(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?Zc(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||k1,i=AA(t.getAttribute("formenctype"))||AA(l.getAttribute("enctype"))||j1,a=new FormData(l,t),!Poe()){let{name:u,type:d,value:f}=t;if(d==="image"){let m=u?`${u}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else u&&a.append(u,f)}}else{if(M2(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=k1,r=null,i=j1,o=t}return a&&i==="text/plain"&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function WR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Ooe(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&Zc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Loe(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 Ioe(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 Foe(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await Loe(a,n);return o.links?o.links():[]}return[]}));return $oe(r.flat(1).filter(Ioe).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function XU(t,e,n,r,i,a){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Uoe(t,e,{includeHydrateFallback:n}={}){return zoe(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let a=[i.module];return i.clientActionModule&&(a=a.concat(i.clientActionModule)),i.clientLoaderModule&&(a=a.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(a=a.concat(i.hydrateFallbackModule)),i.imports&&(a=a.concat(i.imports)),a}).flat(1))}function zoe(t){return[...new Set(t)]}function Boe(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function $oe(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Boe(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function pW(){let t=w.useContext(kg);return WR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Hoe(){let t=w.useContext(S2);return WR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var qR=w.createContext(void 0);qR.displayName="FrameworkContext";function gW(){let t=w.useContext(qR);return WR(t,"You must render this element inside a <HydratedRouter> element"),t}function Voe(t,e){let n=w.useContext(qR),[r,i]=w.useState(!1),[a,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,m=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let v=y=>{y.forEach(M=>{o(M.isIntersecting)})},b=new IntersectionObserver(v,{threshold:.5});return m.current&&b.observe(m.current),()=>{b.disconnect()}}},[t]),w.useEffect(()=>{if(r){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,m,{}]:[a,m,{onFocus:Hx(l,p),onBlur:Hx(c,x),onMouseEnter:Hx(u,p),onMouseLeave:Hx(d,x),onTouchStart:Hx(f,p)}]:[!1,m,{}]}function Hx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Goe({page:t,...e}){let{router:n}=pW(),r=w.useMemo(()=>sW(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(qoe,{page:t,matches:r,...e}):null}function Woe(t){let{manifest:e,routeModules:n}=gW(),[r,i]=w.useState([]);return w.useEffect(()=>{let a=!1;return Foe(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function qoe({page:t,matches:e,...n}){let r=Gl(),{manifest:i,routeModules:a}=gW(),{basename:o}=pW(),{loaderData:l,matches:c}=Hoe(),u=w.useMemo(()=>XU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=w.useMemo(()=>XU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,v=!1;if(e.forEach(y=>{let M=i.routes[y.route.id];!M||!M.hasLoader||(!u.some(S=>S.route.id===y.route.id)&&y.route.id in l&&a[y.route.id]?.shouldRevalidate||M.hasClientLoader?v=!0:x.add(y.route.id))}),x.size===0)return[];let b=Ooe(t,o,"data");return v&&x.size>0&&b.searchParams.set("_routes",e.filter(y=>x.has(y.route.id)).map(y=>y.route.id).join(",")),[b.pathname+b.search]},[o,l,r,i,u,e,t,a]),m=w.useMemo(()=>Uoe(d,i),[d,i]),p=Woe(d);return w.createElement(w.Fragment,null,f.map(x=>w.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),m.map(x=>w.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),p.map(({key:x,link:v})=>w.createElement("link",{key:x,nonce:n.nonce,...v})))}function Koe(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var xW=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{xW&&(window.__reactRouterVersion="7.9.6")}catch{}function Xoe({basename:t,children:e,window:n}){let r=w.useRef();r.current==null&&(r.current=Pse({window:n,v5Compat:!0}));let i=r.current,[a,o]=w.useState({action:i.action,location:i.location}),l=w.useCallback(c=>{w.startTransition(()=>o(c))},[o]);return w.useLayoutEffect(()=>i.listen(l),[i,l]),w.createElement(Moe,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var bW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,as=w.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,...m},p){let{basename:x}=w.useContext(al),v=typeof u=="string"&&bW.test(u),b,y=!1;if(typeof u=="string"&&v&&(b=u,xW))try{let T=new URL(window.location.href),P=u.startsWith("//")?new URL(T.protocol+u):new URL(u),F=Zc(P.pathname,x);P.origin===T.origin&&F!=null?u=F+P.search+P.hash:y=!0}catch{Hs(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=soe(u,{relative:i}),[S,A,E]=Voe(r,m),k=Zoe(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f});function C(T){e&&e(T),T.defaultPrevented||k(T)}let R=w.createElement("a",{...m,...E,href:b||M,onClick:y||a?e:C,ref:Koe(p,A),target:c,"data-discover":!v&&n==="render"?"true":void 0});return S&&!v?w.createElement(w.Fragment,null,R,w.createElement(Goe,{page:M})):R});as.displayName="Link";var pb=w.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:o,viewTransition:l,children:c,...u},d){let f=K0(o,{relative:u.relative}),m=Gl(),p=w.useContext(S2),{navigator:x,basename:v}=w.useContext(al),b=p!=null&&rle(f)&&l===!0,y=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,M=m.pathname,S=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(M=M.toLowerCase(),S=S?S.toLowerCase():null,y=y.toLowerCase()),S&&v&&(S=Zc(S,v)||S);const A=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let E=M===y||!i&&M.startsWith(y)&&M.charAt(A)==="/",k=S!=null&&(S===y||!i&&S.startsWith(y)&&S.charAt(y.length)==="/"),C={isActive:E,isPending:k,isTransitioning:b},R=E?e:void 0,T;typeof r=="function"?T=r(C):T=[r,E?"active":null,k?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let P=typeof a=="function"?a(C):a;return w.createElement(as,{...u,"aria-current":R,className:T,ref:d,style:P,to:o,viewTransition:l},typeof c=="function"?c(C):c)});pb.displayName="NavLink";var Yoe=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=k1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...m},p)=>{let x=tle(),v=nle(l,{relative:u}),b=o.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&bW.test(l),M=S=>{if(c&&c(S),S.defaultPrevented)return;S.preventDefault();let A=S.nativeEvent.submitter,E=A?.getAttribute("formmethod")||o;x(A||S.currentTarget,{fetcherKey:e,method:E,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return w.createElement("form",{ref:p,method:b,action:v,onSubmit:r?c:M,...m,"data-discover":!y&&t==="render"?"true":void 0})});Yoe.displayName="Form";function Qoe(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yW(t){let e=w.useContext(kg);return Rr(e,Qoe(t)),e}function Zoe(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o}={}){let l=sl(),c=Gl(),u=K0(t,{relative:a});return w.useCallback(d=>{if(koe(d,e)){d.preventDefault();let f=n!==void 0?n:t0(c)===t0(u);l(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:o})}},[c,l,u,n,r,e,t,i,a,o])}function vW(t){Hs(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(Cj(t)),n=w.useRef(!1),r=Gl(),i=w.useMemo(()=>joe(r.search,n.current?null:e.current),[r.search]),a=sl(),o=w.useCallback((l,c)=>{const u=Cj(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var Joe=0,ele=()=>`__${String(++Joe)}__`;function tle(){let{router:t}=yW("useSubmit"),{basename:e}=w.useContext(al),n=yoe();return w.useCallback(async(r,i={})=>{let{action:a,method:o,encType:l,formData:c,body:u}=Doe(r,e);if(i.navigate===!1){let d=i.fetcherKey||ele();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function nle(t,{relative:e}={}){let{basename:n}=w.useContext(al),r=w.useContext(jo);Rr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...K0(t||".",{relative:e})},o=Gl();if(t==null){a.search=o.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Vc([n,a.pathname])),t0(a)}function rle(t,{relative:e}={}){let n=w.useContext(uW);Rr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=yW("useViewTransitionState"),i=K0(t,{relative:e});if(!n.isTransitioning)return!1;let a=Zc(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Zc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return sw(i.pathname,o)!=null||sw(i.pathname,a)!=null}var Ic=XG();const ile=ko(Ic);var $f=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(){}},ale={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},sle=class{#t=ale;#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)}},Hh=new sle;function ole(t){setTimeout(t,0)}var xf=typeof window>"u"||"Deno"in globalThis;function Aa(){}function lle(t,e){return typeof t=="function"?t(e):t}function kj(t){return typeof t=="number"&&t>=0&&t!==1/0}function _W(t,e){return Math.max(t+(e||0)-Date.now(),0)}function _d(t,e){return typeof t=="function"?t(e):t}function ho(t,e){return typeof t=="function"?t(e):t}function YU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==KR(o,e.options))return!1}else if(!n0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||a&&!a(e))}function QU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(bf(e.options.mutationKey)!==bf(a))return!1}else if(!n0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function KR(t,e){return(e?.queryKeyHashFn||bf)(t)}function bf(t){return JSON.stringify(t,(e,n)=>jj(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function n0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>n0(t[n],e[n])):!1}var cle=Object.prototype.hasOwnProperty;function XR(t,e){if(t===e)return t;const n=ZU(t)&&ZU(e);if(!n&&!(jj(t)&&jj(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:a[u],f=t[d],m=e[d];if(f===m){l[d]=f,(n?u<i:cle.call(t,d))&&c++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){l[d]=m;continue}const p=XR(f,m);l[d]=p,p===f&&c++}return i===o&&c===i?t:l}function r0(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 ZU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function jj(t){if(!JU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!JU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function JU(t){return Object.prototype.toString.call(t)==="[object Object]"}function ule(t){return new Promise(e=>{Hh.setTimeout(e,t)})}function Pj(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?XR(t,e):e}function dle(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function hle(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var YR=Symbol();function wW(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===YR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function SW(t,e){return typeof t=="function"?t(...e):!!t}var fle=class extends $f{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!xf&&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"}},QR=new fle;function Rj(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var mle=ole;function ple(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=mle;const a=l=>{e?t.push(l):i(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||o()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var Yr=ple(),gle=class extends $f{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!xf&&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}},lw=new gle;function xle(t){return Math.min(1e3*2**t,3e4)}function MW(t){return(t??"online")==="online"?lw.isOnline():!0}var Dj=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function NW(t){let e=!1,n=0,r;const i=Rj(),a=()=>i.status!=="pending",o=v=>{if(!a()){const b=new Dj(v);m(b),t.onCancel?.(b)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>QR.isFocused()&&(t.networkMode==="always"||lw.isOnline())&&t.canRun(),d=()=>MW(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},m=v=>{a()||(r?.(),i.reject(v))},p=()=>new Promise(v=>{r=b=>{(a()||u())&&v(b)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let v;const b=n===0?t.initialPromise:void 0;try{v=b??t.fn()}catch(y){v=Promise.reject(y)}Promise.resolve(v).then(f).catch(y=>{if(a())return;const M=t.retry??(xf?0:3),S=t.retryDelay??xle,A=typeof S=="function"?S(n,y):S,E=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,y);if(e||!E){m(y);return}n++,t.onFail?.(n,y),ule(A).then(()=>u()?void 0:p()).then(()=>{e?m(y):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var EW=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),kj(this.gcTime)&&(this.#t=Hh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(xf?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Hh.clearTimeout(this.#t),this.#t=void 0)}},ble=class extends EW{#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=tz(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=tz(this.options);e.data!==void 0&&(this.setState(ez(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Pj(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(Aa).catch(Aa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>ho(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===YR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>_d(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:!_W(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=wW(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=NW({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof Dj&&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 Dj){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,...AW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...ez(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),Yr.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function AW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:MW(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function ez(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function tz(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 ZR=class extends $f{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=Rj(),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),nz(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Oj(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Oj(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ho(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),e._defaulted&&!r0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&rz(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||ho(this.options.enabled,this.#e)!==ho(e.enabled,this.#e)||_d(this.options.staleTime,this.#e)!==_d(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||ho(this.options.enabled,this.#e)!==ho(e.enabled,this.#e)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return vle(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.#w();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Aa)),e}#g(){this.#v();const t=_d(this.options.staleTime,this.#e);if(xf||this.#i.isStale||!kj(t))return;const n=_W(this.#i.dataUpdatedAt,t)+1;this.#c=Hh.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(xf||ho(this.options.enabled,this.#e)===!1||!kj(this.#l)||this.#l===0)&&(this.#u=Hh.setInterval(()=>{(this.options.refetchIntervalInBackground||QR.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Hh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Hh.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,a=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,m;if(e._optimisticResults){const R=this.hasListeners(),T=!R&&nz(t,e),P=R&&rz(t,n,e,r);(T||P)&&(d={...d,...AW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:v}=d;m=d.data;let b=!1;if(e.placeholderData!==void 0&&m===void 0&&v==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,b=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,R!==void 0&&(v="success",m=Pj(i?.data,R,e),f=!0)}if(e.select&&m!==void 0&&!b)if(i&&m===a?.data&&e.select===this.#f)m=this.#d;else try{this.#f=e.select,m=e.select(m),m=Pj(i?.data,m,e),this.#d=m,this.#s=null}catch(R){this.#s=R}this.#s&&(p=this.#s,m=this.#d,x=Date.now(),v="error");const y=d.fetchStatus==="fetching",M=v==="pending",S=v==="error",A=M&&y,E=m!==void 0,C={status:v,fetchStatus:d.fetchStatus,isPending:M,isSuccess:v==="success",isError:S,isInitialLoading:A,isLoading:A,data:m,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!M,isLoadingError:S&&!E,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&E,isStale:JR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:ho(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=F=>{C.status==="error"?F.reject(C.error):C.data!==void 0&&F.resolve(C.data)},T=()=>{const F=this.#o=C.promise=Rj();R(F)},P=this.#o;switch(P.status){case"pending":t.queryHash===n.queryHash&&R(P);break;case"fulfilled":(C.status==="error"||C.data!==P.value)&&T();break;case"rejected":(C.status!=="error"||C.error!==P.reason)&&T();break}}return C}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),r0(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 a=new Set(i??this.#p);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&a.has(l)})};this.#S({listeners:n()})}#w(){const t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;const e=this.#e;this.#e=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){Yr.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function yle(t,e){return ho(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function nz(t,e){return yle(t,e)||t.state.data!==void 0&&Oj(t,e,e.refetchOnMount)}function Oj(t,e,n){if(ho(e.enabled,t)!==!1&&_d(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&JR(t,e)}return!1}function rz(t,e,n,r){return(t!==e||ho(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&JR(t,n)}function JR(t,e){return ho(e.enabled,t)!==!1&&t.isStaleByTime(_d(e.staleTime,t))}function vle(t,e){return!r0(t.getCurrentResult(),e)}function iz(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},m=wW(e.options,e.fetchOptions),p=async(x,v,b)=>{if(d)return Promise.reject();if(v==null&&x.pages.length)return Promise.resolve(x);const M=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:v,direction:b?"backward":"forward",meta:e.options.meta};return f(k),k})(),S=await m(M),{maxPages:A}=e.options,E=b?hle:dle;return{pages:E(x.pages,S,A),pageParams:E(x.pageParams,v,A)}};if(i&&a.length){const x=i==="backward",v=x?_le:az,b={pages:a,pageParams:o},y=v(r,b);l=await p(b,y,x)}else{const x=t??a.length;do{const v=c===0?o[0]??r.initialPageParam:az(r,l);if(c>0&&v==null)break;l=await p(l,v),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 az(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 _le(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var wle=class extends EW{#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||TW(),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=NW({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#r({type:"pending",context:o,variables:t,isPaused:i})}const a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),Yr.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function TW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Sle=class extends $f{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 wle({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=Kv(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=Kv(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=Kv(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=Kv(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Yr.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=>QU(e,n))}findAll(t={}){return this.getAll().filter(e=>QU(t,e))}notify(t){Yr.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Yr.batch(()=>Promise.all(t.map(e=>e.continue().catch(Aa))))}};function Kv(t){return t.options.scope?.id}var Mle=class extends $f{#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),r0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&bf(n.mutationKey)!==bf(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??TW();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){Yr.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 sz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function Nle(t,e,n){const r=t.slice(0);return r[e]=n,r}var Ele=class extends $f{#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,Yr.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),a=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,f)=>d!==n[f]),c=o||l,u=c?!0:a.some((d,f)=>{const m=this.#e[f];return!m||!r0(d,m)});!c&&!u||(c&&(this.#r=i),this.#e=a,this.hasListeners()&&(c&&(sz(n,i).forEach(d=>{d.destroy()}),sz(i,n).forEach(d=>{d.subscribe(f=>{this.#u(d,f)})})),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,a=>{e.forEach(o=>{o.observer.trackProp(a)})})})}#h(t,e){return e?((!this.#a||this.#e!==this.#s||e!==this.#o)&&(this.#o=e,this.#s=this.#e,this.#a=XR(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 a=e.get(i);a?a.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#t.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new ZR(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=Nle(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&&Yr.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},Ale=class extends $f{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??KR(r,e);let a=this.get(i);return a||(a=new ble({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Yr.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=>YU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>YU(t,n)):e}notify(t){Yr.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Yr.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Yr.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Tle=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new Ale,this.#e=t.mutationCache||new Sle,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=QR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=lw.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(_d(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),a=this.#t.get(r.queryHash)?.state.data,o=lle(e,a);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Yr.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;Yr.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return Yr.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Yr.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Aa).catch(Aa)}invalidateQueries(t,e={}){return Yr.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=Yr.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Aa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Aa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(_d(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Aa).catch(Aa)}fetchInfiniteQuery(t){return t.behavior=iz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Aa).catch(Aa)}ensureInfiniteQueryData(t){return t.behavior=iz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return lw.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(bf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{n0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(bf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{n0(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=KR(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===YR&&(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()}},CW=w.createContext(void 0),Qt=t=>{const e=w.useContext(CW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Cle=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(CW.Provider,{value:t,children:e})),kW=w.createContext(!1),jW=()=>w.useContext(kW);kW.Provider;function kle(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var jle=w.createContext(kle()),PW=()=>w.useContext(jle),RW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},DW=t=>{w.useEffect(()=>{t.clearReset()},[t])},OW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||SW(n,[t.error,r])),LW=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))}},IW=(t,e)=>t.isLoading&&t.isFetching&&!e,Lj=(t,e)=>t?.suspense&&e.isPending,cw=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Ple({queries:t,...e},n){const r=Qt(),i=jW(),a=PW(),o=w.useMemo(()=>t.map(v=>{const b=r.defaultQueryOptions(v);return b._optimisticResults=i?"isRestoring":"optimistic",b}),[t,r,i]);o.forEach(v=>{LW(v),RW(v,a)}),DW(a);const[l]=w.useState(()=>new Ele(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(v=>f?l.subscribe(Yr.batchCalls(v)):Aa,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((v,b)=>Lj(o[b],v))?c.flatMap((v,b)=>{const y=o[b];if(y){const M=new ZR(r,y);if(Lj(y,v))return cw(y,M,a);IW(v,i)&&cw(y,M,a)}return[]}):[];if(p.length>0)throw Promise.all(p);const x=c.find((v,b)=>{const y=o[b];return y&&OW({result:v,errorResetBoundary:a,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(x?.error)throw x.error;return u(d())}function Rle(t,e,n){const r=jW(),i=PW(),a=Qt(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",LW(o),RW(o,i),DW(i);const l=!a.getQueryCache().get(o.queryHash),[c]=w.useState(()=>new e(a,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(f=>{const m=d?c.subscribe(Yr.batchCalls(f)):Aa;return c.updateResult(),m},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),w.useEffect(()=>{c.setOptions(o)},[o,c]),Lj(o,u))throw cw(o,c,i);if(OW({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!xf&&IW(u,r)&&(l?cw(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Aa).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function lt(t,e){return Rle(t,ZR)}function ft(t,e){const n=Qt(),[r]=w.useState(()=>new Mle(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(Yr.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=w.useCallback((o,l)=>{r.mutate(o,l).catch(Aa)},[r]);if(i.error&&SW(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Dle=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ole=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),oz=t=>{const e=Ole(t);return e.charAt(0).toUpperCase()+e.slice(1)},FW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Lle=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Ile={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 Fle=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>w.createElement("svg",{ref:c,...Ile,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:FW("lucide",i),...!a&&!Lle(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(a)?a:[a]]));const He=(t,e)=>{const n=w.forwardRef(({className:r,...i},a)=>w.createElement(Fle,{ref:a,iconNode:e,className:FW(`lucide-${Dle(oz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=oz(t),n};const Ule=[["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"}]],zle=He("air-vent",Ule);const Ble=[["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"}]],Is=He("archive",Ble);const $le=[["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"}]],Hle=He("arrow-down-wide-narrow",$le);const Vle=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],i0=He("arrow-down",Vle);const Gle=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],UW=He("arrow-left",Gle);const Wle=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ij=He("arrow-right",Wle);const qle=[["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"}]],zW=He("arrow-up-down",qle);const Kle=[["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"}]],Xle=He("arrow-up-narrow-wide",Kle);const Yle=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Kp=He("arrow-up",Yle);const Qle=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],ef=He("bell",Qle);const Zle=[["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"}]],Jle=He("bold",Zle);const ece=[["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"}]],tce=He("book",ece);const nce=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],rce=He("bookmark",nce);const ice=[["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"}]],Rs=He("box",ice);const ace=[["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"}]],BW=He("briefcase",ace);const sce=[["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"}]],N2=He("bug",sce);const oce=[["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"}]],lce=He("cable",oce);const cce=[["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"}]],uce=He("calendar-days",cce);const dce=[["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"}]],Qr=He("calendar",dce);const hce=[["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"}]],Xp=He("camera",hce);const fce=[["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"}]],mce=He("chart-column",fce);const pce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ps=He("check",pce);const gce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ji=He("chevron-down",gce);const xce=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Vs=He("chevron-right",xce);const bce=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],yf=He("chevron-left",bce);const yce=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Jc=He("chevron-up",yce);const vce=[["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"}]],ea=He("circle-alert",vce);const _ce=[["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"}]],TA=He("circle-arrow-up",_ce);const wce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],kn=He("circle-check-big",wce);const Sce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],E2=He("circle-check",Sce);const Mce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Nce=He("circle-dot",Mce);const Ece=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Ace=He("circle-stop",Ece);const Tce=[["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"}]],qi=He("circle-x",Tce);const Cce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Fj=He("circle",Cce);const kce=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Hn=He("clock",kce);const jce=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],A2=He("cloud",jce);const Pce=[["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"}]],Rce=He("code-xml",Pce);const Dce=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],$W=He("code",Dce);const Oce=[["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"}]],Lce=He("coffee",Oce);const Ice=[["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"}]],Fce=He("cog",Ice);const Uce=[["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"}]],zce=He("compass",Uce);const Bce=[["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"}]],Gs=He("copy",Bce);const $ce=[["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"}]],Xv=He("cpu",$ce);const Hce=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],Vce=He("cylinder",Hce);const Gce=[["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"}]],Yp=He("database",Gce);const Wce=[["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"}]],Uj=He("dollar-sign",Wce);const qce=[["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"}]],Jr=He("download",qce);const Kce=[["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"}]],eD=He("droplet",Kce);const Xce=[["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"}]],tD=He("droplets",Xce);const Yce=[["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"}]],wd=He("ellipsis-vertical",Yce);const Qce=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],CA=He("equal",Qce);const Zce=[["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"}]],Lr=He("external-link",Zce);const Jce=[["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"}]],T2=He("eye-off",Jce);const eue=[["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"}]],vf=He("eye",eue);const tue=[["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"}]],HW=He("fan",tue);const nue=[["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"}]],tf=He("file-box",nue);const rue=[["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"}]],uw=He("file-code",rue);const iue=[["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"}]],aue=He("file-exclamation-point",iue);const sue=[["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"}]],dw=He("file-spreadsheet",sue);const oue=[["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"}]],Ua=He("file-text",oue);const lue=[["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"}]],C2=He("file",lue);const cue=[["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"}]],Sd=He("film",cue);const uue=[["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"}]],due=He("flame",uue);const hue=[["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"}]],xa=He("folder-kanban",hue);const fue=[["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"}]],el=He("folder-open",fue);const mue=[["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"}]],pue=He("folder-plus",mue);const gue=[["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"}]],xue=He("folder-tree",gue);const bue=[["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"}]],VW=He("folder",bue);const yue=[["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"}]],k2=He("funnel",yue);const vue=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],j2=He("gauge",vue);const _ue=[["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"}]],wue=He("gift",_ue);const Sue=[["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"}]],Rp=He("git-compare",Sue);const Mue=[["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"}]],lz=He("github",Mue);const Nue=[["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"}]],Md=He("globe",Nue);const Eue=[["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"}]],Qp=He("grip-vertical",Eue);const Aue=[["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"}]],GW=He("hand",Aue);const Tue=[["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"}]],P2=He("hard-drive",Tue);const Cue=[["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"}]],kue=He("hash",Cue);const jue=[["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"}]],Pue=He("headphones",jue);const Rue=[["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"}]],Due=He("heart",Rue);const Oue=[["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"}]],hw=He("history",Oue);const Lue=[["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"}]],R2=He("house",Lue);const Iue=[["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"}]],X0=He("image",Iue);const Fue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Rl=He("info",Fue);const Uue=[["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"}]],zue=He("italic",Uue);const Bue=[["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"}]],Vh=He("key",Bue);const $ue=[["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"}]],zj=He("keyboard",$ue);const Hue=[["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"}]],tl=He("layers",Hue);const Vue=[["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"}]],D2=He("layout-grid",Vue);const Gue=[["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"}]],Wue=He("link-2-off",Gue);const que=[["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"}]],Cl=He("link-2",que);const Kue=[["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"}]],Y0=He("link",Kue);const Xue=[["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"}]],WW=He("list-ordered",Xue);const Yue=[["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"}]],Bj=He("list-todo",Yue);const Que=[["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"}]],O2=He("list",Que);const Zue=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],pt=He("loader-circle",Zue);const Jue=[["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"}]],cz=He("lock-open",Jue);const ede=[["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"}]],kA=He("lock",ede);const tde=[["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"}]],uz=He("log-in",tde);const nde=[["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"}]],$j=He("log-out",nde);const rde=[["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"}]],ide=He("mail",rde);const ade=[["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"}]],sde=He("map",ade);const ode=[["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"}]],qW=He("maximize-2",ode);const lde=[["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"}]],cde=He("maximize",lde);const ude=[["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"}]],dde=He("memory-stick",ude);const hde=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],fde=He("menu",hde);const mde=[["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"}]],KW=He("minimize-2",mde);const pde=[["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"}]],gde=He("minimize",pde);const xde=[["path",{d:"M5 12h14",key:"1ays0h"}]],Hj=He("minus",xde);const bde=[["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"}]],yde=He("monitor",bde);const vde=[["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"}]],fw=He("moon",vde);const _de=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],wde=He("move-right",_de);const Sde=[["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"}]],Vj=He("music",Sde);const Mde=[["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"}]],Dl=He("package",Mde);const Nde=[["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"}]],nD=He("palette",Nde);const Ede=[["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"}]],rD=He("pause",Ede);const Ade=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],_f=He("pen-line",Ade);const Tde=[["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"}]],L2=He("pen",Tde);const Cde=[["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"}]],Ha=He("pencil",Cde);const kde=[["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"}]],jde=He("phone",kde);const Pde=[["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"}]],nl=He("play",Pde);const Rde=[["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"}]],Fs=He("plug",Rde);const Dde=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],qn=He("plus",Dde);const Ode=[["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"}]],I2=He("power-off",Ode);const Lde=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],uu=He("power",Lde);const Ide=[["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"}]],Ir=He("printer",Ide);const Fde=[["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"}]],XW=He("qr-code",Fde);const Ude=[["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"}]],yr=He("refresh-cw",Ude);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"}]],Hf=He("rotate-ccw",zde);const Bde=[["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"}]],$de=He("ruler",Bde);const Hde=[["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"}]],cs=He("save",Hde);const Vde=[["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"}]],YW=He("scan-search",Vde);const Gde=[["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"}]],Wde=He("scissors",Gde);const qde=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ws=He("search",qde);const Kde=[["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"}]],iD=He("send",Kde);const Xde=[["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"}]],jh=He("server",Xde);const Yde=[["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"}]],Dd=He("settings-2",Yde);const Qde=[["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"}]],F2=He("settings",Qde);const Zde=[["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"}]],P1=He("shield",Zde);const Jde=[["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"}]],QW=He("shopping-cart",Jde);const ehe=[["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"}]],the=He("signal",ehe);const nhe=[["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"}]],rhe=He("skip-back",nhe);const ihe=[["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"}]],mw=He("skip-forward",ihe);const ahe=[["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"}]],dz=He("sliders-vertical",ahe);const she=[["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"}]],a0=He("sparkles",she);const ohe=[["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"}]],eu=He("square-check-big",ohe);const lhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ol=He("square",lhe);const che=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],wf=He("star",che);const uhe=[["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"}]],ZW=He("sticky-note",uhe);const dhe=[["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"}]],hz=He("sun",dhe);const hhe=[["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"}]],Zp=He("tag",hhe);const fhe=[["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"}]],JW=He("target",fhe);const mhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],eq=He("terminal",mhe);const phe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],ghe=He("text-align-center",phe);const xhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],bhe=He("text-align-end",xhe);const yhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],vhe=He("text-align-start",yhe);const _he=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],U2=He("thermometer",_he);const whe=[["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"}]],md=He("timer",whe);const She=[["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"}]],Jt=He("trash-2",She);const Mhe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],tq=He("trending-down",Mhe);const Nhe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],nq=He("trending-up",Nhe);const Ehe=[["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"}]],En=He("triangle-alert",Ehe);const Ahe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],The=He("underline",Ahe);const Che=[["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"}]],aD=He("unlink",Che);const khe=[["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"}]],bi=He("upload",khe);const jhe=[["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"}]],Gj=He("user",jhe);const Phe=[["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"}]],Gh=He("users",Phe);const Rhe=[["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"}]],sD=He("video",Rhe);const Dhe=[["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"}]],Ohe=He("volume-2",Dhe);const Lhe=[["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"}]],Ihe=He("volume-x",Lhe);const Fhe=[["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"}]],Uhe=He("wand-sparkles",Fhe);const zhe=[["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"}]],Pg=He("wifi-off",zhe);const Bhe=[["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"}]],Dp=He("wifi",Bhe);const $he=[["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"}]],rq=He("wind",$he);const Hhe=[["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"}]],Od=He("wrench",Hhe);const Vhe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ut=He("x",Vhe);const Ghe=[["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"}]],Whe=He("zoom-in",Ghe);const qhe=[["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"}]],Sf=He("zap",qhe);const Khe=[["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"}]],Xhe=He("zoom-out",Khe),fn="/api/v1";let pw=localStorage.getItem("auth_token");function gb(t){pw=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function fz(){return pw}async function Ce(t,e={}){const n={"Content-Type":"application/json",...e.headers};pw&&(n.Authorization=`Bearer ${pw}`);const r=await fetch(`${fn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&gb(null);const a=(await r.json().catch(()=>({}))).detail,o=typeof a=="string"?a:a?JSON.stringify(a):`HTTP ${r.status}`;throw new Error(o)}return await r.json()}const pe={getAuthStatus:()=>Ce("/auth/status"),setupAuth:t=>Ce("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Ce("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Ce("/auth/logout",{method:"POST"}),getCurrentUser:()=>Ce("/auth/me"),disableAuth:()=>Ce("/auth/disable",{method:"POST"}),getUsers:()=>Ce("/users/"),getUser:t=>Ce(`/users/${t}`),createUser:t=>Ce("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Ce(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>Ce(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>Ce("/printers/"),getPrinter:t=>Ce(`/printers/${t}`),createPrinter:t=>Ce("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Ce(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Ce(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Ce(`/printers/${t}/status`),refreshPrinterStatus:t=>Ce(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Ce(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Ce(`/printers/${t}/disconnect`,{method:"POST"}),stopPrint:t=>Ce(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Ce(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Ce(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>Ce(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Ce(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Ce(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Ce(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Ce(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Ce(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Ce(`/printers/${t}/logging`),clearMQTTLogs:t=>Ce(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Ce(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${fn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>Ce(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Ce(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),Ce(`/archives/?${i}`)},getArchive:t=>Ce(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),Ce(`/archives/search?${n}`)},rebuildSearchIndex:()=>Ce("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Ce(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Ce(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Ce(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Ce("/archives/stats"),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),Ce(`/archives/analysis/failures?${e}`)},compareArchives:t=>Ce(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Ce(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n=await fetch(`${fn}/archives/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${fn}/archives/stats/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>Ce(`/archives/${t}/duplicates`),backfillContentHashes:()=>Ce("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${fn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${fn}/archives/${t}/download`,getArchiveGcode:t=>`${fn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${fn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${fn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Ce(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Ce(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getTimelapseInfo:t=>Ce(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Ce(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i=await fetch(`${fn}/archives/${t}/timelapse/process`,{method:"POST",body:r});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getArchivePhotoUrl:(t,e)=>`${fn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/archives/${t}/photos`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteArchivePhoto:(t,e)=>Ce(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${fn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${fn}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/archives/${t}/source`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteSource3mf:t=>Ce(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${fn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/archives/${t}/f3d`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteF3d:t=>Ce(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${fn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Ce(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Ce(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Ce(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${fn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${fn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Ce(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Ce(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Ce(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${fn}/archives/upload?printer_id=${e}`:`${fn}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(a=>n.append("files",a));const r=e?`${fn}/archives/upload-bulk?printer_id=${e}`:`${fn}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>Ce("/settings/"),updateSettings:t=>Ce("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Ce("/settings/mqtt/status"),resetSettings:()=>Ce("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.external_links!==void 0&&e.set("include_external_links",String(t.external_links)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.projects!==void 0&&e.set("include_projects",String(t.projects)),t.pending_uploads!==void 0&&e.set("include_pending_uploads",String(t.pending_uploads)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)),t.api_keys!==void 0&&e.set("include_api_keys",String(t.api_keys)));const n=`${fn}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n);if(!r.ok){const l=await r.text();throw new Error(l||`Backup failed with status ${r.status}`)}const i=r.headers.get("Content-Disposition");let a="bambuddy-backup.json";if(i){const l=i.match(/filename=([^;]+)/);l&&(a=l[1].trim())}return{blob:await r.blob(),filename:a}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${fn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Ce("/settings/check-ffmpeg"),getCloudStatus:()=>Ce("/cloud/status"),cloudLogin:(t,e,n="global")=>Ce("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Ce("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Ce("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Ce("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Ce(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Ce(`/cloud/settings/${t}`),createCloudSetting:t=>Ce("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Ce(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Ce(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Ce("/cloud/devices"),getCloudFields:t=>Ce(`/cloud/fields/${t}`),getAllCloudFields:()=>Ce("/cloud/fields"),getFilamentInfo:t=>Ce("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Ce("/smart-plugs/"),getSmartPlug:t=>Ce(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Ce(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Ce("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Ce(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Ce(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Ce(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Ce(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Ce("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${fn}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>Ce("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${fn}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>Ce("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Ce("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:()=>Ce("/smart-plugs/ha/entities"),getHASensorEntities:()=>Ce("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Ce(`/queue/?${n}`)},getQueueItem:t=>Ce(`/queue/${t}`),addToQueue:t=>Ce("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Ce(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Ce(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Ce("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Ce(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Ce(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Ce(`/queue/${t}/start`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Ce(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Ce(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Ce(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Ce(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Ce(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Ce(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Ce(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Ce(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Ce(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Ce(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Ce(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),Ce(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Ce(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Ce("/filaments/"),getFilament:t=>Ce(`/filaments/${t}`),getFilamentsByType:t=>Ce(`/filaments/by-type/${t}`),getNotificationProviders:()=>Ce("/notifications/"),getNotificationProvider:t=>Ce(`/notifications/${t}`),createNotificationProvider:t=>Ce("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Ce(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Ce(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Ce(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Ce("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Ce("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Ce("/notification-templates"),getNotificationTemplate:t=>Ce(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Ce(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Ce(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Ce("/notification-templates/variables"),previewTemplate:t=>Ce("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),Ce(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Ce(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Ce(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Ce("/spoolman/status"),connectSpoolman:()=>Ce("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Ce("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Ce(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Ce("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Ce("/spoolman/spools"),getSpoolmanFilaments:()=>Ce("/spoolman/filaments"),getUnlinkedSpools:()=>Ce("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Ce(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Ce("/updates/version"),checkForUpdates:()=>Ce("/updates/check"),applyUpdate:()=>Ce("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Ce("/updates/status"),getMaintenanceTypes:()=>Ce("/maintenance/types"),createMaintenanceType:t=>Ce("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Ce(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Ce(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Ce("/maintenance/overview"),getPrinterMaintenance:t=>Ce(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Ce(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Ce(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Ce(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Ce("/maintenance/summary"),setPrinterHours:(t,e)=>Ce(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Ce(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Ce(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${fn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${fn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Ce(`/printers/${t}/camera/test`),getExternalLinks:()=>Ce("/external-links/"),getExternalLink:t=>Ce(`/external-links/${t}`),createExternalLink:t=>Ce("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Ce(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Ce(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Ce("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/external-links/${t}/icon`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteExternalLinkIcon:t=>Ce(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${fn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Ce(`/projects/?${e}`)},getProject:t=>Ce(`/projects/${t}`),createProject:t=>Ce("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Ce(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Ce(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Ce(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Ce(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Ce(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Ce(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/projects/${t}/attachments`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getProjectAttachmentUrl:(t,e)=>`${fn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Ce(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Ce(`/projects/${t}/bom`),createBOMItem:(t,e)=>Ce(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Ce(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Ce(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Ce("/projects/templates/"),createTemplateFromProject:t=>Ce(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Ce(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Ce(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>Ce("/api-keys/"),createAPIKey:t=>Ce("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Ce(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Ce(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Ce(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Ce("/system/info"),getLibraryFolders:()=>Ce("/library/folders"),createLibraryFolder:t=>Ce("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Ce(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Ce(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Ce(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Ce(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),Ce(`/library/files?${n}`)},getLibraryFile:t=>Ce(`/library/files/${t}`),uploadLibraryFile:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`?folder_id=${e}`:"",i=await fetch(`${fn}/library/files${r}`,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},updateLibraryFile:(t,e)=>Ce(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Ce(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${fn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${fn}/library/files/${t}/thumbnail`,getLibraryFileGcodeUrl:t=>`${fn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Ce("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Ce("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Ce("/library/stats"),addLibraryFilesToQueue:t=>Ce("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Ce(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Ce(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Ce(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`)},ml={getInfo:()=>Ce("/discovery/info"),getStatus:()=>Ce("/discovery/status"),startDiscovery:(t=10)=>Ce(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Ce("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Ce("/discovery/printers"),startSubnetScan:(t,e=1)=>Ce("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Ce("/discovery/scan/status"),stopSubnetScan:()=>Ce("/discovery/scan/stop",{method:"POST"})},R1={getSettings:()=>Ce("/settings/virtual-printer"),getModels:()=>Ce("/settings/virtual-printer/models"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),t.model!==void 0&&e.set("model",t.model),Ce(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},yp={list:()=>Ce("/pending-uploads/"),getCount:()=>Ce("/pending-uploads/count"),get:t=>Ce(`/pending-uploads/${t}`),archive:(t,e)=>Ce(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Ce(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Ce("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Ce("/pending-uploads/discard-all",{method:"DELETE"})},D1={checkUpdates:()=>Ce("/firmware/updates"),checkPrinterUpdate:t=>Ce(`/firmware/updates/${t}`),prepareUpload:t=>Ce(`/firmware/updates/${t}/prepare`),startUpload:t=>Ce(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Ce(`/firmware/updates/${t}/upload/status`)},Op={getDebugLoggingState:()=>Ce("/support/debug-logging"),setDebugLogging:t=>Ce("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${fn}/support/bundle`);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${t.status}`)}const n=t.headers.get("Content-Disposition")?.match(/filename=(.+)/),r=n?n[1]:"bambuddy-support.zip",i=await t.blob(),a=window.URL.createObjectURL(i),o=document.createElement("a");o.href=a,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(a)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return Ce(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Ce("/support/logs",{method:"DELETE"})},iq=w.createContext(void 0);function Yhe({children:t}){const[e,n]=w.useState(()=>{const C=localStorage.getItem("theme-mode"),R=localStorage.getItem("theme");return C||R||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[f,m]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,x]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{pe.getSettings().then(C=>{C.dark_style&&(i(C.dark_style),localStorage.setItem("dark-style",C.dark_style)),C.dark_background&&(o(C.dark_background),localStorage.setItem("dark-background",C.dark_background)),C.dark_accent&&(c(C.dark_accent),localStorage.setItem("dark-accent",C.dark_accent)),C.light_style&&(d(C.light_style),localStorage.setItem("light-style",C.light_style)),C.light_background&&(m(C.light_background),localStorage.setItem("light-background",C.light_background)),C.light_accent&&(x(C.light_accent),localStorage.setItem("light-accent",C.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const C=document.documentElement;C.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"?(C.classList.add("dark"),C.classList.add(`style-${r}`),C.classList.add(`bg-${a}`),C.classList.add(`accent-${l}`)):(C.classList.add(`style-${u}`),C.classList.add(`bg-${f}`),C.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const v=()=>n(C=>C==="dark"?"light":"dark"),b=C=>n(C),y=C=>{i(C),localStorage.setItem("dark-style",C),pe.updateSettings({dark_style:C}).catch(()=>{})},M=C=>{o(C),localStorage.setItem("dark-background",C),pe.updateSettings({dark_background:C}).catch(()=>{})},S=C=>{c(C),localStorage.setItem("dark-accent",C),pe.updateSettings({dark_accent:C}).catch(()=>{})},A=C=>{d(C),localStorage.setItem("light-style",C),pe.updateSettings({light_style:C}).catch(()=>{})},E=C=>{m(C),localStorage.setItem("light-background",C),pe.updateSettings({light_background:C}).catch(()=>{})},k=C=>{x(C),localStorage.setItem("light-accent",C),pe.updateSettings({light_accent:C}).catch(()=>{})};return s.jsx(iq.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:v,setMode:b,setDarkStyle:y,setDarkBackground:M,setDarkAccent:S,setLightStyle:A,setLightBackground:E,setLightAccent:k},children:t})}function Xd(){const t=w.useContext(iq);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function wt({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return s.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,...i,children:t})}function mr({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Mt({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function Qhe(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function mz({children:t}){return s.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function Zhe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Tg(),i=Qhe(n,e,r);return w.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:s.jsx(wt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(zj,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),s.jsx("div",{className:"space-y-2",children:a.items.map(o=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&s.jsx(Lr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(mz,{children:l},l))})]},o.description))})]},a.category))}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",s.jsx(mz,{children:"Esc"})," or click outside to close"]})})]})})})}function Me({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",o={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return s.jsx("button",{className:`${a} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Rn({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:o}){w.useEffect(()=>{const u=d=>{d.key==="Escape"&&o()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[o]);const c={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o,children:s.jsx(wt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:s.jsx(En,{className:"w-6 h-6"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),s.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),s.jsxs("div",{className:"flex gap-3 mt-6",children:[s.jsx(Me,{variant:"secondary",onClick:o,className:"flex-1",children:r}),s.jsx(Me,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}function Jhe({plug:t}){const e=Qt(),[n,r]=w.useState(null),{data:i,isLoading:a}=lt({queryKey:["smart-plug-status",t.id],queryFn:()=>pe.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=ft({mutationFn:f=>pe.controlSmartPlug(t.id,f),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=i?.reachable??!1,u=o.isPending,d=()=>{n&&(o.mutate(n),r(null))};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`p-1.5 rounded ${c?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:s.jsx(Fs,{className:`w-4 h-4 ${c?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),s.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?s.jsx(pt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(Dp,{className:"w-3 h-3 text-bambu-green"}),s.jsx("span",{className:l?"text-bambu-green":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(Sf,{className:"w-3 h-3 text-yellow-400"}),s.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Pg,{className:"w-3 h-3 text-red-400"}),s.jsx("span",{className:"text-red-400",children:"Offline"})]})})]})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>r("on"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:u?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(uu,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>r("off"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${!l&&c?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:u?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(I2,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Rn,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:d,onCancel:()=>r(null)})]})}function pz({onClose:t}){const{data:e,isLoading:n}=lt({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return s.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:s.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[s.jsx(Fs,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),s.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?s.jsxs("div",{className:"text-center py-6 px-4",children:[s.jsx(Fs,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):s.jsx("div",{className:"space-y-1",children:r.map(i=>s.jsx(Jhe,{plug:i},i.id))})})]})}const aq=[{name:"globe",icon:Md},{name:"link",icon:Y0},{name:"external-link",icon:Lr},{name:"book",icon:tce},{name:"file-text",icon:Ua},{name:"home",icon:R2},{name:"star",icon:wf},{name:"heart",icon:Due},{name:"bookmark",icon:rce},{name:"shopping-cart",icon:QW},{name:"music",icon:Vj},{name:"video",icon:sD},{name:"image",icon:X0},{name:"camera",icon:Xp},{name:"map",icon:sde},{name:"compass",icon:zce},{name:"coffee",icon:Lce},{name:"gift",icon:wue},{name:"wrench",icon:Od},{name:"zap",icon:Sf},{name:"cloud",icon:A2},{name:"database",icon:Yp},{name:"folder",icon:VW},{name:"mail",icon:ide},{name:"phone",icon:jde},{name:"user",icon:Gj},{name:"users",icon:Gh},{name:"server",icon:jh},{name:"terminal",icon:eq},{name:"code",icon:$W}];function z2(t){return aq.find(n=>n.name===t)?.icon||Y0}function efe({value:t,onChange:e}){const[n,r]=w.useState(!1),i=z2(t);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[s.jsx(i,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),s.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:s.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:aq.map(({name:a,icon:o})=>s.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:s.jsx(o,{className:"w-5 h-5"})},a))})})]})]})}const gz=768;function sq(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<gz:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${gz-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const oq=w.createContext(void 0);function tfe({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[a,o]=w.useState(!0),l=async()=>{try{const m=await pe.getAuthStatus();if(i(m.auth_enabled),m.auth_enabled)if(fz())try{const x=await pe.getCurrentUser();n(x)}catch{gb(null),n(null)}else n(null);else n(null),m.requires_setup&&window.location.pathname!=="/setup"&&(window.location.href="/setup")}catch(m){console.error("Failed to check auth status:",m),i(!1),n(null)}finally{o(!1)}};w.useEffect(()=>{l()},[]);const c=async(m,p)=>{const x=await pe.login({username:m,password:p});gb(x.access_token),n(x.user)},u=()=>{gb(null),n(null),pe.logout().catch(()=>{}),window.location.href="/login"},d=async()=>{if(r&&fz())try{const m=await pe.getCurrentUser();n(m)}catch{gb(null),n(null)}},f=async()=>{await l()};return s.jsx(oq.Provider,{value:{user:e,authEnabled:r,loading:a,login:c,logout:u,refreshUser:d,refreshAuth:f},children:t})}function Vf(){const t=w.useContext(oq);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const s0=[{id:"printers",to:"/",icon:Ir,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Is,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Qr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:mce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:A2,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Od,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:xa,labelKey:"nav.projects"},{id:"files",to:"/files",icon:el,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:F2,labelKey:"nav.settings"}];function nfe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return s0.map(e=>e.id)}return s0.map(e=>e.id)}function rfe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function jA(t){return t.startsWith("ext-")}function lq(){return localStorage.getItem("defaultView")||"/"}function ife(t){localStorage.setItem("defaultView",t)}function afe(){const t=sl(),e=Gl(),{mode:n,toggleMode:r}=Xd(),{t:i}=Tg(),a=sq(),{user:o,authEnabled:l,logout:c}=Vf(),[u,d]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[v,b]=w.useState(!1),[y,M]=w.useState(nfe),[S,A]=w.useState(null),[E,k]=w.useState(null),C=w.useRef(!1),[R,T]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:P}=lt({queryKey:["version"],queryFn:pe.getVersion,staleTime:1/0}),{data:F}=lt({queryKey:["settings"],queryFn:pe.getSettings,staleTime:300*1e3}),{data:I}=lt({queryKey:["updateCheck"],queryFn:pe.checkForUpdates,enabled:F?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:X}=lt({queryKey:["external-links"],queryFn:pe.getExternalLinks}),{data:D}=lt({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs,staleTime:30*1e3}),K=D?.some(B=>B.show_in_switchbar)??!1,{data:Y}=lt({queryKey:["debugLogging"],queryFn:Op.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:q}=lt({queryKey:["queue","pending"],queryFn:()=>pe.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Z=q?.length??0,{data:re}=lt({queryKey:["pending-uploads","count"],queryFn:yp.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),ie=re?.count??0,[U,G]=w.useState(null);w.useEffect(()=>{if(!Y?.enabled||!Y.enabled_at){G(null);return}const B=new Date(Y.enabled_at).getTime(),H=()=>{G(Math.floor((Date.now()-B)/1e3))};H();const W=setInterval(H,1e3);return()=>clearInterval(W)},[Y?.enabled,Y?.enabled_at]);const ee=w.useMemo(()=>new Map(s0.map(B=>[B.id,B])),[]),ne=w.useMemo(()=>new Map((X||[]).map(B=>[`ext-${B.id}`,B])),[X]),se=(()=>{const B=[],H=new Set,W=l&&o?.role==="user";for(const z of y)W&&z==="settings"||(ee.has(z)||ne.has(z))&&(B.push(z),H.add(z));for(const z of s0)W&&z.id==="settings"||H.has(z.id)||(B.push(z.id),H.add(z.id));for(const z of X||[]){const V=`ext-${z.id}`;H.has(V)||(B.push(V),H.add(V))}return B})(),de=(B,H)=>{A(H),B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",H)},he=(B,H)=>{B.preventDefault(),B.dataTransfer.dropEffect="move",k(H)},Ee=()=>{k(null)},ge=(B,H)=>{if(B.preventDefault(),S===null||S===H){A(null),k(null);return}const W=[...se],z=W.indexOf(S),V=W.indexOf(H);if(z===-1||V===-1){A(null),k(null);return}W.splice(z,1),W.splice(V,0,S),M(W),rfe(W),A(null),k(null)},Ne=()=>{A(null),k(null)},Re=I?.update_available&&I.latest_version&&I.latest_version!==R,te=()=>{I?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",I.latest_version),T(I.latest_version))};w.useEffect(()=>{if(!C.current&&e.pathname==="/"){const B=lq();B!=="/"&&(C.current=!0,t(B,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(u))},[u]),w.useEffect(()=>{a&&m(!1)},[e.pathname,a]);const Je=w.useCallback(B=>{const H=B.target;if(!(H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.isContentEditable)&&!B.metaKey&&!B.ctrlKey&&!B.altKey){const W=parseInt(B.key);if(W>=1&&W<=se.length&&W<=9){const z=se[W-1];if(B.preventDefault(),jA(z)){const V=z.replace("ext-","");t(`/external/${V}`)}else{const V=ee.get(z);V&&t(V.to)}return}switch(B.key){case"?":B.preventDefault(),x(!0);break;case"Escape":x(!1);break}}},[t,se,ee]);return w.useEffect(()=>(document.addEventListener("keydown",Je),()=>document.removeEventListener("keydown",Je)),[Je]),s.jsxs("div",{className:"flex min-h-screen",children:[a&&s.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(fde,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&f&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>m(!1)}),s.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${f?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${u?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||u?"p-4":"p-2"}`,children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||u?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),s.jsx("nav",{className:"flex-1 p-2",children:s.jsx("ul",{className:"space-y-2",children:se.map(B=>{if(jA(B)){const W=ne.get(B);if(!W)return null;const z=W.custom_icon?null:z2(W.icon);return s.jsx("li",{draggable:!0,onDragStart:V=>de(V,B),onDragOver:V=>he(V,B),onDragLeave:Ee,onDrop:V=>ge(V,B),onDragEnd:Ne,className:`relative ${S===B?"opacity-50":""} ${E===B&&S!==B?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(pb,{to:`/external/${W.id}`,className:({isActive:V})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${V?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?W.name:void 0,children:[u&&!a&&s.jsx(Qp,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),W.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${W.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):z&&s.jsx(z,{className:"w-5 h-5 flex-shrink-0"}),(a||u)&&s.jsx("span",{children:W.name})]})},B)}else{const W=ee.get(B);if(!W)return null;const{to:z,icon:V,labelKey:Q}=W,Te=B==="queue"&&Z>0,ke=B==="archives"&&ie>0,Ae=Te?Z:ke?ie:0,$=Te||ke;return s.jsx("li",{draggable:!0,onDragStart:L=>de(L,B),onDragOver:L=>he(L,B),onDragLeave:Ee,onDrop:L=>ge(L,B),onDragEnd:Ne,className:`relative ${S===B?"opacity-50":""} ${E===B&&S!==B?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(pb,{to:z,className:({isActive:L})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${L?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?i(Q):void 0,children:[u&&!a&&s.jsx(Qp,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(V,{className:"w-5 h-5 flex-shrink-0"}),$&&s.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${ke?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:Ae>99?"99+":Ae})]}),(a||u)&&s.jsx("span",{children:i(Q)})]})},B)}})})}),!a&&s.jsx("button",{onClick:()=>d(!u),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(u?"nav.collapseSidebar":"nav.expandSidebar"),children:u?s.jsx(yf,{className:"w-5 h-5"}):s.jsx(Vs,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||u?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[K&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>b(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${v?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Fs,{className:"w-5 h-5"})}),v&&s.jsx(pz,{onClose:()=>b(!1)})]}),s.jsx(pb,{to:"/system",className:({isActive:B})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${B?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Rl,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:s.jsx(lz,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>x(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:s.jsx(zj,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx(hz,{className:"w-5 h-5"}):s.jsx(fw,{className:"w-5 h-5"})}),l&&o&&s.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:s.jsx($j,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",P?.version||"..."]}),I?.update_available&&s.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:I.latest_version}),children:[s.jsx(TA,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[I?.update_available&&s.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:I.latest_version}),children:s.jsx(TA,{className:"w-5 h-5"})}),K&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>b(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${v?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Fs,{className:"w-5 h-5"})}),v&&s.jsx(pz,{onClose:()=>b(!1)})]}),s.jsx(pb,{to:"/system",className:({isActive:B})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${B?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Rl,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:s.jsx(lz,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>x(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:s.jsx(zj,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx(hz,{className:"w-5 h-5"}):s.jsx(fw,{className:"w-5 h-5"})}),l&&o&&s.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:s.jsx($j,{className:"w-5 h-5"})})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":u?"ml-64":"ml-16"}`,children:[Y?.enabled&&s.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(N2,{className:"w-4 h-4 text-amber-500 animate-pulse"}),s.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),U!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(U/60),"m ",U%60,"s)"]})]}),s.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),Re&&s.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(TA,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:I?.latest_version,defaultValue:`Version ${I?.latest_version} is available!`})}),s.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),s.jsx("button",{onClick:te,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Ut,{className:"w-4 h-4"})})]}),s.jsx(Soe,{})]}),p&&s.jsx(Zhe,{onClose:()=>x(!1),sidebarItems:se.map(B=>{if(jA(B)){const H=ne.get(B);return H?{type:"external",label:H.name}:null}else{const H=ee.get(B);return H?{type:"nav",label:H.labelKey,labelKey:H.labelKey}:null}}).filter(Boolean)})]})}function Pb(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function mi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Jp(t,e){const n=mi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function eg(t,e="system",n){const r=mi(t);if(!r)return"";const a=Pb(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function sfe(t,e="system",n){const i=Pb({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const cq=w.createContext(void 0);function Un(){const t=w.useContext(cq);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const ofe={success:s.jsx(kn,{className:"w-5 h-5 text-green-400"}),error:s.jsx(qi,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(ea,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Rl,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(pt,{className:"w-5 h-5 text-bambu-green animate-spin"})},lfe={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 cfe({children:t}){const[e,n]=w.useState([]),r=w.useCallback((o,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:o,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=w.useCallback((o,l,c="info")=>{n(u=>u.find(f=>f.id===o)?u.map(f=>f.id===o?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:o,message:l,type:c,persistent:!0}])},[]),a=w.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(cq.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,s.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(o=>s.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${lfe[o.type]}`,children:[ofe[o.type],s.jsx("span",{className:"text-white text-sm",children:o.message}),s.jsx("button",{onClick:()=>a(o.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-4 h-4"})})]},o.id))})]})}function ufe(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 xz(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 dfe(t,e){if(e)return VW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return tf;case"gcode":return Ua;case"mp4":case"avi":return Sd;case"png":case"jpg":case"jpeg":return X0;default:return C2}}const hfe=[{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 ffe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Un(),i=Qt(),[a,o]=w.useState("/"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(null),[p,x]=w.useState("name-asc");w.useEffect(()=>{const T=P=>{P.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);const{data:v,isLoading:b,refetch:y}=lt({queryKey:["printerFiles",t,a],queryFn:()=>pe.getPrinterFiles(t,a)}),{data:M}=lt({queryKey:["printerStorage",t],queryFn:()=>pe.getPrinterStorage(t),staleTime:3e4}),S=ft({mutationFn:T=>pe.deletePrinterFile(t,T),onSuccess:(T,P)=>{r(`Deleted: ${P.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:T=>{r(`Delete failed: ${T.message}`,"error")}}),A=T=>{o(T),c(null)},E=()=>{if(a==="/")return;const T=a.split("/").filter(Boolean);T.pop(),o(T.length?"/"+T.join("/"):"/"),c(null)},k=T=>{window.open(pe.getPrinterFileDownloadUrl(t,T),"_blank")},C=T=>{m(T)},R=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:T=>T.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(P2,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[M&&(M.used_bytes!=null||M.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[M.used_bytes!=null&&s.jsxs("span",{children:["Used: ",xz(M.used_bytes)]}),M.used_bytes!=null&&M.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),M.free_bytes!=null&&s.jsxs("span",{children:["Free: ",xz(M.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[R.map(T=>s.jsx("button",{onClick:()=>{A(T.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===T.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:T.label},T.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ws,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:T=>d(T.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsx(zW,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:p,onChange:T=>x(T.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",children:hfe.map(T=>s.jsx("option",{value:T.value,children:T.label},T.value))})]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:b,children:s.jsx(yr,{className:`w-4 h-4 ${b?"animate-spin":""}`})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[s.jsx("button",{onClick:E,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(yf,{className:"w-4 h-4"})}),s.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:b?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):v?.files?.length?s.jsx("div",{className:"space-y-1",children:[...v.files].filter(T=>!u||T.name.toLowerCase().includes(u.toLowerCase())).sort((T,P)=>{if(T.is_directory&&!P.is_directory)return-1;if(!T.is_directory&&P.is_directory)return 1;switch(p){case"name-asc":return T.name.localeCompare(P.name);case"name-desc":return P.name.localeCompare(T.name);case"size-asc":return T.size-P.size;case"size-desc":return P.size-T.size;case"date-asc":{const F=T.mtime?new Date(T.mtime).getTime():0,I=P.mtime?new Date(P.mtime).getTime():0;return F-I}case"date-desc":{const F=T.mtime?new Date(T.mtime).getTime():0;return(P.mtime?new Date(P.mtime).getTime():0)-F}default:return T.name.localeCompare(P.name)}}).map(T=>{const P=dfe(T.name,T.is_directory),F=l===T.path;return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${F?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{T.is_directory?A(T.path):c(F?null:T.path)},children:[s.jsx(P,{className:`w-5 h-5 flex-shrink-0 ${T.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:T.name}),!T.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:ufe(T.size)}),T.is_directory&&s.jsx(yf,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},T.path)})}):s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${v?.files?.filter(T=>T.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${v?.files?.length||0} items`:`${v?.files?.length||0} items`}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",disabled:!l,onClick:()=>l&&k(l),children:[s.jsx(Jr,{className:"w-4 h-4"}),"Download"]}),s.jsxs(Me,{variant:"secondary",disabled:!l||S.isPending,onClick:()=>l&&C(l),className:"text-red-400 hover:text-red-300",children:[S.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&s.jsx(Rn,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{S.mutate(f),m(null)},onCancel:()=>m(null)})]})}const mfe="embeddedCameraState_",bz=5,pfe=2e3,gfe=3e4,xfe=5e3,PA={x:window.innerWidth-420,y:20,width:400,height:300};function bfe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${mfe}${t}`,a=()=>{try{const he=localStorage.getItem(i);if(he){const Ee=JSON.parse(he);return{x:Math.min(Math.max(0,Ee.x),window.innerWidth-100),y:Math.min(Math.max(0,Ee.y),window.innerHeight-100),width:Math.max(200,Math.min(Ee.width,window.innerWidth-20)),height:Math.max(150,Math.min(Ee.height,window.innerHeight-20))}}}catch{}const de=n*30;return{...PA,x:Math.max(0,PA.x-de),y:Math.max(0,PA.y+de)}},[o,l]=w.useState(a),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,p]=w.useState({x:0,y:0}),[x,v]=w.useState(!1),[b,y]=w.useState(!1),[M,S]=w.useState(!0),[A,E]=w.useState(Date.now()),[k,C]=w.useState(0),[R,T]=w.useState(!1),[P,F]=w.useState(0),I=w.useRef(null),X=w.useRef(null),D=w.useRef(null),K=w.useRef(null),Y=w.useRef(null),{data:q}=lt({queryKey:["printer",t],queryFn:()=>pe.getPrinter(t),enabled:t>0});w.useEffect(()=>{const de=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(de)},[o,i]);const Z=w.useRef(!1);w.useEffect(()=>{Z.current=!1;const de=`/api/v1/printers/${t}/camera/stop`,he=()=>{t>0&&!Z.current&&(Z.current=!0,navigator.sendBeacon(de))},Ee=X.current;return()=>{Ee&&(Ee.src=""),he(),D.current&&clearTimeout(D.current),K.current&&clearInterval(K.current),Y.current&&clearInterval(Y.current)}},[t]),w.useEffect(()=>{if(M){const de=setTimeout(()=>S(!1),3e3);return()=>clearTimeout(de)}},[M,A]);const re=w.useCallback(()=>{if(k>=bz){T(!1),y(!0);return}const de=Math.min(pfe*Math.pow(2,k),gfe);T(!0),F(Math.ceil(de/1e3)),K.current=setInterval(()=>{F(he=>he<=1?(K.current&&clearInterval(K.current),0):he-1)},1e3),D.current=setTimeout(()=>{C(he=>he+1),T(!1),S(!0),y(!1),X.current&&(X.current.src=""),E(Date.now())},de)},[k]);w.useEffect(()=>{if(M||R||x){Y.current&&(clearInterval(Y.current),Y.current=null);return}return Y.current=setInterval(async()=>{try{const de=await fetch(`/api/v1/printers/${t}/camera/status`);if(de.ok){const he=await de.json();(he.stalled||!he.active&&!b)&&(Y.current&&(clearInterval(Y.current),Y.current=null),S(!1),re())}}catch{}},xfe),()=>{Y.current&&(clearInterval(Y.current),Y.current=null)}},[M,b,R,x,t,re]);const ie=()=>{S(!1),k<bz?re():y(!0)},U=()=>{S(!1),y(!1),C(0),T(!1),D.current&&clearTimeout(D.current),K.current&&clearInterval(K.current)},G=()=>{S(!0),y(!1),C(0),T(!1),D.current&&clearTimeout(D.current),K.current&&clearInterval(K.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),X.current&&(X.current.src=""),setTimeout(()=>E(Date.now()),100)},ee=de=>{de.target.closest(".no-drag")||(u(!0),p({x:de.clientX-o.x,y:de.clientY-o.y}))},ne=de=>{de.stopPropagation(),f(!0)};w.useEffect(()=>{const de=Ee=>{if(c)l(ge=>({...ge,x:Math.max(0,Math.min(Ee.clientX-m.x,window.innerWidth-ge.width)),y:Math.max(0,Math.min(Ee.clientY-m.y,window.innerHeight-ge.height))}));else if(d&&I.current){const ge=I.current.getBoundingClientRect();l(Ne=>({...Ne,width:Math.max(200,Math.min(Ee.clientX-ge.left,window.innerWidth-Ne.x-10)),height:Math.max(150,Math.min(Ee.clientY-ge.top,window.innerHeight-Ne.y-10))}))}},he=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",de),document.addEventListener("mouseup",he),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",he)}},[c,d,m]);const se=`/api/v1/printers/${t}/camera/stream?fps=10&t=${A}`;return s.jsxs("div",{ref:I,className:"fixed z-50 bg-bambu-dark-secondary rounded-lg shadow-2xl border border-bambu-dark-tertiary overflow-hidden",style:{left:o.x,top:o.y,width:x?200:o.width,height:x?40:o.height,cursor:c?"grabbing":"default"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:ee,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(Qp,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:q?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:G,disabled:M||R,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(yr,{className:`w-3.5 h-3.5 text-bambu-gray ${M?"animate-spin":""}`})}),s.jsx("button",{onClick:()=>v(!x),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Expand":"Minimize",children:x?s.jsx(qW,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(KW,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:s.jsx(Ut,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!x&&s.jsxs("div",{className:"relative w-full h-[calc(100%-40px)] bg-black flex items-center justify-center",children:[M&&!R&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(yr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),R&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Pg,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",P,"s..."]})]})}),b&&!R&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(En,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),s.jsx("button",{onClick:G,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:X,src:se,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:ie,onLoad:U},A),s.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:ne,title:"Drag to resize",children:s.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function yfe({printerId:t,printerName:e,onClose:n}){const r=Qt(),[i,a]=w.useState(!0),[o,l]=w.useState(new Set),[c,u]=w.useState(""),[d,f]=w.useState("all"),m=w.useRef(null),{data:p,isLoading:x,refetch:v}=lt({queryKey:["mqtt-logs",t],queryFn:()=>pe.getMQTTLogs(t),refetchInterval:1e3}),b=ft({mutationFn:()=>pe.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),y=ft({mutationFn:()=>pe.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=ft({mutationFn:()=>pe.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const T=P=>{P.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[p?.logs,i]);const S=T=>{l(P=>{const F=new Set(P);return F.has(T)?F.delete(T):F.add(T),F})},A=T=>new Date(T).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),E=(T,P)=>{if(T==null)return"<empty>";const F=typeof T=="string"?JSON.parse(T):T,I=JSON.stringify(F,null,P?2:0);return!P&&I.length>100?I.substring(0,100)+"...":I},k=p?.logging_enabled??!1,C=w.useMemo(()=>p?.logs??[],[p?.logs]),R=w.useMemo(()=>C.filter(T=>{if(d!=="all"&&T.direction!==d)return!1;if(c.trim()){const P=c.toLowerCase(),F=T.topic.toLowerCase().includes(P),X=JSON.stringify(T.payload).toLowerCase().includes(P);return F||X}return!0}),[C,c,d]);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[k?s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>y.mutate(),disabled:y.isPending,children:[s.jsx(Ol,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Me,{size:"sm",onClick:()=>b.mutate(),disabled:b.isPending,children:[s.jsx(nl,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||C.length===0,children:[s.jsx(Jt,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:x,children:s.jsx(yr,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:i,onChange:T=>a(T.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[R.length,"/",C.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ws,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:T=>u(T.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&s.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),s.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(i0,{className:"w-3 h-3"}),"In"]}),s.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(Kp,{className:"w-3 h-3"}),"Out"]})]})]})]}),s.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:C.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!k&&s.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):R.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages match your filter"}),s.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):s.jsx("div",{className:"space-y-1",children:R.map((T,P)=>{const F=o.has(P),I=T.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>S(P),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:A(T.timestamp)}),s.jsx("span",{className:`shrink-0 ${I?"text-blue-400":"text-green-400"}`,title:I?"Incoming":"Outgoing",children:I?s.jsx(i0,{className:"w-3 h-3"}):s.jsx(Kp,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:T.topic})]}),F?s.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:E(T.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:E(T.payload,!1)})]},P)})})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:k?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):s.jsx("span",{children:"Logging stopped"})}),s.jsx(Me,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const Wj={"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 vfe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:En};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:En};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:ea};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Rl}}}function qj(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 _fe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=qj(e.attr,n);return Wj[r]!==void 0})}function wfe(){return"https://wiki.bambulab.com/en/hms/home"}function Sfe({printerName:t,errors:e,onClose:n}){console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const r=e.filter(i=>{const a=parseInt(i.code.replace("0x",""),16)||0,o=qj(i.attr,a);return Wj[o]!==void 0});return w.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(En,{className:"w-5 h-5 text-orange-400"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(ea,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{children:"No errors"})]}):s.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:o,color:l,bgColor:c,Icon:u}=vfe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=qj(i.attr,d),m=Wj[f],p=wfe(),x=f.replace("_","-");return s.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(u,{className:`w-5 h-5 ${l} flex-shrink-0 mt-0.5`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsxs("span",{className:`font-mono text-sm ${l}`,children:["[",x,"]"]}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:o})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),s.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(Lr,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function Mfe(t){if(!t)return"ASAP";const e=mi(t);if(!e)return"ASAP";const n=new Date,r=e.getTime()-n.getTime();return r<0?"Now":r<6e4?"In <1 min":r<36e5?`In ${Math.round(r/6e4)} min`:r<864e5?`In ${Math.round(r/36e5)}h`:e.toLocaleDateString()}function Nfe({printerId:t}){const{data:e}=lt({queryKey:["queue",t,"pending"],queryFn:()=>pe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(as,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx(Qr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),s.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[s.jsx(Hn,{className:"w-3 h-3"}),Mfe(n?.scheduled_time||null)]}),r>1&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),s.jsx(Vs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function uq(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=uq(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Dn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=uq(t))&&(r&&(r+=" "),r+=e);return r}var Efe=["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 oD(t){if(typeof t!="string")return!1;var e=Efe;return e.includes(t)}var Afe=["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"],Tfe=new Set(Afe);function dq(t){return typeof t!="string"?!1:Tfe.has(t)}function hq(t){return typeof t=="string"&&t.startsWith("data-")}function Va(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(dq(n)||hq(n))&&(e[n]=t[n]);return e}function Mf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Va(e)}return typeof t=="object"&&!Array.isArray(t)?Va(t):null}function ba(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(dq(n)||hq(n)||oD(n))&&(e[n]=t[n]);return e}function Cfe(t){return t==null?null:w.isValidElement(t)?ba(t.props):typeof t=="object"&&!Array.isArray(t)?ba(t):null}var kfe=["children","width","height","viewBox","className","style","title","desc"];function Kj(){return Kj=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},Kj.apply(null,arguments)}function jfe(t,e){if(t==null)return{};var n,r,i=Pfe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Pfe(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 lD=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=jfe(t,kfe),f=a||{width:r,height:i,x:0,y:0},m=Dn("recharts-surface",o);return w.createElement("svg",Kj({},ba(d),{className:m,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),w.createElement("title",null,c),w.createElement("desc",null,u),n)}),Rfe=["children","className"];function Xj(){return Xj=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},Xj.apply(null,arguments)}function Dfe(t,e){if(t==null)return{};var n,r,i=Ofe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ofe(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 Fr=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=Dfe(t,Rfe),a=Dn("recharts-layer",r);return w.createElement("g",Xj({className:a},ba(i),{ref:e}),n)}),fq=w.createContext(null),Lfe=()=>w.useContext(fq);function br(t){return function(){return t}}const mq=Math.cos,gw=Math.sin,ol=Math.sqrt,xw=Math.PI,B2=2*xw,Yj=Math.PI,Qj=2*Yj,Ph=1e-6,Ife=Qj-Ph;function pq(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Ffe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return pq;const n=10**e;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class Ufe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?pq:Ffe(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,f=l-n,m=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(m>Ph)if(!(Math.abs(f*c-u*d)>Ph)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,x=i-l,v=c*c+u*u,b=p*p+x*x,y=Math.sqrt(v),M=Math.sqrt(m),S=a*Math.tan((Yj-Math.acos((v+m-b)/(2*y*M)))/2),A=S/M,E=S/y;Math.abs(A-1)>Ph&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*p>d*x)},${this._x1=e+E*c},${this._y1=n+E*u}`}}arc(e,n,r,i,a,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^o,m=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Ph||Math.abs(this._y1-d)>Ph)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%Qj+Qj),m>Ife?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:m>Ph&&this._append`A${r},${r},0,${+(m>=Yj)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function cD(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 Ufe(e)}function uD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function gq(t){this._context=t}gq.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 $2(t){return new gq(t)}function xq(t){return t[0]}function bq(t){return t[1]}function yq(t,e){var n=br(!0),r=null,i=$2,a=null,o=cD(l);t=typeof t=="function"?t:t===void 0?xq:br(t),e=typeof e=="function"?e:e===void 0?bq:br(e);function l(c){var u,d=(c=uD(c)).length,f,m=!1,p;for(r==null&&(a=i(p=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===m&&((m=!m)?a.lineStart():a.lineEnd()),m&&a.point(+t(f,u,c),+e(f,u,c));if(p)return a=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:br(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:br(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:br(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),l):r},l}function Yv(t,e,n){var r=null,i=br(!0),a=null,o=$2,l=null,c=cD(u);t=typeof t=="function"?t:t===void 0?xq:br(+t),e=typeof e=="function"?e:br(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?bq:br(+n);function u(f){var m,p,x,v=(f=uD(f)).length,b,y=!1,M,S=new Array(v),A=new Array(v);for(a==null&&(l=o(M=c())),m=0;m<=v;++m){if(!(m<v&&i(b=f[m],m,f))===y)if(y=!y)p=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=m-1;x>=p;--x)l.point(S[x],A[x]);l.lineEnd(),l.areaEnd()}y&&(S[m]=+t(b,m,f),A[m]=+e(b,m,f),l.point(r?+r(b,m,f):S[m],n?+n(b,m,f):A[m]))}if(M)return l=null,M+""||null}function d(){return yq().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:br(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:br(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:br(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:br(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:br(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:br(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:br(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,a!=null&&(l=o(a)),u):o},u.context=function(f){return arguments.length?(f==null?a=l=null:l=o(a=f),u):a},u}class vq{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 zfe(t){return new vq(t,!0)}function Bfe(t){return new vq(t,!1)}const dD={draw(t,e){const n=ol(e/xw);t.moveTo(n,0),t.arc(0,0,n,0,B2)}},$fe={draw(t,e){const n=ol(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()}},_q=ol(1/3),Hfe=_q*2,Vfe={draw(t,e){const n=ol(e/Hfe),r=n*_q;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Gfe={draw(t,e){const n=ol(e),r=-n/2;t.rect(r,r,n,n)}},Wfe=.8908130915292852,wq=gw(xw/10)/gw(7*xw/10),qfe=gw(B2/10)*wq,Kfe=-mq(B2/10)*wq,Xfe={draw(t,e){const n=ol(e*Wfe),r=qfe*n,i=Kfe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=B2*a/5,l=mq(o),c=gw(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},RA=ol(3),Yfe={draw(t,e){const n=-ol(e/(RA*3));t.moveTo(0,n*2),t.lineTo(-RA*n,-n),t.lineTo(RA*n,-n),t.closePath()}},ro=-.5,io=ol(3)/2,Zj=1/ol(12),Qfe=(Zj/2+1)*3,Zfe={draw(t,e){const n=ol(e/Qfe),r=n/2,i=n*Zj,a=r,o=n*Zj+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(ro*r-io*i,io*r+ro*i),t.lineTo(ro*a-io*o,io*a+ro*o),t.lineTo(ro*l-io*c,io*l+ro*c),t.lineTo(ro*r+io*i,ro*i-io*r),t.lineTo(ro*a+io*o,ro*o-io*a),t.lineTo(ro*l+io*c,ro*c-io*l),t.closePath()}};function Jfe(t,e){let n=null,r=cD(i);t=typeof t=="function"?t:br(t||dD),e=typeof e=="function"?e:br(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:br(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:br(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function bw(){}function yw(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 Sq(t){this._context=t}Sq.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:yw(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:yw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function eme(t){return new Sq(t)}function Mq(t){this._context=t}Mq.prototype={areaStart:bw,areaEnd:bw,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:yw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function tme(t){return new Mq(t)}function Nq(t){this._context=t}Nq.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:yw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function nme(t){return new Nq(t)}function Eq(t){this._context=t}Eq.prototype={areaStart:bw,areaEnd:bw,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 rme(t){return new Eq(t)}function yz(t){return t<0?-1:1}function vz(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return(yz(a)+yz(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function _z(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function DA(t,e,n){var r=t._x0,i=t._y0,a=t._x1,o=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,o-l*n,a,o)}function vw(t){this._context=t}vw.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:DA(this,this._t0,_z(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,DA(this,_z(this,n=vz(this,t,e)),n);break;default:DA(this,this._t0,n=vz(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function Aq(t){this._context=new Tq(t)}(Aq.prototype=Object.create(vw.prototype)).point=function(t,e){vw.prototype.point.call(this,e,t)};function Tq(t){this._context=t}Tq.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}};function ime(t){return new vw(t)}function ame(t){return new Aq(t)}function Cq(t){this._context=t}Cq.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=wz(t),i=wz(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[o],e[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function wz(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function sme(t){return new Cq(t)}function H2(t,e){this._context=t,this._t=e}H2.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 ome(t){return new H2(t,.5)}function lme(t){return new H2(t,0)}function cme(t){return new H2(t,1)}function tg(t,e){if((o=t.length)>1)for(var n=1,r,i,a=t[e[0]],o,l=a.length;n<o;++n)for(i=a,a=t[e[n]],r=0;r<l;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function Jj(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function ume(t,e){return t[e]}function dme(t){const e=[];return e.key=t,e}function hme(){var t=br([]),e=Jj,n=tg,r=ume;function i(a){var o=Array.from(t.apply(this,arguments),dme),l,c=o.length,u=-1,d;for(const f of a)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(f,o[l].key,u,a)]).data=f;for(l=0,d=uD(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:br(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:br(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?Jj:typeof a=="function"?a:br(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??tg,i):n},i}function fme(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=t[n][i][1]||0;if(o)for(n=0;n<r;++n)t[n][i][1]/=o}tg(t,e)}}function mme(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}tg(t,e)}}function pme(t,e){if(!(!((o=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,m=d[r-1][1]||0,p=(f-m)/2,x=0;x<l;++x){var v=t[e[x]],b=v[r][1]||0,y=v[r-1][1]||0;p+=b-y}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,tg(t,e)}}var OA={},LA={},Sz;function gme(){return Sz||(Sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(LA)),LA}var IA={},Mz;function kq(){return Mz||(Mz=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})(IA)),IA}var FA={},Nz;function hD(){return Nz||(Nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="string"||typeof n=="symbol"?n:Object.is(n?.valueOf?.(),-0)?"-0":String(n)}t.toKey=e})(FA)),FA}var UA={},zA={},Ez;function xme(){return Ez||(Ez=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})(zA)),zA}var Az;function fD(){return Az||(Az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xme(),n=hD();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(UA)),UA}var Tz;function mD(){return Tz||(Tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gme(),n=kq(),r=hD(),i=fD();function a(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?a(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(OA)),OA}var BA,Cz;function bme(){return Cz||(Cz=1,BA=mD().get),BA}var yme=bme();const Nf=ko(yme);var Xi=t=>t===0?0:t>0?1:-1,gs=t=>typeof t=="number"&&t!=+t,tu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Lt=t=>(typeof t=="number"||t instanceof Number)&&!gs(t),Ao=t=>Lt(t)||typeof t=="string",vme=0,o0=t=>{var e=++vme;return"".concat(t||"").concat(e)},ka=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(!Lt(e)&&typeof e!="string")return r;var a;if(tu(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return gs(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},jq=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[t[r]])n[t[r]]=!0;else return!0;return!1};function Wn(t,e,n){return Lt(t)&&Lt(e)?t+n*(e-t):e}function Pq(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Nf(r,e))===n)}var Ar=t=>t===null||typeof t>"u",Q0=t=>Ar(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function _me(t){return t!=null}function Z0(){}var wme=["type","size","sizeType"];function e3(){return e3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},e3.apply(null,arguments)}function kz(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 jz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kz(Object(n),!0).forEach(function(r){Sme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Sme(t,e,n){return(e=Mme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mme(t){var e=Nme(t,"string");return typeof e=="symbol"?e:e+""}function Nme(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Eme(t,e){if(t==null)return{};var n,r,i=Ame(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ame(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 Rq={symbolCircle:dD,symbolCross:$fe,symbolDiamond:Vfe,symbolSquare:Gfe,symbolStar:Xfe,symbolTriangle:Yfe,symbolWye:Zfe},Tme=Math.PI/180,Cme=t=>{var e="symbol".concat(Q0(t));return Rq[e]||dD},kme=(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*Tme;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}},jme=(t,e)=>{Rq["symbol".concat(Q0(t))]=e},pD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Eme(t,wme),a=jz(jz({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=Cme(o),p=Jfe().type(m).size(kme(n,r,o)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=ba(a);return Lt(u)&&Lt(d)&&Lt(n)?w.createElement("path",e3({},f,{className:Dn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};pD.registerSymbol=jme;var Dq=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,gD=(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=>{oD(i)&&(r[i]=(a=>n[i](n,a)))}),r},Pme=(t,e,n)=>r=>(t(e,n,r),null),J0=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var a=t[i];oD(i)&&typeof a=="function"&&(r||(r={}),r[i]=Pme(a,e,n))}),r};function Pz(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 Rme(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Pz(Object(n),!0).forEach(function(r){Dme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Pz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Dme(t,e,n){return(e=Ome(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ome(t){var e=Lme(t,"string");return typeof e=="symbol"?e:e+""}function Lme(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 Ur(t,e){var n=Rme({},t),r=e,i=Object.keys(e),a=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return a}function _w(){return _w=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},_w.apply(null,arguments)}function Rz(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 Ime(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Rz(Object(n),!0).forEach(function(r){Fme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Rz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Fme(t,e,n){return(e=Ume(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ume(t){var e=zme(t,"string");return typeof e=="symbol"?e:e+""}function zme(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 co=32,Bme={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function $me(t){var{data:e,iconType:n,inactiveColor:r}=t,i=co/2,a=co/6,o=co/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:co,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,`
  11. A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
  12. H`).concat(co,"M").concat(2*o,",").concat(i,`
  13. A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(co/8,"h").concat(co,"v").concat(co*3/4,"h").concat(-co,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=Ime({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(pD,{fill:l,cx:i,cy:i,size:co,sizeType:"diameter",type:c})}function Hme(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:co,height:co},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var m=d.formatter||i,p=Dn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,v=m?m(d.value,d,f):d.value;return w.createElement("li",_w({className:p,style:c,key:"legend-item-".concat(f)},J0(t,d,f)),w.createElement(lD,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(v," legend icon")},w.createElement($me,{data:d,iconType:o,inactiveColor:a})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},v))})}var Vme=t=>{var e=Ur(t,Bme),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return w.createElement("ul",{className:"recharts-default-legend",style:a},w.createElement(Hme,_w({},e,{payload:n})))},$A={},HA={},Dz;function Gme(){return Dz||(Dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const o=n[a],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(HA)),HA}var VA={},Oz;function Oq(){return Oz||(Oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(VA)),VA}var GA={},WA={},qA={},Lz;function Wme(){return Lz||(Lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(qA)),qA}var Iz;function xD(){return Iz||(Iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Wme();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(WA)),WA}var KA={},Fz;function qme(){return Fz||(Fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(KA)),KA}var Uz;function Kme(){return Uz||(Uz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xD(),n=qme();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(GA)),GA}var XA={},YA={},zz;function Xme(){return zz||(zz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(YA)),YA}var QA={},ZA={},JA={},eT={},Bz;function Lq(){return Bz||(Bz=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})(eT)),eT}var tT={},$z;function Iq(){return $z||($z=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})(tT)),tT}var nT={},Hz;function Fq(){return Hz||(Hz=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})(nT)),nT}var Vz;function Yme(){return Vz||(Vz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Lq(),n=Iq(),r=Fq();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):a(d,f,function p(x,v,b,y,M,S){const A=m(x,v,b,y,M,S);return A!==void 0?!!A:a(x,v,p,S)},new Map)}function a(d,f,m,p){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,m,p);case"function":return Object.keys(f).length>0?a(d,{...f},m,p):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,m,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,m,p);if(f instanceof Map)return l(d,f,m,p);if(f instanceof Set)return u(d,f,m,p);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let v=0;v<x.length;v++){const b=x[v];if(!n.isPrimitive(d)&&!(b in d)||f[b]===void 0&&d[b]!==void 0||f[b]===null&&d[b]!==null||!m(d[b],f[b],b,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,m,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,v]of f.entries()){const b=d.get(x);if(m(b,v,x,d,f,p)===!1)return!1}return!0}function c(d,f,m,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let v=0;v<f.length;v++){const b=f[v];let y=!1;for(let M=0;M<d.length;M++){if(x.has(M))continue;const S=d[M];let A=!1;if(m(S,b,v,d,f,p)&&(A=!0),A){x.add(M),y=!0;break}}if(!y)return!1}return!0}function u(d,f,m,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],m,p):!1}t.isMatchWith=i,t.isSetMatch=u})(JA)),JA}var Gz;function Uq(){return Gz||(Gz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Yme();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(ZA)),ZA}var rT={},iT={},aT={},Wz;function Qme(){return Wz||(Wz=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})(aT)),aT}var sT={},qz;function zq(){return qz||(qz=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})(sT)),sT}var oT={},Kz;function Bq(){return Kz||(Kz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",m="[object ArrayBuffer]",p="[object Object]",x="[object Error]",v="[object DataView]",b="[object Uint8Array]",y="[object Uint8ClampedArray]",M="[object Uint16Array]",S="[object Uint32Array]",A="[object BigUint64Array]",E="[object Int8Array]",k="[object Int16Array]",C="[object Int32Array]",R="[object BigInt64Array]",T="[object Float32Array]",P="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=R,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=v,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=T,t.float64ArrayTag=P,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=C,t.int8ArrayTag=E,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=M,t.uint32ArrayTag=S,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=y})(oT)),oT}var lT={},Xz;function Zme(){return Xz||(Xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(lT)),lT}var Yz;function $q(){return Yz||(Yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Qme(),n=zq(),r=Bq(),i=Iq(),a=Zme();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,m,p=new Map,x=void 0){const v=x?.(d,f,m,p);if(v!==void 0)return v;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const b=new Array(d.length);p.set(d,b);for(let y=0;y<d.length;y++)b[y]=l(d[y],y,m,p,x);return Object.hasOwn(d,"index")&&(b.index=d.index),Object.hasOwn(d,"input")&&(b.input=d.input),b}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const b=new RegExp(d.source,d.flags);return b.lastIndex=d.lastIndex,b}if(d instanceof Map){const b=new Map;p.set(d,b);for(const[y,M]of d)b.set(y,l(M,y,m,p,x));return b}if(d instanceof Set){const b=new Set;p.set(d,b);for(const y of d)b.add(l(y,void 0,m,p,x));return b}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const b=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,b);for(let y=0;y<d.length;y++)b[y]=l(d[y],y,m,p,x);return b}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const b=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,b),c(b,d,m,p,x),b}if(typeof File<"u"&&d instanceof File){const b=new File([d],d.name,{type:d.type});return p.set(d,b),c(b,d,m,p,x),b}if(typeof Blob<"u"&&d instanceof Blob){const b=new Blob([d],{type:d.type});return p.set(d,b),c(b,d,m,p,x),b}if(d instanceof Error){const b=new d.constructor;return p.set(d,b),b.message=d.message,b.name=d.name,b.stack=d.stack,b.cause=d.cause,c(b,d,m,p,x),b}if(d instanceof Boolean){const b=new Boolean(d.valueOf());return p.set(d,b),c(b,d,m,p,x),b}if(d instanceof Number){const b=new Number(d.valueOf());return p.set(d,b),c(b,d,m,p,x),b}if(d instanceof String){const b=new String(d.valueOf());return p.set(d,b),c(b,d,m,p,x),b}if(typeof d=="object"&&u(d)){const b=Object.create(Object.getPrototypeOf(d));return p.set(d,b),c(b,d,m,p,x),b}return d}function c(d,f,m=d,p,x){const v=[...Object.keys(f),...e.getSymbols(f)];for(let b=0;b<v.length;b++){const y=v[b],M=Object.getOwnPropertyDescriptor(d,y);(M==null||M.writable)&&(d[y]=l(f[y],y,m,p,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(iT)),iT}var Qz;function Jme(){return Qz||(Qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$q();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(rT)),rT}var Zz;function epe(){return Zz||(Zz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uq(),n=Jme();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(QA)),QA}var cT={},uT={},dT={},Jz;function tpe(){return Jz||(Jz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$q(),n=Bq();function r(i,a){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=a?.(o,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(dT)),dT}var eB;function npe(){return eB||(eB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tpe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(uT)),uT}var hT={},fT={},tB;function Hq(){return tB||(tB=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})(fT)),fT}var mT={},nB;function rpe(){return nB||(nB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zq();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(mT)),mT}var rB;function ipe(){return rB||(rB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kq(),n=Hq(),r=rpe(),i=fD();function a(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(hT)),hT}var iB;function ape(){return iB||(iB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uq(),n=hD(),r=npe(),i=mD(),a=ipe();function o(l,c){switch(typeof l){case"object":{Object.is(l?.valueOf(),-0)&&(l="-0");break}case"number":{l=n.toKey(l);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,l);return d===void 0?a.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(cT)),cT}var aB;function spe(){return aB||(aB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Oq(),n=Xme(),r=epe(),i=ape();function a(o){if(o==null)return e.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?i.matchesProperty(o[0],o[1]):r.matches(o);case"string":case"symbol":case"number":return n.property(o)}}t.iteratee=a})(XA)),XA}var sB;function ope(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Gme(),n=Oq(),r=Kme(),i=spe();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})($A)),$A}var pT,oB;function lpe(){return oB||(oB=1,pT=ope().uniqBy),pT}var cpe=lpe();const lB=ko(cpe);function Vq(t,e,n){return e===!0?lB(t,n):typeof e=="function"?lB(t,e):t}var gT={exports:{}},xT={};var cB;function upe(){if(cB)return xT;cB=1;var t=Ag(),e=nW();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return xT.useSyncExternalStoreWithSelector=function(u,d,f,m,p){var x=a(null);if(x.current===null){var v={hasValue:!1,value:null};x.current=v}else v=x.current;x=l(function(){function y(k){if(!M){if(M=!0,S=k,k=m(k),p!==void 0&&v.hasValue){var C=v.value;if(p(C,k))return A=C}return A=k}if(C=A,r(S,k))return C;var R=m(k);return p!==void 0&&p(C,R)?(S=k,C):(S=k,A=R)}var M=!1,S,A,E=f===void 0?null:f;return[function(){return y(d())},E===null?void 0:function(){return y(E())}]},[d,f,m,p]);var b=i(u,x[0],x[1]);return o(function(){v.hasValue=!0,v.value=b},[b]),c(b),b},xT}var uB;function dpe(){return uB||(uB=1,gT.exports=upe()),gT.exports}var Gq=dpe(),bD=w.createContext(null),hpe=t=>t,xr=()=>{var t=w.useContext(bD);return t?t.store.dispatch:hpe},O1=()=>{},fpe=()=>O1,mpe=(t,e)=>t===e;function Rt(t){var e=w.useContext(bD);return Gq.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:fpe,e?e.store.getState:O1,e?e.store.getState:O1,e?t:O1,mpe)}function ppe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function gpe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function xpe(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 dB=t=>Array.isArray(t)?t:[t];function bpe(t){const e=Array.isArray(t[0])?t[0]:t;return xpe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function ype(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var vpe=class{constructor(t){this.value=t}deref(){return this.value}},_pe=typeof WeakRef<"u"?WeakRef:vpe,wpe=0,hB=1;function Qv(){return{s:wpe,v:void 0,o:null,p:null}}function Wq(t,e={}){let n=Qv();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,m=c;f<m;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const v=x.get(p);v===void 0?(l=Qv(),x.set(p,l)):l=v}else{let x=l.p;x===null&&(l.p=x=new Map);const v=x.get(p);v===void 0?(l=Qv(),x.set(p,l)):l=v}}const u=l;let d;if(l.s===hB)d=l.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new _pe(d):d}return u.s=hB,u.v=d,d}return o.clearCache=()=>{n=Qv(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Spe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),ppe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:p=Wq,argsMemoizeOptions:x=[]}=d,v=dB(m),b=dB(x),y=bpe(i),M=f(function(){return a++,u.apply(null,arguments)},...v),S=p(function(){o++;const E=ype(y,arguments);return l=M.apply(null,E),l},...b);return Object.assign(S,{resultFunc:u,memoizedResultFunc:M,dependencies:y,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var Ze=Spe(Wq),Mpe=Object.assign((t,e=Ze)=>{gpe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>Mpe}),bT={},yT={},vT={},fB;function Npe(){return fB||(fB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?l-o:o-l}return 0};t.compareValues=n})(vT)),vT}var _T={},wT={},mB;function qq(){return mB||(mB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(wT)),wT}var pB;function Epe(){return pB||(pB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qq(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||o!=null&&Object.hasOwn(o,a)}t.isKey=i})(_T)),_T}var gB;function Ape(){return gB||(gB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Npe(),n=Epe(),r=fD();function i(a,o,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(p=>String(p));const u=(p,x)=>{let v=p;for(let b=0;b<x.length&&v!=null;++b)v=v[x[b]];return v},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,f=o.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let v=0;v<f.length;v++){const b=e.compareValues(p.criteria[v],x.criteria[v],l[v]);if(b!==0)return b}return 0}).map(p=>p.original)}t.orderBy=i})(yT)),yT}var ST={},xB;function Tpe(){return xB||(xB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(ST)),ST}var MT={},bB;function Kq(){return bB||(bB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hq(),n=xD(),r=Lq(),i=Fq();function a(o,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],o):!1}t.isIterateeCall=a})(MT)),MT}var yB;function Cpe(){return yB||(yB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ape(),n=Tpe(),r=Kq();function i(a,...o){const l=o.length;return l>1&&r.isIterateeCall(a,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(a,n.flatten(o),["asc"])}t.sortBy=i})(bT)),bT}var NT,vB;function kpe(){return vB||(vB=1,NT=Cpe().sortBy),NT}var jpe=kpe();const V2=ko(jpe);var Xq=t=>t.legend.settings,Ppe=t=>t.legend.size,Rpe=t=>t.legend.payload,Dpe=Ze([Rpe,Xq],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?V2(r,n):r});function Ope(){return Rt(Dpe)}var Zv=1;function Yq(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=w.useState({height:0,left:0,top:0,width:0}),r=w.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-e.height)>Zv||Math.abs(o.left-e.left)>Zv||Math.abs(o.top-e.top)>Zv||Math.abs(o.width-e.width)>Zv)&&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 ua(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 Lpe=typeof Symbol=="function"&&Symbol.observable||"@@observable",_B=Lpe,ET=()=>Math.random().toString(36).substring(7).split("").join("."),Ipe={INIT:`@@redux/INIT${ET()}`,REPLACE:`@@redux/REPLACE${ET()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ET()}`},ww=Ipe;function yD(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 Qq(t,e,n){if(typeof t!="function")throw new Error(ua(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ua(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ua(1));return n(Qq)(t,e)}let r=t,i=e,a=new Map,o=a,l=0,c=!1;function u(){o===a&&(o=new Map,a.forEach((b,y)=>{o.set(y,b)}))}function d(){if(c)throw new Error(ua(3));return i}function f(b){if(typeof b!="function")throw new Error(ua(4));if(c)throw new Error(ua(5));let y=!0;u();const M=l++;return o.set(M,b),function(){if(y){if(c)throw new Error(ua(6));y=!1,u(),o.delete(M),a=null}}}function m(b){if(!yD(b))throw new Error(ua(7));if(typeof b.type>"u")throw new Error(ua(8));if(typeof b.type!="string")throw new Error(ua(17));if(c)throw new Error(ua(9));try{c=!0,i=r(i,b)}finally{c=!1}return(a=o).forEach(M=>{M()}),b}function p(b){if(typeof b!="function")throw new Error(ua(10));r=b,m({type:ww.REPLACE})}function x(){const b=f;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(ua(11));function M(){const A=y;A.next&&A.next(d())}return M(),{unsubscribe:b(M)}},[_B](){return this}}}return m({type:ww.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[_B]:x}}function Fpe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:ww.INIT})>"u")throw new Error(ua(12));if(typeof n(void 0,{type:ww.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ua(13))})}function Zq(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const o=e[a];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{Fpe(n)}catch(a){i=a}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],m=n[f],p=o[f],x=m(p,l);if(typeof x>"u")throw l&&l.type,new Error(ua(14));u[f]=x,c=c||x!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function Sw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Upe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ua(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=Sw(...l)(i.dispatch),{...i,dispatch:a}}}function Jq(t){return yD(t)&&"type"in t&&typeof t.type=="string"}var eK=Symbol.for("immer-nothing"),wB=Symbol.for("immer-draftable"),Ga=Symbol.for("immer-state");function Vo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Ls=Object,ng=Ls.getPrototypeOf,Mw="constructor",G2="prototype",t3="configurable",Nw="enumerable",L1="writable",l0="value",nu=t=>!!t&&!!t[Ga];function rl(t){return t?tK(t)||W2(t)||!!t[wB]||!!t[Mw]?.[wB]||q2(t)||K2(t):!1}var zpe=Ls[G2][Mw].toString(),SB=new WeakMap;function tK(t){if(!t||!vD(t))return!1;const e=ng(t);if(e===null||e===Ls[G2])return!0;const n=Ls.hasOwnProperty.call(e,Mw)&&e[Mw];if(n===Object)return!0;if(!vp(n))return!1;let r=SB.get(n);return r===void 0&&(r=Function.toString.call(n),SB.set(n,r)),r===zpe}function ey(t,e,n=!0){ty(t)===0?(n?Reflect.ownKeys(t):Ls.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function ty(t){const e=t[Ga];return e?e.type_:W2(t)?1:q2(t)?2:K2(t)?3:0}var MB=(t,e,n=ty(t))=>n===2?t.has(e):Ls[G2].hasOwnProperty.call(t,e),n3=(t,e,n=ty(t))=>n===2?t.get(e):t[e],Ew=(t,e,n,r=ty(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Bpe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var W2=Array.isArray,q2=t=>t instanceof Map,K2=t=>t instanceof Set,vD=t=>typeof t=="object",vp=t=>typeof t=="function",AT=t=>typeof t=="boolean",Pc=t=>t.copy_||t.base_,_D=t=>t.modified_?t.copy_:t.base_;function r3(t,e){if(q2(t))return new Map(t);if(K2(t))return new Set(t);if(W2(t))return Array[G2].slice.call(t);const n=tK(t);if(e===!0||e==="class_only"&&!n){const r=Ls.getOwnPropertyDescriptors(t);delete r[Ga];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[L1]===!1&&(l[L1]=!0,l[t3]=!0),(l.get||l.set)&&(r[o]={[t3]:!0,[L1]:!0,[Nw]:l[Nw],[l0]:t[o]})}return Ls.create(ng(t),r)}else{const r=ng(t);if(r!==null&&n)return{...t};const i=Ls.create(r);return Ls.assign(i,t)}}function wD(t,e=!1){return X2(t)||nu(t)||!rl(t)||(ty(t)>1&&Ls.defineProperties(t,{set:Jv,add:Jv,clear:Jv,delete:Jv}),Ls.freeze(t),e&&ey(t,(n,r)=>{wD(r,!0)},!1)),t}function $pe(){Vo(2)}var Jv={[l0]:$pe};function X2(t){return t===null||!vD(t)?!0:Ls.isFrozen(t)}var Aw="MapSet",i3="Patches",nK={};function rg(t){const e=nK[t];return e||Vo(0,t),e}var Hpe=t=>!!nK[t],c0,rK=()=>c0,Vpe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Hpe(Aw)?rg(Aw):void 0});function NB(t,e){e&&(t.patchPlugin_=rg(i3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function a3(t){s3(t),t.drafts_.forEach(Gpe),t.drafts_=null}function s3(t){t===c0&&(c0=t.parent_)}var EB=t=>c0=Vpe(c0,t);function Gpe(t){const e=t[Ga];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function AB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ga].modified_&&(a3(e),Vo(4)),rl(t)&&(t=TB(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ga].base_,t,e)}else t=TB(e,n);return Wpe(e,t,!0),a3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==eK?t:void 0}function TB(t,e){if(X2(e))return e;const n=e[Ga];if(!n)return SD(e,t.handledSet_,t);if(!Y2(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);sK(n,t)}return n.copy_}function Wpe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&wD(e,n)}function iK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Y2=(t,e)=>t.scope_===e,qpe=[];function aK(t,e,n,r){const i=Pc(t),a=t.type_;if(r!==void 0&&n3(i,r,a)===e){Ew(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;ey(i,(c,u)=>{if(nu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??qpe;for(const l of o)Ew(i,l,n,a)}function Kpe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!Y2(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=_D(a);aK(t,a.draft_??a,o,n),sK(a,i)})}function sK(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)}iK(t)}}function Xpe(t,e,n){const{scope_:r}=t;if(nu(n)){const i=n[Ga];Y2(i,r)&&i.callbacks_.push(function(){I1(t);const o=_D(i);aK(t,n,o,e)})}else rl(n)&&t.callbacks_.push(function(){const a=Pc(t);n3(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&SD(n3(t.copy_,e,t.type_),r.handledSet_,r)})}function SD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||nu(t)||e.has(t)||!rl(t)||X2(t)||(e.add(t),ey(t,(r,i)=>{if(nu(i)){const a=i[Ga];if(Y2(a,n)){const o=_D(a);Ew(t,r,o,t.type_),iK(a)}}else rl(i)&&SD(i,e,n)})),t}function Ype(t,e){const n=W2(t),r={type_:n?1:0,scope_:e?e.scope_:rK(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=MD;n&&(i=[r],a=u0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var MD={get(t,e){if(e===Ga)return t;const n=Pc(t);if(!MB(n,e,t.type_))return Qpe(t,n,e);const r=n[e];if(t.finalized_||!rl(r))return r;if(r===TT(t.base_,e)){I1(t);const i=t.type_===1?+e:e,a=l3(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in Pc(t)},ownKeys(t){return Reflect.ownKeys(Pc(t))},set(t,e,n){const r=oK(Pc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=TT(Pc(t),e),a=i?.[Ga];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Bpe(n,i)&&(n!==void 0||MB(t.base_,e,t.type_)))return!0;I1(t),o3(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),Xpe(t,e,n)),!0},deleteProperty(t,e){return I1(t),TT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),o3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Pc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[L1]:!0,[t3]:t.type_!==1||e!=="length",[Nw]:r[Nw],[l0]:n[e]}},defineProperty(){Vo(11)},getPrototypeOf(t){return ng(t.base_)},setPrototypeOf(){Vo(12)}},u0={};ey(MD,(t,e)=>{u0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});u0.deleteProperty=function(t,e){return u0.set.call(this,t,e,void 0)};u0.set=function(t,e,n){return MD.set.call(this,t[0],e,n,t[0])};function TT(t,e){const n=t[Ga];return(n?Pc(n):t)[e]}function Qpe(t,e,n){const r=oK(e,n);return r?l0 in r?r[l0]:r.get?.call(t.draft_):void 0}function oK(t,e){if(!(e in t))return;let n=ng(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=ng(n)}}function o3(t){t.modified_||(t.modified_=!0,t.parent_&&o3(t.parent_))}function I1(t){t.copy_||(t.assigned_=new Map,t.copy_=r3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Zpe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(vp(n)&&!vp(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}vp(r)||Vo(6),i!==void 0&&!vp(i)&&Vo(7);let a;if(rl(n)){const o=EB(this),l=l3(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?a3(o):s3(o)}return NB(o,i),AB(a,o)}else if(!n||!vD(n)){if(a=r(n),a===void 0&&(a=n),a===eK&&(a=void 0),this.autoFreeze_&&wD(a,!0),i){const o=[],l=[];rg(i3).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Vo(1,n)},this.produceWithPatches=(n,r)=>{if(vp(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,a;return[this.produce(n,r,(l,c)=>{i=l,a=c}),i,a]},AT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),AT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),AT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){rl(e)||Vo(8),nu(e)&&(e=Zo(e));const n=EB(this),r=l3(n,e,void 0);return r[Ga].isManual_=!0,s3(n),r}finishDraft(e,n){const r=e&&e[Ga];(!r||!r.isManual_)&&Vo(9);const{scope_:i}=r;return NB(i,n),AB(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=rg(i3).applyPatches_;return nu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function l3(t,e,n,r){const[i,a]=q2(e)?rg(Aw).proxyMap_(e,n):K2(e)?rg(Aw).proxySet_(e,n):Ype(e,n);return(n?.scope_??rK()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Kpe(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function Zo(t){return nu(t)||Vo(10,t),lK(t)}function lK(t){if(!rl(t)||X2(t))return t;const e=t[Ga];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=r3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=r3(t,!0);return ey(n,(i,a)=>{Ew(n,i,lK(a))},r),e&&(e.finalized_=!1),n}var Jpe=new Zpe,cK=Jpe.produce;function uK(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var ege=uK(),tge=uK,nge=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Sw:Sw.apply(null,arguments)};function To(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Us(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=>Jq(r)&&r.type===t,n}var dK=class xb extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,xb.prototype)}static get[Symbol.species](){return xb}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new xb(...e[0].concat(this)):new xb(...e.concat(this))}};function CB(t){return rl(t)?cK(t,()=>{}):t}function e_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function rge(t){return typeof t=="boolean"}var ige=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new dK;return n&&(rge(n)?o.push(ege):o.push(tge(n.extraArgument))),o},hK="RTK_autoBatch",kr=()=>t=>({payload:t,meta:{[hK]:!0}}),kB=t=>e=>{setTimeout(e,t)},fK=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:kB(10):t.type==="callback"?t.queueNotification:kB(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),m=r.subscribe(f);return l.add(d),()=>{m(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[hK],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},age=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new dK(t);return r&&i.push(fK(typeof r=="object"?r:void 0)),i};function sge(t){const e=ige(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(yD(n))l=Zq(n);else throw new Error(Us(1));let c;typeof r=="function"?c=r(e):c=e();let u=Sw;i&&(u=nge({trace:!1,...typeof i=="object"&&i}));const d=Upe(...c),f=age(d);let m=typeof o=="function"?o(f):f();const p=u(...m);return Qq(l,a,p)}function mK(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(Us(28));if(l in e)throw new Error(Us(29));return e[l]=o,i},addAsyncThunk(a,o){return o.pending&&(e[a.pending.type]=o.pending),o.rejected&&(e[a.rejected.type]=o.rejected),o.fulfilled&&(e[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function oge(t){return typeof t=="function"}function lge(t,e){let[n,r,i]=mK(e),a;if(oge(t))a=()=>CB(t());else{const l=CB(t);a=()=>l}function o(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(nu(d)){const p=f(d,c);return p===void 0?d:p}else{if(rl(d))return cK(d,m=>f(m,c));{const m=f(d,c);if(m===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return d},l)}return o.getInitialState=a,o}var cge="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",uge=(t=21)=>{let e="",n=t;for(;n--;)e+=cge[Math.random()*64|0];return e},dge=Symbol.for("rtk-slice-createasyncthunk");function hge(t,e){return`${t}/${e}`}function fge({creators:t}={}){const e=t?.asyncThunk?.[dge];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Us(11));const o=(typeof r.reducers=="function"?r.reducers(pge()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,A){const E=typeof S=="string"?S:S.type;if(!E)throw new Error(Us(12));if(E in c.sliceCaseReducersByType)throw new Error(Us(13));return c.sliceCaseReducersByType[E]=A,u},addMatcher(S,A){return c.sliceMatchers.push({matcher:S,reducer:A}),u},exposeAction(S,A){return c.actionCreators[S]=A,u},exposeCaseReducer(S,A){return c.sliceCaseReducersByName[S]=A,u}};l.forEach(S=>{const A=o[S],E={reducerName:S,type:hge(i,S),createNotation:typeof r.reducers=="function"};xge(A)?yge(E,A,u,e):gge(E,A,u)});function d(){const[S={},A=[],E=void 0]=typeof r.extraReducers=="function"?mK(r.extraReducers):[r.extraReducers],k={...S,...c.sliceCaseReducersByType};return lge(r.initialState,C=>{for(let R in k)C.addCase(R,k[R]);for(let R of c.sliceMatchers)C.addMatcher(R.matcher,R.reducer);for(let R of A)C.addMatcher(R.matcher,R.reducer);E&&C.addDefaultCase(E)})}const f=S=>S,m=new Map,p=new WeakMap;let x;function v(S,A){return x||(x=d()),x(S,A)}function b(){return x||(x=d()),x.getInitialState()}function y(S,A=!1){function E(C){let R=C[S];return typeof R>"u"&&A&&(R=e_(p,E,b)),R}function k(C=f){const R=e_(m,A,()=>new WeakMap);return e_(R,C,()=>{const T={};for(const[P,F]of Object.entries(r.selectors??{}))T[P]=mge(F,C,()=>e_(p,C,b),A);return T})}return{reducerPath:S,getSelectors:k,get selectors(){return k(E)},selectSlice:E}}const M={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:b,...y(a),injectInto(S,{reducerPath:A,...E}={}){const k=A??a;return S.inject({reducerPath:k,reducer:v},E),{...M,...y(k,!0)}}};return M}}function mge(t,e,n,r){function i(a,...o){let l=e(a);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var xs=fge();function pge(){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 gge({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!bge(r))throw new Error(Us(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?To(t,o):To(t))}function xge(t){return t._reducerDefinitionType==="asyncThunk"}function bge(t){return t._reducerDefinitionType==="reducerWithPrepare"}function yge({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Us(18));const{payloadCreator:a,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),o&&r.addCase(f.fulfilled,o),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:o||t_,pending:l||t_,rejected:c||t_,settled:u||t_})}function t_(){}var vge="task",pK="listener",gK="completed",ND="cancelled",_ge=`task-${ND}`,wge=`task-${gK}`,c3=`${pK}-${ND}`,Sge=`${pK}-${gK}`,Q2=class{constructor(t){this.code=t,this.message=`${vge} ${ND} (reason: ${t})`}name="TaskAbortError";message},ED=(t,e)=>{if(typeof t!="function")throw new TypeError(Us(32))},Tw=()=>{},xK=(t,e=Tw)=>(t.catch(e),t),bK=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),nf=(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))},rf=t=>{if(t.aborted){const{reason:e}=t;throw new Q2(e)}};function yK(t,e){let n=Tw;return new Promise((r,i)=>{const a=()=>i(new Q2(t.reason));if(t.aborted){a();return}n=bK(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=Tw})}var Mge=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof Q2?"cancelled":"rejected",error:n}}finally{e?.()}},Cw=t=>e=>xK(yK(t,e).then(n=>(rf(t),n))),vK=t=>{const e=Cw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Lp}=Object,jB={},Z2="listenerMiddleware",Nge=(t,e)=>{const n=r=>bK(t,()=>nf(r,t.reason));return(r,i)=>{ED(r);const a=new AbortController;n(a);const o=Mge(async()=>{rf(t),rf(a.signal);const l=await r({pause:Cw(a.signal),delay:vK(a.signal),signal:a.signal});return rf(a.signal),l},()=>nf(a,wge));return i?.autoJoin&&e.push(o.catch(Tw)),{result:Cw(t)(o),cancel(){nf(a,_ge)}}}},Ege=(t,e)=>{const n=async(r,i)=>{rf(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,m)=>{m.unsubscribe(),c([f,m.getState(),m.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await yK(e,Promise.race(l));return rf(e),c}finally{a()}};return(r,i)=>xK(n(r,i))},_K=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=To(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Us(21));return ED(a),{predicate:i,type:e,effect:a}},wK=Lp(t=>{const{type:e,predicate:n,effect:r}=_K(t);return{id:uge(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Us(22))}}},{withTypes:()=>wK}),PB=(t,e)=>{const{type:n,effect:r,predicate:i}=_K(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},u3=t=>{t.pending.forEach(e=>{nf(e,c3)})},Age=(t,e)=>()=>{for(const n of e.keys())u3(n);t.clear()},RB=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},SK=Lp(To(`${Z2}/add`),{withTypes:()=>SK}),Tge=To(`${Z2}/removeAll`),MK=Lp(To(`${Z2}/remove`),{withTypes:()=>MK}),Cge=(...t)=>{console.error(`${Z2}/error`,...t)},ny=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:a,onError:o=Cge}=t;ED(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&u3(p)}),c=p=>{const x=PB(e,p)??wK(p);return l(x)};Lp(c,{withTypes:()=>c});const u=p=>{const x=PB(e,p);return x&&(x.unsubscribe(),p.cancelActive&&u3(x)),!!x};Lp(u,{withTypes:()=>u});const d=async(p,x,v,b)=>{const y=new AbortController,M=Ege(c,y.signal),S=[];try{p.pending.add(y),r(p),await Promise.resolve(p.effect(x,Lp({},v,{getOriginalState:b,condition:(A,E)=>M(A,E).then(Boolean),take:M,delay:vK(y.signal),pause:Cw(y.signal),extra:a,signal:y.signal,fork:Nge(y.signal,S),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((A,E,k)=>{A!==y&&(nf(A,c3),k.delete(A))})},cancel:()=>{nf(y,c3),p.pending.delete(y)},throwIfCancelled:()=>{rf(y.signal)}})))}catch(A){A instanceof Q2||RB(o,A,{raisedBy:"effect"})}finally{await Promise.all(S),nf(y,Sge),i(p),p.pending.delete(y)}},f=Age(e,n);return{middleware:p=>x=>v=>{if(!Jq(v))return x(v);if(SK.match(v))return c(v.payload);if(Tge.match(v)){f();return}if(MK.match(v))return u(v.payload);let b=p.getState();const y=()=>{if(b===jB)throw new Error(Us(23));return b};let M;try{if(M=x(v),e.size>0){const S=p.getState(),A=Array.from(e.values());for(const E of A){let k=!1;try{k=E.predicate(v,S,b)}catch(C){k=!1,RB(o,C,{raisedBy:"predicate"})}k&&d(E,v,p,y)}}}finally{b=jB}return M},startListening:c,stopListening:u,clearListeners:f}};function Us(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 kge={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},NK=xs({name:"chartLayout",initialState:kge,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:jge,setLayout:Pge,setChartSize:Rge,setScale:Dge}=NK.actions,Oge=NK.reducer;function EK(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function DB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ap(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DB(Object(n),!0).forEach(function(r){Lge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lge(t,e,n){return(e=Ige(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ige(t){var e=Fge(t,"string");return typeof e=="symbol"?e:e+""}function Fge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function er(t,e,n){return Ar(t)||Ar(e)?n:Ao(e)?Nf(t,e,n):typeof e=="function"?e(t):n}var Uge=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&a!=="center"&&Lt(t[a]))return Ap(Ap({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&Lt(t[o]))return Ap(Ap({},t),{},{[o]:t[o]+(i||0)})}return t},Wl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",AK=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,a,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(a=!0),l.coordinate));return i||o.push(e),a||o.push(n),o},TK=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:m,axisType:p}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,v=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(v=p==="angleAxis"&&a&&a.length>=2?Xi(a[0]-a[1])*2*v:v,f||m){var b=(f||m||[]).map((y,M)=>{var S=r?r.indexOf(y):y;return{coordinate:o(S)+v,value:y,offset:v,index:M}});return b.filter(y=>!gs(y.coordinate))}return c&&u?u.map((y,M)=>({coordinate:o(y)+v,value:y,index:M,offset:v})):o.ticks&&d!=null?o.ticks(d).map((y,M)=>({coordinate:o(y)+v,value:y,offset:v,index:M})):o.domain().map((y,M)=>({coordinate:o(y)+v,value:r?r[y]:y,index:M,offset:v}))},OB=1e-4,zge=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-OB,a=Math.max(r[0],r[1])+OB,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},Bge=(t,e)=>{if(!e||e.length!==2||!Lt(e[0])||!Lt(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(!Lt(t[0])||t[0]<n)&&(i[0]=n),(!Lt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},$ge=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,o=0;o<e;++o){var l=gs(t[o][n][1])?t[o][n][0]:t[o][n][1];l>=0?(t[o][n][0]=i,t[o][n][1]=i+l,i=t[o][n][1]):(t[o][n][0]=a,t[o][n][1]=a+l,a=t[o][n][1])}},Hge=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var o=gs(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},Vge={sign:$ge,expand:fme,none:tg,silhouette:mme,wiggle:pme,positive:Hge},Gge=(t,e,n)=>{var r=Vge[n],i=hme().keys(e).value((a,o)=>Number(er(a,o,0))).order(Jj).offset(r);return i(t)};function CK(t){return t==null?void 0:String(t)}function kw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Ar(i[e.dataKey])){var l=Pq(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=er(i,Ar(o)?e.dataKey:o);return Ar(c)?null:e.scale(c)}var LB=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=er(a,e.dataKey,e.scale.domain()[o]);return Ar(l)?null:e.scale(l)-i/2+r},Wge=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]},qge=t=>{var e=t.flat(2).filter(Lt);return[Math.min(...e),Math.max(...e)]},Kge=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Xge=(t,e,n)=>{if(t!=null)return Kge(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=EK(u,e,n),f=qge(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},IB=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,FB=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Ld=(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=V2(e,d=>d.coordinate),a=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function UB(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Ap(Ap({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Yd(t,e){if(t)return String(t);if(typeof e=="string")return e}var Yge=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Qge=(t,e)=>e==="centric"?t.angle:t.radius,du=t=>t.layout.width,hu=t=>t.layout.height,Zge=t=>t.layout.scale,kK=t=>t.layout.margin,J2=Ze(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),eM=Ze(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),jK="data-recharts-item-index",PK="data-recharts-item-data-key",ry=60;function zB(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 n_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zB(Object(n),!0).forEach(function(r){Jge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jge(t,e,n){return(e=exe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function exe(t){var e=txe(t,"string");return typeof e=="symbol"?e:e+""}function txe(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 nxe=t=>t.brush.height;function rxe(t){var e=eM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:ry;return n+i}return n},0)}function ixe(t){var e=eM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:ry;return n+i}return n},0)}function axe(t){var e=J2(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function sxe(t){var e=J2(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var ji=Ze([du,hu,kK,nxe,rxe,ixe,axe,sxe,Xq,Ppe],(t,e,n,r,i,a,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},m=n_(n_({},f),d),p=m.bottom;m.bottom+=r,m=Uge(m,c,u);var x=t-m.left-m.right,v=e-m.top-m.bottom;return n_(n_({brushBottom:p},m),{},{width:Math.max(x,0),height:Math.max(v,0)})}),oxe=Ze(ji,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),AD=Ze(du,hu,(t,e)=>({x:0,y:0,width:t,height:e})),lxe=w.createContext(null),Pi=()=>w.useContext(lxe)!=null,tM=t=>t.brush,nM=Ze([tM,ji,kK],(t,e,n)=>({height:t.height,x:Lt(t.x)?t.x:e.left,y:Lt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Lt(t.width)?t.width:e.width})),CT={},kT={},jT={},BB;function cxe(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),v()};let m=null;const p=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},r)},x=()=>{m!==null&&(clearTimeout(m),m=null)},v=()=>{x(),o=void 0,l=null},b=()=>{d()},y=function(...M){if(i?.aborted)return;o=this,l=M;const S=m==null;p(),c&&S&&d()};return y.schedule=p,y.cancel=v,y.flush=b,i?.addEventListener("abort",v,{once:!0}),y}t.debounce=e})(jT)),jT}var $B;function uxe(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cxe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const m=e.debounce(function(...v){d=r.apply(this,v),f=null},i,{edges:u}),p=function(...v){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,v),f=Date.now(),m.cancel(),m.schedule(),d):(m.apply(this,v),d)},x=()=>(m.flush(),d);return p.cancel=m.cancel,p.flush=x,p}t.debounce=n})(kT)),kT}var HB;function dxe(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uxe();function n(r,i=0,a={}){const{leading:o=!0,trailing:l=!0}=a;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(CT)),CT}var PT,VB;function hxe(){return VB||(VB=1,PT=dxe().throttle),PT}var fxe=hxe();const mxe=ko(fxe);var jw=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},RK=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=tu(r)?t:Number(r),c=tu(i)?e:Number(i);return a&&a>0&&(l?c=l/a:c&&(l=c*a),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},pxe={width:0,height:0,overflow:"visible"},gxe={width:0,overflowX:"visible"},xxe={height:0,overflowY:"visible"},bxe={},yxe=t=>{var{width:e,height:n}=t,r=tu(e),i=tu(n);return r&&i?pxe:r?gxe:i?xxe:bxe};function vxe(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function tr(t){return Number.isFinite(t)}function Ll(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function d3(){return d3=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},d3.apply(null,arguments)}function GB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function WB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GB(Object(n),!0).forEach(function(r){_xe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _xe(t,e,n){return(e=wxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wxe(t){var e=Sxe(t,"string");return typeof e=="symbol"?e:e+""}function Sxe(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 DK=w.createContext({width:-1,height:-1});function Mxe(t){return Ll(t.width)&&Ll(t.height)}function OK(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return Mxe(i)?w.createElement(DK.Provider,{value:i},e):null}var TD=()=>w.useContext(DK),Nxe=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:m,onResize:p,style:x={}}=t,v=w.useRef(null),b=w.useRef();b.current=p,w.useImperativeHandle(e,()=>v.current);var[y,M]=w.useState({containerWidth:r.width,containerHeight:r.height}),S=w.useCallback((R,T)=>{M(P=>{var F=Math.round(R),I=Math.round(T);return P.containerWidth===F&&P.containerHeight===I?P:{containerWidth:F,containerHeight:I}})},[]);w.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return Z0;var R=I=>{var X,{width:D,height:K}=I[0].contentRect;S(D,K),(X=b.current)===null||X===void 0||X.call(b,D,K)};d>0&&(R=mxe(R,d,{trailing:!0,leading:!1}));var T=new ResizeObserver(R),{width:P,height:F}=v.current.getBoundingClientRect();return S(P,F),T.observe(v.current),()=>{T.disconnect()}},[S,d]);var{containerWidth:A,containerHeight:E}=y;jw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:C}=RK(A,E,{width:i,height:a,aspect:n,maxHeight:c});return jw(k!=null&&k>0||C!=null&&C>0,`The width(%s) and height(%s) of chart should be greater than 0,
  14. please check the style of container, or the props width(%s) and height(%s),
  15. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  16. height and width.`,k,C,i,a,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:Dn("recharts-responsive-container",m),style:WB(WB({},x),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:v},w.createElement("div",{style:yxe({width:i,height:a})},w.createElement(OK,{width:k,height:C},u)))}),F1=w.forwardRef((t,e)=>{var n=TD();if(Ll(n.width)&&Ll(n.height))return t.children;var{width:r,height:i}=vxe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=RK(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Lt(a)&&Lt(o)?w.createElement(OK,{width:a,height:o},t.children):w.createElement(Nxe,d3({},t,{width:r,height:i,ref:e}))});function LK(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 iy=()=>{var t,e=Pi(),n=Rt(oxe),r=Rt(nM),i=(t=Rt(tM))===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}},Exe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},IK=()=>{var t;return(t=Rt(ji))!==null&&t!==void 0?t:Exe},CD=()=>Rt(du),kD=()=>Rt(hu),Axe=()=>Rt(t=>t.layout.margin),An=t=>t.layout.layoutType,Gf=()=>Rt(An),Txe=()=>{var t=Gf();if(t==="horizontal"||t==="vertical")return t},Cxe=()=>{var t=Gf();return t!==void 0},rM=t=>{var e=xr(),n=Pi(),{width:r,height:i}=t,a=TD(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),w.useEffect(()=>{!n&&Ll(o)&&Ll(l)&&e(Rge({width:o,height:l}))},[e,n,o,l]),null},FK=Symbol.for("immer-nothing"),qB=Symbol.for("immer-draftable"),qs=Symbol.for("immer-state");function Go(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var d0=Object.getPrototypeOf;function ig(t){return!!t&&!!t[qs]}function Ef(t){return t?UK(t)||Array.isArray(t)||!!t[qB]||!!t.constructor?.[qB]||ay(t)||aM(t):!1}var kxe=Object.prototype.constructor.toString(),KB=new WeakMap;function UK(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=KB.get(n);return r===void 0&&(r=Function.toString.call(n),KB.set(n,r)),r===kxe}function Pw(t,e,n=!0){iM(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 iM(t){const e=t[qs];return e?e.type_:Array.isArray(t)?1:ay(t)?2:aM(t)?3:0}function h3(t,e){return iM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function zK(t,e,n){const r=iM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function jxe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function ay(t){return t instanceof Map}function aM(t){return t instanceof Set}function Rh(t){return t.copy_||t.base_}function f3(t,e){if(ay(t))return new Map(t);if(aM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=UK(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[qs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(d0(t),r)}else{const r=d0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function jD(t,e=!1){return sM(t)||ig(t)||!Ef(t)||(iM(t)>1&&Object.defineProperties(t,{set:r_,add:r_,clear:r_,delete:r_}),Object.freeze(t),e&&Object.values(t).forEach(n=>jD(n,!0))),t}function Pxe(){Go(2)}var r_={value:Pxe};function sM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var Rxe={};function Af(t){const e=Rxe[t];return e||Go(0,t),e}var h0;function BK(){return h0}function Dxe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function XB(t,e){e&&(Af("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function m3(t){p3(t),t.drafts_.forEach(Oxe),t.drafts_=null}function p3(t){t===h0&&(h0=t.parent_)}function YB(t){return h0=Dxe(h0,t)}function Oxe(t){const e=t[qs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function QB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[qs].modified_&&(m3(e),Go(4)),Ef(t)&&(t=Rw(e,t),e.parent_||Dw(e,t)),e.patches_&&Af("Patches").generateReplacementPatches_(n[qs].base_,t,e.patches_,e.inversePatches_)):t=Rw(e,n,[]),m3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==FK?t:void 0}function Rw(t,e,n){if(sM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[qs];if(!i)return Pw(e,(a,o)=>ZB(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return Dw(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let o=a,l=!1;i.type_===3&&(o=new Set(a),a.clear(),l=!0),Pw(o,(c,u)=>ZB(t,i,a,c,u,n,l),r),Dw(t,a,!1),n&&t.patches_&&Af("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function ZB(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=sM(i);if(!(l&&!o)){if(ig(i)){const c=a&&e&&e.type_!==3&&!h3(e.assigned_,r)?a.concat(r):void 0,u=Rw(t,i,c);if(zK(n,r,u),ig(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Ef(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;Rw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(ay(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Dw(t,i)}}}function Dw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&jD(e,n)}function Lxe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:BK(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=PD;n&&(i=[r],a=f0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var PD={get(t,e){if(e===qs)return t;const n=Rh(t);if(!h3(n,e))return Ixe(t,n,e);const r=n[e];return t.finalized_||!Ef(r)?r:r===RT(t.base_,e)?(DT(t),t.copy_[e]=x3(r,t)):r},has(t,e){return e in Rh(t)},ownKeys(t){return Reflect.ownKeys(Rh(t))},set(t,e,n){const r=$K(Rh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=RT(Rh(t),e),a=i?.[qs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(jxe(n,i)&&(n!==void 0||h3(t.base_,e)))return!0;DT(t),g3(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 RT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,DT(t),g3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Rh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Go(11)},getPrototypeOf(t){return d0(t.base_)},setPrototypeOf(){Go(12)}},f0={};Pw(PD,(t,e)=>{f0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});f0.deleteProperty=function(t,e){return f0.set.call(this,t,e,void 0)};f0.set=function(t,e,n){return PD.set.call(this,t[0],e,n,t[0])};function RT(t,e){const n=t[qs];return(n?Rh(n):t)[e]}function Ixe(t,e,n){const r=$K(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function $K(t,e){if(!(e in t))return;let n=d0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=d0(n)}}function g3(t){t.modified_||(t.modified_=!0,t.parent_&&g3(t.parent_))}function DT(t){t.copy_||(t.copy_=f3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Fxe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const o=this;return function(c=a,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Go(6),r!==void 0&&typeof r!="function"&&Go(7);let i;if(Ef(e)){const a=YB(this),o=x3(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?m3(a):p3(a)}return XB(a,r),QB(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===FK&&(i=void 0),this.autoFreeze_&&jD(i,!0),r){const a=[],o=[];Af("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Go(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){Ef(t)||Go(8),ig(t)&&(t=Uxe(t));const e=YB(this),n=x3(t,void 0);return n[qs].isManual_=!0,p3(e),n}finishDraft(t,e){const n=t&&t[qs];(!n||!n.isManual_)&&Go(9);const{scope_:r}=n;return XB(r,e),QB(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=Af("Patches").applyPatches_;return ig(t)?r(t,e):this.produce(t,i=>r(i,e))}};function x3(t,e){const n=ay(t)?Af("MapSet").proxyMap_(t,e):aM(t)?Af("MapSet").proxySet_(t,e):Lxe(t,e);return(e?e.scope_:BK()).drafts_.push(n),n}function Uxe(t){return ig(t)||Go(10,t),HK(t)}function HK(t){if(!Ef(t)||sM(t))return t;const e=t[qs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=f3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=f3(t,!0);return Pw(n,(i,a)=>{zK(n,i,HK(a))},r),e&&(e.finalized_=!1),n}var zxe=new Fxe;zxe.produce;var Bxe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},VK=xs({name:"legend",initialState:Bxe,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:kr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Zo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:kr()},removeLegendPayload:{reducer(t,e){var n=Zo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:kr()}}}),{setLegendSize:JB,setLegendSettings:$xe,addLegendPayload:GK,replaceLegendPayload:WK,removeLegendPayload:qK}=VK.actions,Hxe=VK.reducer,Vxe=["contextPayload"];function b3(){return b3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b3.apply(null,arguments)}function e8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ag(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e8(Object(n),!0).forEach(function(r){Gxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gxe(t,e,n){return(e=Wxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wxe(t){var e=qxe(t,"string");return typeof e=="symbol"?e:e+""}function qxe(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 Kxe(t,e){if(t==null)return{};var n,r,i=Xxe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Xxe(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 Yxe(t){return t.value}function Qxe(t){var{contextPayload:e}=t,n=Kxe(t,Vxe),r=Vq(e,t.payloadUniqBy,Yxe),i=ag(ag({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(Vme,i)}function Zxe(t,e,n,r,i,a){var{layout:o,align:l,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&o==="vertical"?u={left:((r||0)-a.width)/2}:u=l==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),ag(ag({},u),d)}function Jxe(t){var e=xr();return w.useEffect(()=>{e($xe(t))},[e,t]),null}function ebe(t){var e=xr();return w.useEffect(()=>(e(JB(t)),()=>{e(JB({width:0,height:0}))}),[e,t]),null}function tbe(t,e,n,r){return t==="vertical"&&Lt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var nbe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function RD(t){var e=Ur(t,nbe),n=Ope(),r=Lfe(),i=Axe(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=Yq([n]),f=CD(),m=kD();if(f==null||m==null)return null;var p=f-(i?.left||0)-(i?.right||0),x=tbe(e.layout,o,a,p),v=c?l:ag(ag({position:"absolute",width:x?.width||a||"auto",height:x?.height||o||"auto"},Zxe(l,e,i,f,m,u)),l),b=c??r;if(b==null||n==null)return null;var y=w.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},w.createElement(Jxe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(ebe,{width:u.width,height:u.height}),w.createElement(Qxe,b3({},e,x,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Ic.createPortal(y,b)}RD.displayName="Legend";function y3(){return y3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y3.apply(null,arguments)}function t8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function OT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t8(Object(n),!0).forEach(function(r){rbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t8(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 sbe(t){return Array.isArray(t)&&Ao(t[0])&&Ao(t[1])?t.join(" ~ "):t}var obe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:m=!1}=t,p=()=>{if(a&&a.length){var E={padding:0,margin:0},k=(l?V2(a,l):a).map((C,R)=>{if(C.type==="none")return null;var T=C.formatter||o||sbe,{value:P,name:F}=C,I=P,X=F;if(T){var D=T(P,F,C,R,a);if(Array.isArray(D))[I,X]=D;else if(D!=null)I=D;else return null}var K=OT({display:"block",paddingTop:4,paddingBottom:4,color:C.color||"#000"},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(R),style:K},Ao(X)?w.createElement("span",{className:"recharts-tooltip-item-name"},X):null,Ao(X)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},I),w.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:E},k)}return null},x=OT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),v=OT({margin:0},i),b=!Ar(d),y=b?d:"",M=Dn("recharts-default-tooltip",c),S=Dn("recharts-tooltip-label",u);b&&f&&a!==void 0&&a!==null&&(y=f(d,a));var A=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",y3({className:M,style:x},A),w.createElement("p",{className:S,style:v},w.isValidElement(y)?y:"".concat(y)),p())},Vx="recharts-tooltip-wrapper",lbe={visibility:"hidden"};function cbe(t){var{coordinate:e,translateX:n,translateY:r}=t;return Dn(Vx,{["".concat(Vx,"-right")]:Lt(n)&&e&&Lt(e.x)&&n>=e.x,["".concat(Vx,"-left")]:Lt(n)&&e&&Lt(e.x)&&n<e.x,["".concat(Vx,"-bottom")]:Lt(r)&&e&&Lt(e.y)&&r>=e.y,["".concat(Vx,"-top")]:Lt(r)&&e&&Lt(e.y)&&r<e.y})}function n8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Lt(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var m=c[r];if(m==null)return 0;if(o[r]){var p=d,x=m;return p<x?Math.max(f,m):Math.max(d,m)}if(u==null)return 0;var v=f+l,b=m+u;return v>b?Math.max(d,m):Math.max(f,m)}function ube(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 dbe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=n8({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=n8({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=ube({translateX:d,translateY:f,useTranslate3d:l})):u=lbe,{cssProperties:u,cssClasses:cbe({translateX:d,translateY:f,coordinate:n})}}function r8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function i_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r8(Object(n),!0).forEach(function(r){v3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function v3(t,e,n){return(e=hbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hbe(t){var e=fbe(t,"string");return typeof e=="symbol"?e:e+""}function fbe(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 mbe extends w.PureComponent{constructor(){super(...arguments),v3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),v3(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:m,viewBox:p,wrapperStyle:x,lastBoundingBox:v,innerRef:b,hasPortalFromProps:y}=this.props,{cssClasses:M,cssProperties:S}=dbe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:m,viewBox:p}),A=y?{}:i_(i_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),E=i_(i_({},A),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:E,ref:b},a)}}var KK=()=>{var t;return(t=Rt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function _3(){return _3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_3.apply(null,arguments)}function i8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function a8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i8(Object(n),!0).forEach(function(r){pbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pbe(t,e,n){return(e=gbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gbe(t){var e=xbe(t,"string");return typeof e=="symbol"?e:e+""}function xbe(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 s8={curveBasisClosed:tme,curveBasisOpen:nme,curveBasis:eme,curveBumpX:zfe,curveBumpY:Bfe,curveLinearClosed:rme,curveLinear:$2,curveMonotoneX:ime,curveMonotoneY:ame,curveNatural:sme,curveStep:ome,curveStepAfter:cme,curveStepBefore:lme},Ow=t=>tr(t.x)&&tr(t.y),o8=t=>t.base!=null&&Ow(t.base)&&Ow(t),Gx=t=>t.x,Wx=t=>t.y,bbe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Q0(t));return(n==="curveMonotone"||n==="curveBump")&&e?s8["".concat(n).concat(e==="vertical"?"Y":"X")]:s8[n]||$2},ybe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=bbe(e,i),l=a?n.filter(Ow):n,c;if(Array.isArray(r)){var u=n.map((p,x)=>a8(a8({},p),{},{base:r[x]}));i==="vertical"?c=Yv().y(Wx).x1(Gx).x0(p=>p.base.x):c=Yv().x(Gx).y1(Wx).y0(p=>p.base.y);var d=c.defined(o8).curve(o),f=a?u.filter(o8):u;return d(f)}i==="vertical"&&Lt(r)?c=Yv().y(Wx).x1(Gx).x0(r):Lt(r)?c=Yv().x(Gx).y1(Wx).y0(r):c=yq().x(Gx).y(Wx);var m=c.defined(Ow).curve(o);return m(l)},Ip=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?ybe(t):r;return w.createElement("path",_3({},Va(t),gD(t),{className:Dn("recharts-curve",e),d:a===null?void 0:a,ref:i}))},vbe=["x","y","top","left","width","height","className"];function w3(){return w3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},w3.apply(null,arguments)}function l8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _be(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l8(Object(n),!0).forEach(function(r){wbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wbe(t,e,n){return(e=Sbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sbe(t){var e=Mbe(t,"string");return typeof e=="symbol"?e:e+""}function Mbe(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 Nbe(t,e){if(t==null)return{};var n,r,i=Ebe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ebe(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 Abe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),Tbe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=Nbe(t,vbe),u=_be({x:e,y:n,top:r,left:i,width:a,height:o},c);return!Lt(e)||!Lt(n)||!Lt(a)||!Lt(o)||!Lt(r)||!Lt(i)?null:w.createElement("path",w3({},ba(u),{className:Dn("recharts-cross",l),d:Abe(e,n,a,o,r,i)}))};function Cbe(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 c8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function u8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c8(Object(n),!0).forEach(function(r){kbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kbe(t,e,n){return(e=jbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jbe(t){var e=Pbe(t,"string");return typeof e=="symbol"?e:e+""}function Pbe(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 Rbe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),XK=(t,e,n)=>t.map(r=>"".concat(Rbe(r)," ").concat(e,"ms ").concat(n)).join(","),Dbe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),m0=(t,e)=>Object.keys(e).reduce((n,r)=>u8(u8({},n),{},{[r]:t(r,e[r])}),{});function d8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ni(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d8(Object(n),!0).forEach(function(r){Obe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Obe(t,e,n){return(e=Lbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Lbe(t){var e=Ibe(t,"string");return typeof e=="symbol"?e:e+""}function Ibe(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 Lw=(t,e,n)=>t+(e-t)*n,S3=t=>{var{from:e,to:n}=t;return e!==n},YK=(t,e,n)=>{var r=m0((i,a)=>{if(S3(a)){var[o,l]=t(a.from,a.to,a.velocity);return Ni(Ni({},a),{},{from:o,velocity:l})}return a},e);return n<1?m0((i,a)=>S3(a)?Ni(Ni({},a),{},{velocity:Lw(a.velocity,r[i].velocity,n),from:Lw(a.from,r[i].from,n)}):a,e):YK(t,r,n-1)};function Fbe(t,e,n,r,i,a){var o,l=r.reduce((m,p)=>Ni(Ni({},m),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>m0((m,p)=>p.from,l),u=()=>!Object.values(l).filter(S3).length,d=null,f=m=>{o||(o=m);var p=m-o,x=p/n.dt;l=YK(n,l,x),i(Ni(Ni(Ni({},t),e),c())),o=m,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var m;(m=d)===null||m===void 0||m()})}function Ube(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,m)=>Ni(Ni({},f),{},{[m]:[t[m],e[m]]}),{}),u,d=f=>{u||(u=f);var m=(f-u)/r,p=m0((v,b)=>Lw(...b,n(m)),c);if(a(Ni(Ni(Ni({},t),e),p)),m<1)l=o.setTimeout(d);else{var x=m0((v,b)=>Lw(...b,n(1)),c);a(Ni(Ni(Ni({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const zbe=(t,e,n,r,i,a)=>{var o=Dbe(t,e);return n==null?()=>(i(Ni(Ni({},t),e)),()=>{}):n.isStepper===!0?Fbe(t,e,n,o,i,a):Ube(t,e,n,r,o,i,a)};var Iw=1e-4,QK=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],ZK=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),h8=(t,e)=>n=>{var r=QK(t,e);return ZK(r,n)},Bbe=(t,e)=>n=>{var r=QK(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return ZK(i,n)},$be=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=a[1].split(")")[0].split(",").map(l=>parseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return n.length===4?n:[0,0,1,1]},Hbe=(t,e,n,r)=>{var i=h8(t,n),a=h8(e,r),o=Bbe(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,m=0;m<8;++m){var p=i(f)-d,x=o(f);if(Math.abs(p-d)<Iw||x<Iw)return a(f);f=l(f-p/x)}return a(f)};return c.isStepper=!1,c},f8=function(){return Hbe(...$be(...arguments))},Vbe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,m=c*i/1e3+o;return Math.abs(m-l)<Iw&&Math.abs(f)<Iw?[l,0]:[m,f]};return a.isStepper=!0,a.dt=i,a},Gbe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return f8(t);case"spring":return Vbe();default:if(t.split("(")[0]==="cubic-bezier")return f8(t)}return typeof t=="function"?t:null};function Wbe(t){var e,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof o=="string"&&(e=o,n(e)),typeof o=="object"&&(e=o,n(e)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),a(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class qbe{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function Kbe(){return Wbe(new qbe)}var Xbe=w.createContext(Kbe);function Ybe(t,e){var n=w.useContext(Xbe);return w.useMemo(()=>e??n(t),[t,e,n])}var Qbe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Rg={devToolsEnabled:!1,isSsr:Qbe()},Zbe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},m8={t:0},LT={t:1};function Dg(t){var e=Ur(t,Zbe),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Rg.isSsr:n,f=Ybe(e.animationId,e.animationManager),[m,p]=w.useState(d?m8:LT),x=w.useRef(null);return w.useEffect(()=>{d||p(LT)},[d]),w.useEffect(()=>{if(!d||!r)return Z0;var v=zbe(m8,LT,Gbe(a),i,p,f.getTimeoutController()),b=()=>{x.current=v()};return f.start([c,o,b,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,o,c,l,f]),u(m.t)}function Og(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(o0(e)),r=w.useRef(t);return r.current!==t&&(n.current=o0(e),r.current=t),n.current}var Jbe=["radius"],e0e=["radius"];function p8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p8(Object(n),!0).forEach(function(r){t0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t0e(t,e,n){return(e=n0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n0e(t){var e=r0e(t,"string");return typeof e=="symbol"?e:e+""}function r0e(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 Fw(){return Fw=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},Fw.apply(null,arguments)}function x8(t,e){if(t==null)return{};var n,r,i=i0e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function i0e(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 b8=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),o=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,m=4;f<m;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+o*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
  17. `).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,`,
  18. `).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,`,
  19. `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var p=Math.min(a,i);u="M ".concat(t,",").concat(e+o*p,`
  20. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+l*p,",").concat(e,`
  21. L `).concat(t+n-l*p,",").concat(e,`
  22. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*p,`
  23. L `).concat(t+n,",").concat(e+r-o*p,`
  24. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n-l*p,",").concat(e+r,`
  25. L `).concat(t+l*p,",").concat(e+r,`
  26. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*p," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},y8={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},JK=t=>{var e=Ur(t,y8),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var q=n.current.getTotalLength();q&&i(q)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:m,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:v}=e,b=w.useRef(l),y=w.useRef(c),M=w.useRef(a),S=w.useRef(o),A=w.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),E=Og(A,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=Dn("recharts-rectangle",d);if(!v){var C=ba(e),{radius:R}=C,T=x8(C,Jbe);return w.createElement("path",Fw({},T,{radius:typeof u=="number"?u:void 0,className:k,d:b8(a,o,l,c,u)}))}var P=b.current,F=y.current,I=M.current,X=S.current,D="0px ".concat(r===-1?1:r,"px"),K="".concat(r,"px 0px"),Y=XK(["strokeDasharray"],m,typeof f=="string"?f:y8.animationEasing);return w.createElement(Dg,{animationId:E,key:E,canBegin:r>0,duration:m,easing:f,isActive:v,begin:p},q=>{var Z=Wn(P,l,q),re=Wn(F,c,q),ie=Wn(I,a,q),U=Wn(X,o,q);n.current&&(b.current=Z,y.current=re,M.current=ie,S.current=U);var G;x?q>0?G={transition:Y,strokeDasharray:K}:G={strokeDasharray:D}:G={strokeDasharray:K};var ee=ba(e),{radius:ne}=ee,se=x8(ee,e0e);return w.createElement("path",Fw({},se,{radius:typeof u=="number"?u:void 0,className:k,d:b8(ie,U,Z,re,u),ref:n,style:g8(g8({},G),e.style)}))})};function v8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v8(Object(n),!0).forEach(function(r){a0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function a0e(t,e,n){return(e=s0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s0e(t){var e=o0e(t,"string");return typeof e=="symbol"?e:e+""}function o0e(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 Uw=Math.PI/180,l0e=t=>t*180/Math.PI,gi=(t,e,n,r)=>({x:t+Math.cos(-Uw*r)*n,y:e+Math.sin(-Uw*r)*n}),eX=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},c0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},u0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=c0e({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:o,angle:l0e(c),angleInRadian:c}},d0e=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:e-a*360,endAngle:n-a*360}},h0e=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),o=Math.min(i,a);return t+o*360},f0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=u0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=d0e(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?_8(_8({},e),{},{radius:i,angle:h0e(d,e)}):null};function tX(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=gi(e,n,r,i),l=gi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function M3(){return M3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},M3.apply(null,arguments)}var m0e=(t,e)=>{var n=Xi(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},a_=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/Uw,f=c?i:i+a*d,m=gi(e,n,u,f),p=gi(e,n,r,f),x=c?i-a*d:i,v=gi(e,n,u*Math.cos(d*Uw),x);return{center:m,circleTangency:p,lineTangency:v,theta:d}},nX=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=m0e(a,o),c=a+l,u=gi(e,n,i,a),d=gi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
  27. A `).concat(i,",").concat(i,`,0,
  28. `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
  29. `).concat(d.x,",").concat(d.y,`
  30. `);if(r>0){var m=gi(e,n,r,a),p=gi(e,n,r,c);f+="L ".concat(p.x,",").concat(p.y,`
  31. A `).concat(r,",").concat(r,`,0,
  32. `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
  33. `).concat(m.x,",").concat(m.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},p0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Xi(u-c),{circleTangency:f,lineTangency:m,theta:p}=a_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:v,theta:b}=a_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),y=l?Math.abs(c-u):Math.abs(c-u)-p-b;if(y<0)return o?"M ".concat(m.x,",").concat(m.y,`
  34. a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
  35. a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
  36. `):nX({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var M="M ".concat(m.x,",").concat(m.y,`
  37. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
  38. A`).concat(i,",").concat(i,",0,").concat(+(y>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
  39. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(v.x,",").concat(v.y,`
  40. `);if(r>0){var{circleTangency:S,lineTangency:A,theta:E}=a_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:k,lineTangency:C,theta:R}=a_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),T=l?Math.abs(c-u):Math.abs(c-u)-E-R;if(T<0&&a===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(C.x,",").concat(C.y,`
  41. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(k.x,",").concat(k.y,`
  42. A`).concat(r,",").concat(r,",0,").concat(+(T>180),",").concat(+(d>0),",").concat(S.x,",").concat(S.y,`
  43. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},g0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},rX=t=>{var e=Ur(t,g0e),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var m=Dn("recharts-sector",f),p=a-i,x=ka(o,p,0,!0),v;return x>0&&Math.abs(u-d)<360?v=p0e({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):v=nX({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),w.createElement("path",M3({},ba(e),{className:m,d:v}))};function x0e(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(Dq(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=gi(r,i,a,l),u=gi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return tX(e)}}var IT={},FT={},UT={},w8;function b0e(){return w8||(w8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qq();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(UT)),UT}var S8;function y0e(){return S8||(S8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=b0e();function n(r){return r?(r=e.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}t.toFinite=n})(FT)),FT}var M8;function v0e(){return M8||(M8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kq(),n=y0e();function r(i,a,o){o&&typeof o!="number"&&e.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?i<a?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((a-i)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=o;return c}t.range=r})(IT)),IT}var zT,N8;function _0e(){return N8||(N8=1,zT=v0e().range),zT}var w0e=_0e();const iX=ko(w0e);function Nd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function S0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function DD(t){let e,n,r;t.length!==2?(e=Nd,n=(l,c)=>Nd(t(l),c),r=(l,c)=>t(l)-c):(e=t===Nd||t===S0e?t:M0e,n=t,r=t);function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function o(l,c,u=0,d=l.length){const f=i(l,c,u,d-1);return f>u&&r(l[f-1],c)>-r(l[f],c)?f-1:f}return{left:i,center:o,right:a}}function M0e(){return 0}function aX(t){return t===null?NaN:+t}function*N0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const E0e=DD(Nd),sy=E0e.right;DD(aX).center;class E8 extends Map{constructor(e,n=C0e){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(A8(this,e))}has(e){return super.has(A8(this,e))}set(e,n){return super.set(A0e(this,e),n)}delete(e){return super.delete(T0e(this,e))}}function A8({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function A0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function T0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function C0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function k0e(t=Nd){if(t===Nd)return sX;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 sX(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const j0e=Math.sqrt(50),P0e=Math.sqrt(10),R0e=Math.sqrt(2);function zw(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=j0e?10:a>=P0e?5:a>=R0e?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?zw(t,e,n*2):[l,c,u]}function N3(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,o]=r?zw(e,t,n):zw(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(a-u)/-o;else for(let u=0;u<l;++u)c[u]=(a-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(i+u)/-o;else for(let u=0;u<l;++u)c[u]=(i+u)*o;return c}function E3(t,e,n){return e=+e,t=+t,n=+n,zw(t,e,n)[2]}function A3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?E3(e,t,n):E3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function T8(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function C8(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function oX(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?sX:k0e(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),m=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+m)),x=Math.min(r,Math.floor(e+(c-u)*f/c+m));oX(t,e,p,x,i)}const a=t[e];let o=n,l=r;for(qx(t,n,e),i(t[r],a)>0&&qx(t,n,r);o<l;){for(qx(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?qx(t,n,l):(++l,qx(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function qx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function D0e(t,e,n){if(t=Float64Array.from(N0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return C8(t);if(e>=1)return T8(t);var r,i=(r-1)*e,a=Math.floor(i),o=T8(oX(t,a).subarray(0,a+1)),l=C8(t.subarray(a+1));return o+(l-o)*(i-a)}}function O0e(t,e,n=aX){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),o=+n(t[a],a,t),l=+n(t[a+1],a+1,t);return o+(l-o)*(i-a)}}function L0e(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function Po(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function fu(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 T3=Symbol("implicit");function OD(){var t=new E8,e=[],n=[],r=T3;function i(a){let o=t.get(a);if(o===void 0){if(r!==T3)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new E8;for(const o of a)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return OD(e,n).unknown(r)},Po.apply(i,arguments),i}function LD(){var t=OD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var m=e().length,p=i<r,x=p?i:r,v=p?r:i;a=(v-x)/Math.max(1,m-c+u*2),l&&(a=Math.floor(a)),x+=(v-x-a*(m-c))*d,o=a*(1-c),l&&(x=Math.round(x),o=Math.round(o));var b=L0e(m).map(function(y){return x+a*y});return n(p?b.reverse():b)}return t.domain=function(m){return arguments.length?(e(m),f()):e()},t.range=function(m){return arguments.length?([r,i]=m,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(m){return[r,i]=m,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(m){return arguments.length?(l=!!m,f()):l},t.padding=function(m){return arguments.length?(c=Math.min(1,u=+m),f()):c},t.paddingInner=function(m){return arguments.length?(c=Math.min(1,m),f()):c},t.paddingOuter=function(m){return arguments.length?(u=+m,f()):u},t.align=function(m){return arguments.length?(d=Math.max(0,Math.min(1,m)),f()):d},t.copy=function(){return LD(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},Po.apply(f(),arguments)}function lX(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return lX(e())},t}function I0e(){return lX(LD.apply(null,arguments).paddingInner(1))}function ID(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function cX(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function oy(){}var p0=.7,Bw=1/p0,Fp="\\s*([+-]?\\d+)\\s*",g0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",kl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",F0e=/^#([0-9a-f]{3,8})$/,U0e=new RegExp(`^rgb\\(${Fp},${Fp},${Fp}\\)$`),z0e=new RegExp(`^rgb\\(${kl},${kl},${kl}\\)$`),B0e=new RegExp(`^rgba\\(${Fp},${Fp},${Fp},${g0}\\)$`),$0e=new RegExp(`^rgba\\(${kl},${kl},${kl},${g0}\\)$`),H0e=new RegExp(`^hsl\\(${g0},${kl},${kl}\\)$`),V0e=new RegExp(`^hsla\\(${g0},${kl},${kl},${g0}\\)$`),k8={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ID(oy,x0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:j8,formatHex:j8,formatHex8:G0e,formatHsl:W0e,formatRgb:P8,toString:P8});function j8(){return this.rgb().formatHex()}function G0e(){return this.rgb().formatHex8()}function W0e(){return uX(this).formatHsl()}function P8(){return this.rgb().formatRgb()}function x0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=F0e.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?R8(e):n===3?new us(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?s_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?s_(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=U0e.exec(t))?new us(e[1],e[2],e[3],1):(e=z0e.exec(t))?new us(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=B0e.exec(t))?s_(e[1],e[2],e[3],e[4]):(e=$0e.exec(t))?s_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=H0e.exec(t))?L8(e[1],e[2]/100,e[3]/100,1):(e=V0e.exec(t))?L8(e[1],e[2]/100,e[3]/100,e[4]):k8.hasOwnProperty(t)?R8(k8[t]):t==="transparent"?new us(NaN,NaN,NaN,0):null}function R8(t){return new us(t>>16&255,t>>8&255,t&255,1)}function s_(t,e,n,r){return r<=0&&(t=e=n=NaN),new us(t,e,n,r)}function q0e(t){return t instanceof oy||(t=x0(t)),t?(t=t.rgb(),new us(t.r,t.g,t.b,t.opacity)):new us}function C3(t,e,n,r){return arguments.length===1?q0e(t):new us(t,e,n,r??1)}function us(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}ID(us,C3,cX(oy,{brighter(t){return t=t==null?Bw:Math.pow(Bw,t),new us(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?p0:Math.pow(p0,t),new us(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new us(af(this.r),af(this.g),af(this.b),$w(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:D8,formatHex:D8,formatHex8:K0e,formatRgb:O8,toString:O8}));function D8(){return`#${Wh(this.r)}${Wh(this.g)}${Wh(this.b)}`}function K0e(){return`#${Wh(this.r)}${Wh(this.g)}${Wh(this.b)}${Wh((isNaN(this.opacity)?1:this.opacity)*255)}`}function O8(){const t=$w(this.opacity);return`${t===1?"rgb(":"rgba("}${af(this.r)}, ${af(this.g)}, ${af(this.b)}${t===1?")":`, ${t})`}`}function $w(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function af(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Wh(t){return t=af(t),(t<16?"0":"")+t.toString(16)}function L8(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Wo(t,e,n,r)}function uX(t){if(t instanceof Wo)return new Wo(t.h,t.s,t.l,t.opacity);if(t instanceof oy||(t=x0(t)),!t)return new Wo;if(t instanceof Wo)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,l=a-i,c=(a+i)/2;return l?(e===a?o=(n-r)/l+(n<r)*6:n===a?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?a+i:2-a-i,o*=60):l=c>0&&c<1?0:o,new Wo(o,l,c,t.opacity)}function X0e(t,e,n,r){return arguments.length===1?uX(t):new Wo(t,e,n,r??1)}function Wo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}ID(Wo,X0e,cX(oy,{brighter(t){return t=t==null?Bw:Math.pow(Bw,t),new Wo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?p0:Math.pow(p0,t),new Wo(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 us(BT(t>=240?t-240:t+120,i,r),BT(t,i,r),BT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Wo(I8(this.h),o_(this.s),o_(this.l),$w(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=$w(this.opacity);return`${t===1?"hsl(":"hsla("}${I8(this.h)}, ${o_(this.s)*100}%, ${o_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function I8(t){return t=(t||0)%360,t<0?t+360:t}function o_(t){return Math.max(0,Math.min(1,t||0))}function BT(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 FD=t=>()=>t;function Y0e(t,e){return function(n){return t+n*e}}function Q0e(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 Z0e(t){return(t=+t)==1?dX:function(e,n){return n-e?Q0e(e,n,t):FD(isNaN(e)?n:e)}}function dX(t,e){var n=e-t;return n?Y0e(t,n):FD(isNaN(t)?e:t)}const F8=(function t(e){var n=Z0e(e);function r(i,a){var o=n((i=C3(i)).r,(a=C3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=dX(i.opacity,a.opacity);return function(d){return i.r=o(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function J0e(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function eye(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function tye(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),o;for(o=0;o<r;++o)i[o]=Lg(t[o],e[o]);for(;o<n;++o)a[o]=e[o];return function(l){for(o=0;o<r;++o)a[o]=i[o](l);return a}}function nye(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Hw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function rye(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]=Lg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var k3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$T=new RegExp(k3.source,"g");function iye(t){return function(){return t}}function aye(t){return function(e){return t(e)+""}}function sye(t,e){var n=k3.lastIndex=$T.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=k3.exec(t))&&(i=$T.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:Hw(r,i)})),n=$T.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?aye(c[0].x):iye(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function Lg(t,e){var n=typeof e,r;return e==null||n==="boolean"?FD(e):(n==="number"?Hw:n==="string"?(r=x0(e))?(e=r,F8):sye:e instanceof x0?F8:e instanceof Date?nye:eye(e)?J0e:Array.isArray(e)?tye:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?rye:Hw)(t,e)}function UD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function oye(t,e){e===void 0&&(e=t,t=Lg);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return a[l](o-l)}}function lye(t){return function(){return t}}function Vw(t){return+t}var U8=[0,1];function za(t){return t}function j3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:lye(isNaN(e)?NaN:.5)}function cye(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function uye(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=j3(i,r),a=n(o,a)):(r=j3(r,i),a=n(a,o)),function(l){return a(r(l))}}function dye(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=j3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=sy(t,l,1,r)-1;return a[c](i[c](l))}}function ly(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function oM(){var t=U8,e=U8,n=Lg,r,i,a,o=za,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==za&&(o=cye(t[0],t[m-1])),l=m>2?dye:uye,c=u=null,f}function f(m){return m==null||isNaN(m=+m)?a:(c||(c=l(t.map(r),e,n)))(r(o(m)))}return f.invert=function(m){return o(i((u||(u=l(e,t.map(r),Hw)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,Vw),d()):t.slice()},f.range=function(m){return arguments.length?(e=Array.from(m),d()):e.slice()},f.rangeRound=function(m){return e=Array.from(m),n=UD,d()},f.clamp=function(m){return arguments.length?(o=m?!0:za,d()):o!==za},f.interpolate=function(m){return arguments.length?(n=m,d()):n},f.unknown=function(m){return arguments.length?(a=m,f):a},function(m,p){return r=m,i=p,d()}}function zD(){return oM()(za,za)}function hye(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Gw(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 sg(t){return t=Gw(Math.abs(t)),t?t[1]:NaN}function fye(t,e){return function(n,r){for(var i=n.length,a=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),a.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return a.reverse().join(e)}}function mye(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var pye=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function b0(t){if(!(e=pye.exec(t)))throw new Error("invalid format: "+t);var e;return new BD({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]})}b0.prototype=BD.prototype;function BD(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+""}BD.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 gye(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 hX;function xye(t,e){var n=Gw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(hX=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Gw(t,Math.max(0,e+a-1))[0]}function z8(t,e){var n=Gw(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 B8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:hye,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)=>z8(t*100,e),r:z8,s:xye,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function $8(t){return t}var H8=Array.prototype.map,V8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function bye(t){var e=t.grouping===void 0||t.thousands===void 0?$8:fye(H8.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?$8:mye(H8.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=b0(f);var m=f.fill,p=f.align,x=f.sign,v=f.symbol,b=f.zero,y=f.width,M=f.comma,S=f.precision,A=f.trim,E=f.type;E==="n"?(M=!0,E="g"):B8[E]||(S===void 0&&(S=12),A=!0,E="g"),(b||m==="0"&&p==="=")&&(b=!0,m="0",p="=");var k=v==="$"?n:v==="#"&&/[boxX]/.test(E)?"0"+E.toLowerCase():"",C=v==="$"?r:/[%p]/.test(E)?o:"",R=B8[E],T=/[defgprs%]/.test(E);S=S===void 0?6:/[gprs]/.test(E)?Math.max(1,Math.min(21,S)):Math.max(0,Math.min(20,S));function P(F){var I=k,X=C,D,K,Y;if(E==="c")X=R(F)+X,F="";else{F=+F;var q=F<0||1/F<0;if(F=isNaN(F)?c:R(Math.abs(F),S),A&&(F=gye(F)),q&&+F==0&&x!=="+"&&(q=!1),I=(q?x==="("?x:l:x==="-"||x==="("?"":x)+I,X=(E==="s"?V8[8+hX/3]:"")+X+(q&&x==="("?")":""),T){for(D=-1,K=F.length;++D<K;)if(Y=F.charCodeAt(D),48>Y||Y>57){X=(Y===46?i+F.slice(D+1):F.slice(D))+X,F=F.slice(0,D);break}}}M&&!b&&(F=e(F,1/0));var Z=I.length+F.length+X.length,re=Z<y?new Array(y-Z+1).join(m):"";switch(M&&b&&(F=e(re+F,re.length?y-X.length:1/0),re=""),p){case"<":F=I+F+X+re;break;case"=":F=I+re+F+X;break;case"^":F=re.slice(0,Z=re.length>>1)+I+F+X+re.slice(Z);break;default:F=re+I+F+X;break}return a(F)}return P.toString=function(){return f+""},P}function d(f,m){var p=u((f=b0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(sg(m)/3)))*3,v=Math.pow(10,-x),b=V8[8+x/3];return function(y){return p(v*y)+b}}return{format:u,formatPrefix:d}}var l_,$D,fX;yye({thousands:",",grouping:[3],currency:["$",""]});function yye(t){return l_=bye(t),$D=l_.format,fX=l_.formatPrefix,l_}function vye(t){return Math.max(0,-sg(Math.abs(t)))}function _ye(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(sg(e)/3)))*3-sg(Math.abs(t)))}function wye(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,sg(e)-sg(t))+1}function mX(t,e,n,r){var i=A3(t,e,n),a;switch(r=b0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=_ye(i,o))&&(r.precision=a),fX(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=wye(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=vye(i))&&(r.precision=a-(r.type==="%")*2);break}}return $D(r)}function Qd(t){var e=t.domain;return t.ticks=function(n){var r=e();return N3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return mX(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,o=r[i],l=r[a],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=E3(o,l,n),u===c)return r[i]=o,r[a]=l,e(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function pX(){var t=zD();return t.copy=function(){return ly(t,pX())},Po.apply(t,arguments),Qd(t)}function gX(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,Vw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return gX(t).unknown(e)},t=arguments.length?Array.from(t,Vw):[0,1],Qd(n)}function xX(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function G8(t){return Math.log(t)}function W8(t){return Math.exp(t)}function Sye(t){return-Math.log(-t)}function Mye(t){return-Math.exp(-t)}function Nye(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Eye(t){return t===10?Nye:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Aye(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 q8(t){return(e,n)=>-t(-e,n)}function HD(t){const e=t(G8,W8),n=e.domain;let r=10,i,a;function o(){return i=Aye(r),a=Eye(r),n()[0]<0?(i=q8(i),a=q8(a),t(Sye,Mye)):t(G8,W8),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let m=i(u),p=i(d),x,v;const b=l==null?10:+l;let y=[];if(!(r%1)&&p-m<b){if(m=Math.floor(m),p=Math.ceil(p),u>0){for(;m<=p;++m)for(x=1;x<r;++x)if(v=m<0?x/a(-m):x*a(m),!(v<u)){if(v>d)break;y.push(v)}}else for(;m<=p;++m)for(x=r-1;x>=1;--x)if(v=m>0?x/a(-m):x*a(m),!(v<u)){if(v>d)break;y.push(v)}y.length*2<b&&(y=N3(u,d,b))}else y=N3(m,p,Math.min(p-m,b)).map(a);return f?y.reverse():y},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=b0(c)).precision==null&&(c.trim=!0),c=$D(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(xX(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function bX(){const t=HD(oM()).domain([1,10]);return t.copy=()=>ly(t,bX()).base(t.base()),Po.apply(t,arguments),t}function K8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function X8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function VD(t){var e=1,n=t(K8(e),X8(e));return n.constant=function(r){return arguments.length?t(K8(e=+r),X8(e)):e},Qd(n)}function yX(){var t=VD(oM());return t.copy=function(){return ly(t,yX()).constant(t.constant())},Po.apply(t,arguments)}function Y8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Tye(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Cye(t){return t<0?-t*t:t*t}function GD(t){var e=t(za,za),n=1;function r(){return n===1?t(za,za):n===.5?t(Tye,Cye):t(Y8(n),Y8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Qd(e)}function WD(){var t=GD(oM());return t.copy=function(){return ly(t,WD()).exponent(t.exponent())},Po.apply(t,arguments),t}function kye(){return WD.apply(null,arguments).exponent(.5)}function Q8(t){return Math.sign(t)*t*t}function jye(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function vX(){var t=zD(),e=[0,1],n=!1,r;function i(a){var o=jye(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(Q8(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,Vw)).map(Q8)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return vX(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},Po.apply(i,arguments),Qd(i)}function _X(){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]=O0e(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[sy(n,o)]}return a.invertExtent=function(o){var l=e.indexOf(o);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},a.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let l of o)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(Nd),i()},a.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},a.unknown=function(o){return arguments.length?(r=o,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return _X().domain(t).range(e).unknown(r)},Po.apply(a,arguments)}function wX(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[sy(r,c,0,n)]:a}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return o}return o.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},o.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):i.slice()},o.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},o.unknown=function(c){return arguments.length&&(a=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return wX().domain([t,e]).range(i).unknown(a)},Po.apply(Qd(o),arguments)}function SX(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[sy(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var o=e.indexOf(a);return[t[o-1],t[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return SX().domain(t).range(e).unknown(n)},Po.apply(i,arguments)}const HT=new Date,VT=new Date;function Ri(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const o=i(a),l=i.ceil(a);return a-o<l-a?o:l},i.offset=(a,o)=>(e(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,l)=>{const c=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<o)||!(l>0))return c;let u;do c.push(u=new Date(+a)),e(a,l),t(a);while(u<a&&a<o);return c},i.filter=a=>Ri(o=>{if(o>=o)for(;t(o),!a(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!a(o););else for(;--l>=0;)for(;e(o,1),!a(o););}),n&&(i.count=(a,o)=>(HT.setTime(+a),VT.setTime(+o),t(HT),t(VT),Math.floor(n(HT,VT))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const Ww=Ri(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Ww.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ri(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Ww);Ww.range;const Fc=1e3,_o=Fc*60,Uc=_o*60,ru=Uc*24,qD=ru*7,Z8=ru*30,GT=ru*365,qh=Ri(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Fc)},(t,e)=>(e-t)/Fc,t=>t.getUTCSeconds());qh.range;const KD=Ri(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Fc)},(t,e)=>{t.setTime(+t+e*_o)},(t,e)=>(e-t)/_o,t=>t.getMinutes());KD.range;const XD=Ri(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*_o)},(t,e)=>(e-t)/_o,t=>t.getUTCMinutes());XD.range;const YD=Ri(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Fc-t.getMinutes()*_o)},(t,e)=>{t.setTime(+t+e*Uc)},(t,e)=>(e-t)/Uc,t=>t.getHours());YD.range;const QD=Ri(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Uc)},(t,e)=>(e-t)/Uc,t=>t.getUTCHours());QD.range;const cy=Ri(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*_o)/ru,t=>t.getDate()-1);cy.range;const lM=Ri(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ru,t=>t.getUTCDate()-1);lM.range;const MX=Ri(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ru,t=>Math.floor(t/ru));MX.range;function Wf(t){return Ri(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())*_o)/qD)}const cM=Wf(0),qw=Wf(1),Pye=Wf(2),Rye=Wf(3),og=Wf(4),Dye=Wf(5),Oye=Wf(6);cM.range;qw.range;Pye.range;Rye.range;og.range;Dye.range;Oye.range;function qf(t){return Ri(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)/qD)}const uM=qf(0),Kw=qf(1),Lye=qf(2),Iye=qf(3),lg=qf(4),Fye=qf(5),Uye=qf(6);uM.range;Kw.range;Lye.range;Iye.range;lg.range;Fye.range;Uye.range;const ZD=Ri(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());ZD.range;const JD=Ri(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());JD.range;const iu=Ri(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());iu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ri(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)});iu.range;const au=Ri(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());au.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ri(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)});au.range;function NX(t,e,n,r,i,a){const o=[[qh,1,Fc],[qh,5,5*Fc],[qh,15,15*Fc],[qh,30,30*Fc],[a,1,_o],[a,5,5*_o],[a,15,15*_o],[a,30,30*_o],[i,1,Uc],[i,3,3*Uc],[i,6,6*Uc],[i,12,12*Uc],[r,1,ru],[r,2,2*ru],[n,1,qD],[e,1,Z8],[e,3,3*Z8],[t,1,GT]];function l(u,d,f){const m=d<u;m&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),x=p?p.range(u,+d+1):[];return m?x.reverse():x}function c(u,d,f){const m=Math.abs(d-u)/f,p=DD(([,,b])=>b).right(o,m);if(p===o.length)return t.every(A3(u/GT,d/GT,f));if(p===0)return Ww.every(Math.max(A3(u,d,f),1));const[x,v]=o[m/o[p-1][2]<o[p][2]/m?p-1:p];return x.every(v)}return[l,c]}const[zye,Bye]=NX(au,JD,uM,MX,QD,XD),[$ye,Hye]=NX(iu,ZD,cM,cy,YD,KD);function WT(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 qT(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 Kx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function Vye(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=Xx(i),d=Yx(i),f=Xx(a),m=Yx(a),p=Xx(o),x=Yx(o),v=Xx(l),b=Yx(l),y=Xx(c),M=Yx(c),S={a:q,A:Z,b:re,B:ie,c:null,d:i6,e:i6,f:fve,g:Sve,G:Nve,H:uve,I:dve,j:hve,L:EX,m:mve,M:pve,p:U,q:G,Q:o6,s:l6,S:gve,u:xve,U:bve,V:yve,w:vve,W:_ve,x:null,X:null,y:wve,Y:Mve,Z:Eve,"%":s6},A={a:ee,A:ne,b:se,B:de,c:null,d:a6,e:a6,f:kve,g:zve,G:$ve,H:Ave,I:Tve,j:Cve,L:TX,m:jve,M:Pve,p:he,q:Ee,Q:o6,s:l6,S:Rve,u:Dve,U:Ove,V:Lve,w:Ive,W:Fve,x:null,X:null,y:Uve,Y:Bve,Z:Hve,"%":s6},E={a:P,A:F,b:I,B:X,c:D,d:n6,e:n6,f:sve,g:t6,G:e6,H:r6,I:r6,j:nve,L:ave,m:tve,M:rve,p:T,q:eve,Q:lve,s:cve,S:ive,u:Xye,U:Yye,V:Qye,w:Kye,W:Zye,x:K,X:Y,y:t6,Y:e6,Z:Jye,"%":ove};S.x=k(n,S),S.X=k(r,S),S.c=k(e,S),A.x=k(n,A),A.X=k(r,A),A.c=k(e,A);function k(ge,Ne){return function(Re){var te=[],Je=-1,B=0,H=ge.length,W,z,V;for(Re instanceof Date||(Re=new Date(+Re));++Je<H;)ge.charCodeAt(Je)===37&&(te.push(ge.slice(B,Je)),(z=J8[W=ge.charAt(++Je)])!=null?W=ge.charAt(++Je):z=W==="e"?" ":"0",(V=Ne[W])&&(W=V(Re,z)),te.push(W),B=Je+1);return te.push(ge.slice(B,Je)),te.join("")}}function C(ge,Ne){return function(Re){var te=Kx(1900,void 0,1),Je=R(te,ge,Re+="",0),B,H;if(Je!=Re.length)return null;if("Q"in te)return new Date(te.Q);if("s"in te)return new Date(te.s*1e3+("L"in te?te.L:0));if(Ne&&!("Z"in te)&&(te.Z=0),"p"in te&&(te.H=te.H%12+te.p*12),te.m===void 0&&(te.m="q"in te?te.q:0),"V"in te){if(te.V<1||te.V>53)return null;"w"in te||(te.w=1),"Z"in te?(B=qT(Kx(te.y,0,1)),H=B.getUTCDay(),B=H>4||H===0?Kw.ceil(B):Kw(B),B=lM.offset(B,(te.V-1)*7),te.y=B.getUTCFullYear(),te.m=B.getUTCMonth(),te.d=B.getUTCDate()+(te.w+6)%7):(B=WT(Kx(te.y,0,1)),H=B.getDay(),B=H>4||H===0?qw.ceil(B):qw(B),B=cy.offset(B,(te.V-1)*7),te.y=B.getFullYear(),te.m=B.getMonth(),te.d=B.getDate()+(te.w+6)%7)}else("W"in te||"U"in te)&&("w"in te||(te.w="u"in te?te.u%7:"W"in te?1:0),H="Z"in te?qT(Kx(te.y,0,1)).getUTCDay():WT(Kx(te.y,0,1)).getDay(),te.m=0,te.d="W"in te?(te.w+6)%7+te.W*7-(H+5)%7:te.w+te.U*7-(H+6)%7);return"Z"in te?(te.H+=te.Z/100|0,te.M+=te.Z%100,qT(te)):WT(te)}}function R(ge,Ne,Re,te){for(var Je=0,B=Ne.length,H=Re.length,W,z;Je<B;){if(te>=H)return-1;if(W=Ne.charCodeAt(Je++),W===37){if(W=Ne.charAt(Je++),z=E[W in J8?Ne.charAt(Je++):W],!z||(te=z(ge,Re,te))<0)return-1}else if(W!=Re.charCodeAt(te++))return-1}return te}function T(ge,Ne,Re){var te=u.exec(Ne.slice(Re));return te?(ge.p=d.get(te[0].toLowerCase()),Re+te[0].length):-1}function P(ge,Ne,Re){var te=p.exec(Ne.slice(Re));return te?(ge.w=x.get(te[0].toLowerCase()),Re+te[0].length):-1}function F(ge,Ne,Re){var te=f.exec(Ne.slice(Re));return te?(ge.w=m.get(te[0].toLowerCase()),Re+te[0].length):-1}function I(ge,Ne,Re){var te=y.exec(Ne.slice(Re));return te?(ge.m=M.get(te[0].toLowerCase()),Re+te[0].length):-1}function X(ge,Ne,Re){var te=v.exec(Ne.slice(Re));return te?(ge.m=b.get(te[0].toLowerCase()),Re+te[0].length):-1}function D(ge,Ne,Re){return R(ge,e,Ne,Re)}function K(ge,Ne,Re){return R(ge,n,Ne,Re)}function Y(ge,Ne,Re){return R(ge,r,Ne,Re)}function q(ge){return o[ge.getDay()]}function Z(ge){return a[ge.getDay()]}function re(ge){return c[ge.getMonth()]}function ie(ge){return l[ge.getMonth()]}function U(ge){return i[+(ge.getHours()>=12)]}function G(ge){return 1+~~(ge.getMonth()/3)}function ee(ge){return o[ge.getUTCDay()]}function ne(ge){return a[ge.getUTCDay()]}function se(ge){return c[ge.getUTCMonth()]}function de(ge){return l[ge.getUTCMonth()]}function he(ge){return i[+(ge.getUTCHours()>=12)]}function Ee(ge){return 1+~~(ge.getUTCMonth()/3)}return{format:function(ge){var Ne=k(ge+="",S);return Ne.toString=function(){return ge},Ne},parse:function(ge){var Ne=C(ge+="",!1);return Ne.toString=function(){return ge},Ne},utcFormat:function(ge){var Ne=k(ge+="",A);return Ne.toString=function(){return ge},Ne},utcParse:function(ge){var Ne=C(ge+="",!0);return Ne.toString=function(){return ge},Ne}}}var J8={"-":"",_:" ",0:"0"},ta=/^\s*\d+/,Gye=/^%/,Wye=/[\\^$*+?|[\]().{}]/g;function Fn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function qye(t){return t.replace(Wye,"\\$&")}function Xx(t){return new RegExp("^(?:"+t.map(qye).join("|")+")","i")}function Yx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Kye(t,e,n){var r=ta.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Xye(t,e,n){var r=ta.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Yye(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Qye(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Zye(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function e6(t,e,n){var r=ta.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function t6(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Jye(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 eve(t,e,n){var r=ta.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function tve(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function n6(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function nve(t,e,n){var r=ta.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function r6(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function rve(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ive(t,e,n){var r=ta.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function ave(t,e,n){var r=ta.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function sve(t,e,n){var r=ta.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ove(t,e,n){var r=Gye.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function lve(t,e,n){var r=ta.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function cve(t,e,n){var r=ta.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function i6(t,e){return Fn(t.getDate(),e,2)}function uve(t,e){return Fn(t.getHours(),e,2)}function dve(t,e){return Fn(t.getHours()%12||12,e,2)}function hve(t,e){return Fn(1+cy.count(iu(t),t),e,3)}function EX(t,e){return Fn(t.getMilliseconds(),e,3)}function fve(t,e){return EX(t,e)+"000"}function mve(t,e){return Fn(t.getMonth()+1,e,2)}function pve(t,e){return Fn(t.getMinutes(),e,2)}function gve(t,e){return Fn(t.getSeconds(),e,2)}function xve(t){var e=t.getDay();return e===0?7:e}function bve(t,e){return Fn(cM.count(iu(t)-1,t),e,2)}function AX(t){var e=t.getDay();return e>=4||e===0?og(t):og.ceil(t)}function yve(t,e){return t=AX(t),Fn(og.count(iu(t),t)+(iu(t).getDay()===4),e,2)}function vve(t){return t.getDay()}function _ve(t,e){return Fn(qw.count(iu(t)-1,t),e,2)}function wve(t,e){return Fn(t.getFullYear()%100,e,2)}function Sve(t,e){return t=AX(t),Fn(t.getFullYear()%100,e,2)}function Mve(t,e){return Fn(t.getFullYear()%1e4,e,4)}function Nve(t,e){var n=t.getDay();return t=n>=4||n===0?og(t):og.ceil(t),Fn(t.getFullYear()%1e4,e,4)}function Eve(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Fn(e/60|0,"0",2)+Fn(e%60,"0",2)}function a6(t,e){return Fn(t.getUTCDate(),e,2)}function Ave(t,e){return Fn(t.getUTCHours(),e,2)}function Tve(t,e){return Fn(t.getUTCHours()%12||12,e,2)}function Cve(t,e){return Fn(1+lM.count(au(t),t),e,3)}function TX(t,e){return Fn(t.getUTCMilliseconds(),e,3)}function kve(t,e){return TX(t,e)+"000"}function jve(t,e){return Fn(t.getUTCMonth()+1,e,2)}function Pve(t,e){return Fn(t.getUTCMinutes(),e,2)}function Rve(t,e){return Fn(t.getUTCSeconds(),e,2)}function Dve(t){var e=t.getUTCDay();return e===0?7:e}function Ove(t,e){return Fn(uM.count(au(t)-1,t),e,2)}function CX(t){var e=t.getUTCDay();return e>=4||e===0?lg(t):lg.ceil(t)}function Lve(t,e){return t=CX(t),Fn(lg.count(au(t),t)+(au(t).getUTCDay()===4),e,2)}function Ive(t){return t.getUTCDay()}function Fve(t,e){return Fn(Kw.count(au(t)-1,t),e,2)}function Uve(t,e){return Fn(t.getUTCFullYear()%100,e,2)}function zve(t,e){return t=CX(t),Fn(t.getUTCFullYear()%100,e,2)}function Bve(t,e){return Fn(t.getUTCFullYear()%1e4,e,4)}function $ve(t,e){var n=t.getUTCDay();return t=n>=4||n===0?lg(t):lg.ceil(t),Fn(t.getUTCFullYear()%1e4,e,4)}function Hve(){return"+0000"}function s6(){return"%"}function o6(t){return+t}function l6(t){return Math.floor(+t/1e3)}var jm,kX,jX;Vve({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 Vve(t){return jm=Vye(t),kX=jm.format,jm.parse,jX=jm.utcFormat,jm.utcParse,jm}function Gve(t){return new Date(t)}function Wve(t){return t instanceof Date?+t:+new Date(+t)}function e4(t,e,n,r,i,a,o,l,c,u){var d=zD(),f=d.invert,m=d.domain,p=u(".%L"),x=u(":%S"),v=u("%I:%M"),b=u("%I %p"),y=u("%a %d"),M=u("%b %d"),S=u("%B"),A=u("%Y");function E(k){return(c(k)<k?p:l(k)<k?x:o(k)<k?v:a(k)<k?b:r(k)<k?i(k)<k?y:M:n(k)<k?S:A)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?m(Array.from(k,Wve)):m().map(Gve)},d.ticks=function(k){var C=m();return t(C[0],C[C.length-1],k??10)},d.tickFormat=function(k,C){return C==null?E:u(C)},d.nice=function(k){var C=m();return(!k||typeof k.range!="function")&&(k=e(C[0],C[C.length-1],k??10)),k?m(xX(C,k)):d},d.copy=function(){return ly(d,e4(t,e,n,r,i,a,o,l,c,u))},d}function qve(){return Po.apply(e4($ye,Hye,iu,ZD,cM,cy,YD,KD,qh,kX).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Kve(){return Po.apply(e4(zye,Bye,au,JD,uM,lM,QD,XD,qh,jX).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function dM(){var t=0,e=1,n,r,i,a,o=za,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(m){var p,x;return arguments.length?([p,x]=m,o=f(p,x),u):[o(0),o(1)]}}return u.range=d(Lg),u.rangeRound=d(UD),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function Zd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function PX(){var t=Qd(dM()(za));return t.copy=function(){return Zd(t,PX())},fu.apply(t,arguments)}function RX(){var t=HD(dM()).domain([1,10]);return t.copy=function(){return Zd(t,RX()).base(t.base())},fu.apply(t,arguments)}function DX(){var t=VD(dM());return t.copy=function(){return Zd(t,DX()).constant(t.constant())},fu.apply(t,arguments)}function t4(){var t=GD(dM());return t.copy=function(){return Zd(t,t4()).exponent(t.exponent())},fu.apply(t,arguments)}function Xve(){return t4.apply(null,arguments).exponent(.5)}function OX(){var t=[],e=za;function n(r){if(r!=null&&!isNaN(r=+r))return e((sy(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(Nd),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>D0e(t,a/r))},n.copy=function(){return OX(e).domain(t)},fu.apply(n,arguments)}function hM(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=za,d,f=!1,m;function p(v){return isNaN(v=+v)?m:(v=.5+((v=+d(v))-a)*(r*v<r*a?l:c),u(f?Math.max(0,Math.min(1,v)):v))}p.domain=function(v){return arguments.length?([t,e,n]=v,i=d(t=+t),a=d(e=+e),o=d(n=+n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p):[t,e,n]},p.clamp=function(v){return arguments.length?(f=!!v,p):f},p.interpolator=function(v){return arguments.length?(u=v,p):u};function x(v){return function(b){var y,M,S;return arguments.length?([y,M,S]=b,u=oye(v,[y,M,S]),p):[u(0),u(.5),u(1)]}}return p.range=x(Lg),p.rangeRound=x(UD),p.unknown=function(v){return arguments.length?(m=v,p):m},function(v){return d=v,i=v(t),a=v(e),o=v(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function LX(){var t=Qd(hM()(za));return t.copy=function(){return Zd(t,LX())},fu.apply(t,arguments)}function IX(){var t=HD(hM()).domain([.1,1,10]);return t.copy=function(){return Zd(t,IX()).base(t.base())},fu.apply(t,arguments)}function FX(){var t=VD(hM());return t.copy=function(){return Zd(t,FX()).constant(t.constant())},fu.apply(t,arguments)}function n4(){var t=GD(hM());return t.copy=function(){return Zd(t,n4()).exponent(t.exponent())},fu.apply(t,arguments)}function Yve(){return n4.apply(null,arguments).exponent(.5)}const bb=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:LD,scaleDiverging:LX,scaleDivergingLog:IX,scaleDivergingPow:n4,scaleDivergingSqrt:Yve,scaleDivergingSymlog:FX,scaleIdentity:gX,scaleImplicit:T3,scaleLinear:pX,scaleLog:bX,scaleOrdinal:OD,scalePoint:I0e,scalePow:WD,scaleQuantile:_X,scaleQuantize:wX,scaleRadial:vX,scaleSequential:PX,scaleSequentialLog:RX,scaleSequentialPow:t4,scaleSequentialQuantile:OX,scaleSequentialSqrt:Xve,scaleSequentialSymlog:DX,scaleSqrt:kye,scaleSymlog:yX,scaleThreshold:SX,scaleTime:qve,scaleUtc:Kve,tickFormat:mX},Symbol.toStringTag,{value:"Module"}));var Jd=t=>t.chartData,r4=Ze([Jd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),uy=(t,e,n,r)=>r?r4(t):Jd(t);function Id(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(tr(e)&&tr(n))return!0}return!1}function c6(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function UX(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(tr(n))i=n;else if(typeof n=="function")return;if(tr(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(Id(o))return o}}function Qve(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Id(r))return c6(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(Lt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&IB.test(i)){var c=IB.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(Lt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&FB.test(a)){var d=FB.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var m=[o,l];if(Id(m))return e==null?m:c6(m,e,n)}}}var Ig=1e9,Zve={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},a4,Pr=!0,Co="[DecimalError] ",sf=Co+"Invalid argument: ",i4=Co+"Exponent out of range: ",Fg=Math.floor,Dh=Math.pow,Jve=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ds,Gi=1e7,Er=7,zX=9007199254740991,Xw=Fg(zX/Er),It={};It.absoluteValue=It.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};It.comparedTo=It.cmp=function(t){var e,n,r,i,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};It.decimalPlaces=It.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Er;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};It.dividedBy=It.div=function(t){return Gc(this,new this.constructor(t))};It.dividedToIntegerBy=It.idiv=function(t){var e=this,n=e.constructor;return gr(Gc(e,new n(t),0,1),n.precision)};It.equals=It.eq=function(t){return!this.cmp(t)};It.exponent=function(){return yi(this)};It.greaterThan=It.gt=function(t){return this.cmp(t)>0};It.greaterThanOrEqualTo=It.gte=function(t){return this.cmp(t)>=0};It.isInteger=It.isint=function(){return this.e>this.d.length-2};It.isNegative=It.isneg=function(){return this.s<0};It.isPositive=It.ispos=function(){return this.s>0};It.isZero=function(){return this.s===0};It.lessThan=It.lt=function(t){return this.cmp(t)<0};It.lessThanOrEqualTo=It.lte=function(t){return this.cmp(t)<1};It.logarithm=It.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(Ds))throw Error(Co+"NaN");if(n.s<1)throw Error(Co+(n.s?"NaN":"-Infinity"));return n.eq(Ds)?new r(0):(Pr=!1,e=Gc(y0(n,a),y0(t,a),a),Pr=!0,gr(e,i))};It.minus=It.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?HX(e,t):BX(e,(t.s=-t.s,t))};It.modulo=It.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Co+"NaN");return n.s?(Pr=!1,e=Gc(n,t,0,1).times(t),Pr=!0,n.minus(e)):gr(new r(n),i)};It.naturalExponential=It.exp=function(){return $X(this)};It.naturalLogarithm=It.ln=function(){return y0(this)};It.negated=It.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};It.plus=It.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?BX(e,t):HX(e,(t.s=-t.s,t))};It.precision=It.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(sf+t);if(e=yi(i)+1,r=i.d.length-1,n=r*Er+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};It.squareRoot=It.sqrt=function(){var t,e,n,r,i,a,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(Co+"NaN")}for(t=yi(l),Pr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=El(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Fg((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(a=r,r=a.plus(Gc(l,a,o+2)).times(.5),El(a.d).slice(0,o)===(e=El(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(gr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return Pr=!0,gr(r,n)};It.times=It.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,m=d.d,p=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=m.length,u=p.length,c<u&&(a=m,m=p,p=a,o=c,c=u,u=o),a=[],o=c+u,r=o;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=a[i]+p[r]*m[i-r-1]+e,a[i--]=l%Gi|0,e=l/Gi|0;a[i]=(a[i]+e)%Gi|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,Pr?gr(t,f.precision):t};It.toDecimalPlaces=It.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Il(t,0,Ig),e===void 0?e=r.rounding:Il(e,0,8),gr(n,t+yi(n)+1,e))};It.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Tf(r,!0):(Il(t,0,Ig),e===void 0?e=i.rounding:Il(e,0,8),r=gr(new i(r),t+1,e),n=Tf(r,!0,t+1)),n};It.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Tf(i):(Il(t,0,Ig),e===void 0?e=a.rounding:Il(e,0,8),r=gr(new a(i),t+yi(i)+1,e),n=Tf(r.abs(),!1,t+yi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};It.toInteger=It.toint=function(){var t=this,e=t.constructor;return gr(new e(t),yi(t)+1,e.rounding)};It.toNumber=function(){return+this};It.toPower=It.pow=function(t){var e,n,r,i,a,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(Ds);if(l=new c(l),!l.s){if(t.s<1)throw Error(Co+"Infinity");return l}if(l.eq(Ds))return l;if(r=c.precision,t.eq(Ds))return gr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=zX){for(i=new c(Ds),e=Math.ceil(r/Er+4),Pr=!1;n%2&&(i=i.times(l),d6(i.d,e)),n=Fg(n/2),n!==0;)l=l.times(l),d6(l.d,e);return Pr=!0,t.s<0?new c(Ds).div(i):gr(i,r)}}else if(a<0)throw Error(Co+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Pr=!1,i=t.times(y0(l,r+u)),Pr=!0,i=$X(i),i.s=a,i};It.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=yi(i),r=Tf(i,n<=a.toExpNeg||n>=a.toExpPos)):(Il(t,1,Ig),e===void 0?e=a.rounding:Il(e,0,8),i=gr(new a(i),t,e),n=yi(i),r=Tf(i,t<=n||n<=a.toExpNeg,t)),r};It.toSignificantDigits=It.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Il(t,1,Ig),e===void 0?e=r.rounding:Il(e,0,8)),gr(new r(n),t,e)};It.toString=It.valueOf=It.val=It.toJSON=It[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=yi(t),n=t.constructor;return Tf(t,e<=n.toExpNeg||e>=n.toExpPos)};function BX(t,e){var n,r,i,a,o,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),Pr?gr(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Er),l=o>l?o+1:l+1,a>l&&(a=l,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(l=c.length,a=u.length,l-a<0&&(a=l,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/Gi|0,c[a]%=Gi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Pr?gr(e,f):e}function Il(t,e,n){if(t!==~~t||t<e||t>n)throw Error(sf+t)}function El(t){var e,n,r,i=t.length-1,a="",o=t[0];if(i>0){for(a+=o,e=1;e<i;e++)r=t[e]+"",n=Er-r.length,n&&(a+=nd(n)),a+=r;o=t[e],r=o+"",n=Er-r.length,n&&(a+=nd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var Gc=(function(){function t(r,i){var a,o=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+o,r[l]=a%Gi|0,o=a/Gi|0;return o&&r.unshift(o),r}function e(r,i,a,o){var l,c;if(a!=o)c=a>o?1:-1;else for(l=c=0;l<a;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,a){for(var o=0;a--;)r[a]-=o,o=r[a]<i[a]?1:0,r[a]=o*Gi+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,m,p,x,v,b,y,M,S,A,E,k,C,R,T=r.constructor,P=r.s==i.s?1:-1,F=r.d,I=i.d;if(!r.s)return new T(r);if(!i.s)throw Error(Co+"Division by zero");for(c=r.e-i.e,C=I.length,E=F.length,p=new T(P),x=p.d=[],u=0;I[u]==(F[u]||0);)++u;if(I[u]>(F[u]||0)&&--c,a==null?M=a=T.precision:o?M=a+(yi(r)-yi(i))+1:M=a,M<0)return new T(0);if(M=M/Er+2|0,u=0,C==1)for(d=0,I=I[0],M++;(u<E||d)&&M--;u++)S=d*Gi+(F[u]||0),x[u]=S/I|0,d=S%I|0;else{for(d=Gi/(I[0]+1)|0,d>1&&(I=t(I,d),F=t(F,d),C=I.length,E=F.length),A=C,v=F.slice(0,C),b=v.length;b<C;)v[b++]=0;R=I.slice(),R.unshift(0),k=I[0],I[1]>=Gi/2&&++k;do d=0,l=e(I,v,C,b),l<0?(y=v[0],C!=b&&(y=y*Gi+(v[1]||0)),d=y/k|0,d>1?(d>=Gi&&(d=Gi-1),f=t(I,d),m=f.length,b=v.length,l=e(f,v,m,b),l==1&&(d--,n(f,C<m?R:I,m))):(d==0&&(l=d=1),f=I.slice()),m=f.length,m<b&&f.unshift(0),n(v,f,b),l==-1&&(b=v.length,l=e(I,v,C,b),l<1&&(d++,n(v,C<b?R:I,b))),b=v.length):l===0&&(d++,v=[0]),x[u++]=d,l&&v[0]?v[b++]=F[A]||0:(v=[F[A]],b=1);while((A++<E||v[0]!==void 0)&&M--)}return x[0]||x.shift(),p.e=c,gr(p,o?a+yi(p)+1:a)}})();function $X(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(yi(t)>16)throw Error(i4+yi(t));if(!t.s)return new d(Ds);for(Pr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Dh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Ds),d.precision=l;;){if(i=gr(i.times(t),l),n=n.times(++c),o=a.plus(Gc(i,n,l)),El(o.d).slice(0,l)===El(a.d).slice(0,l)){for(;u--;)a=gr(a.times(a),l);return d.precision=f,e==null?(Pr=!0,gr(a,f)):a}a=o}}function yi(t){for(var e=t.e*Er,n=t.d[0];n>=10;n/=10)e++;return e}function KT(t,e,n){if(e>t.LN10.sd())throw Pr=!0,n&&(t.precision=n),Error(Co+"LN10 precision limit exceeded");return gr(new t(t.LN10),e)}function nd(t){for(var e="";t--;)e+="0";return e}function y0(t,e){var n,r,i,a,o,l,c,u,d,f=1,m=10,p=t,x=p.d,v=p.constructor,b=v.precision;if(p.s<1)throw Error(Co+(p.s?"NaN":"-Infinity"));if(p.eq(Ds))return new v(0);if(e==null?(Pr=!1,u=b):u=e,p.eq(10))return e==null&&(Pr=!0),KT(v,u);if(u+=m,v.precision=u,n=El(x),r=n.charAt(0),a=yi(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=El(p.d),r=n.charAt(0),f++;a=yi(p),r>1?(p=new v("0."+n),a++):p=new v(r+"."+n.slice(1))}else return c=KT(v,u+2,b).times(a+""),p=y0(new v(r+"."+n.slice(1)),u-m).plus(c),v.precision=b,e==null?(Pr=!0,gr(p,b)):p;for(l=o=p=Gc(p.minus(Ds),p.plus(Ds),u),d=gr(p.times(p),u),i=3;;){if(o=gr(o.times(d),u),c=l.plus(Gc(o,new v(i),u)),El(c.d).slice(0,u)===El(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(KT(v,u+2,b).times(a+""))),l=Gc(l,new v(f),u),v.precision=b,e==null?(Pr=!0,gr(l,b)):l;l=c,i+=2}}function u6(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=Fg(n/Er),t.d=[],r=(n+1)%Er,n<0&&(r+=Er),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Er;r<i;)t.d.push(+e.slice(r,r+=Er));e=e.slice(r),r=Er-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Pr&&(t.e>Xw||t.e<-Xw))throw Error(i4+n)}else t.s=0,t.e=0,t.d=[0];return t}function gr(t,e,n){var r,i,a,o,l,c,u,d,f=t.d;for(o=1,a=f[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=Er,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Er),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Er,i=r-Er+o}if(n!==void 0&&(a=Dh(10,o-i-1),l=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/Dh(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=yi(t),f.length=1,e=e-a-1,f[0]=Dh(10,(Er-e%Er)%Er),t.e=Fg(-e/Er)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=Dh(10,Er-r),f[d]=i>0?(u/Dh(10,o-i)%Dh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Gi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Gi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(Pr&&(t.e>Xw||t.e<-Xw))throw Error(i4+yi(t));return t}function HX(t,e){var n,r,i,a,o,l,c,u,d,f,m=t.constructor,p=m.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new m(t),Pr?gr(e,p):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(p/Er),l)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=c.length,l=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}o=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>o;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=Gi-1;--c[a],c[i]+=Gi}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,Pr?gr(e,p):e):new m(0)}function Tf(t,e,n){var r,i=yi(t),a=El(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+nd(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+nd(-i-1)+a,n&&(r=n-o)>0&&(a+=nd(r))):i>=o?(a+=nd(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+nd(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=nd(r))),t.s<0?"-"+a:a}function d6(t,e){if(t.length>e)return t.length=e,!0}function VX(t){var e,n,r;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(sf+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return u6(o,a.toString())}else if(typeof a!="string")throw Error(sf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,Jve.test(a))u6(o,a);else throw Error(sf+a)}if(i.prototype=It,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=VX,i.config=i.set=e_e,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 e_e(t){if(!t||typeof t!="object")throw Error(Co+"Object expected");var e,n,r,i=["precision",1,Ig,"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(Fg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(sf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(sf+n+": "+r);return this}var a4=VX(Zve);Ds=new a4(1);const Jn=a4;var t_e=t=>t,GX={},WX=t=>t===GX,h6=t=>function e(){return arguments.length===0||arguments.length===1&&WX(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},qX=(t,e)=>t===1?e:h6(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(o=>o!==GX).length;return a>=t?e(...r):qX(t-a,h6(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>WX(d)?l.shift():d);return e(...u,...l)}))}),n_e=t=>qX(t.length,t),P3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},r_e=n_e((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),i_e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return t_e;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},R3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function KX(t){var e;return t===0?e=1:e=Math.floor(new Jn(t).abs().log(10).toNumber())+1,e}function XX(t,e,n){for(var r=new Jn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var YX=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},QX=(t,e,n)=>{if(t.lte(0))return new Jn(0);var r=KX(t.toNumber()),i=new Jn(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new Jn(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new Jn(c.toNumber()):new Jn(Math.ceil(c.toNumber()))},a_e=(t,e,n)=>{var r=new Jn(1),i=new Jn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Jn(10).pow(KX(t)-1),i=new Jn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Jn(Math.floor(t)))}else t===0?i=new Jn(Math.floor((e-1)/2)):n||(i=new Jn(Math.floor(t)));var o=Math.floor((e-1)/2),l=i_e(r_e(c=>i.add(new Jn(c-o).mul(r)).toNumber()),P3);return l(0,e)},ZX=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new Jn(0),tickMin:new Jn(0),tickMax:new Jn(0)};var o=QX(new Jn(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new Jn(0):(l=new Jn(e).add(n).div(2),l=l.sub(new Jn(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new Jn(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?ZX(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new Jn(c).mul(o)),tickMax:l.add(new Jn(u).mul(o))})},s_e=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),[l,c]=YX([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...P3(0,i-1).map(()=>1/0)]:[...P3(0,i-1).map(()=>-1/0),c];return n>r?R3(u):u}if(l===c)return a_e(l,i,a);var{step:d,tickMin:f,tickMax:m}=ZX(l,c,o,a,0),p=XX(f,m.add(new Jn(.1).mul(d)),d);return n>r?R3(p):p},o_e=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=YX([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=QX(new Jn(l).sub(o).div(c-1),a,0),d=[...XX(new Jn(o),new Jn(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?R3(d):d},JX=t=>t.rootProps.maxBarSize,l_e=t=>t.rootProps.barGap,eY=t=>t.rootProps.barCategoryGap,c_e=t=>t.rootProps.barSize,dy=t=>t.rootProps.stackOffset,tY=t=>t.rootProps.reverseStackOrder,s4=t=>t.options.chartName,o4=t=>t.rootProps.syncId,nY=t=>t.rootProps.syncMethod,l4=t=>t.options.eventEmitter,u_e=t=>t.rootProps.baseValue,Zr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Rc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},js={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},fM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},d_e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Rc.angleAxisId,includeHidden:!1,name:void 0,reversed:Rc.reversed,scale:Rc.scale,tick:Rc.tick,tickCount:void 0,ticks:void 0,type:Rc.type,unit:void 0},h_e={allowDataOverflow:js.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:js.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:js.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:js.scale,tick:js.tick,tickCount:js.tickCount,ticks:void 0,type:js.type,unit:void 0},f_e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Rc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Rc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Rc.scale,tick:Rc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},m_e={allowDataOverflow:js.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:js.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:js.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:js.scale,tick:js.tick,tickCount:js.tickCount,ticks:void 0,type:"category",unit:void 0},c4=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?f_e:d_e,u4=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?m_e:h_e,mM=t=>t.polarOptions,d4=Ze([du,hu,ji],eX),rY=Ze([mM,d4],(t,e)=>{if(t!=null)return ka(t.innerRadius,e,0)}),iY=Ze([mM,d4],(t,e)=>{if(t!=null)return ka(t.outerRadius,e,e*.8)}),p_e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},aY=Ze([mM],p_e);Ze([c4,aY],fM);var sY=Ze([d4,rY,iY],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ze([u4,sY],fM);var oY=Ze([An,mM,rY,iY,du,hu],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:ka(o,i,i/2),cy:ka(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Dr=(t,e)=>e,hy=(t,e,n)=>n;function pM(t){return t?.id}function lY(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=pM(l);u.forEach((f,m)=>{var p=a==null||i?m:String(er(f,a,null)),x=er(f,l.dataKey,0),v;o.has(p)?v=o.get(p):v={},Object.assign(v,{[d]:x}),o.set(p,v)})}}),Array.from(o.values())}function gM(t){return t.stackId!=null&&t.dataKey!=null}var xM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function bM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function g_e(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 Di=t=>{var e=An(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Ug=t=>t.tooltip.settings.axisId;function f6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Yw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?f6(Object(n),!0).forEach(function(r){x_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function x_e(t,e,n){return(e=b_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b_e(t){var e=y_e(t,"string");return typeof e=="symbol"?e:e+""}function y_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var D3=[0,"auto"],Hi={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},cY=(t,e)=>t.cartesianAxis.xAxis[e],ql=(t,e)=>{var n=cY(t,e);return n??Hi},Vi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:D3,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:ry},uY=(t,e)=>t.cartesianAxis.yAxis[e],Kl=(t,e)=>{var n=uY(t,e);return n??Vi},v_e={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:""},h4=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??v_e},zr=(t,e,n)=>{switch(e){case"xAxis":return ql(t,n);case"yAxis":return Kl(t,n);case"zAxis":return h4(t,n);case"angleAxis":return c4(t,n);case"radiusAxis":return u4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},__e=(t,e,n)=>{switch(e){case"xAxis":return ql(t,n);case"yAxis":return Kl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},fy=(t,e,n)=>{switch(e){case"xAxis":return ql(t,n);case"yAxis":return Kl(t,n);case"angleAxis":return c4(t,n);case"radiusAxis":return u4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},dY=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function f4(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 my=t=>t.graphicalItems.cartesianItems,w_e=Ze([Dr,hy],f4),m4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),py=Ze([my,zr,w_e],m4,{memoizeOptions:{resultEqualityCheck:bM}}),hY=Ze([py],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(gM)),fY=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),S_e=Ze([py],fY),p4=t=>t.map(e=>e.data).filter(Boolean).flat(1),M_e=Ze([py],p4,{memoizeOptions:{resultEqualityCheck:bM}}),g4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},x4=Ze([M_e,uy],g4),b4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:er(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:er(i,r)}))):t.map(r=>({value:r})),yM=Ze([x4,zr,py],b4);function mY(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function U1(t){if(Ao(t)||t instanceof Date){var e=Number(t);if(tr(e))return e}}function m6(t){if(Array.isArray(t)){var e=[U1(t[0]),U1(t[1])];return Id(e)?e:void 0}var n=U1(t);if(n!=null)return[n,n]}function su(t){return t.map(U1).filter(_me)}function N_e(t,e,n){return!n||typeof e!="number"||gs(e)?[]:n.length?su(n.flatMap(r=>{var i=er(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!tr(a)||!tr(o)))return[e-a,e+o]})):[]}var Oi=t=>{var e=Di(t),n=Ug(t);return fy(t,e,n)},gy=Ze([Oi],t=>t?.dataKey),E_e=Ze([hY,uy,Oi],lY),pY=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(pM);return[l,{stackedData:Gge(t,d,n),graphicalItems:u}]}))},v0=Ze([E_e,hY,dy,tY],pY),gY=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=Xge(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},A_e=Ze([zr],t=>t.allowDataOverflow),y4=t=>{var e;if(t==null||!("domain"in t))return D3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=su(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:D3},v4=Ze([zr],y4),_4=Ze([v4,A_e],UX),T_e=Ze([v0,Jd,Dr,_4],gY,{memoizeOptions:{resultEqualityCheck:xM}}),vM=t=>t.errorBars,C_e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>mY(n,r)),Qw=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),o=Math.min(...a),l=Math.max(...a);return[o,l]}},w4=(t,e,n,r,i)=>{var a,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(y=>mY(i,y)),m=er(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=N_e(l,m,f);if(p.length>=2){var x=Math.min(...p),v=Math.max(...p);(a==null||x<a)&&(a=x),(o==null||v>o)&&(o=v)}var b=m6(m);b!=null&&(a=a==null?b[0]:Math.min(a,b[0]),o=o==null?b[1]:Math.max(o,b[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=m6(er(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),tr(a)&&tr(o))return[a,o]},k_e=Ze([x4,zr,S_e,vM,Dr],w4,{memoizeOptions:{resultEqualityCheck:xM}});function j_e(t){var{value:e}=t;if(Ao(e)||e instanceof Date)return e}var P_e=(t,e,n)=>{var r=t.map(j_e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&jq(r))?iX(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},xY=t=>t.referenceElements.dots,zg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),R_e=Ze([xY,Dr,hy],zg),bY=t=>t.referenceElements.areas,D_e=Ze([bY,Dr,hy],zg),yY=t=>t.referenceElements.lines,O_e=Ze([yY,Dr,hy],zg),vY=(t,e)=>{var n=su(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},L_e=Ze(R_e,Dr,vY),_Y=(t,e)=>{var n=su(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)]},I_e=Ze([D_e,Dr],_Y);function F_e(t){var e;if(t.x!=null)return su([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:su(n)}function U_e(t){var e;if(t.y!=null)return su([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:su(n)}var wY=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?F_e(r):U_e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},z_e=Ze([O_e,Dr],wY),B_e=Ze(L_e,z_e,I_e,(t,e,n)=>Qw(t,n,e)),S4=(t,e,n,r,i,a,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?Qw(r,a,i):Qw(a,i);return Qve(e,u,t.allowDataOverflow)},$_e=Ze([zr,v4,_4,T_e,k_e,B_e,An,Dr],S4,{memoizeOptions:{resultEqualityCheck:xM}}),H_e=[0,1],M4=(t,e,n,r,i,a,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Wl(e,a);if(u&&l==null){var d;return iX(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?P_e(r,t,u):i==="expand"?H_e:o}},N4=Ze([zr,An,x4,yM,dy,Dr,$_e],M4),SY=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:o}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":o==="category"?"band":"linear";if(typeof a=="string"){var l="scale".concat(Q0(a));return l in bb?l:"point"}}},Bg=Ze([zr,An,dY,s4,Dr],SY);function V_e(t){if(t!=null){if(t in bb)return bb[t]();var e="scale".concat(Q0(t));if(e in bb)return bb[e]()}}function E4(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=V_e(e);if(i!=null){var a=i.domain(n).range(r);return zge(a),a}}}var A4=(t,e,n)=>{var r=y4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Id(t))return s_e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Id(t))return o_e(t,e.tickCount,e.allowDecimals)}},T4=Ze([N4,fy,Bg],A4),C4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Id(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(o,l)]}return e},G_e=Ze([zr,N4,T4,Dr],C4),W_e=Ze(yM,zr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(su(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var o=r[a+1]-r[a];n=Math.min(n,o)}return n/i}}),MY=Ze(W_e,An,eY,ji,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!tr(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=ka(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),q_e=(t,e)=>{var n=ql(t,e);return n==null||typeof n.padding!="string"?0:MY(t,"xAxis",e,n.padding)},K_e=(t,e)=>{var n=Kl(t,e);return n==null||typeof n.padding!="string"?0:MY(t,"yAxis",e,n.padding)},X_e=Ze(ql,q_e,(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}}),Y_e=Ze(Kl,K_e,(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}}),Q_e=Ze([ji,X_e,nM,tM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),Z_e=Ze([ji,An,Y_e,nM,tM,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),xy=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Q_e(t,n,r);case"yAxis":return Z_e(t,n,r);case"zAxis":return(i=h4(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return aY(t);case"radiusAxis":return sY(t,n);default:return}},NY=Ze([zr,xy],fM),Fd=Ze([zr,Bg,G_e,NY],E4);Ze([py,vM,Dr],C_e);function EY(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var _M=(t,e)=>e,wM=(t,e,n)=>n,J_e=Ze(J2,_M,wM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(EY)),e1e=Ze(eM,_M,wM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(EY)),AY=(t,e)=>({width:t.width,height:e.height}),t1e=(t,e)=>{var n=typeof e.width=="number"?e.width:ry;return{width:n,height:t.height}},TY=Ze(ji,ql,AY),n1e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},r1e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},i1e=Ze(hu,ji,J_e,_M,wM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=AY(e,l);o==null&&(o=n1e(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),a}),a1e=Ze(du,ji,e1e,_M,wM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=t1e(e,l);o==null&&(o=r1e(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),a}),s1e=(t,e)=>{var n=ql(t,e);if(n!=null)return i1e(t,n.orientation,n.mirror)},o1e=Ze([ji,ql,s1e,(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}}}),l1e=(t,e)=>{var n=Kl(t,e);if(n!=null)return a1e(t,n.orientation,n.mirror)},c1e=Ze([ji,Kl,l1e,(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}}}),CY=Ze(ji,Kl,(t,e)=>{var n=typeof e.width=="number"?e.width:ry;return{width:n,height:t.height}}),p6=(t,e,n)=>{switch(e){case"xAxis":return TY(t,n).width;case"yAxis":return CY(t,n).height;default:return}},kY=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=Wl(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&jq(c))return c}},k4=Ze([An,yM,zr,Dr],kY),jY=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Wl(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},j4=Ze([An,yM,fy,Dr],jY),g6=Ze([An,__e,Bg,Fd,k4,j4,xy,T4,Dr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=Wl(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),u1e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=Wl(t,c),{type:d,ticks:f,tickCount:m}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Xi(a[0]-a[1])*2*x:x;var v=f||i;if(v){var b=v.map((y,M)=>{var S=o?o.indexOf(y):y;return{index:M,coordinate:r(S)+x,value:y,offset:x}});return b.filter(y=>tr(y.coordinate))}return u&&l?l.map((y,M)=>({coordinate:r(y)+x,value:y,index:M,offset:x})).filter(y=>tr(y.coordinate)):r.ticks?r.ticks(m).map(y=>({coordinate:r(y)+x,value:y,offset:x})):r.domain().map((y,M)=>({coordinate:r(y)+x,value:o?o[y]:y,index:M,offset:x}))}},PY=Ze([An,fy,Bg,Fd,T4,xy,k4,j4,Dr],u1e),d1e=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Wl(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Xi(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},Fl=Ze([An,fy,Fd,xy,k4,j4,Dr],d1e),Ul=Ze(zr,Fd,(t,e)=>{if(!(t==null||e==null))return Yw(Yw({},t),{},{scale:e})}),h1e=Ze([zr,Bg,N4,NY],E4);Ze((t,e,n)=>h4(t,n),h1e,(t,e)=>{if(!(t==null||e==null))return Yw(Yw({},t),{},{scale:e})});var f1e=Ze([An,J2,eM],(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}}),RY=t=>t.options.defaultTooltipEventType,DY=t=>t.options.validateTooltipEventTypes;function OY(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function P4(t,e){var n=RY(t),r=DY(t);return OY(e,n,r)}function m1e(t){return Rt(e=>P4(e,t))}var LY=(t,e)=>{var n,r=Number(e);if(!(gs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},p1e=t=>t.tooltip.settings,ud={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},g1e={itemInteraction:{click:ud,hover:ud},axisInteraction:{click:ud,hover:ud},keyboardInteraction:ud,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}},IY=xs({name:"tooltip",initialState:g1e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:kr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Zo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:kr()},removeTooltipEntrySettings:{reducer(t,e){var n=Zo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:kr()},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:x1e,replaceTooltipEntrySettings:b1e,removeTooltipEntrySettings:y1e,setTooltipSettingsState:v1e,setActiveMouseOverItemIndex:FY,mouseLeaveItem:_1e,mouseLeaveChart:UY,setActiveClickItemIndex:w1e,setMouseOverAxisIndex:zY,setMouseClickAxisIndex:S1e,setSyncInteraction:O3,setKeyboardInteraction:L3}=IY.actions,M1e=IY.reducer;function x6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function c_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x6(Object(n),!0).forEach(function(r){N1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function N1e(t,e,n){return(e=E1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function E1e(t){var e=A1e(t,"string");return typeof e=="symbol"?e:e+""}function A1e(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 T1e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function C1e(t){return t.index!=null}var BY=(t,e,n,r)=>{if(e==null)return ud;var i=T1e(t,e,n);if(i==null)return ud;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var a=t.settings.active===!0;if(C1e(i)){if(a)return c_(c_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return c_(c_({},ud),{},{coordinate:i.coordinate})};function k1e(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 j1e(t,e){var n=k1e(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function P1e(t,e,n){if(n==null||e==null)return!0;var r=er(t,e);return r==null||!Id(n)?!0:j1e(r,n)}var R4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!tr(a))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(a,l)),u=e[c];return u==null||P1e(u,n,r)?String(c):null},$Y=(t,e,n,r,i,a,o,l)=>{if(!(a==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},HY=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var o;return((o=a.settings)===null||o===void 0?void 0:o.dataKey)===i})},by=t=>t.options.tooltipPayloadSearcher,$g=t=>t.tooltip;function b6(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 y6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b6(Object(n),!0).forEach(function(r){R1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R1e(t,e,n){return(e=D1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D1e(t){var e=O1e(t,"string");return typeof e=="symbol"?e:e+""}function O1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function L1e(t,e){return t??e}var VY=(t,e,n,r,i,a,o)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((m,p)=>{var x,{dataDefinedOnItem:v,settings:b}=p,y=L1e(v,l),M=Array.isArray(y)?EK(y,u,d):y,S=(x=b?.dataKey)!==null&&x!==void 0?x:r,A=b?.nameKey,E;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&o==="axis"?E=Pq(M,r,i):E=a(M,e,c,A),Array.isArray(E))E.forEach(C=>{var R=y6(y6({},b),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});m.push(UB({tooltipEntrySettings:R,dataKey:C.dataKey,payload:C.payload,value:er(C.payload,C.dataKey),name:C.name}))});else{var k;m.push(UB({tooltipEntrySettings:b,dataKey:S,payload:E,value:er(E,S),name:(k=er(E,A))!==null&&k!==void 0?k:b?.name}))}return m},f)}},D4=Ze([Oi,An,dY,s4,Di],SY),I1e=Ze([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),F1e=Ze([Di,Ug],f4),yy=Ze([I1e,Oi,F1e],m4,{memoizeOptions:{resultEqualityCheck:bM}}),U1e=Ze([yy],t=>t.filter(gM)),z1e=Ze([yy],p4,{memoizeOptions:{resultEqualityCheck:bM}}),Hg=Ze([z1e,Jd],g4),B1e=Ze([U1e,Jd,Oi],lY),O4=Ze([Hg,Oi,yy],b4),GY=Ze([Oi],y4),$1e=Ze([Oi],t=>t.allowDataOverflow),WY=Ze([GY,$1e],UX),H1e=Ze([yy],t=>t.filter(gM)),V1e=Ze([B1e,H1e,dy,tY],pY),G1e=Ze([V1e,Jd,Di,WY],gY),W1e=Ze([yy],fY),q1e=Ze([Hg,Oi,W1e,vM,Di],w4,{memoizeOptions:{resultEqualityCheck:xM}}),K1e=Ze([xY,Di,Ug],zg),X1e=Ze([K1e,Di],vY),Y1e=Ze([bY,Di,Ug],zg),Q1e=Ze([Y1e,Di],_Y),Z1e=Ze([yY,Di,Ug],zg),J1e=Ze([Z1e,Di],wY),ewe=Ze([X1e,J1e,Q1e],Qw),twe=Ze([Oi,GY,WY,G1e,q1e,ewe,An,Di],S4),vy=Ze([Oi,An,Hg,O4,dy,Di,twe],M4),nwe=Ze([vy,Oi,D4],A4),rwe=Ze([Oi,vy,nwe,Di],C4),qY=t=>{var e=Di(t),n=Ug(t),r=!1;return xy(t,e,n,r)},KY=Ze([Oi,qY],fM),XY=Ze([Oi,D4,rwe,KY],E4),iwe=Ze([An,O4,Oi,Di],kY),awe=Ze([An,O4,Oi,Di],jY),swe=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=Wl(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?Xi(i[0]-i[1])*2*f:f,u&&o?o.map((m,p)=>({coordinate:r(m)+f,value:m,index:p,offset:f})):r.domain().map((m,p)=>({coordinate:r(m)+f,value:a?a[m]:m,index:p,offset:f}))}}},mu=Ze([An,Oi,D4,XY,qY,iwe,awe,Di],swe),L4=Ze([RY,DY,p1e],(t,e,n)=>OY(n.shared,t,e)),YY=t=>t.tooltip.settings.trigger,I4=t=>t.tooltip.settings.defaultIndex,_y=Ze([$g,L4,YY,I4],BY),Ud=Ze([_y,Hg,gy,vy],R4),QY=Ze([mu,Ud],LY),F4=Ze([_y],t=>{if(t)return t.dataKey}),owe=Ze([_y],t=>{if(t)return t.graphicalItemId}),ZY=Ze([$g,L4,YY,I4],HY),lwe=Ze([du,hu,An,ji,mu,I4,ZY,by],$Y),cwe=Ze([_y,lwe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),uwe=Ze([_y],t=>t.active),dwe=Ze([ZY,Ud,Jd,gy,QY,by,L4],VY),hwe=Ze([dwe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function v6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v6(Object(n),!0).forEach(function(r){fwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fwe(t,e,n){return(e=mwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mwe(t){var e=pwe(t,"string");return typeof e=="symbol"?e:e+""}function pwe(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 gwe=()=>Rt(Oi),xwe=()=>{var t=gwe(),e=Rt(mu),n=Rt(XY);return Ld(!t||!n?void 0:_6(_6({},t),{},{scale:n}),e)};function w6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Pm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w6(Object(n),!0).forEach(function(r){bwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bwe(t,e,n){return(e=ywe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ywe(t){var e=vwe(t,"string");return typeof e=="symbol"?e:e+""}function vwe(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 _we=(t,e,n,r)=>{var i=e.find(a=>a&&a.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},wwe=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:o}=r;return Pm(Pm(Pm({},r),gi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return Pm(Pm(Pm({},r),gi(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 Swe(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 JY=(t,e,n,r,i)=>{var a,o=-1,l=(a=e?.length)!==null&&a!==void 0?a:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,m=void 0;if(Xi(d-u)!==Xi(f-d)){var p=[];if(Xi(f-d)===Xi(i[1]-i[0])){m=f;var x=d+i[1]-i[0];p[0]=Math.min(x,(x+u)/2),p[1]=Math.max(x,(x+u)/2)}else{m=u;var v=f+i[1]-i[0];p[0]=Math.min(d,(v+d)/2),p[1]=Math.max(d,(v+d)/2)}var b=[Math.min(d,(m+d)/2),Math.max(d,(m+d)/2)];if(t>b[0]&&t<=b[1]||t>=p[0]&&t<=p[1]){({index:o}=n[c]);break}}else{var y=Math.min(u,f),M=Math.max(u,f);if(t>(y+d)/2&&t<=(M+d)/2){({index:o}=n[c]);break}}}else if(e){for(var S=0;S<l;S++)if(S===0&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S>0&&S<l-1&&t>(e[S].coordinate+e[S-1].coordinate)/2&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S===l-1&&t>(e[S].coordinate+e[S-1].coordinate)/2){({index:o}=e[S]);break}}return o},eQ=()=>Rt(s4),U4=(t,e)=>e,tQ=(t,e,n)=>n,z4=(t,e,n,r)=>r,Mwe=Ze(mu,t=>V2(t,e=>e.coordinate)),B4=Ze([$g,U4,tQ,z4],BY),$4=Ze([B4,Hg,gy,vy],R4),Nwe=(t,e,n)=>{if(e!=null){var r=$g(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},nQ=Ze([$g,U4,tQ,z4],HY),Zw=Ze([du,hu,An,ji,mu,z4,nQ,by],$Y),Ewe=Ze([B4,Zw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),rQ=Ze([mu,$4],LY),Awe=Ze([nQ,$4,Jd,gy,rQ,by,U4],VY),Twe=Ze([B4,$4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),Cwe=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&Swe(t,o)){var l=Yge(t,e),c=JY(l,a,i,n,r),u=_we(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},kwe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=f0e(t,n);if(l){var c=Qge(l,e),u=JY(c,o,a,r,i),d=wwe(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},jwe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?Cwe(t,e,r,i,a,o,l):kwe(t,e,n,r,i,a,o)},Pwe=Ze(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}}),Rwe=Ze(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Zr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:g_e}});function S6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function M6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S6(Object(n),!0).forEach(function(r){Dwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Dwe(t,e,n){return(e=Owe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Owe(t){var e=Lwe(t,"string");return typeof e=="symbol"?e:e+""}function Lwe(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 Iwe={},Fwe={zIndexMap:Object.values(Zr).reduce((t,e)=>M6(M6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),Iwe)},Uwe=new Set(Object.values(Zr));function zwe(t){return Uwe.has(t)}var iQ=xs({name:"zIndex",initialState:Fwe,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:kr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!zwe(n)&&delete t.zIndexMap[n])},prepare:kr()},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:kr()},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:kr()}}}),{registerZIndexPortal:Bwe,unregisterZIndexPortal:$we,registerZIndexPortalId:Hwe,unregisterZIndexPortalId:Vwe}=iQ.actions,Gwe=iQ.reducer;function ja(t){var{zIndex:e,children:n}=t,r=Cxe(),i=r&&e!==void 0&&e!==0,a=Pi(),o=xr();w.useLayoutEffect(()=>i?(o(Bwe({zIndex:e})),()=>{o($we({zIndex:e}))}):Z0,[o,e,i]);var l=Rt(u=>Pwe(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Ic.createPortal(n,c):null}function I3(){return I3=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},I3.apply(null,arguments)}function N6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function u_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N6(Object(n),!0).forEach(function(r){Wwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Wwe(t,e,n){return(e=qwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qwe(t){var e=Kwe(t,"string");return typeof e=="symbol"?e:e+""}function Kwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Xwe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function Ywe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,m=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,v,b;if(d==="ScatterChart")x=f,v=Tbe,b=Zr.cursorLine;else if(d==="BarChart")x=Cbe(l,f,a,o),v=JK,b=Zr.cursorRectangle;else if(l==="radial"&&Dq(f)){var{cx:y,cy:M,radius:S,startAngle:A,endAngle:E}=tX(f);x={cx:y,cy:M,startAngle:A,endAngle:E,innerRadius:S,outerRadius:S},v=rX,b=Zr.cursorLine}else x={points:x0e(l,f,a)},v=Ip,b=Zr.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,C=u_(u_(u_(u_({stroke:"#ccc",pointerEvents:"none"},a),x),Mf(c)),{},{payload:m,payloadIndex:p,className:Dn("recharts-tooltip-cursor",k)});return w.createElement(ja,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},w.createElement(Xwe,{cursor:c,cursorComp:v,cursorProps:C}))}function Qwe(t){var e=xwe(),n=IK(),r=Gf(),i=eQ();return e==null||n==null||r==null||i==null?null:w.createElement(Ywe,I3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var aQ=w.createContext(null),Zwe=()=>w.useContext(aQ),XT={exports:{}},E6;function Jwe(){return E6||(E6=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,m),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var m=0,p=f.length,x=new Array(p);m<p;m++)x[m]=f[m].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,m,p,x){var v=n?n+u:u;if(!this._events[v])return!1;var b=this._events[v],y=arguments.length,M,S;if(b.fn){switch(b.once&&this.removeListener(u,b.fn,void 0,!0),y){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,d),!0;case 3:return b.fn.call(b.context,d,f),!0;case 4:return b.fn.call(b.context,d,f,m),!0;case 5:return b.fn.call(b.context,d,f,m,p),!0;case 6:return b.fn.call(b.context,d,f,m,p,x),!0}for(S=1,M=new Array(y-1);S<y;S++)M[S-1]=arguments[S];b.fn.apply(b.context,M)}else{var A=b.length,E;for(S=0;S<A;S++)switch(b[S].once&&this.removeListener(u,b[S].fn,void 0,!0),y){case 1:b[S].fn.call(b[S].context);break;case 2:b[S].fn.call(b[S].context,d);break;case 3:b[S].fn.call(b[S].context,d,f);break;case 4:b[S].fn.call(b[S].context,d,f,m);break;default:if(!M)for(E=1,M=new Array(y-1);E<y;E++)M[E-1]=arguments[E];b[S].fn.apply(b[S].context,M)}}return!0},l.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,m){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return o(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!m||x.once)&&(!f||x.context===f)&&o(this,p);else{for(var v=0,b=[],y=x.length;v<y;v++)(x[v].fn!==d||m&&!x[v].once||f&&x[v].context!==f)&&b.push(x[v]);b.length?this._events[p]=b.length===1?b[0]:b:o(this,p)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(XT)),XT.exports}var eSe=Jwe();const tSe=ko(eSe);var _0=new tSe,F3="recharts.syncEvent.tooltip",A6="recharts.syncEvent.brush";function SM(t,e){if(e){var n=Number.parseInt(e,10);if(!gs(n))return t?.[n]}}var nSe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},sQ=xs({name:"options",initialState:nSe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),rSe=sQ.reducer,{createEventEmitter:iSe}=sQ.actions;function aSe(t){return t.tooltip.syncInteraction}var sSe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},oQ=xs({name:"chartData",initialState:sSe,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:T6,setDataStartEndIndexes:oSe,setComputedData:nXe}=oQ.actions,lSe=oQ.reducer,cSe=["x","y"];function C6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Rm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C6(Object(n),!0).forEach(function(r){uSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uSe(t,e,n){return(e=dSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dSe(t){var e=hSe(t,"string");return typeof e=="symbol"?e:e+""}function hSe(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 fSe(t,e){if(t==null)return{};var n,r,i=mSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function mSe(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 pSe(){var t=Rt(o4),e=Rt(l4),n=xr(),r=Rt(nY),i=Rt(mu),a=Gf(),o=iy(),l=Rt(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return Z0;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var m;if(o&&d!==null&&d!==void 0&&(m=d.payload)!==null&&m!==void 0&&m.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x,y:v}=p,b=fSe(p,cSe),{x:y,y:M,width:S,height:A}=d.payload.sourceViewBox,E=Rm(Rm({},b),{},{x:o.x+(S?(x-y)/S:0)*o.width,y:o.y+(A?(v-M)/A:0)*o.height});n(Rm(Rm({},d),{},{payload:Rm(Rm({},d.payload),{},{coordinate:E})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var C={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},R=r(i,C);k=i[R]}else r==="value"&&(k=i.find(Y=>String(Y.value)===d.payload.label));var{coordinate:T}=d.payload;if(k==null||d.payload.active===!1||T==null||o==null){n(O3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:P,y:F}=T,I=Math.min(P,o.x+o.width),X=Math.min(F,o.y+o.height),D={x:a==="horizontal"?k.coordinate:I,y:a==="horizontal"?X:k.coordinate},K=O3({active:d.payload.active,coordinate:D,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(K)}}};return _0.on(F3,c),()=>{_0.off(F3,c)}},[l,n,e,t,r,i,a,o])}function gSe(){var t=Rt(o4),e=Rt(l4),n=xr();w.useEffect(()=>{if(t==null)return Z0;var r=(i,a,o)=>{e!==o&&t===i&&n(oSe(a))};return _0.on(A6,r),()=>{_0.off(A6,r)}},[n,e,t])}function xSe(){var t=xr();w.useEffect(()=>{t(iSe())},[t]),pSe(),gSe()}function bSe(t,e,n,r,i,a){var o=Rt(p=>Nwe(p,t,e)),l=Rt(l4),c=Rt(o4),u=Rt(nY),d=Rt(aSe),f=d?.active,m=iy();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=O3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});_0.emit(F3,c,p,l)}},[f,n,o,i,r,l,c,u,a,m])}function k6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function j6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k6(Object(n),!0).forEach(function(r){ySe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ySe(t,e,n){return(e=vSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vSe(t){var e=_Se(t,"string");return typeof e=="symbol"?e:e+""}function _Se(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 wSe(t){return t.dataKey}function SSe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(obe,e)}var P6=[],MSe={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 z1(t){var e,n,r=Ur(t,MSe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:m,position:p,reverseDirection:x,useTranslate3d:v,wrapperStyle:b,cursor:y,shared:M,trigger:S,defaultIndex:A,portal:E,axisId:k}=r,C=xr(),R=typeof A=="number"?String(A):A;w.useEffect(()=>{C(v1e({shared:M,trigger:S,axisId:k,active:i,defaultIndex:R}))},[C,M,S,k,i,R]);var T=iy(),P=KK(),F=m1e(M),{activeIndex:I,isActive:X}=(e=Rt(he=>Twe(he,F,S,R)))!==null&&e!==void 0?e:{},D=Rt(he=>Awe(he,F,S,R)),K=Rt(he=>rQ(he,F,S,R)),Y=Rt(he=>Ewe(he,F,S,R)),q=D,Z=Zwe(),re=(n=i??X)!==null&&n!==void 0?n:!1,[ie,U]=Yq([q,re]),G=F==="axis"?K:void 0;bSe(F,S,Y,G,I,re);var ee=E??Z;if(ee==null||T==null||F==null)return null;var ne=q??P6;re||(ne=P6),u&&ne.length&&(ne=Vq(ne.filter(he=>he.value!=null&&(he.hide!==!0||r.includeHidden)),m,wSe));var se=ne.length>0,de=w.createElement(mbe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:re,coordinate:Y,hasPayload:se,offset:f,position:p,reverseDirection:x,useTranslate3d:v,viewBox:T,wrapperStyle:b,lastBoundingBox:ie,innerRef:U,hasPortalFromProps:!!E},SSe(c,j6(j6({},r),{},{payload:ne,label:G,active:re,activeIndex:I,coordinate:Y,accessibilityLayer:P})));return w.createElement(w.Fragment,null,Ic.createPortal(de,ee),re&&w.createElement(Qwe,{cursor:y,tooltipEventType:F,coordinate:Y,payload:ne,index:I}))}var wy=t=>null;wy.displayName="Cell";function NSe(t,e,n){return(e=ESe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ESe(t){var e=ASe(t,"string");return typeof e=="symbol"?e:e+""}function ASe(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 TSe{constructor(e){NSe(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 R6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function CSe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R6(Object(n),!0).forEach(function(r){kSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kSe(t,e,n){return(e=jSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jSe(t){var e=PSe(t,"string");return typeof e=="symbol"?e:e+""}function PSe(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 RSe={cacheSize:2e3,enableCache:!0},lQ=CSe({},RSe),D6=new TSe(lQ.cacheSize),DSe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},O6="recharts_measurement_span";function OSe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(o,"|").concat(l)}var L6=(t,e)=>{try{var n=document.getElementById(O6);n||(n=document.createElement("span"),n.setAttribute("id",O6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,DSe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Rb=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Rg.isSsr)return{width:0,height:0};if(!lQ.enableCache)return L6(e,n);var r=OSe(e,n),i=D6.get(r);if(i)return i;var a=L6(e,n);return D6.set(r,a),a},I6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,F6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,LSe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,ISe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,cQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},FSe=Object.keys(cQ),Tp="NaN";function USe(t,e){return t*cQ[e]}class is{static parse(e){var n,[,r,i]=(n=ISe.exec(e))!==null&&n!==void 0?n:[];return new is(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,gs(e)&&(this.unit=""),n!==""&&!LSe.test(n)&&(this.num=NaN,this.unit=""),FSe.includes(n)&&(this.num=USe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new is(NaN,""):new is(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new is(NaN,""):new is(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new is(NaN,""):new is(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new is(NaN,""):new is(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return gs(this.num)}}function uQ(t){if(t.includes(Tp))return Tp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=I6.exec(e))!==null&&n!==void 0?n:[],o=is.parse(r??""),l=is.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Tp;e=e.replace(I6,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=F6.exec(e))!==null&&u!==void 0?u:[],p=is.parse(d??""),x=is.parse(m??""),v=f==="+"?p.add(x):p.subtract(x);if(v.isNaN())return Tp;e=e.replace(F6,v.toString())}return e}var U6=/\(([^()]*)\)/;function zSe(t){for(var e=t,n;(n=U6.exec(e))!=null;){var[,r]=n;e=e.replace(U6,uQ(r))}return e}function BSe(t){var e=t.replace(/\s+/g,"");return e=zSe(e),e=uQ(e),e}function $Se(t){try{return BSe(t)}catch{return Tp}}function YT(t){var e=$Se(t.slice(5,-1));return e===Tp?"":e}var HSe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],VSe=["dx","dy","angle","className","breakAll"];function U3(){return U3=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},U3.apply(null,arguments)}function z6(t,e){if(t==null)return{};var n,r,i=GSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function GSe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var dQ=/[ \f\n\r\t\v\u2028\u2029]+/,hQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Ar(e)||(n?i=e.toString().split(""):i=e.toString().split(dQ));var a=i.map(l=>({word:l,width:Rb(l,r).width})),o=n?0:Rb(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function WSe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var fQ=(t,e,n,r)=>t.reduce((i,a)=>{var{word:o,width:l}=a,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(o),c.width+=l+n;else{var u={words:[o],width:l};i.push(u)}return i},[]),mQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),qSe="…",B6=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=hQ({breakAll:n,style:r,children:c+qSe});if(!u)return[!1,[]];var d=fQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||mQ(d).width>Number(a);return[f,d]},KSe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=Lt(a),d=String(o),f=fQ(e,r,n,i);if(!u||i)return f;var m=f.length>a||mQ(f).width>Number(r);if(!m)return f;for(var p=0,x=d.length-1,v=0,b;p<=x&&v<=d.length-1;){var y=Math.floor((p+x)/2),M=y-1,[S,A]=B6(d,M,c,l,a,r,n,i),[E]=B6(d,y,c,l,a,r,n,i);if(!S&&!E&&(p=y+1),S&&E&&(x=y-1),!S&&E){b=A;break}v++}return b||f},$6=t=>{var e=Ar(t)?[]:t.toString().split(dQ);return[{words:e,width:void 0}]},XSe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!Rg.isSsr){var l,c,u=hQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return $6(r);return KSe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return $6(r)},pQ="#808080",YSe={angle:0,breakAll:!1,capHeight:"0.71em",fill:pQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},MM=w.forwardRef((t,e)=>{var n=Ur(t,YSe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=z6(n,HSe),m=w.useMemo(()=>XSe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:p,dy:x,angle:v,className:b,breakAll:y}=f,M=z6(f,VSe);if(!Ao(r)||!Ao(i)||m.length===0)return null;var S=Number(r)+(Lt(p)?p:0),A=Number(i)+(Lt(x)?x:0);if(!tr(S)||!tr(A))return null;var E;switch(d){case"start":E=YT("calc(".concat(o,")"));break;case"middle":E=YT("calc(".concat((m.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:E=YT("calc(".concat(m.length-1," * -").concat(a,")"));break}var k=[];if(c){var C=m[0].width,{width:R}=f;k.push("scale(".concat(Lt(R)&&Lt(C)?R/C:1,")"))}return v&&k.push("rotate(".concat(v,", ").concat(S,", ").concat(A,")")),k.length&&(M.transform=k.join(" ")),w.createElement("text",U3({},ba(M),{ref:e,x:S,y:A,className:Dn("recharts-text",b),textAnchor:u,fill:l.includes("url")?pQ:l}),m.map((T,P)=>{var F=T.words.join(y?"":" ");return w.createElement("tspan",{x:S,dy:P===0?E:a,key:"".concat(F,"-").concat(P)},F)}))});MM.displayName="Text";var QSe=["labelRef"];function ZSe(t,e){if(t==null)return{};var n,r,i=JSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function JSe(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 H6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ii(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H6(Object(n),!0).forEach(function(r){e2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function e2e(t,e,n){return(e=t2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function t2e(t){var e=n2e(t,"string");return typeof e=="symbol"?e:e+""}function n2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Dc(){return Dc=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},Dc.apply(null,arguments)}var gQ=w.createContext(null),xQ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=w.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return w.createElement(gQ.Provider,{value:c},l)},bQ=()=>{var t=w.useContext(gQ),e=iy();return t||LK(e)},r2e=w.createContext(null),i2e=()=>{var t=w.useContext(r2e),e=Rt(oY);return t||e},a2e=t=>{var{value:e,formatter:n}=t,r=Ar(t.children)?e:t.children;return typeof n=="function"?n(r):r},H4=t=>t!=null&&typeof t=="function",s2e=(t,e)=>{var n=Xi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},o2e=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:m,clockWise:p}=i,x=(u+d)/2,v=s2e(f,m),b=v>=0?1:-1,y,M;switch(e){case"insideStart":y=f+b*a,M=p;break;case"insideEnd":y=m-b*a,M=!p;break;case"end":y=m+b*a,M=p;break;default:throw new Error("Unsupported position ".concat(e))}M=v<=0?M:!M;var S=gi(l,c,x,y),A=gi(l,c,x,y+(M?1:-1)*359),E="M".concat(S.x,",").concat(S.y,`
  44. A`).concat(x,",").concat(x,",0,1,").concat(M?0:1,`,
  45. `).concat(A.x,",").concat(A.y),k=Ar(t.id)?o0("recharts-radial-line-"):t.id;return w.createElement("text",Dc({},r,{dominantBaseline:"central",className:Dn("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:k,d:E})),w.createElement("textPath",{xlinkHref:"#".concat(k)},n))},l2e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=gi(r,i,o+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var m=(a+o)/2,{x:p,y:x}=gi(r,i,m,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},z3=t=>"cx"in t&&Lt(t.cx),c2e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!z3(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,m=o+(c-u)/2,p=(f+m)/2,x=(c+u)/2,v=f+c/2,b=d>=0?1:-1,y=b*r,M=b>0?"end":"start",S=b>0?"start":"end",A=c>=0?1:-1,E=A*r,k=A>0?"end":"start",C=A>0?"start":"end";if(i==="top"){var R={x:f+c/2,y:l-y,textAnchor:"middle",verticalAnchor:M};return ii(ii({},R),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var T={x:m+u/2,y:l+d+y,textAnchor:"middle",verticalAnchor:S};return ii(ii({},T),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var P={x:p-E,y:l+d/2,textAnchor:k,verticalAnchor:"middle"};return ii(ii({},P),a?{width:Math.max(P.x-a.x,0),height:d}:{})}if(i==="right"){var F={x:p+x+E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return ii(ii({},F),a?{width:Math.max(a.x+a.width-F.x,0),height:d}:{})}var I=a?{width:x,height:d}:{};return i==="insideLeft"?ii({x:p+E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},I):i==="insideRight"?ii({x:p+x-E,y:l+d/2,textAnchor:k,verticalAnchor:"middle"},I):i==="insideTop"?ii({x:f+c/2,y:l+y,textAnchor:"middle",verticalAnchor:S},I):i==="insideBottom"?ii({x:m+u/2,y:l+d-y,textAnchor:"middle",verticalAnchor:M},I):i==="insideTopLeft"?ii({x:f+E,y:l+y,textAnchor:C,verticalAnchor:S},I):i==="insideTopRight"?ii({x:f+c-E,y:l+y,textAnchor:k,verticalAnchor:S},I):i==="insideBottomLeft"?ii({x:m+E,y:l+d-y,textAnchor:C,verticalAnchor:M},I):i==="insideBottomRight"?ii({x:m+u-E,y:l+d-y,textAnchor:k,verticalAnchor:M},I):i&&typeof i=="object"&&(Lt(i.x)||tu(i.x))&&(Lt(i.y)||tu(i.y))?ii({x:o+ka(i.x,x),y:l+ka(i.y,d),textAnchor:"end",verticalAnchor:"end"},I):ii({x:v,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},I)},u2e={angle:0,offset:5,zIndex:Zr.label,position:"middle",textBreakAll:!1};function rd(t){var e=Ur(t,u2e),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=i2e(),f=bQ(),m=r==="center"?f:d??f,p,x,v;if(n==null?p=m:z3(n)?p=n:p=LK(n),!p||Ar(i)&&Ar(a)&&!w.isValidElement(o)&&typeof o!="function")return null;var b=ii(ii({},e),{},{viewBox:p});if(w.isValidElement(o)){var{labelRef:y}=b,M=ZSe(b,QSe);return w.cloneElement(o,M)}if(typeof o=="function"){if(x=w.createElement(o,b),w.isValidElement(x))return x}else x=a2e(e);var S=ba(e);if(z3(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return o2e(e,r,x,S,p);v=l2e(p,e.offset,e.position)}else v=c2e(e,p);return w.createElement(ja,{zIndex:e.zIndex},w.createElement(MM,Dc({ref:u,className:Dn("recharts-label",l)},S,v,{textAnchor:WSe(S.textAnchor)?S.textAnchor:v.textAnchor,breakAll:c}),x))}rd.displayName="Label";var d2e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(rd,Dc({key:"label-implicit"},r)):Ao(t)?w.createElement(rd,Dc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===rd?w.cloneElement(t,ii({key:"label-implicit"},r)):w.createElement(rd,Dc({key:"label-implicit",content:t},r)):H4(t)?w.createElement(rd,Dc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(rd,Dc({},t,{key:"label-implicit"},r)):null};function yQ(t){var{label:e,labelRef:n}=t,r=bQ();return d2e(e,r,n)||null}var QT={},ZT={},V6;function h2e(){return V6||(V6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(ZT)),ZT}var JT={},G6;function f2e(){return G6||(G6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(JT)),JT}var W6;function m2e(){return W6||(W6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=h2e(),n=f2e(),r=xD();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(QT)),QT}var eC,q6;function p2e(){return q6||(q6=1,eC=m2e().last),eC}var g2e=p2e();const x2e=ko(g2e);var b2e=["valueAccessor"],y2e=["dataKey","clockWise","id","textBreakAll","zIndex"];function Jw(){return Jw=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},Jw.apply(null,arguments)}function K6(t,e){if(t==null)return{};var n,r,i=v2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function v2e(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 _2e=t=>Array.isArray(t.value)?x2e(t.value):t.value,vQ=w.createContext(void 0),V4=vQ.Provider,_Q=w.createContext(void 0),w2e=_Q.Provider;function S2e(){return w.useContext(vQ)}function M2e(){return w.useContext(_Q)}function B1(t){var{valueAccessor:e=_2e}=t,n=K6(t,b2e),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=K6(n,y2e),u=S2e(),d=M2e(),f=u||d;return!f||!f.length?null:w.createElement(ja,{zIndex:l??Zr.label},w.createElement(Fr,{className:"recharts-label-list"},f.map((m,p)=>{var x,v=Ar(r)?e(m,p):er(m&&m.payload,r),b=Ar(a)?{}:{id:"".concat(a,"-").concat(p)};return w.createElement(rd,Jw({key:"label-".concat(p)},ba(m),c,b,{fill:(x=n.fill)!==null&&x!==void 0?x:m.fill,parentViewBox:m.parentViewBox,value:v,textBreakAll:o,viewBox:m.viewBox,index:p,zIndex:0}))})))}B1.displayName="LabelList";function NM(t){var{label:e}=t;return e?e===!0?w.createElement(B1,{key:"labelList-implicit"}):w.isValidElement(e)||H4(e)?w.createElement(B1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(B1,Jw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function B3(){return B3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},B3.apply(null,arguments)}var wQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=Dn("recharts-dot",i);return Lt(e)&&Lt(n)&&Lt(r)?w.createElement("circle",B3({},Va(t),gD(t),{className:a,cx:e,cy:n,r})):null},SQ=t=>t.graphicalItems.polarItems,N2e=Ze([Dr,hy],f4),EM=Ze([SQ,zr,N2e],m4),E2e=Ze([EM],p4),AM=Ze([E2e,r4],g4),A2e=Ze([AM,zr,EM],b4);Ze([AM,zr,EM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=er(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:er(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var X6=()=>{},T2e=Ze([AM,zr,EM,vM,Dr],w4),C2e=Ze([zr,v4,_4,X6,T2e,X6,An,Dr],S4),MQ=Ze([zr,An,AM,A2e,dy,Dr,C2e],M4),k2e=Ze([MQ,zr,Bg],A4);Ze([zr,MQ,k2e,Dr],C4);var j2e={radiusAxis:{},angleAxis:{}},NQ=xs({name:"polarAxis",initialState:j2e,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:rXe,removeRadiusAxis:iXe,addAngleAxis:aXe,removeAngleAxis:sXe}=NQ.actions,P2e=NQ.reducer;function Y6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Q6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y6(Object(n),!0).forEach(function(r){R2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R2e(t,e,n){return(e=D2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D2e(t){var e=O2e(t,"string");return typeof e=="symbol"?e:e+""}function O2e(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 L2e=(t,e)=>e,G4=Ze([SQ,L2e],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),I2e=[],W4=(t,e,n)=>n?.length===0?I2e:n,EQ=Ze([r4,G4,W4],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>Q6(Q6({},e.presentationProps),a.props))),i!=null)return i}}),F2e=Ze([EQ,G4,W4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=er(r,e.nameKey,e.name),l;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Yd(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),U2e=Ze([EQ,G4,W4,ji],(t,e,n,r)=>{if(!(e==null||t==null))return zMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),tC={exports:{}},ar={};var Z6;function z2e(){if(Z6)return ar;Z6=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(v){if(typeof v=="object"&&v!==null){var b=v.$$typeof;switch(b){case t:switch(v=v.type,v){case n:case i:case r:case c:case u:case m:return v;default:switch(v=v&&v.$$typeof,v){case o:case l:case f:case d:return v;case a:return v;default:return b}}case e:return b}}}return ar.ContextConsumer=a,ar.ContextProvider=o,ar.Element=t,ar.ForwardRef=l,ar.Fragment=n,ar.Lazy=f,ar.Memo=d,ar.Portal=e,ar.Profiler=i,ar.StrictMode=r,ar.Suspense=c,ar.SuspenseList=u,ar.isContextConsumer=function(v){return x(v)===a},ar.isContextProvider=function(v){return x(v)===o},ar.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},ar.isForwardRef=function(v){return x(v)===l},ar.isFragment=function(v){return x(v)===n},ar.isLazy=function(v){return x(v)===f},ar.isMemo=function(v){return x(v)===d},ar.isPortal=function(v){return x(v)===e},ar.isProfiler=function(v){return x(v)===i},ar.isStrictMode=function(v){return x(v)===r},ar.isSuspense=function(v){return x(v)===c},ar.isSuspenseList=function(v){return x(v)===u},ar.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===d||v.$$typeof===o||v.$$typeof===a||v.$$typeof===l||v.$$typeof===p||v.getModuleId!==void 0)},ar.typeOf=x,ar}var J6;function B2e(){return J6||(J6=1,tC.exports=z2e()),tC.exports}var $2e=B2e(),e$=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",t$=null,nC=null,AQ=t=>{if(t===t$&&Array.isArray(nC))return nC;var e=[];return w.Children.forEach(t,n=>{Ar(n)||($2e.isFragment(n)?e=e.concat(AQ(n.props.children)):e.push(n))}),nC=e,t$=t,e};function q4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>e$(i)):r=[e$(e)],AQ(t).forEach(i=>{var a=Nf(i,"type.displayName")||Nf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var K4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,rC={},n$;function H2e(){return n$||(n$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})(rC)),rC}var iC,r$;function V2e(){return r$||(r$=1,iC=H2e().isPlainObject),iC}var G2e=V2e();const W2e=ko(G2e);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 a$(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){q2e(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 q2e(t,e,n){return(e=K2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function K2e(t){var e=X2e(t,"string");return typeof e=="symbol"?e:e+""}function X2e(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 eS(){return eS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},eS.apply(null,arguments)}var s$=(t,e,n,r,i)=>{var a=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-a/2,",").concat(e+i),o+="L ".concat(t+n-a/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},Y2e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Q2e=t=>{var e=Ur(t,Y2e),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,m=w.useRef(null),[p,x]=w.useState(-1),v=w.useRef(i),b=w.useRef(a),y=w.useRef(o),M=w.useRef(n),S=w.useRef(r),A=Og(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var D=m.current.getTotalLength();D&&x(D)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var E=Dn("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",eS({},ba(e),{className:E,d:s$(n,r,i,a,o)})));var k=v.current,C=b.current,R=y.current,T=M.current,P=S.current,F="0px ".concat(p===-1?1:p,"px"),I="".concat(p,"px 0px"),X=XK(["strokeDasharray"],u,c);return w.createElement(Dg,{animationId:A,key:A,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},D=>{var K=Wn(k,i,D),Y=Wn(C,a,D),q=Wn(R,o,D),Z=Wn(T,n,D),re=Wn(P,r,D);m.current&&(v.current=K,b.current=Y,y.current=q,M.current=Z,S.current=re);var ie=D>0?{transition:X,strokeDasharray:I}:{strokeDasharray:F};return w.createElement("path",eS({},ba(e),{className:E,d:s$(Z,re,K,Y,q),ref:m,style:a$(a$({},ie),e.style)}))})},Z2e=["option","shapeType","propTransformer","activeClassName"];function J2e(t,e){if(t==null)return{};var n,r,i=eMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function eMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function o$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o$(Object(n),!0).forEach(function(r){tMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tMe(t,e,n){return(e=nMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nMe(t){var e=rMe(t,"string");return typeof e=="symbol"?e:e+""}function rMe(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 iMe(t,e){return tS(tS({},e),t)}function aMe(t,e){return t==="symbols"}function l$(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(JK,n);case"trapezoid":return w.createElement(Q2e,n);case"sector":return w.createElement(rX,n);case"symbols":if(aMe(e))return w.createElement(pD,n);break;case"curve":return w.createElement(Ip,n);default:return null}}function sMe(t){return w.isValidElement(t)?t.props:t}function X4(t){var{option:e,shapeType:n,propTransformer:r=iMe,activeClassName:i="recharts-active-shape"}=t,a=J2e(t,Z2e),o;if(w.isValidElement(e))o=w.cloneElement(e,tS(tS({},a),sMe(e)));else if(typeof e=="function")o=e(a,a.index);else if(W2e(e)&&typeof e!="boolean"){var l=r(e,a);o=w.createElement(l$,{shapeType:n,elementProps:l})}else{var c=a;o=w.createElement(l$,{shapeType:n,elementProps:c})}return a.isActive?w.createElement(Fr,{className:i},o):o}var Y4=(t,e,n)=>{var r=xr();return(i,a)=>o=>{t?.(i,a,o),r(FY({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},Q4=t=>{var e=xr();return(n,r)=>i=>{t?.(n,r,i),e(_1e())}},Z4=(t,e,n)=>{var r=xr();return(i,a)=>o=>{t?.(i,a,o),r(w1e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function TM(t){var{tooltipEntrySettings:e}=t,n=xr(),r=Pi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(x1e(e)):i.current!==e&&n(b1e({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(y1e(i.current)),i.current=null)},[n]),null}function J4(t){var{legendPayload:e}=t,n=xr(),r=Pi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(GK(e)):i.current!==e&&n(WK({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(qK(i.current)),i.current=null)},[n]),null}function oMe(t){var{legendPayload:e}=t,n=xr(),r=Rt(An),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(GK(e)):i.current!==e&&n(WK({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(qK(i.current)),i.current=null)},[n]),null}var aC,lMe=()=>{var[t]=w.useState(()=>o0("uid-"));return t},cMe=(aC=Sae.useId)!==null&&aC!==void 0?aC:lMe;function TQ(t,e){var n=cMe();return e||(t?"".concat(t,"-").concat(n):n)}var uMe=w.createContext(void 0),CM=t=>{var{id:e,type:n,children:r}=t,i=TQ("recharts-".concat(n),e);return w.createElement(uMe.Provider,{value:i},r(i))},dMe={cartesianItems:[],polarItems:[]},CQ=xs({name:"graphicalItems",initialState:dMe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:kr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Zo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:kr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Zo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:kr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:kr()},removePolarGraphicalItem:{reducer(t,e){var n=Zo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:kr()}}}),{addCartesianGraphicalItem:hMe,replaceCartesianGraphicalItem:fMe,removeCartesianGraphicalItem:mMe,addPolarGraphicalItem:pMe,removePolarGraphicalItem:gMe}=CQ.actions,xMe=CQ.reducer,bMe=t=>{var e=xr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(hMe(t)):n.current!==t&&e(fMe({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(mMe(n.current)),n.current=null)},[e]),null},eO=w.memo(bMe);function yMe(t){var e=xr();return w.useLayoutEffect(()=>(e(pMe(t)),()=>{e(gMe(t))}),[e,t]),null}var vMe=["key"],_Me=["onMouseEnter","onClick","onMouseLeave"],wMe=["id"],SMe=["id"];function c$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Kr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c$(Object(n),!0).forEach(function(r){MMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MMe(t,e,n){return(e=NMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NMe(t){var e=EMe(t,"string");return typeof e=="symbol"?e:e+""}function EMe(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 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 kM(t,e){if(t==null)return{};var n,r,i=AMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function AMe(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 TMe(t){var e=w.useMemo(()=>q4(t.children,wy),[t.children]),n=Rt(r=>F2e(r,t.id,e));return n==null?null:w.createElement(oMe,{legendPayload:n})}var CMe=w.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:o,dataKey:e,nameKey:n,name:Yd(l,e),hide:c,type:u,color:o,unit:""}};return w.createElement(TM,{tooltipEntrySettings:d})}),kMe=(t,e)=>t>e?"start":t<e?"end":"middle",jMe=(t,e,n)=>ka(typeof e=="function"?e(t):e,n,n*.8),PMe=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=eX(a,o),c=i+ka(t.cx,a,a/2),u=r+ka(t.cy,o,o/2),d=ka(t.innerRadius,l,0),f=jMe(n,t.outerRadius,l),m=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:m}},RMe=(t,e)=>{var n=Xi(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function DMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var OMe=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Dn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=kM(e,vMe);return w.createElement(Ip,zd({},i,{type:"linear",className:n}))},LMe=(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=Dn("recharts-pie-label-text",DMe(t));return w.createElement(MM,zd({},e,{alignmentBaseline:"middle",className:i}),r)};function IMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=Va(n),c=Mf(i),u=Mf(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((m,p)=>{var x=(m.startAngle+m.endAngle)/2,v=gi(m.cx,m.cy,m.outerRadius+d,x),b=Kr(Kr(Kr(Kr({},l),m),{},{stroke:"none"},c),{},{index:p,textAnchor:kMe(v.x,m.cx)},v),y=Kr(Kr(Kr(Kr({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:p,points:[gi(m.cx,m.cy,m.outerRadius,x),v],key:"line"});return w.createElement(ja,{zIndex:Zr.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(p)},w.createElement(Fr,null,a&&OMe(a,y),LMe(i,b,er(m,o))))});return w.createElement(Fr,{className:"recharts-pie-labels"},f)}function FMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(NM,{label:i}):w.createElement(IMe,{sectors:e,props:n,showLabels:r})}function UMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Rt(Ud),c=Rt(F4),u=Rt(owe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,p=kM(i,_Me),x=Y4(d,i.dataKey,o),v=Q4(m),b=Z4(f,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((y,M)=>{if(y?.startAngle===0&&y?.endAngle===0&&e.length!==1)return null;var S=u==null||u===o,A=String(M)===l&&(c==null||i.dataKey===c)&&S,E=l?r:null,k=n&&A?n:E,C=Kr(Kr({},y),{},{stroke:y.stroke,tabIndex:-1,[jK]:M,[PK]:i.dataKey});return w.createElement(Fr,zd({key:"sector-".concat(y?.startAngle,"-").concat(y?.endAngle,"-").concat(y.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},J0(p,y,M),{onMouseEnter:x(y,M),onMouseLeave:v(y,M),onClick:b(y,M)}),w.createElement(X4,zd({option:a??k,index:M,shapeType:"sector",isActive:A},C)))}))}function zMe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,m=Math.abs(n.minAngle),p=RMe(l,c),x=Math.abs(p),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(k=>er(k,u,0)!==0).length,y=(x>=360?b:b-1)*v,M=x-b*m-y,S=r.reduce((k,C)=>{var R=er(C,u,0);return k+(Lt(R)?R:0)},0),A;if(S>0){var E;A=r.map((k,C)=>{var R=er(k,u,0),T=er(k,d,C),P=PMe(n,a,k),F=(Lt(R)?R:0)/S,I,X=Kr(Kr({},k),i&&i[C]&&i[C].props);C?I=E.endAngle+Xi(p)*v*(R!==0?1:0):I=l;var D=I+Xi(p)*((R!==0?m:0)+F*M),K=(I+D)/2,Y=(P.innerRadius+P.outerRadius)/2,q=[{name:T,value:R,payload:X,dataKey:u,type:f}],Z=gi(P.cx,P.cy,Y,K);return E=Kr(Kr(Kr(Kr({},n.presentationProps),{},{percent:F,cornerRadius:typeof o=="string"?parseFloat(o):o,name:T,tooltipPayload:q,midAngle:K,middleRadius:Y,tooltipPosition:Z},X),P),{},{value:R,dataKey:u,startAngle:I,endAngle:D,payload:X,paddingAngle:Xi(p)*v}),E})}return A}function BMe(t){var{showLabels:e,sectors:n,children:r}=t,i=w.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return w.createElement(w2e,{value:e?i:void 0},r)}function $Me(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:m}=e,p=Og(e,"recharts-pie-"),x=n.current,[v,b]=w.useState(!1),y=w.useCallback(()=>{typeof m=="function"&&m(),b(!1)},[m]),M=w.useCallback(()=>{typeof f=="function"&&f(),b(!0)},[f]);return w.createElement(BMe,{showLabels:!v,sectors:i},w.createElement(Dg,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:M,onAnimationEnd:y,key:p},S=>{var A=[],E=i&&i[0],k=E?.startAngle;return i?.forEach((C,R)=>{var T=x&&x[R],P=R>0?Nf(C,"paddingAngle",0):0;if(T){var F=Wn(T.endAngle-T.startAngle,C.endAngle-C.startAngle,S),I=Kr(Kr({},C),{},{startAngle:k+P,endAngle:k+F+P});A.push(I),k=I.endAngle}else{var{endAngle:X,startAngle:D}=C,K=Wn(0,X-D,S),Y=Kr(Kr({},C),{},{startAngle:k+P,endAngle:k+K+P});A.push(Y),k=Y.endAngle}}),n.current=A,w.createElement(Fr,null,w.createElement(UMe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(FMe,{showLabels:!v,sectors:i,props:e}),e.children)}var HMe={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:Zr.area};function VMe(t){var{id:e}=t,n=kM(t,wMe),{hide:r,className:i,rootTabIndex:a}=t,o=w.useMemo(()=>q4(t.children,wy),[t.children]),l=Rt(d=>U2e(d,e,o)),c=w.useRef(null),u=Dn("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(Fr,{tabIndex:a,className:u})):w.createElement(ja,{zIndex:t.zIndex},w.createElement(CMe,{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(Fr,{tabIndex:a,className:u},w.createElement($Me,{props:Kr(Kr({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function kQ(t){var e=Ur(t,HMe),{id:n}=e,r=kM(e,SMe),i=Va(r);return w.createElement(CM,{id:n,type:"pie"},a=>w.createElement(w.Fragment,null,w.createElement(yMe,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),w.createElement(TMe,zd({},r,{id:a})),w.createElement(VMe,zd({},r,{id:a}))))}kQ.displayName="Pie";var GMe=["points"];function u$(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 sC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u$(Object(n),!0).forEach(function(r){WMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function WMe(t,e,n){return(e=qMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qMe(t){var e=KMe(t,"string");return typeof e=="symbol"?e:e+""}function KMe(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 nS(){return nS=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},nS.apply(null,arguments)}function XMe(t,e){if(t==null)return{};var n,r,i=YMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function YMe(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 QMe(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=Dn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=XMe(a,GMe);return w.createElement(wQ,nS({},l,{className:i}))}function ZMe(t,e){return t==null?!1:e?!0:t.length===1}function jQ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=Zr.scatter}=t;if(!ZMe(e,n))return null;var d=K4(n),f=Cfe(n),m=e.map((x,v)=>{var b,y,M=sC(sC(sC({r:3},o),f),{},{index:v,cx:(b=x.x)!==null&&b!==void 0?b:void 0,cy:(y=x.y)!==null&&y!==void 0?y:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return w.createElement(QMe,{key:"dot-".concat(v),option:n,dotProps:M,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement(ja,{zIndex:u},w.createElement(Fr,nS({className:r},p),m))}function d$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function h$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d$(Object(n),!0).forEach(function(r){JMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JMe(t,e,n){return(e=eNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eNe(t){var e=tNe(t,"string");return typeof e=="symbol"?e:e+""}function tNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var nNe={xAxis:{},yAxis:{},zAxis:{}},PQ=xs({name:"cartesianAxis",initialState:nNe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:kr()},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:kr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:kr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:kr()},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:kr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:kr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:kr()},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:kr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:kr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var o=[...a,r].slice(-3);t.yAxis[n]=h$(h$({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:rNe,replaceXAxis:iNe,removeXAxis:aNe,addYAxis:sNe,replaceYAxis:oNe,removeYAxis:lNe,addZAxis:oXe,replaceZAxis:lXe,removeZAxis:cXe,updateYAxisWidth:cNe}=PQ.actions,uNe=PQ.reducer,dNe=Ze([ji],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),hNe=Ze([dNe,du,hu],(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)}}),jM=()=>Rt(hNe),fNe=()=>Rt(hwe);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 oC(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){mNe(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 mNe(t,e,n){return(e=pNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pNe(t){var e=gNe(t,"string");return typeof e=="symbol"?e:e+""}function gNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var xNe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=oC(oC(oC({},l),Mf(i)),gD(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(wQ,c),w.createElement(Fr,{className:"recharts-active-dot",clipPath:o},u)};function $3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=Zr.activeDot}=t,l=Rt(Ud),c=fNe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Ar(u)?null:w.createElement(ja,{zIndex:o},w.createElement(xNe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var bNe="Invariant failed";function yNe(t,e){throw new Error(bNe)}var vNe=["x","y"];function H3(){return H3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},H3.apply(null,arguments)}function m$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Qx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m$(Object(n),!0).forEach(function(r){_Ne(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _Ne(t,e,n){return(e=wNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wNe(t){var e=SNe(t,"string");return typeof e=="symbol"?e:e+""}function SNe(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 MNe(t,e){if(t==null)return{};var n,r,i=NNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function NNe(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 ENe(t,e){var{x:n,y:r}=t,i=MNe(t,vNe),a="".concat(n),o=parseInt(a,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),m=parseInt(f,10);return Qx(Qx(Qx(Qx(Qx({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:m,name:e.name,radius:e.radius})}function rS(t){return w.createElement(X4,H3({shapeType:"rectangle",propTransformer:ENe,activeClassName:"recharts-active-bar"},t))}var ANe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Lt(e))return e;var a=Lt(r)||Ar(r);return a?e(r,i):(a||yNe(),n)}},TNe={},RQ=xs({name:"errorBars",initialState:TNe,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:uXe,replaceErrorBar:dXe,removeErrorBar:hXe}=RQ.actions,CNe=RQ.reducer,kNe=["children"];function jNe(t,e){if(t==null)return{};var n,r,i=PNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PNe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var RNe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},DNe=w.createContext(RNe);function DQ(t){var{children:e}=t,n=jNe(t,kNe);return w.createElement(DNe.Provider,{value:n},e)}function PM(t,e){var n,r,i=Rt(u=>ql(u,t)),a=Rt(u=>Kl(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Hi.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Vi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function tO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=jM(),{needClipX:a,needClipY:o,needClip:l}=PM(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}function ONe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&tr(t.zIndex)?t.zIndex:e}var lC={exports:{}},cC={};var p$;function LNe(){if(p$)return cC;p$=1;var t=Ag();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return cC.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=o(function(){function b(E){if(!y){if(y=!0,M=E,E=f(E),m!==void 0&&x.hasValue){var k=x.value;if(m(k,E))return S=k}return S=E}if(k=S,n(M,E))return k;var C=f(E);return m!==void 0&&m(k,C)?(M=E,k):(M=E,S=C)}var y=!1,M,S,A=d===void 0?null:d;return[function(){return b(u())},A===null?void 0:function(){return b(A())}]},[u,d,f,m]);var v=r(c,p[0],p[1]);return a(function(){x.hasValue=!0,x.value=v},[v]),l(v),v},cC}var g$;function INe(){return g$||(g$=1,lC.exports=LNe()),lC.exports}INe();function FNe(t){t()}function UNe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){FNe(()=>{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 x$={notify(){},get:()=>[]};function zNe(t,e){let n,r=x$,i=0,a=!1;function o(v){d();const b=r.subscribe(v);let y=!1;return()=>{y||(y=!0,b(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=UNe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=x$)}function m(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:m,tryUnsubscribe:p,getListeners:()=>r};return x}var BNe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",$Ne=BNe(),HNe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",VNe=HNe(),GNe=()=>$Ne||VNe?w.useLayoutEffect:w.useEffect,WNe=GNe();function b$(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function qNe(t,e){if(b$(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])||!b$(t[n[i]],e[n[i]]))return!1;return!0}var KNe=Symbol.for("react-redux-context"),XNe=typeof globalThis<"u"?globalThis:{};function YNe(){if(!w.createContext)return{};const t=XNe[KNe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var QNe=YNe();function ZNe(t){const{children:e,context:n,serverState:r,store:i}=t,a=w.useMemo(()=>{const c=zNe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);WNe(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,o]);const l=n||QNe;return w.createElement(l.Provider,{value:a},e)}var JNe=ZNe,eEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function tEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Sy(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(eEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!qNe(t[r],e[r]))return!1}else if(!tEe(t[r],e[r]))return!1;return!0}var nEe=["onMouseEnter","onMouseLeave","onClick"],rEe=["value","background","tooltipPosition"],iEe=["id"],aEe=["onMouseEnter","onClick","onMouseLeave"];function ou(){return ou=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},ou.apply(null,arguments)}function y$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Fa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y$(Object(n),!0).forEach(function(r){sEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sEe(t,e,n){return(e=oEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oEe(t){var e=lEe(t,"string");return typeof e=="symbol"?e:e+""}function lEe(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 iS(t,e){if(t==null)return{};var n,r,i=cEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function cEe(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 uEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Yd(n,e),payload:t}]},dEe=w.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Yd(a,e),hide:o,type:c,color:i,unit:l}};return w.createElement(TM,{tooltipEntrySettings:u})});function hEe(t){var e=Rt(Ud),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=iS(a,nEe),d=Y4(o,r),f=Q4(l),m=Z4(c,r);if(!i||n==null)return null;var p=Mf(i);return w.createElement(ja,{zIndex:ONe(i,Zr.barBackground)},n.map((x,v)=>{var{value:b,background:y,tooltipPosition:M}=x,S=iS(x,rEe);if(!y)return null;var A=d(x,v),E=f(x,v),k=m(x,v),C=Fa(Fa(Fa(Fa(Fa({option:i,isActive:String(v)===e},S),{},{fill:"#eee"},y),p),J0(u,x,v)),{},{onMouseEnter:A,onMouseLeave:E,onClick:k,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return w.createElement(rS,ou({key:"background-bar-".concat(v)},C))}))}function fEe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var o={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return Fa(Fa({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return w.createElement(V4,{value:e?i:void 0},n)}function mEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Rt(Ud),c=Rt(F4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(ja,{zIndex:Zr.activeBar},w.createElement(rS,ou({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):w.createElement(rS,ou({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function pEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return w.createElement(rS,ou({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function gEe(t){var e,{data:n,props:r}=t,i=(e=Va(r))!==null&&e!==void 0?e:{},{id:a}=i,o=iS(i,iEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,p=iS(r,aEe),x=Y4(d,c),v=Q4(m),b=Z4(f,c);return n?w.createElement(w.Fragment,null,n.map((y,M)=>w.createElement(Fr,ou({key:"rectangle-".concat(y?.x,"-").concat(y?.y,"-").concat(y?.value,"-").concat(M),className:"recharts-bar-rectangle"},J0(p,y,M),{onMouseEnter:x(y,M),onMouseLeave:v(y,M),onClick:b(y,M)}),u?w.createElement(mEe,{shape:l,activeBar:u,baseProps:o,entry:y,index:M,dataKey:c}):w.createElement(pEe,{shape:l,baseProps:o,entry:y,index:M,dataKey:c})))):null}function xEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,m=Og(e,"recharts-bar-"),[p,x]=w.useState(!1),v=!p,b=w.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),y=w.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return w.createElement(fEe,{showLabels:v,rects:r},w.createElement(Dg,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:b,onAnimationStart:y,key:m},M=>{var S=M===1?r:r?.map((A,E)=>{var k=f&&f[E];if(k)return Fa(Fa({},A),{},{x:Wn(k.x,A.x,M),y:Wn(k.y,A.y,M),width:Wn(k.width,A.width,M),height:Wn(k.height,A.height,M)});if(i==="horizontal"){var C=Wn(0,A.height,M),R=Wn(A.stackedBarStart,A.y,M);return Fa(Fa({},A),{},{y:R,height:C})}var T=Wn(0,A.width,M),P=Wn(A.stackedBarStart,A.x,M);return Fa(Fa({},A),{},{width:T,x:P})});return M>0&&(n.current=S??null),S==null?null:w.createElement(Fr,null,w.createElement(gEe,{props:e,data:S}))}),w.createElement(NM,{label:e.label}),e.children)}function bEe(t){var e=w.useRef(null);return w.createElement(xEe,{previousRectanglesRef:e,props:t})}var OQ=0,yEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:er(t,e)}};class vEe extends w.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=Dn("recharts-bar",i),f=u;return w.createElement(Fr,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(tO,{clipPathId:f,xAxisId:a,yAxisId:o})),w.createElement(Fr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement(hEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(bEe,this.props)))}}var _Ee={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:OQ,xAxisId:0,yAxisId:0,zIndex:Zr.bar};function wEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=PM(e,n),m=Gf(),p=Pi(),x=q4(t.children,wy),v=Rt(M=>YEe(M,e,n,p,t.id,x));if(m!=="vertical"&&m!=="horizontal")return null;var b,y=v?.[0];return y==null||y.height==null||y.width==null?b=0:b=m==="vertical"?y.height/2:y.width/2,w.createElement(DQ,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:yEe,errorBarOffset:b},w.createElement(vEe,ou({},t,{layout:m,needClip:f,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function SEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:m,cells:p,parentViewBox:x,dataStartIndex:v}=t,b=e==="horizontal"?l:o,y=d?b.scale.domain():null,M=Wge({numericAxis:b}),S=b.scale(M);return f.map((A,E)=>{var k,C,R,T,P,F;d?k=Bge(d[E+v],y):(k=er(A,n),Array.isArray(k)||(k=[M,k]));var I=ANe(r,OQ)(k[1],E);if(e==="horizontal"){var X,[D,K]=[l.scale(k[0]),l.scale(k[1])];C=LB({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:A,index:E}),R=(X=K??D)!==null&&X!==void 0?X:void 0,T=i.size;var Y=D-K;if(P=gs(Y)?0:Y,F={x:C,y:m.top,width:T,height:m.height},Math.abs(I)>0&&Math.abs(P)<Math.abs(I)){var q=Xi(P||I)*(Math.abs(I)-Math.abs(P));R-=q,P+=q}}else{var[Z,re]=[o.scale(k[0]),o.scale(k[1])];if(C=Z,R=LB({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:A,index:E}),T=re-Z,P=i.size,F={x:m.left,y:R,width:m.width,height:P},Math.abs(I)>0&&Math.abs(T)<Math.abs(I)){var ie=Xi(T||I)*(Math.abs(I)-Math.abs(T));T+=ie}}if(C==null||R==null||T==null||P==null)return null;var U=Fa(Fa({},A),{},{stackedBarStart:S,x:C,y:R,width:T,height:P,value:d?k:k[1],payload:A,background:F,tooltipPosition:{x:C+T/2,y:R+P/2},parentViewBox:x},p&&p[E]&&p[E].props);return U}).filter(Boolean)}function MEe(t){var e=Ur(t,_Ee),n=Pi();return w.createElement(CM,{id:e.id,type:"bar"},r=>w.createElement(w.Fragment,null,w.createElement(J4,{legendPayload:uEe(e)}),w.createElement(dEe,{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(eO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:CK(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),w.createElement(ja,{zIndex:e.zIndex},w.createElement(wEe,ou({},e,{id:r})))))}var LQ=w.memo(MEe,Sy);LQ.displayName="Bar";function v$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function d_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v$(Object(n),!0).forEach(function(r){NEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function NEe(t,e,n){return(e=EEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EEe(t){var e=AEe(t,"string");return typeof e=="symbol"?e:e+""}function AEe(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 TEe=(t,e)=>e,CEe=(t,e,n)=>n,kEe=(t,e,n,r)=>r,jEe=(t,e,n,r,i)=>i,My=Ze([my,jEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),PEe=Ze([My],t=>t?.maxBarSize),REe=(t,e,n,r,i,a)=>a,_$=(t,e,n)=>{var r=n??t;if(!Ar(r))return ka(r,e,0)},DEe=Ze([An,my,TEe,CEe,kEe],(t,e,n,r,i)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),OEe=(t,e,n,r)=>{var i=An(t);return i==="horizontal"?v0(t,"yAxis",n,r):v0(t,"xAxis",e,r)},LEe=(t,e,n)=>{var r=An(t);return r==="horizontal"?p6(t,"xAxis",e):p6(t,"yAxis",n)},IEe=(t,e,n)=>{var r={},i=t.filter(gM),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,f]=u,m=f.map(x=>x.dataKey),p=_$(e,n,f[0].barSize);return{stackId:d,dataKeys:m,barSize:p}}),c=a.map(u=>{var d=[u.dataKey].filter(m=>m!=null),f=_$(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},FEe=Ze([DEe,c_e,LEe],IEe),UEe=(t,e,n,r,i)=>{var a,o,l=My(t,e,n,r,i);if(l!=null){var c=An(t),u=JX(t),{maxBarSize:d}=l,f=Ar(d)?u:d,m,p;return c==="horizontal"?(m=Ul(t,"xAxis",e,r),p=Fl(t,"xAxis",e,r)):(m=Ul(t,"yAxis",n,r),p=Fl(t,"yAxis",n,r)),(a=(o=Ld(m,p,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},IQ=(t,e,n,r)=>{var i=An(t),a,o;return i==="horizontal"?(a=Ul(t,"xAxis",e,r),o=Fl(t,"xAxis",e,r)):(a=Ul(t,"yAxis",n,r),o=Fl(t,"yAxis",n,r)),Ld(a,o)};function zEe(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=ka(t,n,0,!0),l,c=[];if(tr(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((y,M)=>y+(M.barSize||0),0);f+=(a-1)*o,f>=n&&(f-=(a-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var m=(n-f)/2>>0,p={offset:m-o,size:0};l=r.reduce((y,M)=>{var S,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:p.offset+p.size+o,size:u?d:(S=M.barSize)!==null&&S!==void 0?S:0}},E=[...y,A];return p=E[E.length-1].position,E},c)}else{var x=ka(e,n,0,!0);n-2*x-(a-1)*o<=0&&(o=0);var v=(n-2*x-(a-1)*o)/a;v>1&&(v>>=0);var b=tr(i)?Math.min(v,i):v;l=r.reduce((y,M,S)=>[...y,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:x+(v+o)*S+(v-b)/2,size:b}}],c)}return l}}var BEe=(t,e,n,r,i,a,o)=>{var l=Ar(o)?e:o,c=zEe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>d_(d_({},u),{},{position:d_(d_({},u.position),{},{offset:u.position.offset-i/2})}))),c},$Ee=Ze([FEe,JX,l_e,eY,UEe,IQ,PEe],BEe),HEe=(t,e,n,r)=>Ul(t,"xAxis",e,r),VEe=(t,e,n,r)=>Ul(t,"yAxis",n,r),GEe=(t,e,n,r)=>Fl(t,"xAxis",e,r),WEe=(t,e,n,r)=>Fl(t,"yAxis",n,r),qEe=Ze([$Ee,My],(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}}),KEe=(t,e)=>{var n=pM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(o=>o.key===n)}}}},XEe=Ze([OEe,My],KEe),YEe=Ze([ji,AD,HEe,VEe,GEe,WEe,qEe,An,uy,IQ,XEe,My,REe],(t,e,n,r,i,a,o,l,c,u,d,f,m)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:v}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:b}=f,y;if(b!=null&&b.length>0?y=b:y=p?.slice(x,v+1),y!=null)return SEe({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:y,offset:t,cells:m,dataStartIndex:x})}}),FQ=t=>{var{chartData:e}=t,n=xr(),r=Pi();return w.useEffect(()=>r?()=>{}:(n(T6(e)),()=>{n(T6(void 0))}),[e,n,r]),null},w$={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},UQ=xs({name:"brush",initialState:w$,reducers:{setBrushSettings(t,e){return e.payload==null?w$:e.payload}}}),{setBrushSettings:fXe}=UQ.actions,QEe=UQ.reducer;function S$(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 h_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S$(Object(n),!0).forEach(function(r){zQ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zQ(t,e,n){return(e=ZEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZEe(t){var e=JEe(t,"string");return typeof e=="symbol"?e:e+""}function JEe(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 eAe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},tAe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return eAe({x:e,y:n},{x:r,y:i})};class RM{static create(e){return new RM(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+o}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}zQ(RM,"EPS",1e-4);var nAe=t=>{var e=Object.keys(t).reduce((n,r)=>h_(h_({},n),{},{[r]:RM.create(t[r])}),{});return h_(h_({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[o,l]=a;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function rAe(t){return(t%180+180)%180}var iAe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=rAe(i),o=a*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},aAe={dots:[],areas:[],lines:[]},BQ=xs({name:"referenceElements",initialState:aAe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Zo(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=Zo(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=Zo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:mXe,removeDot:pXe,addArea:gXe,removeArea:xXe,addLine:sAe,removeLine:oAe}=BQ.actions,lAe=BQ.reducer,$Q=w.createContext(void 0),cAe=t=>{var{children:e}=t,[n]=w.useState("".concat(o0("recharts"),"-clip")),r=jM();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return w.createElement($Q.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},uAe=()=>w.useContext($Q);function M$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function N$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M$(Object(n),!0).forEach(function(r){dAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dAe(t,e,n){return(e=hAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hAe(t){var e=fAe(t,"string");return typeof e=="symbol"?e:e+""}function fAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function aS(){return aS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},aS.apply(null,arguments)}var mAe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!tr(e.x1)||!tr(e.y1)||!tr(e.x2)||!tr(e.y2))return null;n=w.createElement("line",aS({},e,{className:"recharts-reference-line-line"}))}return n},pAe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if(gs(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},gAe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if(gs(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},xAe=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},bAe=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=Ao(o),f=Ao(l);return f?pAe(l,u,n,i,t,e):d?gAe(o,u,n,r,t,e):c!=null&&c.length===2?xAe(c,u,n,t):null};function yAe(t){var e=xr();return w.useEffect(()=>(e(sAe(t)),()=>{e(oAe(t))})),null}function vAe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Pi(),l=uAe(),c=Rt(k=>ql(k,e)),u=Rt(k=>Kl(k,n)),d=Rt(k=>Fd(k,"xAxis",e,o)),f=Rt(k=>Fd(k,"yAxis",n,o)),m=iy();if(!l||!m||c==null||u==null||d==null||f==null)return null;var p=nAe({x:d,y:f}),x=bAe(p,m,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:v,y:b},{x:y,y:M}]=x,S=a==="hidden"?"url(#".concat(l,")"):void 0,A=N$(N$({clipPath:S},ba(t)),{},{x1:v,y1:b,x2:y,y2:M}),E=tAe({x1:v,y1:b,x2:y,y2:M});return w.createElement(ja,{zIndex:t.zIndex},w.createElement(Fr,{className:Dn("recharts-reference-line",i)},mAe(r,A),w.createElement(xQ,aS({},E,{lowerWidth:E.width,upperWidth:E.width}),w.createElement(yQ,{label:t.label}),t.children)))}var _Ae={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Zr.line};function yb(t){var e=Ur(t,_Ae);return w.createElement(w.Fragment,null,w.createElement(yAe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(vAe,e))}yb.displayName="ReferenceLine";function HQ(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 wAe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return iAe(r,n)}function SAe(t,e,n){var r=n==="width",{x:i,y:a,width:o,height:l}=t;return e===1?{start:r?i:a,end:r?i+o:a+l}:{start:r?i+o:a+l,end:r?i:a}}function sS(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var a=n();return t*(e-t*a/2-r)>=0&&t*(e+t*a/2-i)<=0}function MAe(t,e){return HQ(t,e+1)}function NAe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var x=r?.[c];if(x===void 0)return{v:HQ(r,u)};var v=c,b,y=()=>(b===void 0&&(b=n(x,v)),b),M=x.coordinate,S=c===0||sS(t,M,y,d,l);S||(c=0,d=o,u+=1),S&&(d=M+t*(y()/2+i),c+=u)},m;u<=a.length;)if(m=f(),m)return m.v;return[]}function E$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Na(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E$(Object(n),!0).forEach(function(r){EAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EAe(t,e,n){return(e=AAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function AAe(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 CAe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(m){var p=a[m],x,v=()=>(x===void 0&&(x=n(p,m)),x);if(m===o-1){var b=t*(p.coordinate+t*v()/2-c);a[m]=p=Na(Na({},p),{},{tickCoord:b>0?p.coordinate-b*t:p.coordinate})}else a[m]=p=Na(Na({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var y=sS(t,p.tickCoord,v,l,c);y&&(c=p.tickCoord-t*(v()/2+i),a[m]=Na(Na({},p),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function kAe(t,e,n,r,i,a){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(a){var d=r[l-1],f=n(d,l-1),m=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=Na(Na({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var p=sS(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Na(Na({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,v=function(M){var S=o[M],A,E=()=>(A===void 0&&(A=n(S,M)),A);if(M===0){var k=t*(S.coordinate-t*E()/2-c);o[M]=S=Na(Na({},S),{},{tickCoord:k<0?S.coordinate-k*t:S.coordinate})}else o[M]=S=Na(Na({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var C=sS(t,S.tickCoord,E,c,u);C&&(c=S.tickCoord+t*(E()/2+i),o[M]=Na(Na({},S),{},{isShow:!0}))}},b=0;b<x;b++)v(b);return o}function nO(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Lt(c)||Rg.isSsr){var m;return(m=MAe(i,Lt(c)?c:0))!==null&&m!==void 0?m:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",v=d&&x==="width"?Rb(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(S,A)=>{var E=typeof u=="function"?u(S.value,A):S.value;return x==="width"?wAe(Rb(E,{fontSize:e,letterSpacing:n}),v,f):Rb(E,{fontSize:e,letterSpacing:n})[x]},y=i.length>=2?Xi(i[1].coordinate-i[0].coordinate):1,M=SAe(a,y,x);return c==="equidistantPreserveStart"?NAe(y,M,b,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=kAe(y,M,b,i,o,c==="preserveStartEnd"):p=CAe(y,M,b,i,o),p.filter(S=>S.isShow))}var jAe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+a,u=o+c+l+(n?r:0);return Math.round(u)}return 0},PAe=["axisLine","width","height","className","hide","ticks","axisType"];function RAe(t,e){if(t==null)return{};var n,r,i=DAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function DAe(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 Cf(){return Cf=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},Cf.apply(null,arguments)}function A$(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 fi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A$(Object(n),!0).forEach(function(r){OAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OAe(t,e,n){return(e=LAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LAe(t){var e=IAe(t,"string");return typeof e=="symbol"?e:e+""}function IAe(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 Wc={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:Zr.axis};function FAe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=fi(fi(fi({},c),Va(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=fi(fi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=fi(fi({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return w.createElement("line",Cf({},u,{className:Dn("recharts-cartesian-axis-line",Nf(l,"className"))}))}function UAe(t,e,n,r,i,a,o,l,c){var u,d,f,m,p,x,v=l?-1:1,b=t.tickSize||o,y=Lt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,m=n+ +!l*i,f=m-v*b,x=f-v*c,p=y;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-v*b,p=u-v*c,x=y;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+v*b,p=u+v*c,x=y;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+v*b,x=f+v*c,p=y;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:p,y:x}}}function zAe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function BAe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function $Ae(t){var{option:e,tickProps:n,value:r}=t,i,a=Dn(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,fi(fi({},n),{},{className:a}));else if(typeof e=="function")i=e(fi(fi({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=Dn(o,e?.className)),i=w.createElement(MM,Cf({},n,{className:o}),r)}return i}var HAe=w.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:m,y:p,width:x,height:v,tickSize:b,tickMargin:y,fontSize:M,letterSpacing:S,getTicksConfig:A,events:E,axisType:k}=t,C=nO(fi(fi({},A),{},{ticks:n}),M,S),R=zAe(d,f),T=BAe(d,f),P=Va(A),F=Mf(r),I={};typeof i=="object"&&(I=i);var X=fi(fi({},P),{},{fill:"none"},I),D=C.map(q=>fi({entry:q},UAe(q,m,p,x,v,d,b,f,y))),K=D.map(q=>{var{entry:Z,line:re}=q;return w.createElement(Fr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&w.createElement("line",Cf({},X,re,{className:Dn("recharts-cartesian-axis-tick-line",Nf(i,"className"))})))}),Y=D.map((q,Z)=>{var{entry:re,tick:ie}=q,U=fi(fi(fi(fi({textAnchor:R,verticalAnchor:T},P),{},{stroke:"none",fill:a},F),ie),{},{index:Z,payload:re,visibleTicksCount:C.length,tickFormatter:o,padding:c},u);return w.createElement(Fr,Cf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(re.value,"-").concat(re.coordinate,"-").concat(re.tickCoord)},J0(E,re,Z)),r&&w.createElement($Ae,{option:r,tickProps:U,value:"".concat(typeof o=="function"?o(re.value,Z):re.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},Y.length>0&&w.createElement(ja,{zIndex:Zr.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},Y)),K.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},K))}),VAe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=RAe(t,PAe),[d,f]=w.useState(""),[m,p]=w.useState(""),x=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return jAe({ticks:x.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=w.useCallback(b=>{if(b){var y=b.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=y;var M=y[0];if(M){var S=window.getComputedStyle(M),A=S.fontSize,E=S.letterSpacing;(A!==d||E!==m)&&(f(A),p(E))}}},[d,m]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(ja,{zIndex:t.zIndex},w.createElement(Fr,{className:Dn("recharts-cartesian-axis",a)},w.createElement(FAe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Va(t)}),w.createElement(HAe,{ref:v,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:m,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),w.createElement(xQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(yQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),rO=w.forwardRef((t,e)=>{var n=Ur(t,Wc);return w.createElement(VAe,Cf({},n,{ref:e}))});rO.displayName="CartesianAxis";var GAe=["x1","y1","x2","y2","key"],WAe=["offset"],qAe=["xAxisId","yAxisId"],KAe=["xAxisId","yAxisId"];function T$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ta(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T$(Object(n),!0).forEach(function(r){XAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XAe(t,e,n){return(e=YAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YAe(t){var e=QAe(t,"string");return typeof e=="symbol"?e:e+""}function QAe(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 Kh(){return Kh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Kh.apply(null,arguments)}function oS(t,e){if(t==null)return{};var n,r,i=ZAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ZAe(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 JAe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:l}=t;return w.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function VQ(t){var{option:e,lineItemProps:n}=t,r;if(w.isValidElement(e))r=w.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:o,x2:l,y2:c,key:u}=n,d=oS(n,GAe),f=(i=Va(d))!==null&&i!==void 0?i:{},{offset:m}=f,p=oS(f,WAe);r=w.createElement("line",Kh({},p,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function eTe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=oS(t,qAe),c=i.map((u,d)=>{var f=Ta(Ta({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(VQ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function tTe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=oS(t,KAe),c=i.map((u,d)=>{var f=Ta(Ta({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(VQ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function nTe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=!u[m+1],x=p?i+o-f:u[m+1]-f;if(x<=0)return null;var v=m%e.length;return w.createElement("rect",{key:"react-".concat(m),y:f,x:r,height:x,width:a,stroke:"none",fill:e[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function rTe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=!u[m+1],x=p?i+o-f:u[m+1]-f;if(x<=0)return null;var v=m%n.length;return w.createElement("rect",{key:"react-".concat(m),x:f,y:a,width:x,height:l,stroke:"none",fill:n[v],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var iTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return AK(nO(Ta(Ta(Ta({},Wc),n),{},{ticks:TK(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},aTe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return AK(nO(Ta(Ta(Ta({},Wc),n),{},{ticks:TK(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},sTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Zr.grid};function lS(t){var e=CD(),n=kD(),r=IK(),i=Ta(Ta({},Ur(t,sTe)),{},{x:Lt(t.x)?t.x:r.left,y:Lt(t.y)?t.y:r.top,width:Lt(t.width)?t.width:r.width,height:Lt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:m,verticalValues:p}=i,x=Pi(),v=Rt(T=>g6(T,"xAxis",a,x)),b=Rt(T=>g6(T,"yAxis",o,x));if(!Ll(u)||!Ll(d)||!Lt(l)||!Lt(c))return null;var y=i.verticalCoordinatesGenerator||iTe,M=i.horizontalCoordinatesGenerator||aTe,{horizontalPoints:S,verticalPoints:A}=i;if((!S||!S.length)&&typeof M=="function"){var E=m&&m.length,k=M({yAxis:b?Ta(Ta({},b),{},{ticks:E?m:b.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);jw(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(S=k)}if((!A||!A.length)&&typeof y=="function"){var C=p&&p.length,R=y({xAxis:v?Ta(Ta({},v),{},{ticks:C?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},C?!0:f);jw(Array.isArray(R),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(A=R)}return w.createElement(ja,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(JAe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(nTe,Kh({},i,{horizontalPoints:S})),w.createElement(rTe,Kh({},i,{verticalPoints:A})),w.createElement(eTe,Kh({},i,{offset:r,horizontalPoints:S,xAxis:v,yAxis:b})),w.createElement(tTe,Kh({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:b}))))}lS.displayName="CartesianGrid";var GQ=(t,e,n,r)=>Ul(t,"xAxis",e,r),WQ=(t,e,n,r)=>Fl(t,"xAxis",e,r),qQ=(t,e,n,r)=>Ul(t,"yAxis",n,r),KQ=(t,e,n,r)=>Fl(t,"yAxis",n,r),oTe=Ze([An,GQ,qQ,WQ,KQ],(t,e,n,r,i)=>Wl(t,"xAxis")?Ld(e,r,!1):Ld(n,i,!1)),lTe=(t,e,n,r,i)=>i;function cTe(t){return t.type==="line"}var uTe=Ze([my,lTe],(t,e)=>t.filter(cTe).find(n=>n.id===e)),dTe=Ze([An,GQ,qQ,WQ,KQ,uTe,oTe,uy],(t,e,n,r,i,a,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:m}=a,p;if(m!=null&&m.length>0?p=m:p=c?.slice(u,d+1),p!=null)return jTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function XQ(t){var e=Mf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,o=Number(i),l=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:n,strokeWidth:r}}var hTe=["id"],fTe=["type","layout","connectNulls","needClip","shape"],mTe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function w0(){return w0=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},w0.apply(null,arguments)}function C$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _l(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C$(Object(n),!0).forEach(function(r){pTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pTe(t,e,n){return(e=gTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gTe(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)}function iO(t,e){if(t==null)return{};var n,r,i=bTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function bTe(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 yTe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Yd(n,e),payload:t}]},vTe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Yd(o,e),hide:l,type:u,color:r,unit:c}};return w.createElement(TM,{tooltipEntrySettings:d})}),YQ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function _Te(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var wTe=(t,e,n)=>{var r=n.reduce((f,m)=>f+m);if(!r)return YQ(e,t);for(var i=Math.floor(t/r),a=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){l=[...n.slice(0,c),a-u];break}var d=l.length%2===0?[0,o]:[o];return[..._Te(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function STe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=iO(r,hTe),u=Va(c);return w.createElement(jQ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function MTe(t){var{showLabels:e,children:n,points:r}=t,i=w.useMemo(()=>r?.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return _l(_l({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(V4,{value:e?i:void 0},n)}function k$(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=iO(a,fTe),m=_l(_l({},ba(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return w.createElement(w.Fragment,null,r?.length>1&&w.createElement(X4,w0({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(STe,{points:r,clipPathId:e,props:a}))}function NTe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function ETe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:m,width:p,height:x,onAnimationEnd:v,onAnimationStart:b}=n,y=i.current,M=Og(o,"recharts-line-"),S=w.useRef(M),[A,E]=w.useState(!1),k=!A,C=w.useCallback(()=>{typeof v=="function"&&v(),E(!1)},[v]),R=w.useCallback(()=>{typeof b=="function"&&b(),E(!0)},[b]),T=NTe(r.current),P=w.useRef(0);S.current!==M&&(P.current=a.current,S.current=M);var F=P.current;return w.createElement(MTe,{points:o,showLabels:k},n.children,w.createElement(Dg,{animationId:M,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:C,onAnimationStart:R,key:M},I=>{var X=Wn(F,T+F,I),D=Math.min(X,T),K;if(c)if(l){var Y="".concat(l).split(/[,\s]+/gim).map(re=>parseFloat(re));K=wTe(D,T,Y)}else K=YQ(T,D);else K=l==null?void 0:String(l);if(I>0&&T>0&&(i.current=o,a.current=Math.max(a.current,D)),y){var q=y.length/o.length,Z=I===1?o:o.map((re,ie)=>{var U=Math.floor(ie*q);if(y[U]){var G=y[U];return _l(_l({},re),{},{x:Wn(G.x,re.x,I),y:Wn(G.y,re.y,I)})}return m?_l(_l({},re),{},{x:Wn(p*2,re.x,I),y:Wn(x/2,re.y,I)}):_l(_l({},re),{},{x:re.x,y:re.y})});return i.current=Z,w.createElement(k$,{props:n,points:Z,clipPathId:e,pathRef:r,strokeDasharray:K})}return w.createElement(k$,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:K})}),w.createElement(NM,{label:n.label}))}function ATe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),a=w.useRef(null);return w.createElement(ETe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var TTe=(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:er(t.payload,e)}};class CTe extends w.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:m,zIndex:p}=this.props;if(e)return null;var x=Dn("recharts-line",i),v=f,{r:b,strokeWidth:y}=XQ(n),M=K4(n),S=b*2+y,A=m?"url(#clipPath-".concat(M?"":"dots-").concat(v,")"):void 0;return w.createElement(ja,{zIndex:p},w.createElement(Fr,{className:x},m&&w.createElement("defs",null,w.createElement(tO,{clipPathId:v,xAxisId:a,yAxisId:o}),!M&&w.createElement("clipPath",{id:"clipPath-dots-".concat(v)},w.createElement("rect",{x:c-S/2,y:l-S/2,width:u+S,height:d+S}))),w.createElement(DQ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:TTe,errorBarOffset:0},w.createElement(ATe,{props:this.props,clipPathId:v}))),w.createElement($3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var QQ={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:Zr.line,type:"linear"};function kTe(t){var e=Ur(t,QQ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:m,xAxisId:p,yAxisId:x,id:v}=e,b=iO(e,mTe),{needClip:y}=PM(p,x),M=jM(),S=Gf(),A=Pi(),E=Rt(P=>dTe(P,p,x,A,v));if(S!=="horizontal"&&S!=="vertical"||E==null||M==null)return null;var{height:k,width:C,x:R,y:T}=M;return w.createElement(CTe,w0({},b,{id:v,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:m,xAxisId:p,yAxisId:x,points:E,layout:S,height:k,width:C,left:R,top:T,needClip:y}))}function jTe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=er(u,o);if(e==="horizontal"){var m=kw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Ar(f)?null:r.scale(f);return{x:m,y:p,value:f,payload:u}}var x=Ar(f)?null:n.scale(f),v=kw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||v==null?null:{x,y:v,value:f,payload:u}}).filter(Boolean)}function PTe(t){var e=Ur(t,QQ),n=Pi();return w.createElement(CM,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(J4,{legendPayload:yTe(e)}),w.createElement(vTe,{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(eO,{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(kTe,w0({},e,{id:r}))))}var ZQ=w.memo(PTe,Sy);ZQ.displayName="Line";var JQ=(t,e,n,r)=>Ul(t,"xAxis",e,r),eZ=(t,e,n,r)=>Fl(t,"xAxis",e,r),tZ=(t,e,n,r)=>Ul(t,"yAxis",n,r),nZ=(t,e,n,r)=>Fl(t,"yAxis",n,r),RTe=Ze([An,JQ,tZ,eZ,nZ],(t,e,n,r,i)=>Wl(t,"xAxis")?Ld(e,r,!1):Ld(n,i,!1)),DTe=(t,e,n,r,i)=>i,rZ=Ze([my,DTe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),OTe=(t,e,n,r,i)=>{var a,o=rZ(t,e,n,r,i);if(o!=null){var l=An(t),c=Wl(l,"xAxis"),u;if(c?u=v0(t,"yAxis",n,r):u=v0(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=pM(o);if(!(d==null||f==null)){var m=(a=u[d])===null||a===void 0?void 0:a.stackedData;return m?.find(p=>p.key===f)}}}},LTe=Ze([An,JQ,tZ,eZ,nZ,OTe,uy,RTe,rZ,u_e],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:m}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(f,m+1),x!=null)return tCe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),ITe=["id"],FTe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function of(){return of=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},of.apply(null,arguments)}function iZ(t,e){if(t==null)return{};var n,r,i=UTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function j$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Cp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j$(Object(n),!0).forEach(function(r){zTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zTe(t,e,n){return(e=BTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BTe(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 cS(t,e){return t&&t!=="none"?t:e}var HTe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:cS(r,i),value:Yd(n,e),payload:t}]},VTe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Yd(o,e),hide:l,type:u,color:cS(r,a),unit:c}};return w.createElement(TM,{tooltipEntrySettings:d})});function GTe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=Va(r);return w.createElement(jQ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function WTe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Cp(Cp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(V4,{value:e?i:void 0},n)}function P$(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,m=iZ(a,ITe),p=Va(m),x=ba(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(Fr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(Ip,of({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(Ip,of({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(Ip,of({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(GTe,{points:e,props:m,clipPathId:i}))}function qTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!tr(a)||!tr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return Lt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Lt(c)?w.createElement("rect",{x:0,y:a<o?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function KTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!tr(a)||!tr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return Lt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Lt(c)?w.createElement("rect",{x:a<o?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function XTe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?w.createElement(qTe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):w.createElement(KTe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function YTe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:m,onAnimationEnd:p}=r,x=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),v=Og(x,"recharts-area-"),b=Txe(),[y,M]=w.useState(!1),S=!y,A=w.useCallback(()=>{typeof p=="function"&&p(),M(!1)},[p]),E=w.useCallback(()=>{typeof m=="function"&&m(),M(!0)},[m]);if(b==null)return null;var k=i.current,C=a.current;return w.createElement(WTe,{showLabels:S,points:o},r.children,w.createElement(Dg,{animationId:v,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:E,key:v},R=>{if(k){var T=k.length/o.length,P=R===1?o:o.map((I,X)=>{var D=Math.floor(X*T);if(k[D]){var K=k[D];return Cp(Cp({},I),{},{x:Wn(K.x,I.x,R),y:Wn(K.y,I.y,R)})}return I}),F;return Lt(l)?F=Wn(C,l,R):Ar(l)||gs(l)?F=Wn(C,0,R):F=l.map((I,X)=>{var D=Math.floor(X*T);if(Array.isArray(C)&&C[D]){var K=C[D];return Cp(Cp({},I),{},{x:Wn(K.x,I.x,R),y:Wn(K.y,I.y,R)})}return I}),R>0&&(i.current=P,a.current=F),w.createElement(P$,{points:P,baseLine:F,needClip:e,clipPathId:n,props:r})}return R>0&&(i.current=o,a.current=l),w.createElement(Fr,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(XTe,{alpha:R,points:o,baseLine:l,layout:b,strokeWidth:r.strokeWidth}))),w.createElement(Fr,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(P$,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(NM,{label:r.label}))}function QTe(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),a=w.useRef();return w.createElement(YTe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class ZTe extends w.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:m,baseLine:p,zIndex:x}=this.props;if(e)return null;var v=Dn("recharts-area",i),b=m,{r:y,strokeWidth:M}=XQ(n),S=K4(n),A=y*2+M,E=l?"url(#clipPath-".concat(S?"":"dots-").concat(b,")"):void 0;return w.createElement(ja,{zIndex:x},w.createElement(Fr,{className:v},l&&w.createElement("defs",null,w.createElement(tO,{clipPathId:b,xAxisId:c,yAxisId:u}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(b)},w.createElement("rect",{x:o-A/2,y:a-A/2,width:d+A,height:f+A}))),w.createElement(QTe,{needClip:l,clipPathId:b,props:this.props})),w.createElement($3,{points:r,mainColor:cS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}),this.props.isRange&&Array.isArray(p)&&w.createElement($3,{points:p,mainColor:cS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}))}}var aZ={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:Zr.area};function JTe(t){var e,n=Ur(t,aZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:m,legendType:p,stroke:x,xAxisId:v,yAxisId:b}=n,y=iZ(n,FTe),M=Gf(),S=eQ(),{needClip:A}=PM(v,b),E=Pi(),{points:k,isRange:C,baseLine:R}=(e=Rt(D=>LTe(D,v,b,E,t.id)))!==null&&e!==void 0?e:{},T=jM();if(M!=="horizontal"&&M!=="vertical"||T==null||S!=="AreaChart"&&S!=="ComposedChart")return null;var{height:P,width:F,x:I,y:X}=T;return!k||!k.length?null:w.createElement(ZTe,of({},y,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:R,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:P,hide:f,layout:M,isAnimationActive:m==="auto"?!Rg.isSsr:m,isRange:C,legendType:p,needClip:A,points:k,stroke:x,width:F,left:I,top:X,xAxisId:v,yAxisId:b}))}var eCe=(t,e,n,r,i)=>{var a=n??e;if(Lt(a))return a;var o=t==="horizontal"?i:r,l=o.scale.domain();if(o.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return a==="dataMin"?l[0]:a==="dataMax"?l[1]:l[0]};function tCe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:m,bandSize:p}=t,x=i&&i.length,v=eCe(a,o,n,l,c),b=a==="horizontal",y=!1,M=u.map((A,E)=>{var k;x?k=i[d+E]:(k=er(A,r),Array.isArray(k)?y=!0:k=[v,k]);var C=k[1]==null||x&&!e&&er(A,r)==null;return b?{x:kw({axis:l,ticks:f,bandSize:p,entry:A,index:E}),y:C?null:c.scale(k[1]),value:k,payload:A}:{x:C?null:l.scale(k[1]),y:kw({axis:c,ticks:m,bandSize:p,entry:A,index:E}),value:k,payload:A}}),S;return x||y?S=M.map(A=>{var E=Array.isArray(A.value)?A.value[0]:null;return b?{x:A.x,y:E!=null&&A.y!=null?c.scale(E):null,payload:A.payload}:{x:E!=null?l.scale(E):null,y:A.y,payload:A.payload}}):S=b?c.scale(v):l.scale(v),{points:M,baseLine:S,isRange:y}}function nCe(t){var e=Ur(t,aZ),n=Pi();return w.createElement(CM,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(J4,{legendPayload:HTe(e)}),w.createElement(VTe,{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(eO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:CK(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(JTe,of({},e,{id:r}))))}var sZ=w.memo(nCe,Sy);sZ.displayName="Area";var rCe=["domain","range"],iCe=["domain","range"];function R$(t,e){if(t==null)return{};var n,r,i=aCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function aCe(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 D$(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 oZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=R$(t,rCe),{domain:a,range:o}=e,l=R$(e,iCe);return!D$(n,a)||!D$(r,o)?!1:Sy(i,l)}var sCe=["dangerouslySetInnerHTML","ticks"],oCe=["id"];function V3(){return V3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},V3.apply(null,arguments)}function O$(t,e){if(t==null)return{};var n,r,i=lCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lCe(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 cCe(t){var e=xr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(rNe(t)):n.current!==t&&e(iNe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(aNe(n.current)),n.current=null)},[e]),null}var uCe=t=>{var{xAxisId:e,className:n}=t,r=Rt(AD),i=Pi(),a="xAxis",o=Rt(b=>Fd(b,a,e,i)),l=Rt(b=>PY(b,a,e,i)),c=Rt(b=>TY(b,e)),u=Rt(b=>o1e(b,e)),d=Rt(b=>cY(b,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:m}=t,p=O$(t,sCe),{id:x}=d,v=O$(d,oCe);return w.createElement(rO,V3({},p,v,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:Dn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},dCe={allowDataOverflow:Hi.allowDataOverflow,allowDecimals:Hi.allowDecimals,allowDuplicatedCategory:Hi.allowDuplicatedCategory,angle:Hi.angle,axisLine:Wc.axisLine,height:Hi.height,hide:!1,includeHidden:Hi.includeHidden,interval:Hi.interval,minTickGap:Hi.minTickGap,mirror:Hi.mirror,orientation:Hi.orientation,padding:Hi.padding,reversed:Hi.reversed,scale:Hi.scale,tick:Hi.tick,tickCount:Hi.tickCount,tickLine:Wc.tickLine,tickSize:Wc.tickSize,type:Hi.type,xAxisId:0},hCe=t=>{var e=Ur(t,dCe);return w.createElement(w.Fragment,null,w.createElement(cCe,{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(uCe,e))},uS=w.memo(hCe,oZ);uS.displayName="XAxis";var fCe=["dangerouslySetInnerHTML","ticks"],mCe=["id"];function G3(){return G3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},G3.apply(null,arguments)}function L$(t,e){if(t==null)return{};var n,r,i=pCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function pCe(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 gCe(t){var e=xr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(sNe(t)):n.current!==t&&e(oNe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(lNe(n.current)),n.current=null)},[e]),null}var xCe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=w.useRef(null),o=w.useRef(null),l=Rt(AD),c=Pi(),u=xr(),d="yAxis",f=Rt(E=>Fd(E,d,e,c)),m=Rt(E=>CY(E,e)),p=Rt(E=>c1e(E,e)),x=Rt(E=>PY(E,d,e,c)),v=Rt(E=>uY(E,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!m||H4(i)||w.isValidElement(i)||v==null)){var E=a.current;if(E){var k=E.getCalculatedWidth();Math.round(m.width)!==Math.round(k)&&u(cNe({id:e,width:k}))}}},[x,m,u,i,e,r,v]),m==null||p==null||v==null)return null;var{dangerouslySetInnerHTML:b,ticks:y}=t,M=L$(t,fCe),{id:S}=v,A=L$(v,mCe);return w.createElement(rO,G3({},M,A,{ref:a,labelRef:o,scale:f,x:p.x,y:p.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:m.width,height:m.height,className:Dn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},bCe={allowDataOverflow:Vi.allowDataOverflow,allowDecimals:Vi.allowDecimals,allowDuplicatedCategory:Vi.allowDuplicatedCategory,angle:Vi.angle,axisLine:Wc.axisLine,hide:!1,includeHidden:Vi.includeHidden,interval:Vi.interval,minTickGap:Vi.minTickGap,mirror:Vi.mirror,orientation:Vi.orientation,padding:Vi.padding,reversed:Vi.reversed,scale:Vi.scale,tick:Vi.tick,tickCount:Vi.tickCount,tickLine:Wc.tickLine,tickSize:Wc.tickSize,type:Vi.type,width:Vi.width,yAxisId:0},yCe=t=>{var e=Ur(t,bCe);return w.createElement(w.Fragment,null,w.createElement(gCe,{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(xCe,e))},dS=w.memo(yCe,oZ);dS.displayName="YAxis";var vCe=(t,e)=>e,aO=Ze([vCe,An,oY,Di,KY,mu,Mwe,ji],jwe),sO=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)}},lZ=To("mouseClick"),cZ=ny();cZ.startListening({actionCreator:lZ,effect:(t,e)=>{var n=t.payload,r=aO(e.getState(),sO(n));r?.activeIndex!=null&&e.dispatch(S1e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var W3=To("mouseMove"),uZ=ny(),f_=null;uZ.startListening({actionCreator:W3,effect:(t,e)=>{var n=t.payload;f_!==null&&cancelAnimationFrame(f_);var r=sO(n);f_=requestAnimationFrame(()=>{var i=e.getState(),a=P4(i,i.tooltip.settings.shared);if(a==="axis"){var o=aO(i,r);o?.activeIndex!=null?e.dispatch(zY({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(UY())}f_=null})}});var I$={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},dZ=xs({name:"rootProps",initialState:I$,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:I$.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}}}),_Ce=dZ.reducer,{updateOptions:wCe}=dZ.actions,hZ=xs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:SCe}=hZ.actions,MCe=hZ.reducer,fZ=To("keyDown"),mZ=To("focus"),oO=ny();oO.startListening({actionCreator:fZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var o=R4(i,Hg(n),gy(n),vy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=mu(n);if(a==="Enter"){var u=Zw(n,"axis","hover",String(i.index));e.dispatch(L3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=f1e(n),f=d==="left-to-right"?1:-1,m=a==="ArrowRight"?1:-1,p=l+m*f;if(!(c==null||p>=c.length||p<0)){var x=Zw(n,"axis","hover",String(p));e.dispatch(L3({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});oO.startListening({actionCreator:mZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",o=Zw(n,"axis","hover",String(a));e.dispatch(L3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var lo=To("externalEvent"),pZ=ny(),uC=new Map;pZ.startListening({actionCreator:lo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=uC.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:cwe(l),activeDataKey:F4(l),activeIndex:Ud(l),activeLabel:QY(l),activeTooltipIndex:Ud(l),isTooltipActive:uwe(l)};n(c,r)}finally{uC.delete(i)}});uC.set(i,o)}}});var NCe=Ze([$g],t=>t.tooltipItemPayloads),ECe=Ze([NCe,by,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var o=e(a,n);return o}}}),gZ=To("touchMove"),xZ=ny();xZ.startListening({actionCreator:gZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=P4(r,r.tooltip.settings.shared);if(i==="axis"){var a=aO(r,sO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(zY({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var o,l=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(jK),d=(o=c.getAttribute(PK))!==null&&o!==void 0?o:void 0,f=ECe(e.getState(),u,d);e.dispatch(FY({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var ACe=Zq({brush:QEe,cartesianAxis:uNe,chartData:lSe,errorBars:CNe,graphicalItems:xMe,layout:Oge,legend:Hxe,options:rSe,polarAxis:P2e,polarOptions:MCe,referenceElements:lAe,rootProps:_Ce,tooltip:M1e,zIndex:Gwe}),TCe=function(e){return sge({reducer:ACe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([cZ.middleware,uZ.middleware,oO.middleware,pZ.middleware,xZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(fK({type:"raf"}))},devTools:Rg.devToolsEnabled})};function bZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Pi(),a=w.useRef(null);if(i)return n;a.current==null&&(a.current=TCe(e));var o=bD;return w.createElement(JNe,{context:o,store:a.current},n)}function CCe(t){var{layout:e,margin:n}=t,r=xr(),i=Pi();return w.useEffect(()=>{i||(r(Pge(e)),r(jge(n)))},[r,i,e,n]),null}var yZ=w.memo(CCe,Sy);function vZ(t){var e=xr();return w.useEffect(()=>{e(wCe(t))},[e,t]),null}function F$(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=TQ("".concat(r).concat(e)),a=xr();return w.useLayoutEffect(()=>(a(Hwe({zIndex:e,elementId:i,isPanorama:n})),()=>{a(Vwe({zIndex:e,isPanorama:n}))}),[a,e,i,n]),w.createElement("g",{tabIndex:-1,id:i})}function U$(t){var{children:e,isPanorama:n}=t,r=Rt(Rwe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return w.createElement(w.Fragment,null,i.map(o=>w.createElement(F$,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>w.createElement(F$,{key:o,zIndex:o,isPanorama:n})))}var kCe=["children"];function jCe(t,e){if(t==null)return{};var n,r,i=PCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PCe(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 hS(){return hS=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},hS.apply(null,arguments)}var RCe={width:"100%",height:"100%",display:"block"},DCe=w.forwardRef((t,e)=>{var n=CD(),r=kD(),i=KK();if(!Ll(n)||!Ll(r))return null;var{children:a,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),w.createElement(lD,hS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:RCe,ref:e}),a)}),OCe=t=>{var{children:e}=t,n=Rt(nM);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return w.createElement(lD,{width:r,height:i,x:o,y:a},e)},z$=w.forwardRef((t,e)=>{var{children:n}=t,r=jCe(t,kCe),i=Pi();return i?w.createElement(OCe,null,w.createElement(U$,{isPanorama:!0},n)):w.createElement(DCe,hS({ref:e},r),w.createElement(U$,{isPanorama:!1},n))});function LCe(){var t=xr(),[e,n]=w.useState(null),r=Rt(Zge);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;tr(a)&&a!==r&&t(Dge(a))}},[e,t,r]),n}function B$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ICe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B$(Object(n),!0).forEach(function(r){FCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FCe(t,e,n){return(e=UCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UCe(t){var e=zCe(t,"string");return typeof e=="symbol"?e:e+""}function zCe(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 kf(){return kf=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},kf.apply(null,arguments)}var BCe=()=>(xSe(),null);function fS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var $Ce=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[a,o]=w.useState({containerWidth:fS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:fS((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((u,d)=>{o(f=>{var m=Math.round(u),p=Math.round(d);return f.containerWidth===m&&f.containerHeight===p?f:{containerWidth:m,containerHeight:p}})},[]),c=w.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var m=x=>{var{width:v,height:b}=x[0].contentRect;l(v,b)},p=new ResizeObserver(m);p.observe(u),i.current=p}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(rM,{width:a.containerWidth,height:a.containerHeight}),w.createElement("div",kf({ref:c},t)))}),HCe=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=w.useState({containerWidth:fS(n),containerHeight:fS(r)}),o=w.useCallback((c,u)=>{a(d=>{var f=Math.round(c),m=Math.round(u);return d.containerWidth===f&&d.containerHeight===m?d:{containerWidth:f,containerHeight:m}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(rM,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",kf({ref:l},t)))}),VCe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(rM,{width:n,height:r}),w.createElement("div",kf({ref:e},t)))}),GCe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return tu(n)||tu(r)?w.createElement(HCe,kf({},t,{ref:e})):w.createElement(VCe,kf({},t,{ref:e}))});function WCe(t){return t===!0?$Ce:GCe}var qCe=w.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:m,onTouchEnd:p,onTouchMove:x,onTouchStart:v,style:b,width:y,responsive:M,dispatchTouchEvents:S=!0}=t,A=w.useRef(null),E=xr(),[k,C]=w.useState(null),[R,T]=w.useState(null),P=LCe(),F=TD(),I=F?.width>0?F.width:y,X=F?.height>0?F.height:i,D=w.useCallback(ge=>{P(ge),typeof e=="function"&&e(ge),C(ge),T(ge),ge!=null&&(A.current=ge)},[P,e,C,T]),K=w.useCallback(ge=>{E(lZ(ge)),E(lo({handler:a,reactEvent:ge}))},[E,a]),Y=w.useCallback(ge=>{E(W3(ge)),E(lo({handler:u,reactEvent:ge}))},[E,u]),q=w.useCallback(ge=>{E(UY()),E(lo({handler:d,reactEvent:ge}))},[E,d]),Z=w.useCallback(ge=>{E(W3(ge)),E(lo({handler:f,reactEvent:ge}))},[E,f]),re=w.useCallback(()=>{E(mZ())},[E]),ie=w.useCallback(ge=>{E(fZ(ge.key))},[E]),U=w.useCallback(ge=>{E(lo({handler:o,reactEvent:ge}))},[E,o]),G=w.useCallback(ge=>{E(lo({handler:l,reactEvent:ge}))},[E,l]),ee=w.useCallback(ge=>{E(lo({handler:c,reactEvent:ge}))},[E,c]),ne=w.useCallback(ge=>{E(lo({handler:m,reactEvent:ge}))},[E,m]),se=w.useCallback(ge=>{E(lo({handler:v,reactEvent:ge}))},[E,v]),de=w.useCallback(ge=>{S&&E(gZ(ge)),E(lo({handler:x,reactEvent:ge}))},[E,S,x]),he=w.useCallback(ge=>{E(lo({handler:p,reactEvent:ge}))},[E,p]),Ee=WCe(M);return w.createElement(aQ.Provider,{value:k},w.createElement(fq.Provider,{value:R},w.createElement(Ee,{width:I??b?.width,height:X??b?.height,className:Dn("recharts-wrapper",r),style:ICe({position:"relative",cursor:"default",width:I,height:X},b),onClick:K,onContextMenu:U,onDoubleClick:G,onFocus:re,onKeyDown:ie,onMouseDown:ee,onMouseEnter:Y,onMouseLeave:q,onMouseMove:Z,onMouseUp:ne,onTouchEnd:he,onTouchMove:de,onTouchStart:se,ref:D},w.createElement(BCe,null),n)))}),KCe=["width","height","responsive","children","className","style","compact","title","desc"];function XCe(t,e){if(t==null)return{};var n,r,i=YCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function YCe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var _Z=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=XCe(t,KCe),m=Va(f);return c?w.createElement(w.Fragment,null,w.createElement(rM,{width:n,height:r}),w.createElement(z$,{otherAttributes:m,title:u,desc:d},a)):w.createElement(qCe,{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(z$,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(cAe,null,a)))});function q3(){return q3=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},q3.apply(null,arguments)}var QCe={top:5,right:5,bottom:5,left:5},ZCe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:QCe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},lO=w.forwardRef(function(e,n){var r,i=Ur(e.categoricalChartProps,ZCe),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(bZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},w.createElement(FQ,{chartData:u.data}),w.createElement(yZ,{layout:i.layout,margin:i.margin}),w.createElement(vZ,{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(_Z,q3({},i,{ref:n})))}),JCe=["axis"],eke=w.forwardRef((t,e)=>w.createElement(lO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:JCe,tooltipPayloadSearcher:SM,categoricalChartProps:t,ref:e})),tke=["axis","item"],nke=w.forwardRef((t,e)=>w.createElement(lO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:tke,tooltipPayloadSearcher:SM,categoricalChartProps:t,ref:e}));function rke(t){var e=xr();return w.useEffect(()=>{e(SCe(t))},[e,t]),null}var ike=["layout"];function K3(){return K3=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},K3.apply(null,arguments)}function ake(t,e){if(t==null)return{};var n,r,i=ske(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ske(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 oke={top:5,right:5,bottom:5,left:5},wZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:oke,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},lke=w.forwardRef(function(e,n){var r,i=Ur(e.categoricalChartProps,wZ),{layout:a}=i,o=ake(i,ike),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(bZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(FQ,{chartData:i.data}),w.createElement(yZ,{layout:a,margin:i.margin}),w.createElement(vZ,{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(rke,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(_Z,K3({},o,{ref:n})))});function $$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function H$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$$(Object(n),!0).forEach(function(r){cke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cke(t,e,n){return(e=uke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uke(t){var e=dke(t,"string");return typeof e=="symbol"?e:e+""}function dke(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 hke=["item"],fke=H$(H$({},wZ),{},{layout:"centric",startAngle:0,endAngle:360}),mke=w.forwardRef((t,e)=>{var n=Ur(t,fke);return w.createElement(lke,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:hke,tooltipPayloadSearcher:SM,categoricalChartProps:n,ref:e})}),pke=["axis"],gke=w.forwardRef((t,e)=>w.createElement(lO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:pke,tooltipPayloadSearcher:SM,categoricalChartProps:t,ref:e}));const V$=[{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 xke({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Tg(),{mode:u}=Xd(),[d,f]=w.useState("24h"),[m,p]=w.useState(o),x=u==="dark",{data:v}=lt({queryKey:["settings"],queryFn:pe.getSettings}),b=v?.time_format||"system";w.useEffect(()=>{if(!t)return;const ne=se=>{se.key==="Escape"&&e()};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[t,e]);const y=V$.find(ne=>ne.value===d)?.hours||24,{data:M,isLoading:S,error:A}=lt({queryKey:["ams-history",n,i,y],queryFn:()=>pe.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const E=M?.data.map(ne=>{const se=mi(ne.recorded_at)||new Date,de={hour:"2-digit",minute:"2-digit",...y>24?{day:"numeric",month:"short"}:{}};return{time:se.getTime(),humidity:ne.humidity,temperature:ne.temperature,timeLabel:se.toLocaleTimeString([],Pb(de,b))}})||[],k=l?.humidityGood||40,C=l?.humidityFair||60,R=l?.tempGood||30,T=l?.tempFair||35,P=E[E.length-1],F=P?.humidity,I=P?.temperature,X=ne=>{const se=ne.filter(Re=>Re!=null);if(se.length<4)return"stable";const de=se.slice(0,Math.floor(se.length/4)),he=se.slice(-Math.floor(se.length/4)),Ee=de.reduce((Re,te)=>Re+te,0)/de.length,Ne=he.reduce((Re,te)=>Re+te,0)/he.length-Ee;return Math.abs(Ne)<2?"stable":Ne>0?"up":"down"},D=X(E.map(ne=>ne.humidity)),K=X(E.map(ne=>ne.temperature)),Y=({trend:ne})=>ne==="up"?s.jsx(nq,{className:"w-4 h-4 text-red-400"}):ne==="down"?s.jsx(tq,{className:"w-4 h-4 text-green-400"}):s.jsx(Hj,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),q=ne=>ne==null?"#9ca3af":ne<=k?"#22a352":ne<=C?"#d4a017":"#c62828",Z=ne=>ne==null?"#9ca3af":ne<=R?"#22a352":ne<=T?"#d4a017":"#c62828",re=x?"#2d2d2d":"#ffffff",ie=x?"#1d1d1d":"#f3f4f6",U=x?"#3d3d3d":"#e5e7eb",G=x?"#ffffff":"#111827",ee=x?"#9ca3af":"#4b5563";return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:re},onClick:ne=>ne.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:U},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:G},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:ee},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ee},children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ie},children:[s.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="humidity"?"bg-blue-600 text-white":""}`,style:m!=="humidity"?{color:ee}:void 0,children:[s.jsx(tD,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="temperature"?"bg-orange-600 text-white":""}`,style:m!=="temperature"?{color:ee}:void 0,children:[s.jsx(U2,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ie},children:V$.map(ne=>s.jsx("button",{onClick:()=>f(ne.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ne.value?"bg-bambu-green text-white":""}`,style:d!==ne.value?{color:ee}:void 0,children:ne.label},ne.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:q(F)},children:F!=null?`${F}%`:"—"}),s.jsx(Y,{trend:D})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:G},children:M?.avg_humidity!=null?`${M.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:M?.min_humidity!=null?`${M.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:M?.max_humidity!=null?`${M.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:Z(I)},children:I!=null?`${I}°C`:"—"}),s.jsx(Y,{trend:K})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:G},children:M?.avg_temperature!=null?`${M.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:M?.min_temperature!=null?`${M.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:M?.max_temperature!=null?`${M.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:ie},children:S?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ee},children:c("common.loading","Loading...")}):A?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):E.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ee},children:c("common.noData","No data available for this time range")}):s.jsx(F1,{width:"100%",height:300,children:s.jsxs(eke,{data:E,children:[s.jsx(lS,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),s.jsx(uS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ne=>{const se=new Date(ne);return y>24?se.toLocaleDateString([],{day:"numeric",month:"short"}):se.toLocaleTimeString([],Pb({hour:"2-digit",minute:"2-digit"},b))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(dS,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:ne=>m==="humidity"?`${ne}%`:`${ne}°C`}),s.jsx(z1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:ne=>new Date(ne).toLocaleString(void 0,Pb({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},b)),formatter:ne=>[m==="humidity"?`${ne}%`:`${ne}°C`,m==="humidity"?"Humidity":"Temperature"]}),s.jsx(RD,{}),m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(yb,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(yb,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(yb,{y:R,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(yb,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(ZQ,{type:"monotone",dataKey:m,name:m==="humidity"?"Humidity":"Temperature",stroke:m==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:ee},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function dC({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const[o,l]=w.useState(!1),[c,u]=w.useState("top"),[d,f]=w.useState(!1),m=w.useRef(null),p=w.useRef(null),x=w.useRef(null),v=()=>{const k=t.trayUuid;k&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(k).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{b(k)}):b(k))},b=k=>{const C=document.createElement("textarea");C.value=k,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(C)};w.useEffect(()=>{if(o&&m.current&&p.current){const k=m.current.getBoundingClientRect(),C=p.current.offsetHeight,R=k.top,T=window.innerHeight-k.bottom;R<C+12&&T>R?u("bottom"):u("top")}},[o]);const y=()=>{n||(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!0),80))},M=()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const S=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",A=k=>{if(!k)return!1;const C=k.replace("#",""),R=parseInt(C.slice(0,2),16),T=parseInt(C.slice(2,4),16),P=parseInt(C.slice(4,6),16);return(.299*R+.587*T+.114*P)/255>.6},E=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:y,onMouseLeave:M,children:[e,o&&s.jsxs("div",{ref:p,className:`
  46. absolute left-1/2 -translate-x-1/2 z-50
  47. ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
  48. animate-in fade-in-0 zoom-in-95 duration-150
  49. `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
  50. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  51. rounded-lg shadow-xl overflow-hidden
  52. backdrop-blur-sm
  53. `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:E||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
  54. absolute inset-0 flex items-center justify-center
  55. font-semibold text-sm tracking-wide
  56. ${A(E)?"text-black/80":"text-white/90"}
  57. `,children:t.colorName}),s.jsx("div",{className:`
  58. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  59. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  60. `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Profile"}),s.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"K Factor"}),s.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[s.jsx(tD,{className:"w-3 h-3"}),"Fill"]}),s.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),s.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:S(t.fillLevel)}}):s.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Spool ID"}),s.jsxs("button",{onClick:k=>{k.stopPropagation(),v()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[s.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),d?s.jsx(ps,{className:"w-3 h-3 text-bambu-green"}):s.jsx(Gs,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:k=>{k.stopPropagation(),i.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?"No unlinked spools available":"Link this spool to a Spoolman spool",children:[s.jsx(Cl,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]}),a?.enabled&&s.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("button",{onClick:k=>{k.stopPropagation(),a.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[s.jsx(Dd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),s.jsx("div",{className:`
  61. absolute left-1/2 -translate-x-1/2 w-0 h-0
  62. border-l-[6px] border-l-transparent
  63. border-r-[6px] border-r-transparent
  64. ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  65. `})]})]})}function G$({children:t,className:e="",configureSlot:n}){const[r,i]=w.useState(!1),a=w.useRef(null),o=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!0),80)},l=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),100)};return w.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:o,onMouseLeave:l,children:[t,r&&s.jsxs("div",{className:`
  66. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  67. animate-in fade-in-0 zoom-in-95 duration-150
  68. `,children:[s.jsxs("div",{className:`
  69. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  70. rounded-md shadow-lg overflow-hidden
  71. `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:"Empty slot"}),n?.enabled&&s.jsx("div",{className:"px-2 pb-2",children:s.jsxs("button",{onClick:c=>{c.stopPropagation(),n.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[s.jsx(Dd,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),s.jsx("div",{className:`
  72. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  73. border-l-[5px] border-l-transparent
  74. border-r-[5px] border-r-transparent
  75. border-t-[5px] border-t-bambu-dark-tertiary
  76. `})]})]})}function bke({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=Qt(),[a,o]=w.useState(null),{data:l,isLoading:c}=lt({queryKey:["unlinked-spools"],queryFn:pe.getUnlinkedSpools,enabled:t}),u=ft({mutationFn:f=>pe.linkSpool(f,n),onSuccess:()=>{i.invalidateQueries({queryKey:["unlinked-spools"]}),i.invalidateQueries({queryKey:["spoolman-status"]}),e()}});if(!t)return null;const d=()=>{a&&u.mutate(a)};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Cl,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Link to Spoolman"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[r&&s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),s.jsx("span",{className:"text-white font-medium",children:r.type}),s.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Spool UUID:"}),s.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Select a Spoolman spool to link:"}),c?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):l&&l.length>0?s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:l.map(f=>s.jsx("button",{onClick:()=>o(f.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${a===f.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[f.filament_color_hex&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${f.filament_color_hex}`}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:f.filament_name||"Unknown filament"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[f.filament_material||"Unknown",f.remaining_weight!==null&&` - ${Math.round(f.remaining_weight)}g`,f.location&&` - ${f.location}`]})]}),a===f.id&&s.jsx(ps,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},f.id))}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx("p",{children:"No unlinked spools found in Spoolman."}),s.jsx("p",{className:"text-xs mt-1",children:"All spools are already linked to AMS trays."})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Cl,{className:"w-4 h-4"}),"Link Spool"]})})]}),u.isError&&s.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:u.error.message})]})]})}function yke(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 W$(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 vke=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function q$(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of vke){const a=new RegExp(`\\b${i}\\b`,"i");if(a.test(n)){const o=e.split(a),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function hC(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const _ke={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"},wke=[{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"}],Ske=[{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 Mke(t){const e=t.toLowerCase().trim();return _ke[e]||null}function Nke({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:a}){const[o,l]=w.useState(""),[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState(""),[x,v]=w.useState(""),[b,y]=w.useState(!1),[M,S]=w.useState(!1),{data:A,isLoading:E}=lt({queryKey:["cloudSettings"],queryFn:()=>pe.getCloudSettings(),enabled:t}),{data:k,isLoading:C}=lt({queryKey:["kprofiles",n,i],queryFn:()=>pe.getKProfiles(n,i),enabled:t&&!!n}),R=ft({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Z=A?.filament.find(ge=>ge.setting_id===o);if(!Z)throw new Error("Selected preset not found");const re=q$(Z.name),ie=c?.slot_id??-1,U=d||r.trayColor?.slice(0,6)||"FFFFFF",G=Z.name.replace(/@.+$/,"").trim();let ee=W$(o);if(!o.startsWith("GFS"))try{const ge=await pe.getCloudSettingDetail(o);ge.filament_id?ee=ge.filament_id:ge.base_id&&(ee=W$(ge.base_id),console.log(`Derived tray_info_idx from base_id: ${ge.base_id} -> ${ee}`))}catch(ge){console.warn("Failed to fetch preset detail for filament_id:",ge)}let ne=190,se=230;const de=re.material.toUpperCase();de.includes("PLA")?(ne=190,se=230):de.includes("PETG")?(ne=220,se=260):de.includes("ABS")||de.includes("ASA")?(ne=240,se=280):de.includes("TPU")?(ne=200,se=240):de.includes("PC")?(ne=260,se=300):(de.includes("PA")||de.includes("NYLON"))&&(ne=250,se=290);const he=c?.k_value?parseFloat(c.k_value):0,Ee=await pe.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ee,tray_type:re.material||"PLA",tray_sub_brands:G,tray_color:U+"FF",nozzle_temp_min:ne,nozzle_temp_max:se,cali_idx:ie,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:he});try{await pe.saveSlotPreset(n,r.amsId,r.trayId,o,G)}catch(ge){console.warn("Failed to save slot preset mapping:",ge)}return Ee},onSuccess:()=>{y(!0),a?.(),setTimeout(()=>{y(!1),e()},1500)}}),T=ft({mutationFn:async()=>pe.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{y(!0),a?.(),setTimeout(()=>{y(!1),e()},1500)}}),P=w.useMemo(()=>{if(!A?.filament)return[];const Z=x.toLowerCase();return A.filament.filter(re=>Z?re.name.toLowerCase().includes(Z):!0).sort((re,ie)=>{const U=hC(re.setting_id),G=hC(ie.setting_id);return U&&!G?-1:!U&&G?1:re.name.localeCompare(ie.name)})},[A?.filament,x]),F=w.useMemo(()=>{if(!o||!A?.filament)return null;const Z=A.filament.find(U=>U.setting_id===o);if(!Z)return null;let re=Z.name.replace(/@.+$/,"").trim();re.startsWith("# ")&&(re=re.slice(2).trim());const ie=q$(re);return{fullName:re,material:ie.material,brand:ie.brand}},[o,A?.filament]),I=F?.fullName||"",X=w.useMemo(()=>{if(!k?.profiles||!F)return[];const{fullName:Z,material:re,brand:ie}=F,U=Z.toUpperCase(),G=re.toUpperCase(),ee=ie.toUpperCase();if(!G||G.length<2)return[];const ne=k.profiles.filter(de=>{const he=de.name.toUpperCase();if(ee)return!(!he.includes(ee)||!he.includes(G));if(he.includes(U)||he.includes(G))return!0;const ge={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[G]||[];for(const Ne of ge)if(he.includes(Ne))return!0;return!1}),se=new Map;for(const de of ne){const he=`${de.name}|${de.k_value}`,Ee=se.get(he);Ee?de.extruder_id===1&&Ee.extruder_id===0&&se.set(he,de):se.set(he,de)}return Array.from(se.values())},[k?.profiles,F]);w.useEffect(()=>{if(t&&A?.filament){if(r.trayInfoIdx){const Z=A.filament.find(re=>re.setting_id===r.trayInfoIdx);Z&&l(Z.setting_id)}}else t||(l(""),u(null),f(""),p(""),v(""),y(!1))},[t,A?.filament,r.trayInfoIdx]),w.useEffect(()=>{X.length>0?u(X[0]):u(null)},[o,X]);const D=w.useCallback(Z=>{Z.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[t,D]),!t)return null;const K=E||C,Y=o&&!R.isPending,q=d||r.trayColor?.slice(0,6)||"FFFFFF";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Dd,{className:"w-5 h-5 text-bambu-blue"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[b&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx(E2,{className:"w-16 h-16 text-bambu-green mx-auto"}),s.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),s.jsxs("span",{className:"text-white font-medium",children:[yke(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),K?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",placeholder:"Search presets...",value:x,onChange:Z=>v(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:P.length===0?s.jsx("p",{className:"text-center py-4 text-bambu-gray",children:A?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):P.map(Z=>s.jsx("button",{onClick:()=>l(Z.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Z.setting_id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-white text-sm truncate",children:Z.name}),hC(Z.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Z.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",I&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",I]})]}),X.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Z=>{const re=X.find(ie=>ie.name===Z.target.value);u(re||null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10",children:[s.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),X.map(Z=>s.jsxs("option",{value:Z.name,children:[Z.name," (K=",Z.k_value,")"]},`${Z.name}-${Z.extruder_id}`))]}),s.jsx(Ji,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?s.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):s.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),c&&s.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[wke.map(Z=>s.jsx("button",{onClick:()=>{f(Z.hex),p(Z.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Z.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Z.hex}`},title:Z.name},Z.hex)),s.jsx("button",{onClick:()=>S(!M),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:M?"Show less colors":"Show more colors",children:M?"−":"+"})]}),M&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:Ske.map(Z=>s.jsx("button",{onClick:()=>{f(Z.hex),p(Z.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Z.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Z.hex}`},title:Z.name},Z.hex))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${q}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:m,onChange:Z=>{const re=Z.target.value;p(re);const ie=Mke(re);if(ie)f(ie);else{const U=re.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();U.length===6?f(U):U.length===3&&f(U.split("").map(G=>G+G).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),d&&s.jsx("button",{onClick:()=>{f(""),p("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:"Clear custom color",children:"Clear"})]}),d&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),s.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:()=>T.mutate(),disabled:T.isPending||R.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:T.isPending?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Hf,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:()=>R.mutate(),disabled:!Y,children:R.isPending?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Dd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(R.isError||T.isError)&&s.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:R.error?.message||T.error?.message})]})]})}function Eke({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return s.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[s.jsxs("g",{stroke:r,opacity:i,children:[s.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),s.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),s.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),s.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),s.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),s.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),s.jsx("path",{d:"M12 24h8",stroke:r}),s.jsx("path",{d:"M12 27h8",stroke:r}),s.jsx("path",{d:"M13 30h6",stroke:r})]})}const K$=({className:t})=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),s.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),s.jsx("polyline",{points:"12,10 14,12 12,14"})]}),X$={"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"},Ake={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 fC(t){if(!t)return null;if(X$[t])return X$[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return Ake[n]||null}function mC(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,a=Math.min(e,n,r)/255,o=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=o>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,m=r/255;i===d?l=((f-m)/u+(f<m?6:0))/6:i===f?l=((m-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function pC(t){return(t??.02).toFixed(3)}function Y$({side:t}){const{mode:e}=Xd(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return s.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function Q$({className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function Tke({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),s.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function Cke({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),s.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function kke({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function jke({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Pke({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function gC({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?s.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function Z$({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=o?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=o?d=Q$:a<=l?d=Tke:d=Cke,s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${a}% - ${u}${r?" (click for history)":""}`,children:[s.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function J$({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=kke):t<=o?(l="#d4a017",c="Fair",u=jke):(l="#c62828",c="Bad",u=Pke),s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[s.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Uu(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,o=String.fromCharCode(65+a);return i?`HT-${o}`:`AMS-${o}`}function eH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function Rke(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Dke(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const a=new Date(r);a.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((a.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function Oke(t){if(!t)return"/img/printers/default.png";const e=t.toLowerCase().replace(/\s+/g,"");return e.includes("x1e")?"/img/printers/x1e.png":e.includes("x1c")||e.includes("x1carbon")||e.includes("x1")?"/img/printers/x1c.png":e.includes("h2d")||e.includes("h2c")||e.includes("h2s")?"/img/printers/h2d.png":e.includes("p2s")||e.includes("p1s")?"/img/printers/p1s.png":e.includes("p1p")?"/img/printers/p1p.png":e.includes("a1mini")?"/img/printers/a1mini.png":e.includes("a1")?"/img/printers/a1.png":"/img/printers/default.png"}function Lke(t){return t==null?{label:"",color:"text-bambu-gray",bars:0}:t>=-50?{label:"Excellent",color:"text-bambu-green",bars:4}:t>=-60?{label:"Good",color:"text-bambu-green",bars:3}:t>=-70?{label:"Fair",color:"text-yellow-400",bars:2}:t>=-80?{label:"Weak",color:"text-orange-400",bars:1}:{label:"Very weak",color:"text-red-400",bars:1}}function xC(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function Ike({url:t,printName:e}){const[n,r]=w.useState(!1),[i,a]=w.useState(!1),[o,l]=w.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&l(!0),children:t&&!i?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&s.jsx(Rs,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(Rs,{className:"w-8 h-8 text-bambu-gray"})}),o&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&s.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function Fke({printers:t}){const e=Qt(),n=w.useMemo(()=>{let i=0,a=0,o=0,l=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?l++:u.connected?u.state==="RUNNING"?i++:a++:o++}),{printing:i,idle:a,offline:o,loading:l,total:t?.length||0}},[t,e]),[,r]=w.useState(0);return w.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(o=>o+1),i=!1}))});return()=>a()},[e]),t?.length?s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function tH(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 nH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system",cameraViewMode:u="window",onOpenEmbeddedCamera:d}){const f=Qt(),m=sl(),{showToast:p}=Un(),[x,v]=w.useState(!1),[b,y]=w.useState(!1),[M,S]=w.useState(!0),[A,E]=w.useState(!1),[k,C]=w.useState(!1),[R,T]=w.useState(!1),[P,F]=w.useState(!1),[I,X]=w.useState(!1),[D,K]=w.useState(!1),[Y,q]=w.useState(!1),[Z,re]=w.useState(!1),[ie,U]=w.useState(!1),[G,ee]=w.useState(!1),[ne,se]=w.useState(null),[de,he]=w.useState(null),[Ee,ge]=w.useState(null),[Ne,Re]=w.useState(!1),{data:te}=lt({queryKey:["printerStatus",t.id],queryFn:()=>pe.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Je}=lt({queryKey:["firmwareUpdate",t.id],queryFn:()=>D1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),B=w.useMemo(()=>{const bt=new Set;if(te?.ams)for(const Yt of te.ams)for(const yn of Yt.tray||[])yn.tray_info_idx&&bt.add(yn.tray_info_idx);return te?.vt_tray?.tray_info_idx&&bt.add(te.vt_tray.tray_info_idx),Array.from(bt)},[te?.ams,te?.vt_tray]),{data:H}=lt({queryKey:["filamentInfo",B],queryFn:()=>pe.getFilamentInfo(B),enabled:B.length>0,staleTime:300*1e3}),{data:W}=lt({queryKey:["slotPresets",t.id],queryFn:()=>pe.getSlotPresets(t.id),staleTime:120*1e3}),[z,V]=w.useState(null);w.useEffect(()=>{te?.wifi_signal!=null&&V(te.wifi_signal)},[te?.wifi_signal]);const Q=te?.wifi_signal??z,Te=w.useRef(void 0);w.useEffect(()=>{te?.connected!==void 0&&(Te.current=te.connected)},[te?.connected]);const ke=te?.connected??Te.current,Ae=w.useRef({});w.useEffect(()=>{te?.ams_extruder_map&&Object.keys(te.ams_extruder_map).length>0&&(Ae.current=te.ams_extruder_map)},[te?.ams_extruder_map]);const $=te?.ams_extruder_map&&Object.keys(te.ams_extruder_map).length>0?te.ams_extruder_map:Ae.current,L=w.useRef([]);w.useEffect(()=>{te?.ams&&te.ams.length>0&&(L.current=te.ams)},[te?.ams]);const oe=te?.ams&&te.ams.length>0?te.ams:L.current,ce=w.useRef(255),xe=te?.tray_now;xe!==void 0&&xe!==255&&(ce.current=xe);const ve=xe===void 0||xe===255?ce.current:xe,{data:_e}=lt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>pe.getSmartPlugByPrinter(t.id)}),{data:Ie}=lt({queryKey:["smartPlugStatus",_e?.id],queryFn:()=>_e?pe.getSmartPlugStatus(_e.id):null,enabled:!!_e,refetchInterval:1e4}),{data:We}=lt({queryKey:["queue",t.id,"pending"],queryFn:()=>pe.getQueue(t.id,"pending")}),ht=We?.length||0,{data:qe}=lt({queryKey:["archives",t.id,"last"],queryFn:()=>pe.getArchives(t.id,1,0),enabled:te?.connected&&te?.state!=="RUNNING"}),me=qe?.[0],rt=e&&ke===!1,Xe=ft({mutationFn:bt=>pe.deletePrinter(t.id,bt.deleteArchives),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),f.invalidateQueries({queryKey:["archives"]}),f.invalidateQueries({queryKey:["maintenanceOverview"]})}}),nt=ft({mutationFn:()=>pe.connectPrinter(t.id),onSuccess:()=>{f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),ut=ft({mutationFn:bt=>_e?pe.controlSmartPlug(_e.id,bt):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugStatus",_e?.id]})}}),ae=ft({mutationFn:bt=>_e?pe.updateSmartPlug(_e.id,{auto_off:bt}):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),f.invalidateQueries({queryKey:["smart-plugs"]})}}),$e=ft({mutationFn:()=>pe.stopPrint(t.id),onSuccess:()=>{p("Print stopped"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>p(bt.message||"Failed to stop print","error")}),ye=ft({mutationFn:()=>pe.pausePrint(t.id),onSuccess:()=>{p("Print paused"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>p(bt.message||"Failed to pause print","error")}),Be=ft({mutationFn:()=>pe.resumePrint(t.id),onSuccess:()=>{p("Print resumed"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>p(bt.message||"Failed to resume print","error")}),De=ft({mutationFn:bt=>pe.setChamberLight(t.id,bt),onMutate:async bt=>{await f.cancelQueries({queryKey:["printerStatus",t.id]});const Yt=f.getQueryData(["printerStatus",t.id]);return f.setQueryData(["printerStatus",t.id],yn=>({...yn,chamber_light:bt})),{previousStatus:Yt}},onSuccess:(bt,Yt)=>{p(`Chamber light ${Yt?"on":"off"}`)},onError:(bt,Yt,yn)=>{yn?.previousStatus&&f.setQueryData(["printerStatus",t.id],yn.previousStatus),p(bt.message||"Failed to control chamber light","error")}}),we=(te?.state==="RUNNING"||te?.state==="PAUSE"||te?.state==="PAUSED")&&(te?.printable_objects_count??0)>=2,{data:Ve,refetch:dt}=lt({queryKey:["printableObjects",t.id],queryFn:()=>pe.getPrintableObjects(t.id),enabled:G||we,refetchInterval:G?5e3:we?3e4:!1}),Tt=ft({mutationFn:bt=>pe.skipObjects(t.id,bt),onSuccess:bt=>{p(bt.message||"Objects skipped"),dt()},onError:bt=>p(bt.message||"Failed to skip objects","error")}),[Ct,Xt]=w.useState(null),Pt=w.useRef(!1),an=w.useRef(null),bn=w.useRef(!1),Kn=ft({mutationFn:({amsId:bt,slotId:Yt})=>pe.refreshAmsSlot(t.id,bt,Yt),onMutate:({amsId:bt,slotId:Yt})=>{an.current&&clearTimeout(an.current),Pt.current=!1,bn.current=!1,Xt({amsId:bt,slotId:Yt}),setTimeout(()=>{bn.current=!0},2e3),an.current=setTimeout(()=>{Xt(null)},3e4)},onSuccess:bt=>{p(bt.message||"RFID re-read initiated")},onError:bt=>{p(bt.message||"Failed to re-read RFID","error"),an.current&&clearTimeout(an.current),Xt(null)}}),zn=w.useRef(null);w.useEffect(()=>{if(!Ct)return;const bt=te?.ams_status_main??0;return bt!==0&&(Pt.current=!0,zn.current&&(clearTimeout(zn.current),zn.current=null)),Pt.current&&bt===0&&(bn.current?(an.current&&clearTimeout(an.current),Xt(null)):zn.current||(zn.current=setTimeout(()=>{an.current&&clearTimeout(an.current),Xt(null)},2e3))),()=>{zn.current&&clearTimeout(zn.current)}},[te?.ams_status_main,Ct]);const[Vn,_r]=w.useState(null);if(rt)return null;const $r=()=>{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"}},Tr=()=>{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"}},hr=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return s.jsxs(wt,{className:"relative",children:[s.jsxs(Mt,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:hr(),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("img",{src:Oke(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${$r()}`}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-semibold text-white ${Tr()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${te?.connected?"bg-bambu-green":"bg-red-500"}`,title:te?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&te?.nozzles&&te.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:te.nozzles[0].nozzle_type||"Nozzle",children:["• ",te.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&s.jsxs("span",{className:"ml-2 text-bambu-gray",children:[s.jsx(Hn,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>v(!x),children:s.jsx(wd,{className:"w-4 h-4"})}),x&&s.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{E(!0),v(!1)},children:[s.jsx(Ha,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{nt.mutate(),v(!1)},children:[s.jsx(yr,{className:"w-4 h-4"}),"Reconnect"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{T(!0),v(!1)},children:[s.jsx(eq,{className:"w-4 h-4"}),"MQTT Debug"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{y(!0),v(!1)},children:[s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[s.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${te?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[te?.connected?s.jsx(Y0,{className:"w-3 h-3"}):s.jsx(aD,{className:"w-3 h-3"}),te?.connected?"Connected":"Offline"]}),te?.connected&&Q!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Q>=-50||Q>=-60?"bg-bambu-green/20 text-bambu-green":Q>=-70?"bg-amber-500/20 text-amber-600":Q>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${Q} dBm - ${Lke(Q).label}`,children:[s.jsx(the,{className:"w-3 h-3"}),Q,"dBm"]}),te?.connected&&(()=>{const bt=te.hms_errors?_fe(te.hms_errors):[];return s.jsxs("button",{onClick:()=>K(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${bt.length>0?bt.some(Yt=>Yt.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[s.jsx(En,{className:"w-3 h-3"}),bt.length>0?bt.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>m("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[s.jsx(Od,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),ht>0&&s.jsxs("button",{onClick:()=>m("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${ht} print${ht>1?"s":""} in queue`,children:[s.jsx(tl,{className:"w-3 h-3"}),ht]}),Je?.update_available&&s.jsxs("button",{onClick:()=>Re(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:`Firmware update available: ${Je.current_version} → ${Je.latest_version}`,children:[s.jsx(Jr,{className:"w-3 h-3"}),"Update"]})]})]}),b&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(wt,{className:"w-full max-w-md mx-4",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:s.jsx(En,{className:"w-5 h-5 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:M,onChange:bt=>S(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"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:M?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:()=>{y(!1),S(!0)},children:"Cancel"}),s.jsx(Me,{variant:"danger",onClick:()=>{Xe.mutate({deleteArchives:M}),y(!1),S(!0)},children:"Delete"})]})]})})}),te?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:te.state==="RUNNING"?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:s.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${te.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(te.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:tH(te.state,te.stg_cur_name)})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[s.jsxs("button",{onClick:()=>ee(!0),disabled:!(te.state==="RUNNING"||te.state==="PAUSE"||te.state==="PAUSED")||(te.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(te.state==="RUNNING"||te.state==="PAUSE"||te.state==="PAUSED")&&(te.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:te.state==="RUNNING"||te.state==="PAUSE"||te.state==="PAUSED"?(te.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(K$,{className:"w-4 h-4"}),Ve&&Ve.skipped_count>0&&s.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:Ve.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ike,{url:te.state==="RUNNING"?te.cover_url:null,printName:te.state==="RUNNING"&&(te.subtask_name||te.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:te.current_print&&te.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:te.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:te.subtask_name||te.current_print}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${te.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(te.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[te.remaining_time!=null&&te.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Hn,{className:"w-3 h-3"}),Rke(te.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",Dke(te.remaining_time,c)]})]}),te.layer_num!=null&&te.total_layers!=null&&te.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(tl,{className:"w-3 h-3"}),te.layer_num,"/",te.total_layers]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("p",{className:"text-white text-sm mb-2",children:tH(te.state,te.stg_cur_name)}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),s.jsx("span",{className:"text-bambu-gray",children:"—"})]}),me?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:me.print_name||me.filename,children:["Last: ",me.print_name||me.filename,me.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Jp(me.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),te.state!=="RUNNING"&&s.jsx(Nfe,{printerId:t.id})]}),te.temperatures&&r==="expanded"&&(()=>{const bt=te.temperatures.nozzle_heating||te.temperatures.nozzle_2_heating||!1,Yt=te.temperatures.bed_heating||!1,yn=te.temperatures.chamber_heating||!1,ue=t.nozzle_count===2||te.temperatures.nozzle_2!==void 0,ze=te.active_extruder===1?"L":"R";return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(gC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:bt}),te.temperatures.nozzle_2!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(te.temperatures.nozzle||0),"° / ",Math.round(te.temperatures.nozzle_2||0),"°"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(te.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(gC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:Yt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(te.temperatures.bed||0),"°C"]})]}),te.temperatures.chamber!==void 0&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(gC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:yn}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(te.temperatures.chamber||0),"°C"]})]}),ue&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${ze==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${ze==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),s.jsx("p",{className:`text-[11px] font-bold ${ze==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const bt=te.state==="RUNNING",Yt=te.state==="PAUSED"||te.state==="PAUSE",yn=bt||Yt,ue=$e.isPending||ye.isPending||Be.isPending,ze=te.cooling_fan_speed,Ye=te.big_fan1_speed,Ke=te.big_fan2_speed;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Controls"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${ze&&ze>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(HW,{className:`w-3.5 h-3.5 ${ze&&ze>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${ze&&ze>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[ze??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Ye&&Ye>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(rq,{className:`w-3.5 h-3.5 ${Ye&&Ye>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Ye&&Ye>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Ye??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Ke&&Ke>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(zle,{className:`w-3.5 h-3.5 ${Ke&&Ke>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Ke&&Ke>0?"text-green-400":"text-bambu-gray/50"}`,children:[Ke??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>q(!0),disabled:!yn||ue,className:`
  77. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  78. transition-colors
  79. ${yn?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  80. `,title:"Stop print",children:[s.jsx(Ol,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>Yt?U(!0):re(!0),disabled:!yn||ue,className:`
  81. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  82. transition-colors
  83. ${yn?Yt?"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"}
  84. `,title:Yt?"Resume print":"Pause print",children:[Yt?s.jsx(nl,{className:"w-3 h-3"}):s.jsx(rD,{className:"w-3 h-3"}),Yt?"Resume":"Pause"]})]})]})]})})(),oe&&oe.length>0&&r==="expanded"&&(()=>{const bt=oe.filter(ue=>ue.tray.length>1),Yt=oe.filter(ue=>ue.tray.length===1),yn=t.nozzle_count===2||te?.temperatures?.nozzle_2!==void 0;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Filaments"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"space-y-3",children:[bt.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:bt.map(ue=>{const ze=$[String(ue.id)],Ye=ue.id>=128?ue.id-128:ue.id,Ke=ze!==void 0?ze:Ye,Qe=Ke===1,Nt=Ke===0;return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:Uu(ue.id,ue.tray.length)}),yn&&(Qe||Nt)&&s.jsx(Y$,{side:Qe?"L":"R"})]}),(ue.humidity!=null||ue.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[ue.humidity!=null&&s.jsx(Z$,{humidity:ue.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>se({amsId:ue.id,amsLabel:Uu(ue.id,ue.tray.length),mode:"humidity"}),compact:!0}),ue.temp!=null&&s.jsx(J$,{temp:ue.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>se({amsId:ue.id,amsLabel:Uu(ue.id,ue.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(le=>{const Se=ue.tray[le]||ue.tray.find(st=>st.id===le),Le=Se?.tray_type&&Se.remain>=0,Oe=!Se?.tray_type,Pe=ue.id*4+le,ct=ve===Pe,vt=Se?.tray_info_idx?H?.[Se.tray_info_idx]:null,Et=W?.[Pe],_t=Se?.tray_type?{vendor:xC(Se)?"Bambu Lab":"Generic",profile:vt?.name||Et?.preset_name||Se.tray_sub_brands||Se.tray_type,colorName:fC(Se.tray_id_name)||mC(Se.tray_color),colorHex:Se.tray_color||null,kFactor:pC(Se.k),fillLevel:Le?Se.remain:null,trayUuid:Se.tray_uuid||null}:null,yt=Ct?.amsId===ue.id&&Ct?.slotId===le,be=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Oe?"opacity-50":""} ${ct?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:Se?.tray_color?`#${Se.tray_color}`:Se?.tray_type?"#333":"transparent",borderColor:Oe?"#666":"rgba(255,255,255,0.1)",borderStyle:Oe?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Se?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Le&&Se?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Se.remain}%`,backgroundColor:eH(Se.remain)}}):Se?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"relative group",children:[yt&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(yr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),te?.state!=="RUNNING"&&s.jsx("button",{onClick:st=>{st.stopPropagation(),_r(Vn?.amsId===ue.id&&Vn?.slotId===le?null:{amsId:ue.id,slotId:le})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:s.jsx(wd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),te?.state!=="RUNNING"&&Vn?.amsId===ue.id&&Vn?.slotId===le&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:st=>{st.stopPropagation(),Kn.mutate({amsId:ue.id,slotId:le}),_r(null)},disabled:yt,children:[s.jsx(yr,{className:`w-3 h-3 ${yt?"animate-spin":""}`}),"Re-read RFID"]})}),_t?s.jsx(dC,{data:_t,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&_t.trayUuid?st=>{he({trayUuid:st,trayInfo:{type:_t.profile,color:_t.colorHex||"",location:`${Uu(ue.id,ue.tray.length)} Slot ${le+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ue.id,trayId:le,trayCount:ue.tray.length,trayType:Se?.tray_type||void 0,trayColor:Se?.tray_color||void 0,traySubBrands:Se?.tray_sub_brands||void 0,trayInfoIdx:Se?.tray_info_idx||void 0})},children:be}):s.jsx(G$,{configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ue.id,trayId:le,trayCount:ue.tray.length})},children:be})]},le)})})]},ue.id)})}),(Yt.length>0||te.vt_tray&&te.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Yt.map(ue=>{const ze=$[String(ue.id)],Ye=ue.id>=128?ue.id-128:ue.id,Ke=ze!==void 0?ze:Ye,Qe=Ke===1,Nt=Ke===0,le=ue.tray[0],Se=le?.tray_type&&le.remain>=0,Le=!le?.tray_type,Oe=ue.id*4+(le?.id??0),Pe=ve===Oe,ct=le?.tray_info_idx?H?.[le.tray_info_idx]:null,vt=W?.[Oe],Et=le?.tray_type?{vendor:xC(le)?"Bambu Lab":"Generic",profile:ct?.name||vt?.preset_name||le.tray_sub_brands||le.tray_type,colorName:fC(le.tray_id_name)||mC(le.tray_color),colorHex:le.tray_color||null,kFactor:pC(le.k),fillLevel:Se?le.remain:null,trayUuid:le.tray_uuid||null}:null,_t=le?.id??0,yt=Ct?.amsId===ue.id&&Ct?.slotId===_t,be=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Le?"opacity-50":""} ${Pe?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:le?.tray_color?`#${le.tray_color}`:le?.tray_type?"#333":"transparent",borderColor:Le?"#666":"rgba(255,255,255,0.1)",borderStyle:Le?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:le?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Se?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${le.remain}%`,backgroundColor:eH(le.remain)}}):le?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:Uu(ue.id,ue.tray.length)}),yn&&(Qe||Nt)&&s.jsx(Y$,{side:Qe?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[yt&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(yr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),te?.state!=="RUNNING"&&s.jsx("button",{onClick:st=>{st.stopPropagation(),_r(Vn?.amsId===ue.id&&Vn?.slotId===_t?null:{amsId:ue.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:"Slot options",children:s.jsx(wd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),te?.state!=="RUNNING"&&Vn?.amsId===ue.id&&Vn?.slotId===_t&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:st=>{st.stopPropagation(),Kn.mutate({amsId:ue.id,slotId:_t}),_r(null)},disabled:yt,children:[s.jsx(yr,{className:`w-3 h-3 ${yt?"animate-spin":""}`}),"Re-read RFID"]})}),Et?s.jsx(dC,{data:Et,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Et.trayUuid?st=>{he({trayUuid:st,trayInfo:{type:Et.profile,color:Et.colorHex||"",location:Uu(ue.id,ue.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ue.id,trayId:_t,trayCount:ue.tray.length,trayType:le?.tray_type||void 0,trayColor:le?.tray_color||void 0,traySubBrands:le?.tray_sub_brands||void 0,trayInfoIdx:le?.tray_info_idx||void 0})},children:be}):s.jsx(G$,{configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:ue.id,trayId:_t,trayCount:ue.tray.length})},children:be})]}),(ue.humidity!=null||ue.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[ue.temp!=null&&s.jsx(J$,{temp:ue.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>se({amsId:ue.id,amsLabel:Uu(ue.id,ue.tray.length),mode:"temperature"}),compact:!0}),ue.humidity!=null&&s.jsx(Z$,{humidity:ue.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>se({amsId:ue.id,amsLabel:Uu(ue.id,ue.tray.length),mode:"humidity"}),compact:!0})]})]})]},ue.id)}),te.vt_tray&&te.vt_tray.tray_type&&(()=>{const ue=te.vt_tray,ze=ve===254,Ye=ue.tray_info_idx?H?.[ue.tray_info_idx]:null,Ke=W?.[1020],Qe={vendor:xC(ue)?"Bambu Lab":"Generic",profile:Ye?.name||Ke?.preset_name||ue.tray_sub_brands||ue.tray_type||"Unknown",colorName:fC(ue.tray_id_name)||mC(ue.tray_color),colorHex:ue.tray_color||null,kFactor:pC(ue.k),fillLevel:null,trayUuid:ue.tray_uuid||null},Nt=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${ze?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:ue.tray_color?`#${ue.tray_color}`:"#333",borderColor:ze?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ue.tray_type||"Spool"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsx("div",{className:"flex items-center gap-1 mb-2",children:s.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),s.jsx(dC,{data:Qe,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Qe.trayUuid?le=>{he({trayUuid:le,trayInfo:{type:Qe.profile,color:Qe.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>ge({amsId:255,trayId:0,trayCount:1,trayType:ue.tray_type||void 0,trayColor:ue.tray_color||void 0,traySubBrands:ue.tray_sub_brands||void 0,trayInfoIdx:ue.tray_info_idx||void 0})},children:Nt})]})})()]})]})]})})()]}),_e&&r==="expanded"&&s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Sf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:_e.name}),Ie&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Ie.state==="ON"?"bg-bambu-green/20 text-bambu-green":Ie.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[Ie.state||"?",Ie.state==="ON"&&Ie.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",Ie.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>F(!0),disabled:ut.isPending||Ie?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Ie?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(uu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>X(!0),disabled:ut.isPending||Ie?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Ie?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(I2,{className:"w-3 h-3"}),"Off"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:`text-xs hidden sm:inline ${_e.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:_e.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>ae.mutate(!_e.auto_off),disabled:ae.isPending||_e.auto_off_executed,title:_e.auto_off_executed?"Auto-off was executed - turn printer on to reset":"Auto power-off after print",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${_e.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":_e.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${_e.auto_off||_e.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"text-xs text-bambu-gray",children:[s.jsx("p",{children:t.ip_address}),s.jsx("p",{className:"truncate",children:t.serial_number})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>De.mutate(!te?.chamber_light),disabled:!te?.connected||De.isPending,title:te?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:te?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(Eke,{on:te?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const bt=localStorage.getItem("cameraWindowState"),Yt=bt?JSON.parse(bt):{width:640,height:400},yn=[`width=${Yt.width}`,`height=${Yt.height}`,Yt.left!==void 0?`left=${Yt.left}`:"",Yt.top!==void 0?`top=${Yt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,yn)}},disabled:!te?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:s.jsx(sD,{className:"w-4 h-4"})}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>C(!0),title:"Browse printer files",children:[s.jsx(P2,{className:"w-4 h-4"}),"Files"]})]})]})]}),k&&s.jsx(ffe,{printerId:t.id,printerName:t.name,onClose:()=>C(!1)}),R&&s.jsx(yfe,{printerId:t.id,printerName:t.name,onClose:()=>T(!1)}),P&&_e&&s.jsx(Rn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{ut.mutate("on"),F(!1)},onCancel:()=>F(!1)}),I&&_e&&s.jsx(Rn,{title:"Power Off Printer",message:te?.state==="RUNNING"?`WARNING: "${t.name}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.`:`Are you sure you want to turn OFF the power for "${t.name}"?`,confirmText:"Power Off",variant:"danger",onConfirm:()=>{ut.mutate("off"),X(!1)},onCancel:()=>X(!1)}),Y&&s.jsx(Rn,{title:"Stop Print",message:`Are you sure you want to stop the current print on "${t.name}"? This will cancel the print job.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{$e.mutate(),q(!1)},onCancel:()=>q(!1)}),Z&&s.jsx(Rn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{ye.mutate(),re(!1)},onCancel:()=>re(!1)}),ie&&s.jsx(Rn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{Be.mutate(),U(!1)},onCancel:()=>U(!1)}),G&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>ee(!1),onKeyDown:bt=>bt.key==="Escape"&&ee(!1),tabIndex:-1,ref:bt=>bt?.focus(),children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),s.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] overflow-hidden",onClick:bt=>bt.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(K$,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),s.jsx("button",{onClick:()=>ee(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),Ve?Ve.objects.length===0?s.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[s.jsx("p",{className:"text-sm",children:"No objects found"}),s.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Objects are loaded when a print starts"})]}):s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[s.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:s.jsx(yde,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:"Match IDs with your printer display"}),s.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:"The printer screen shows object IDs on the build plate"})]}),s.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[Ve.skipped_count,"/",Ve.total," skipped"]})]}),(te?.layer_num??0)<=1&&s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[s.jsx(ea,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),s.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Wait for layer 2+ to skip objects (currently layer ",te?.layer_num??0,")"]})]}),s.jsxs("div",{className:"flex",children:[s.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary",children:s.jsxs("div",{className:"relative",children:[te?.cover_url?s.jsx("img",{src:`${te.cover_url}?view=top`,alt:"Print preview",className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):s.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:s.jsx(Rs,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Ve.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Ve.objects.map((bt,Yt)=>{let yn,ue;if(bt.x!=null&&bt.y!=null&&Ve.bbox_all){const[ze,Ye,Ke,Qe]=Ve.bbox_all,Nt=Ke-ze,le=Qe-Ye,Se=8,Le=100-Se*2;yn=Se+(bt.x-ze)/Nt*Le,ue=Se+(Qe-bt.y)/le*Le,yn=Math.max(5,Math.min(95,yn)),ue=Math.max(5,Math.min(95,ue))}else if(bt.x!=null&&bt.y!=null)yn=bt.x/256*100,ue=100-bt.y/256*100,yn=Math.max(5,Math.min(95,yn)),ue=Math.max(5,Math.min(95,ue));else{const ze=Math.ceil(Math.sqrt(Ve.objects.length)),Ye=Math.floor(Yt/ze),Ke=Yt%ze,Qe=Math.ceil(Ve.objects.length/ze);yn=15+Ke*(70/ze)+35/ze,ue=15+Ye*(70/Qe)+35/Qe}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${bt.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${yn}%`,top:`${ue}%`,transform:"translate(-50%, -50%)"},title:bt.name,children:bt.id},bt.id)})}),s.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm",children:[Ve.objects.filter(bt=>!bt.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0",children:Ve.objects.map(bt=>s.jsxs("div",{className:`
  85. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  86. ${bt.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  87. `,children:[s.jsxs("div",{className:`
  88. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  89. ${bt.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"}
  90. `,children:[s.jsx("span",{className:`text-lg font-mono font-bold ${bt.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:bt.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${bt.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:`block text-sm truncate ${bt.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:bt.name}),bt.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),bt.skipped?s.jsx("span",{className:"px-4 py-2 text-xs text-red-500 dark:text-red-400/70 bg-red-100 dark:bg-red-500/10 rounded-lg",children:"Skipped"}):s.jsx("button",{onClick:()=>Tt.mutate([bt.id]),disabled:Tt.isPending||(te?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(te?.layer_num??0)<=1?"bg-gray-100 dark:bg-bambu-dark text-gray-400 dark:text-bambu-gray/50 cursor-not-allowed":"bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-500/30 border border-red-300 dark:border-red-500/30"}`,title:(te?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},bt.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(pt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),D&&s.jsx(Sfe,{printerName:t.name,errors:te?.hms_errors||[],onClose:()=>K(!1)}),ne&&s.jsx(xke,{isOpen:!!ne,onClose:()=>se(null),printerId:t.id,printerName:t.name,amsId:ne.amsId,amsLabel:ne.amsLabel,initialMode:ne.mode,thresholds:a}),de&&s.jsx(bke,{isOpen:!!de,onClose:()=>he(null),trayUuid:de.trayUuid,trayInfo:de.trayInfo}),Ee&&s.jsx(Nke,{isOpen:!!Ee,onClose:()=>ge(null),printerId:t.id,slotInfo:Ee,onSuccess:()=>{f.invalidateQueries({queryKey:["slotPresets",t.id]}),f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),A&&s.jsx(Bke,{printer:t,onClose:()=>E(!1)}),Ne&&Je&&s.jsx(zke,{printer:t,firmwareInfo:Je,onClose:()=>Re(!1)}),Vn&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>_r(null)})]})}function Uke({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,o]=w.useState(!1),[l,c]=w.useState([]),[u,d]=w.useState(""),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[v,b]=w.useState("192.168.1.0/24"),[y,M]=w.useState({scanned:0,total:0});w.useEffect(()=>{ml.getInfo().then(C=>{x(C.is_docker)}).catch(()=>{})},[]);const S=l.filter(C=>!n.includes(C.serial)),A=async()=>{d(""),c([]),o(!0),m(!1),M({scanned:0,total:0});try{if(p){await ml.startSubnetScan(v);const C=setInterval(async()=>{try{const R=await ml.getScanStatus();M({scanned:R.scanned,total:R.total});const T=await ml.getDiscoveredPrinters();c(T),R.running||(clearInterval(C),o(!1),m(!0))}catch(R){console.error("Failed to get scan status:",R)}},500)}else{await ml.startDiscovery(10);const C=setInterval(async()=>{try{const R=await ml.getDiscoveredPrinters();c(R)}catch(R){console.error("Failed to get discovered printers:",R)}},1e3);setTimeout(async()=>{clearInterval(C);try{await ml.stopDiscovery()}catch{}o(!1),m(!0);try{const R=await ml.getDiscoveredPrinters();c(R)}catch(R){console.error("Failed to get final discovered printers:",R)}},1e4)}}catch(C){console.error("Failed to start discovery:",C),d(C instanceof Error?C.message:"Failed to start discovery"),o(!1),m(!0)}},E=C=>C?{O1D:"H2D",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D",H2C:"H2C",H2S:"H2S"}[C]||C:"",k=C=>{i({...r,name:C.name||"",serial_number:C.serial,ip_address:C.ip_address,model:E(C.model)}),c([])};return w.useEffect(()=>()=>{ml.stopDiscovery().catch(()=>{}),ml.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const C=R=>{R.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(wt,{className:"w-full max-w-md",onClick:C=>C.stopPropagation(),children:s.jsxs(Mt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),s.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[p&&s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Subnet to scan"}),s.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",value:v,onChange:C=>b(C.target.value),placeholder:"192.168.1.0/24",disabled:a}),s.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",s.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),s.jsx(Me,{type:"button",variant:"secondary",onClick:A,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),p&&y.total>0?`Scanning... ${y.scanned}/${y.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ws,{className:"w-4 h-4"}),p?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),S.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:S.map(C=>s.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>k(C),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:C.name||C.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[E(C.model)||"Unknown"," • ",C.ip_address]})]}),s.jsx(Ji,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},C.serial))}),a&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:p?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!a&&l.length===0&&s.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",p?" in the specified subnet":" on the network","."]}),f&&!a&&l.length>0&&S.length===0&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),s.jsxs("form",{onSubmit:C=>{C.preventDefault(),e(r)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:C=>i({...r,name:C.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:C=>i({...r,ip_address:C.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.serial_number,onChange:C=>i({...r,serial_number:C.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:C=>i({...r,access_code:C.target.value}),placeholder:"From printer settings"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model||"",onChange:C=>i({...r,model:C.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:C=>i({...r,auto_archive:C.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function zke({printer:t,firmwareInfo:e,onClose:n}){const r=Qt(),{showToast:i}=Un(),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),{data:f,isLoading:m}=lt({queryKey:["firmwarePrepare",t.id],queryFn:()=>D1.prepareUpload(t.id),staleTime:3e4}),p=ft({mutationFn:()=>D1.startUpload(t.id),onSuccess:()=>{c(!0);const v=setInterval(async()=>{try{const b=await D1.getUploadStatus(t.id);o(b),(b.status==="complete"||b.status==="error")&&(clearInterval(v),d(null),c(!1),b.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(v)},onError:v=>{i(`Failed to start upload: ${v.message}`,"error"),c(!1)}});w.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const x=()=>{o(null),p.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(wt,{className:"w-full max-w-md mx-4",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:s.jsx(Jr,{className:"w-5 h-5 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Firmware Update"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[s.jsxs("div",{className:"flex justify-between items-center text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:"Current:"}),s.jsx("span",{className:"text-white font-mono",children:e.current_version||"Unknown"})]}),s.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Latest:"}),s.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&s.jsxs("details",{className:"mt-3 text-sm",children:[s.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:"Release Notes"}),s.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),m?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Checking prerequisites..."]}):f&&!l&&!a?s.jsx("div",{className:"mb-4",children:f.can_proceed?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[s.jsx(Rs,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):s.jsx("div",{className:"space-y-1",children:f.errors.map((v,b)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(ea,{className:"w-4 h-4 flex-shrink-0"}),v]},b))})}):null,(l||a)&&a&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray capitalize",children:a.status}),s.jsxs("span",{className:"text-white",children:[a.progress,"%"]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:`h-2 rounded-full transition-all ${a.status==="error"?"bg-red-500":a.status==="complete"?"bg-bambu-green":"bg-orange-500"} ${a.status==="uploading"?"animate-pulse":""}`,style:{width:`${a.progress}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.message}),a.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:a.error})]}),a?.status==="complete"&&s.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:"Firmware uploaded to SD card!"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["On the printer's touchscreen, go to ",s.jsx("strong",{className:"text-white",children:"Settings"})]}),s.jsxs("li",{children:["Navigate to ",s.jsx("strong",{className:"text-white",children:"Firmware"})]}),s.jsxs("li",{children:["Select ",s.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),s.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Me,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Me,{onClick:x,disabled:p.isPending,children:p.isPending?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Jr,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function Bke({printer:t,onClose:e}){const n=Qt(),[r,i]=w.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=ft({mutationFn:l=>pe.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});w.useEffect(()=>{const l=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e]);const o=l=>{l.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(wt,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:s.jsxs(Mt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),s.jsxs("form",{onSubmit:o,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:l=>i({...r,name:l.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:l=>i({...r,ip_address:l.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:l=>i({...r,access_code:l.target.value}),placeholder:"Leave empty to keep current"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:l=>i({...r,model:l.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),s.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:l=>i({...r,location:l.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:l=>i({...r,auto_archive:l.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function $ke(t){const{data:e}=lt({queryKey:["printerStatus",t],queryFn:()=>pe.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function Hke({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=$ke(t.id),{data:a}=lt({queryKey:["smartPlugStatus",e.id],queryFn:()=>pe.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),s.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[s.jsx(uu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function Vke(){const[t,e]=w.useState(!1),[n,r]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,p]=w.useState(()=>{const G=localStorage.getItem("printerCardSize");return G?parseInt(G,10):2}),x=m===1?"compact":"expanded",v=Qt(),[b,y]=w.useState(()=>{const G=localStorage.getItem("openEmbeddedCameras");if(G)try{const ee=JSON.parse(G);return new Map(ee.map(ne=>[ne.id,ne]))}catch{return new Map}return new Map});w.useEffect(()=>{const G=Array.from(b.values());G.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(G)):localStorage.removeItem("openEmbeddedCameras")},[b]);const{data:M,isLoading:S}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:A}=lt({queryKey:["settings"],queryFn:pe.getSettings});w.useEffect(()=>{A?.camera_view_mode==="window"&&b.size>0&&y(new Map)},[A?.camera_view_mode,b.size]);const{data:E}=lt({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:k}=lt({queryKey:["maintenanceOverview"],queryFn:pe.getMaintenanceOverview,staleTime:60*1e3}),{data:C}=lt({queryKey:["spoolman-status"],queryFn:pe.getSpoolmanStatus,staleTime:60*1e3}),R=C?.enabled&&C?.connected,{data:T}=lt({queryKey:["unlinked-spools"],queryFn:pe.getUnlinkedSpools,enabled:!!R,staleTime:30*1e3}),P=T&&T.length>0,F=k?.reduce((G,ee)=>(G[ee.printer_id]={due_count:ee.due_count,warning_count:ee.warning_count,total_print_hours:ee.total_print_hours},G),{})||{},I=E?.reduce((G,ee)=>(ee.printer_id&&(G[ee.printer_id]=ee),G),{})||{},X=ft({mutationFn:pe.createPrinter,onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),v.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),D=ft({mutationFn:G=>pe.controlSmartPlug(G,"on"),onSuccess:()=>{v.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),K=()=>{const G=!n;r(G),localStorage.setItem("hideDisconnectedPrinters",String(G))},Y=G=>{u(G),localStorage.setItem("printerSortBy",G)},q=()=>{const G=!d;f(G),localStorage.setItem("printerSortAsc",String(G))},Z=()=>{switch(m){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},re=["S","M","L","XL"],ie=w.useMemo(()=>{if(!M)return[];const G=[...M];switch(c){case"name":G.sort((ee,ne)=>ee.name.localeCompare(ne.name));break;case"model":G.sort((ee,ne)=>(ee.model||"").localeCompare(ne.model||""));break;case"location":G.sort((ee,ne)=>{const se=ee.location||"",de=ne.location||"";return!se&&de?1:se&&!de?-1:se.localeCompare(de)||ee.name.localeCompare(ne.name)});break;case"status":G.sort((ee,ne)=>{const se=v.getQueryData(["printerStatus",ee.id]),de=v.getQueryData(["printerStatus",ne.id]),he=Ee=>Ee?.connected?Ee.state==="RUNNING"?0:1:2;return he(se)-he(de)});break}return d||G.reverse(),G},[M,c,d,v]),U=w.useMemo(()=>{if(c!=="location")return null;const G={};return ie.forEach(ee=>{const ne=ee.location||"Ungrouped";G[ne]||(G[ne]=[]),G[ne].push(ee)}),G},[c,ie]);return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),s.jsx(Fke,{printers:M})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("select",{value:c,onChange:G=>Y(G.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"status",children:"Status"}),s.jsx("option",{value:"model",children:"Model"}),s.jsx("option",{value:"location",children:"Location"})]}),s.jsx("button",{onClick:q,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(Kp,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(i0,{className:"w-4 h-4 text-bambu-gray"})})]}),s.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:re.map((G,ee)=>{const ne=ee+1,se=m===ne;return s.jsx("button",{onClick:()=>{p(ne),localStorage.setItem("printerCardSize",String(ne))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${ee===0?"rounded-l-lg":""} ${ee===re.length-1?"rounded-r-lg":""} ${se?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${G==="S"?"Small":G==="M"?"Medium":G==="L"?"Large":"Extra large"} cards`,children:G},G)})}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:n,onChange:K,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(I).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[s.jsx(uu,{className:"w-4 h-4"}),"Power On",s.jsx(Ji,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[s.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),M?.filter(G=>I[G.id]).map(G=>s.jsx(Hke,{printer:G,plug:I[G.id],onPowerOn:ee=>{l(ee),D.mutate(ee)},isPowering:o===I[G.id]?.id},G.id)),M?.filter(G=>I[G.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Me,{onClick:()=>e(!0),children:[s.jsx(qn,{className:"w-4 h-4"}),"Add Printer"]})]})]}),S?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):M?.length===0?s.jsx(wt,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),s.jsxs(Me,{onClick:()=>e(!0),children:[s.jsx(qn,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):U?s.jsx("div",{className:"space-y-6",children:Object.entries(U).map(([G,ee])=>s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),G,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ee.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Z()}`,children:ee.map(ne=>s.jsx(nH,{printer:ne,hideIfDisconnected:n,maintenanceInfo:F[ne.id],viewMode:x,cardSize:m,amsThresholds:A?{humidityGood:Number(A.ams_humidity_good)||40,humidityFair:Number(A.ams_humidity_fair)||60,tempGood:Number(A.ams_temp_good)||28,tempFair:Number(A.ams_temp_fair)||35}:void 0,spoolmanEnabled:R,hasUnlinkedSpools:P,timeFormat:A?.time_format||"system",cameraViewMode:A?.camera_view_mode||"window",onOpenEmbeddedCamera:(se,de)=>y(he=>new Map(he).set(se,{id:se,name:de}))},ne.id))})]},G))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Z()}`,children:ie.map(G=>s.jsx(nH,{printer:G,hideIfDisconnected:n,maintenanceInfo:F[G.id],viewMode:x,cardSize:m,spoolmanEnabled:R,hasUnlinkedSpools:P,amsThresholds:A?{humidityGood:Number(A.ams_humidity_good)||40,humidityFair:Number(A.ams_humidity_fair)||60,tempGood:Number(A.ams_temp_good)||28,tempFair:Number(A.ams_temp_fair)||35}:void 0,timeFormat:A?.time_format||"system",cameraViewMode:A?.camera_view_mode||"window",onOpenEmbeddedCamera:(ee,ne)=>y(se=>new Map(se).set(ee,{id:ee,name:ne}))},G.id))}),t&&s.jsx(Uke,{onClose:()=>e(!1),onAdd:G=>X.mutate(G),existingSerials:M?.map(G=>G.serial_number)||[]}),Array.from(b.values()).map((G,ee)=>s.jsx(bfe,{printerId:G.id,printerName:G.name,viewerIndex:ee,onClose:()=>y(ne=>{const se=new Map(ne);return se.delete(G.id),se})},G.id))]})}function Gke(){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 Wke(){switch(Gke()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function Oc(t){const e=Wke();window.location.href=`${e}${encodeURIComponent(t)}`}const cO="181",Up={ROTATE:0,DOLLY:1,PAN:2},kp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},qke=0,rH=1,Kke=2,SZ=1,Xke=2,Tc=3,Bd=0,ds=1,Sl=2,qc=0,zp=1,iH=2,aH=3,sH=4,Yke=5,Lh=100,Qke=101,Zke=102,Jke=103,eje=104,tje=200,nje=201,rje=202,ije=203,X3=204,Y3=205,aje=206,sje=207,oje=208,lje=209,cje=210,uje=211,dje=212,hje=213,fje=214,Q3=0,Z3=1,J3=2,cg=3,eP=4,tP=5,nP=6,rP=7,uO=0,mje=1,pje=2,Ed=0,gje=1,xje=2,bje=3,yje=4,vje=5,_je=6,wje=7,MZ=300,ug=301,dg=302,iP=303,aP=304,DM=306,sP=1e3,zc=1001,oP=1002,zs=1003,Sje=1004,m_=1005,wo=1006,bC=1007,Xh=1008,zl=1009,NZ=1010,EZ=1011,S0=1012,dO=1013,jf=1014,Bc=1015,Vg=1016,hO=1017,fO=1018,M0=1020,AZ=35902,TZ=35899,CZ=1021,kZ=1022,Xo=1023,N0=1026,E0=1027,jZ=1028,mO=1029,pO=1030,gO=1031,xO=1033,$1=33776,H1=33777,V1=33778,G1=33779,lP=35840,cP=35841,uP=35842,dP=35843,hP=36196,fP=37492,mP=37496,pP=37808,gP=37809,xP=37810,bP=37811,yP=37812,vP=37813,_P=37814,wP=37815,SP=37816,MP=37817,NP=37818,EP=37819,AP=37820,TP=37821,CP=36492,kP=36494,jP=36495,PP=36283,RP=36284,DP=36285,OP=36286,Mje=3200,Nje=3201,PZ=0,Eje=1,dd="",fo="srgb",hg="srgb-linear",mS="linear",sr="srgb",Dm=7680,oH=519,Aje=512,Tje=513,Cje=514,RZ=515,kje=516,jje=517,Pje=518,Rje=519,lH=35044,cH="300 es",Al=2e3,pS=2001;function DZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function gS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Dje(){const t=gS("canvas");return t.style.display="block",t}const uH={};function dH(...t){const e="THREE."+t.shift();console.log(e,...t)}function nn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function ai(...t){const e="THREE."+t.shift();console.error(e,...t)}function A0(...t){const e=t.join(" ");e in uH||(uH[e]=!0,nn(...t))}function Oje(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}let Kf=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}};const va=["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"],W1=Math.PI/180,LP=180/Math.PI;function Ny(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(va[t&255]+va[t>>8&255]+va[t>>16&255]+va[t>>24&255]+"-"+va[e&255]+va[e>>8&255]+"-"+va[e>>16&15|64]+va[e>>24&255]+"-"+va[n&63|128]+va[n>>8&255]+"-"+va[n>>16&255]+va[n>>24&255]+va[r&255]+va[r>>8&255]+va[r>>16&255]+va[r>>24&255]).toLowerCase()}function Mn(t,e,n){return Math.max(e,Math.min(n,t))}function Lje(t,e){return(t%e+e)%e}function yC(t,e,n){return(1-n)*t+n*e}function Zx(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 ns(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 Ije={DEG2RAD:W1};let gn=class OZ{constructor(e=0,n=0){OZ.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=Mn(this.x,e.x,n.x),this.y=Mn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Mn(this.x,e,n),this.y=Mn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Mn(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(Mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Pf=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],m=a[o+0],p=a[o+1],x=a[o+2],v=a[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=m,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==m||u!==p||d!==x){let b=c*m+u*p+d*x+f*v;b<0&&(m=-m,p=-p,x=-x,v=-v,b=-b);let y=1-l;if(b<.9995){const M=Math.acos(b),S=Math.sin(M);y=Math.sin(y*M)/S,l=Math.sin(l*M)/S,c=c*y+m*l,u=u*y+p*l,d=d*y+x*l,f=f*y+v*l}else{c=c*y+m*l,u=u*y+p*l,d=d*y+x*l,f=f*y+v*l;const M=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=M,u*=M,d*=M,f*=M}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],m=a[o+1],p=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*p-u*m,e[n+1]=c*x+d*m+u*f-l*p,e[n+2]=u*x+d*p+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),m=c(r/2),p=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"YXZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"ZXY":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"ZYX":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"YZX":this._x=m*d*f+u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f-m*p*x;break;case"XZY":this._x=m*d*f-u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f+m*p*x;break;default:nn("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Mn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,o=-o,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},at=class LZ{constructor(e=0,n=0,r=0){LZ.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(hH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(hH.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Mn(this.x,e.x,n.x),this.y=Mn(this.y,e.y,n.y),this.z=Mn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Mn(this.x,e,n),this.y=Mn(this.y,e,n),this.z=Mn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return vC.copy(this).projectOnVector(e),this.sub(vC)}reflect(e){return this.sub(vC.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(Mn(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 vC=new at,hH=new Pf;let vn=class IZ{constructor(e,n,r,i,a,o,l,c,u){IZ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],m=r[2],p=r[5],x=r[8],v=i[0],b=i[3],y=i[6],M=i[1],S=i[4],A=i[7],E=i[2],k=i[5],C=i[8];return a[0]=o*v+l*M+c*E,a[3]=o*b+l*S+c*k,a[6]=o*y+l*A+c*C,a[1]=u*v+d*M+f*E,a[4]=u*b+d*S+f*k,a[7]=u*y+d*A+f*C,a[2]=m*v+p*M+x*E,a[5]=m*b+p*S+x*k,a[8]=m*y+p*A+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,m=l*c-d*a,p=u*a-o*c,x=n*f+r*m+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*o)*v,e[3]=m*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(o*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(_C.makeScale(e,n)),this}rotate(e){return this.premultiply(_C.makeRotation(-e)),this}translate(e,n){return this.premultiply(_C.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 _C=new vn,fH=new vn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mH=new vn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Fje(){const t={enabled:!0,workingColorSpace:hg,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===sr&&(i.r=Kc(i.r),i.g=Kc(i.g),i.b=Kc(i.b)),this.spaces[a].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===sr&&(i.r=Bp(i.r),i.g=Bp(i.g),i.b=Bp(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===dd?mS:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,o){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return A0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return A0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[hg]:{primaries:e,whitePoint:r,transfer:mS,toXYZ:fH,fromXYZ:mH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:fo},outputColorSpaceConfig:{drawingBufferColorSpace:fo}},[fo]:{primaries:e,whitePoint:r,transfer:sr,toXYZ:fH,fromXYZ:mH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:fo}}}),t}const In=Fje();function Kc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Bp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Om,Uje=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{Om===void 0&&(Om=gS("canvas")),Om.width=e.width,Om.height=e.height;const i=Om.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Om}return r.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=gS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Kc(a[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Kc(n[r]/255)*255):n[r]=Kc(n[r]);return{data:n,width:e.width,height:e.height}}else return nn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},zje=0,bO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zje++}),this.uuid=Ny(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(wC(i[o].image)):a.push(wC(i[o]))}else a=wC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function wC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Uje.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(nn("Texture: Unable to serialize Texture."),{})}let Bje=0;const SC=new at;let ll=class q1 extends Kf{constructor(e=q1.DEFAULT_IMAGE,n=q1.DEFAULT_MAPPING,r=zc,i=zc,a=wo,o=Xh,l=Xo,c=zl,u=q1.DEFAULT_ANISOTROPY,d=dd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Bje++}),this.uuid=Ny(),this.name="",this.source=new bO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new gn(0,0),this.repeat=new gn(1,1),this.center=new gn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new vn,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(SC).x}get height(){return this.source.getSize(SC).y}get depth(){return this.source.getSize(SC).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){nn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){nn(`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!==MZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case sP:e.x=e.x-Math.floor(e.x);break;case zc:e.x=e.x<0?0:1;break;case oP: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 sP:e.y=e.y-Math.floor(e.y);break;case zc:e.y=e.y<0?0:1;break;case oP: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++}};ll.DEFAULT_IMAGE=null;ll.DEFAULT_MAPPING=MZ;ll.DEFAULT_ANISOTROPY=1;let pi=class FZ{constructor(e=0,n=0,r=0,i=1){FZ.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],m=c[1],p=c[5],x=c[9],v=c[2],b=c[6],y=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-v)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+v)<.1&&Math.abs(x+b)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(p+1)/2,E=(y+1)/2,k=(d+m)/4,C=(f+v)/4,R=(x+b)/4;return S>A&&S>E?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=k/r,a=C/r):A>E?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=R/i):E<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(E),r=C/a,i=R/a),this.set(r,i,a,n),this}let M=Math.sqrt((b-x)*(b-x)+(f-v)*(f-v)+(m-d)*(m-d));return Math.abs(M)<.001&&(M=1),this.x=(b-x)/M,this.y=(f-v)/M,this.z=(m-d)/M,this.w=Math.acos((u+p+y-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=Mn(this.x,e.x,n.x),this.y=Mn(this.y,e.y,n.y),this.z=Mn(this.z,e.z,n.z),this.w=Mn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Mn(this.x,e,n),this.y=Mn(this.y,e,n),this.z=Mn(this.z,e,n),this.w=Mn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Mn(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}},$je=class extends Kf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wo,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 pi(0,0,e,n),this.scissorTest=!1,this.viewport=new pi(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new ll(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=a.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:wo,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new bO(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"})}},Rf=class extends $je{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},UZ=class extends ll{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=zs,this.minFilter=zs,this.wrapR=zc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Hje=class extends ll{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=zs,this.minFilter=zs,this.wrapR=zc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Df=class{constructor(e=new at(1/0,1/0,1/0),n=new at(-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(Io.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Io.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=Io.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Io):Io.fromBufferAttribute(a,o),Io.applyMatrix4(e.matrixWorld),this.expandByPoint(Io);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),p_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),p_.copy(r.boundingBox)),p_.applyMatrix4(e.matrixWorld),this.union(p_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Io),Io.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(Jx),g_.subVectors(this.max,Jx),Lm.subVectors(e.a,Jx),Im.subVectors(e.b,Jx),Fm.subVectors(e.c,Jx),zu.subVectors(Im,Lm),Bu.subVectors(Fm,Im),yh.subVectors(Lm,Fm);let n=[0,-zu.z,zu.y,0,-Bu.z,Bu.y,0,-yh.z,yh.y,zu.z,0,-zu.x,Bu.z,0,-Bu.x,yh.z,0,-yh.x,-zu.y,zu.x,0,-Bu.y,Bu.x,0,-yh.y,yh.x,0];return!MC(n,Lm,Im,Fm,g_)||(n=[1,0,0,0,1,0,0,0,1],!MC(n,Lm,Im,Fm,g_))?!1:(x_.crossVectors(zu,Bu),n=[x_.x,x_.y,x_.z],MC(n,Lm,Im,Fm,g_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Io).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Io).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:(mc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),mc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),mc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),mc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),mc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),mc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),mc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),mc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(mc),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 mc=[new at,new at,new at,new at,new at,new at,new at,new at],Io=new at,p_=new Df,Lm=new at,Im=new at,Fm=new at,zu=new at,Bu=new at,yh=new at,Jx=new at,g_=new at,x_=new at,vh=new at;function MC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){vh.fromArray(t,a);const l=i.x*Math.abs(vh.x)+i.y*Math.abs(vh.y)+i.z*Math.abs(vh.z),c=e.dot(vh),u=n.dot(vh),d=r.dot(vh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const Vje=new Df,eb=new at,NC=new at;let OM=class{constructor(e=new at,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):Vje.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;eb.subVectors(e,this.center);const n=eb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(eb,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):(NC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(eb.copy(e.center).add(NC)),this.expandByPoint(eb.copy(e.center).sub(NC))),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 pc=new at,EC=new at,b_=new at,$u=new at,AC=new at,y_=new at,TC=new at;let yO=class{constructor(e=new at,n=new at(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,pc)),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=pc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(pc.copy(this.origin).addScaledVector(this.direction,n),pc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){EC.copy(e).add(n).multiplyScalar(.5),b_.copy(n).sub(e).normalize(),$u.copy(this.origin).sub(EC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(b_),l=$u.dot(this.direction),c=-$u.dot(b_),u=$u.lengthSq(),d=Math.abs(1-o*o);let f,m,p,x;if(d>0)if(f=o*c-l,m=o*l-c,x=a*d,f>=0)if(m>=-x)if(m<=x){const v=1/d;f*=v,m*=v,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-x?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(EC).addScaledVector(b_,m),p}intersectSphere(e,n){pc.subVectors(e.center,this.origin);const r=pc.dot(this.direction),i=pc.dot(pc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,pc)!==null}intersectTriangle(e,n,r,i,a){AC.subVectors(n,e),y_.subVectors(r,e),TC.crossVectors(AC,y_);let o=this.direction.dot(TC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;$u.subVectors(this.origin,e);const c=l*this.direction.dot(y_.crossVectors($u,y_));if(c<0)return null;const u=l*this.direction.dot(AC.cross($u));if(u<0||c+u>o)return null;const d=-l*$u.dot(TC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},vi=class IP{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,x,v,b){IP.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,m,p,x,v,b)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,x,v,b){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=m,y[3]=p,y[7]=x,y[11]=v,y[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 IP().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/Um.setFromMatrixColumn(e,0).length(),a=1/Um.setFromMatrixColumn(e,1).length(),o=1/Um.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const m=o*d,p=o*f,x=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=m-v*u,n[9]=-l*c,n[2]=v-m*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,x=u*d,v=u*f;n[0]=m+v*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=v+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,x=u*d,v=u*f;n[0]=m-v*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=v-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,x=l*d,v=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=m*u+v,n[1]=c*f,n[5]=v*u+m,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,x=l*c,v=l*u;n[0]=c*d,n[4]=v-m*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=m-v*f}else if(e.order==="XZY"){const m=o*c,p=o*u,x=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+v,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=v*f+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Gje,e,Wje)}lookAt(e,n,r){const i=this.elements;return As.subVectors(e,n),As.lengthSq()===0&&(As.z=1),As.normalize(),Hu.crossVectors(r,As),Hu.lengthSq()===0&&(Math.abs(r.z)===1?As.x+=1e-4:As.z+=1e-4,As.normalize(),Hu.crossVectors(r,As)),Hu.normalize(),v_.crossVectors(As,Hu),i[0]=Hu.x,i[4]=v_.x,i[8]=As.x,i[1]=Hu.y,i[5]=v_.y,i[9]=As.y,i[2]=Hu.z,i[6]=v_.z,i[10]=As.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],m=r[9],p=r[13],x=r[2],v=r[6],b=r[10],y=r[14],M=r[3],S=r[7],A=r[11],E=r[15],k=i[0],C=i[4],R=i[8],T=i[12],P=i[1],F=i[5],I=i[9],X=i[13],D=i[2],K=i[6],Y=i[10],q=i[14],Z=i[3],re=i[7],ie=i[11],U=i[15];return a[0]=o*k+l*P+c*D+u*Z,a[4]=o*C+l*F+c*K+u*re,a[8]=o*R+l*I+c*Y+u*ie,a[12]=o*T+l*X+c*q+u*U,a[1]=d*k+f*P+m*D+p*Z,a[5]=d*C+f*F+m*K+p*re,a[9]=d*R+f*I+m*Y+p*ie,a[13]=d*T+f*X+m*q+p*U,a[2]=x*k+v*P+b*D+y*Z,a[6]=x*C+v*F+b*K+y*re,a[10]=x*R+v*I+b*Y+y*ie,a[14]=x*T+v*X+b*q+y*U,a[3]=M*k+S*P+A*D+E*Z,a[7]=M*C+S*F+A*K+E*re,a[11]=M*R+S*I+A*Y+E*ie,a[15]=M*T+S*X+A*q+E*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],p=e[14],x=e[3],v=e[7],b=e[11],y=e[15];return x*(+a*c*f-i*u*f-a*l*m+r*u*m+i*l*p-r*c*p)+v*(+n*c*p-n*u*m+a*o*m-i*o*p+i*u*d-a*c*d)+b*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+y*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],m=e[10],p=e[11],x=e[12],v=e[13],b=e[14],y=e[15],M=f*b*u-v*m*u+v*c*p-l*b*p-f*c*y+l*m*y,S=x*m*u-d*b*u-x*c*p+o*b*p+d*c*y-o*m*y,A=d*v*u-x*f*u+x*l*p-o*v*p-d*l*y+o*f*y,E=x*f*c-d*v*c-x*l*m+o*v*m+d*l*b-o*f*b,k=n*M+r*S+i*A+a*E;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=M*C,e[1]=(v*m*a-f*b*a-v*i*p+r*b*p+f*i*y-r*m*y)*C,e[2]=(l*b*a-v*c*a+v*i*u-r*b*u-l*i*y+r*c*y)*C,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*C,e[4]=S*C,e[5]=(d*b*a-x*m*a+x*i*p-n*b*p-d*i*y+n*m*y)*C,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*y-n*c*y)*C,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*C,e[8]=A*C,e[9]=(x*f*a-d*v*a-x*r*p+n*v*p+d*r*y-n*f*y)*C,e[10]=(o*v*a-x*l*a+x*r*u-n*v*u-o*r*y+n*l*y)*C,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*C,e[12]=E*C,e[13]=(d*v*i-x*f*i+x*r*m-n*v*m-d*r*b+n*f*b)*C,e[14]=(x*l*i-o*v*i-x*r*c+n*v*c+o*r*b-n*l*b)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,m=a*u,p=a*d,x=a*f,v=o*d,b=o*f,y=l*f,M=c*u,S=c*d,A=c*f,E=r.x,k=r.y,C=r.z;return i[0]=(1-(v+y))*E,i[1]=(p+A)*E,i[2]=(x-S)*E,i[3]=0,i[4]=(p-A)*k,i[5]=(1-(m+y))*k,i[6]=(b+M)*k,i[7]=0,i[8]=(x+S)*C,i[9]=(b-M)*C,i[10]=(1-(m+v))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Um.set(i[0],i[1],i[2]).length();const o=Um.set(i[4],i[5],i[6]).length(),l=Um.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Fo.copy(this);const u=1/a,d=1/o,f=1/l;return Fo.elements[0]*=u,Fo.elements[1]*=u,Fo.elements[2]*=u,Fo.elements[4]*=d,Fo.elements[5]*=d,Fo.elements[6]*=d,Fo.elements[8]*=f,Fo.elements[9]*=f,Fo.elements[10]*=f,n.setFromRotationMatrix(Fo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Al,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),m=(n+e)/(n-e),p=(r+i)/(r-i);let x,v;if(c)x=a/(o-a),v=o*a/(o-a);else if(l===Al)x=-(o+a)/(o-a),v=-2*o*a/(o-a);else if(l===pS)x=-o/(o-a),v=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Al,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),m=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,v;if(c)x=1/(o-a),v=o/(o-a);else if(l===Al)x=-2/(o-a),v=-(o+a)/(o-a);else if(l===pS)x=-1/(o-a),v=-a/(o-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=m,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=v,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 Um=new at,Fo=new vi,Gje=new at(0,0,0),Wje=new at(1,1,1),Hu=new at,v_=new at,As=new at,pH=new vi,gH=new Pf;let $d=class zZ{constructor(e=0,n=0,r=0,i=zZ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(Mn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Mn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Mn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Mn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Mn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-Mn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:nn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return pH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(pH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return gH.setFromEuler(this),this.setFromQuaternion(gH,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}};$d.DEFAULT_ORDER="XYZ";let BZ=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}},qje=0;const xH=new at,zm=new Pf,gc=new vi,__=new at,tb=new at,Kje=new at,Xje=new Pf,bH=new at(1,0,0),yH=new at(0,1,0),vH=new at(0,0,1),_H={type:"added"},Yje={type:"removed"},Bm={type:"childadded",child:null},CC={type:"childremoved",child:null};let Ks=class K1 extends Kf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qje++}),this.uuid=Ny(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=K1.DEFAULT_UP.clone();const e=new at,n=new $d,r=new Pf,i=new at(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new vi},normalMatrix:{value:new vn}}),this.matrix=new vi,this.matrixWorld=new vi,this.matrixAutoUpdate=K1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=K1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new BZ,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 zm.setFromAxisAngle(e,n),this.quaternion.multiply(zm),this}rotateOnWorldAxis(e,n){return zm.setFromAxisAngle(e,n),this.quaternion.premultiply(zm),this}rotateX(e){return this.rotateOnAxis(bH,e)}rotateY(e){return this.rotateOnAxis(yH,e)}rotateZ(e){return this.rotateOnAxis(vH,e)}translateOnAxis(e,n){return xH.copy(e).applyQuaternion(this.quaternion),this.position.add(xH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(bH,e)}translateY(e){return this.translateOnAxis(yH,e)}translateZ(e){return this.translateOnAxis(vH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(gc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?__.copy(e):__.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),tb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?gc.lookAt(tb,__,this.up):gc.lookAt(__,tb,this.up),this.quaternion.setFromRotationMatrix(gc),i&&(gc.extractRotation(i.matrixWorld),zm.setFromRotationMatrix(gc),this.quaternion.premultiply(zm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(ai("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(_H),Bm.child=e,this.dispatchEvent(Bm),Bm.child=null):ai("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(Yje),CC.child=e,this.dispatchEvent(CC),CC.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),gc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),gc.multiply(e.parent.matrixWorld)),e.applyMatrix4(gc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(_H),Bm.child=e,this.dispatchEvent(Bm),Bm.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(tb,e,Kje),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(tb,Xje,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),m=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Ks.DEFAULT_UP=new at(0,1,0);Ks.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ks.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Uo=new at,xc=new at,kC=new at,bc=new at,$m=new at,Hm=new at,wH=new at,jC=new at,PC=new at,RC=new at,DC=new pi,OC=new pi,LC=new pi;let nb=class _p{constructor(e=new at,n=new at,r=new at){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Uo.subVectors(e,n),i.cross(Uo);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Uo.subVectors(i,n),xc.subVectors(r,n),kC.subVectors(e,n);const o=Uo.dot(Uo),l=Uo.dot(xc),c=Uo.dot(kC),u=xc.dot(xc),d=xc.dot(kC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const m=1/f,p=(u*c-l*d)*m,x=(o*d-l*c)*m;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,bc)===null?!1:bc.x>=0&&bc.y>=0&&bc.x+bc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,bc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,bc.x),c.addScaledVector(o,bc.y),c.addScaledVector(l,bc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return DC.setScalar(0),OC.setScalar(0),LC.setScalar(0),DC.fromBufferAttribute(e,n),OC.fromBufferAttribute(e,r),LC.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(DC,a.x),o.addScaledVector(OC,a.y),o.addScaledVector(LC,a.z),o}static isFrontFacing(e,n,r,i){return Uo.subVectors(r,n),xc.subVectors(e,n),Uo.cross(xc).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 Uo.subVectors(this.c,this.b),xc.subVectors(this.a,this.b),Uo.cross(xc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return _p.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return _p.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return _p.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return _p.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _p.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;$m.subVectors(i,r),Hm.subVectors(a,r),jC.subVectors(e,r);const c=$m.dot(jC),u=Hm.dot(jC);if(c<=0&&u<=0)return n.copy(r);PC.subVectors(e,i);const d=$m.dot(PC),f=Hm.dot(PC);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector($m,o);RC.subVectors(e,a);const p=$m.dot(RC),x=Hm.dot(RC);if(x>=0&&p<=x)return n.copy(a);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Hm,l);const b=d*x-p*f;if(b<=0&&f-d>=0&&p-x>=0)return wH.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(wH,l);const y=1/(b+v+m);return o=v*y,l=m*y,n.copy(r).addScaledVector($m,o).addScaledVector(Hm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const $Z={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},Vu={h:0,s:0,l:0},w_={h:0,s:0,l:0};function IC(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 Nn=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=fo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,In.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=In.workingColorSpace){return this.r=e,this.g=n,this.b=r,In.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=In.workingColorSpace){if(e=Lje(e,1),n=Mn(n,0,1),r=Mn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=IC(o,a,e+1/3),this.g=IC(o,a,e),this.b=IC(o,a,e-1/3)}return In.colorSpaceToWorking(this,i),this}setStyle(e,n=fo){function r(a){a!==void 0&&parseFloat(a)<1&&nn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:nn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);nn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=fo){const r=$Z[e.toLowerCase()];return r!==void 0?this.setHex(r,n):nn("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=Kc(e.r),this.g=Kc(e.g),this.b=Kc(e.b),this}copyLinearToSRGB(e){return this.r=Bp(e.r),this.g=Bp(e.g),this.b=Bp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=fo){return In.workingToColorSpace(_a.copy(this),e),Math.round(Mn(_a.r*255,0,255))*65536+Math.round(Mn(_a.g*255,0,255))*256+Math.round(Mn(_a.b*255,0,255))}getHexString(e=fo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=In.workingColorSpace){In.workingToColorSpace(_a.copy(this),n);const r=_a.r,i=_a.g,a=_a.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=In.workingColorSpace){return In.workingToColorSpace(_a.copy(this),n),e.r=_a.r,e.g=_a.g,e.b=_a.b,e}getStyle(e=fo){In.workingToColorSpace(_a.copy(this),e);const n=_a.r,r=_a.g,i=_a.b;return e!==fo?`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(Vu),this.setHSL(Vu.h+e,Vu.s+n,Vu.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(Vu),e.getHSL(w_);const r=yC(Vu.h,w_.h,n),i=yC(Vu.s,w_.s,n),a=yC(Vu.l,w_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const _a=new Nn;Nn.NAMES=$Z;let Qje=0,Gg=class extends Kf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Qje++}),this.uuid=Ny(),this.name="",this.type="Material",this.blending=zp,this.side=Bd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=X3,this.blendDst=Y3,this.blendEquation=Lh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Nn(0,0,0),this.blendAlpha=0,this.depthFunc=cg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=oH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Dm,this.stencilZFail=Dm,this.stencilZPass=Dm,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){nn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){nn(`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!==zp&&(r.blending=this.blending),this.side!==Bd&&(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!==X3&&(r.blendSrc=this.blendSrc),this.blendDst!==Y3&&(r.blendDst=this.blendDst),this.blendEquation!==Lh&&(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!==cg&&(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!==oH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Dm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Dm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Dm&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},vO=class extends Gg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Nn(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 $d,this.combine=uO,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 di=new at,S_=new gn;let Zje=0,So=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:Zje++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=lH,this.updateRanges=[],this.gpuType=Bc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)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++)di.fromBufferAttribute(this,n),di.applyMatrix3(e),this.setXYZ(n,di.x,di.y,di.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.applyMatrix4(e),this.setXYZ(n,di.x,di.y,di.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.applyNormalMatrix(e),this.setXYZ(n,di.x,di.y,di.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.transformDirection(e),this.setXYZ(n,di.x,di.y,di.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=Zx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=ns(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Zx(n,this.array)),n}setX(e,n){return this.normalized&&(n=ns(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Zx(n,this.array)),n}setY(e,n){return this.normalized&&(n=ns(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=Zx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=ns(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=Zx(n,this.array)),n}setW(e,n){return this.normalized&&(n=ns(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=ns(n,this.array),r=ns(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=ns(n,this.array),r=ns(r,this.array),i=ns(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=ns(n,this.array),r=ns(r,this.array),i=ns(i,this.array),a=ns(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==lH&&(e.usage=this.usage),e}},HZ=class extends So{constructor(e,n,r){super(new Uint16Array(e),n,r)}},VZ=class extends So{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Jo=class extends So{constructor(e,n,r){super(new Float32Array(e),n,r)}},Jje=0;const ao=new vi,FC=new Ks,Vm=new at,Ts=new Df,rb=new Df,zi=new at;let Xl=class GZ extends Kf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Jje++}),this.uuid=Ny(),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(DZ(e)?VZ:HZ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new vn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return ao.makeRotationFromQuaternion(e),this.applyMatrix4(ao),this}rotateX(e){return ao.makeRotationX(e),this.applyMatrix4(ao),this}rotateY(e){return ao.makeRotationY(e),this.applyMatrix4(ao),this}rotateZ(e){return ao.makeRotationZ(e),this.applyMatrix4(ao),this}translate(e,n,r){return ao.makeTranslation(e,n,r),this.applyMatrix4(ao),this}scale(e,n,r){return ao.makeScale(e,n,r),this.applyMatrix4(ao),this}lookAt(e){return FC.lookAt(e),FC.updateMatrix(),this.applyMatrix4(FC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Vm).negate(),this.translate(Vm.x,Vm.y,Vm.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Jo(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&nn("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 Df);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ai("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new at(-1/0,-1/0,-1/0),new at(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];Ts.setFromBufferAttribute(a),this.morphTargetsRelative?(zi.addVectors(this.boundingBox.min,Ts.min),this.boundingBox.expandByPoint(zi),zi.addVectors(this.boundingBox.max,Ts.max),this.boundingBox.expandByPoint(zi)):(this.boundingBox.expandByPoint(Ts.min),this.boundingBox.expandByPoint(Ts.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ai('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 OM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ai("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new at,1/0);return}if(e){const r=this.boundingSphere.center;if(Ts.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];rb.setFromBufferAttribute(l),this.morphTargetsRelative?(zi.addVectors(Ts.min,rb.min),Ts.expandByPoint(zi),zi.addVectors(Ts.max,rb.max),Ts.expandByPoint(zi)):(Ts.expandByPoint(rb.min),Ts.expandByPoint(rb.max))}Ts.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)zi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(zi));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)zi.fromBufferAttribute(l,u),c&&(Vm.fromBufferAttribute(e,u),zi.add(Vm)),i=Math.max(i,r.distanceToSquared(zi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ai('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){ai("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new So(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let R=0;R<r.count;R++)l[R]=new at,c[R]=new at;const u=new at,d=new at,f=new at,m=new gn,p=new gn,x=new gn,v=new at,b=new at;function y(R,T,P){u.fromBufferAttribute(r,R),d.fromBufferAttribute(r,T),f.fromBufferAttribute(r,P),m.fromBufferAttribute(a,R),p.fromBufferAttribute(a,T),x.fromBufferAttribute(a,P),d.sub(u),f.sub(u),p.sub(m),x.sub(m);const F=1/(p.x*x.y-x.x*p.y);isFinite(F)&&(v.copy(d).multiplyScalar(x.y).addScaledVector(f,-p.y).multiplyScalar(F),b.copy(f).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(F),l[R].add(v),l[T].add(v),l[P].add(v),c[R].add(b),c[T].add(b),c[P].add(b))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let R=0,T=M.length;R<T;++R){const P=M[R],F=P.start,I=P.count;for(let X=F,D=F+I;X<D;X+=3)y(e.getX(X+0),e.getX(X+1),e.getX(X+2))}const S=new at,A=new at,E=new at,k=new at;function C(R){E.fromBufferAttribute(i,R),k.copy(E);const T=l[R];S.copy(T),S.sub(E.multiplyScalar(E.dot(T))).normalize(),A.crossVectors(k,T);const F=A.dot(c[R])<0?-1:1;o.setXYZW(R,S.x,S.y,S.z,F)}for(let R=0,T=M.length;R<T;++R){const P=M[R],F=P.start,I=P.count;for(let X=F,D=F+I;X<D;X+=3)C(e.getX(X+0)),C(e.getX(X+1)),C(e.getX(X+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 So(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new at,a=new at,o=new at,l=new at,c=new at,u=new at,d=new at,f=new at;if(e)for(let m=0,p=e.count;m<p;m+=3){const x=e.getX(m+0),v=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),o.fromBufferAttribute(n,b),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)zi.fromBufferAttribute(e,n),zi.normalize(),e.setXYZ(n,zi.x,zi.y,zi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,b=c.length;v<b;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let y=0;y<d;y++)m[x++]=u[p++]}return new So(m,d,f)}if(this.index===null)return nn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new GZ,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const m=u[d],p=e(m,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let m=0,p=f.length;m<p;m++)d.push(f[m].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const SH=new vi,_h=new yO,M_=new OM,MH=new at,N_=new at,E_=new at,A_=new at,UC=new at,T_=new at,NH=new at,C_=new at;let Bl=class extends Ks{constructor(e=new Xl,n=new vO){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){T_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(UC.fromBufferAttribute(f,e),o?T_.addScaledVector(UC,d):T_.addScaledVector(UC.sub(n),d))}n.add(T_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),M_.copy(r.boundingSphere),M_.applyMatrix4(a),_h.copy(e.ray).recast(e.near),!(M_.containsPoint(_h.origin)===!1&&(_h.intersectSphere(M_,MH)===null||_h.origin.distanceToSquared(MH)>(e.far-e.near)**2))&&(SH.copy(a).invert(),_h.copy(e.ray).applyMatrix4(SH),!(r.boundingBox!==null&&_h.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,_h)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,v=m.length;x<v;x++){const b=m[x],y=o[b.materialIndex],M=Math.max(b.start,p.start),S=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let A=M,E=S;A<E;A+=3){const k=l.getX(A),C=l.getX(A+1),R=l.getX(A+2);i=k_(this,y,e,r,u,d,f,k,C,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let b=x,y=v;b<y;b+=3){const M=l.getX(b),S=l.getX(b+1),A=l.getX(b+2);i=k_(this,o,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,v=m.length;x<v;x++){const b=m[x],y=o[b.materialIndex],M=Math.max(b.start,p.start),S=Math.min(c.count,Math.min(b.start+b.count,p.start+p.count));for(let A=M,E=S;A<E;A+=3){const k=A,C=A+1,R=A+2;i=k_(this,y,e,r,u,d,f,k,C,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let b=x,y=v;b<y;b+=3){const M=b,S=b+1,A=b+2;i=k_(this,o,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function e3e(t,e,n,r,i,a,o,l){let c;if(e.side===ds?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Bd,l),c===null)return null;C_.copy(l),C_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(C_);return u<n.near||u>n.far?null:{distance:u,point:C_.clone(),object:t}}function k_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,N_),t.getVertexPosition(c,E_),t.getVertexPosition(u,A_);const d=e3e(t,e,n,r,N_,E_,A_,NH);if(d){const f=new at;nb.getBarycoord(NH,N_,E_,A_,f),i&&(d.uv=nb.getInterpolatedAttribute(i,l,c,u,f,new gn)),a&&(d.uv1=nb.getInterpolatedAttribute(a,l,c,u,f,new gn)),o&&(d.normal=nb.getInterpolatedAttribute(o,l,c,u,f,new at),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new at,materialIndex:0};nb.getNormal(N_,E_,A_,m.normal),d.face=m,d.barycoord=f}return d}let _O=class WZ extends Xl{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let m=0,p=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Jo(u,3)),this.setAttribute("normal",new Jo(d,3)),this.setAttribute("uv",new Jo(f,2));function x(v,b,y,M,S,A,E,k,C,R,T){const P=A/C,F=E/R,I=A/2,X=E/2,D=k/2,K=C+1,Y=R+1;let q=0,Z=0;const re=new at;for(let ie=0;ie<Y;ie++){const U=ie*F-X;for(let G=0;G<K;G++){const ee=G*P-I;re[v]=ee*M,re[b]=U*S,re[y]=D,u.push(re.x,re.y,re.z),re[v]=0,re[b]=0,re[y]=k>0?1:-1,d.push(re.x,re.y,re.z),f.push(G/C),f.push(1-ie/R),q+=1}}for(let ie=0;ie<R;ie++)for(let U=0;U<C;U++){const G=m+U+K*ie,ee=m+U+K*(ie+1),ne=m+(U+1)+K*(ie+1),se=m+(U+1)+K*ie;c.push(G,ee,se),c.push(ee,ne,se),Z+=6}l.addGroup(p,Z,T),p+=Z,m+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new WZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function fg(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(nn("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 La(t){const e={};for(let n=0;n<t.length;n++){const r=fg(t[n]);for(const i in r)e[i]=r[i]}return e}function t3e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function qZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:In.workingColorSpace}const n3e={clone:fg,merge:La};var r3e=`void main() {
  91. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  92. }`,i3e=`void main() {
  93. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  94. }`;let lu=class extends Gg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=r3e,this.fragmentShader=i3e,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=fg(e.uniforms),this.uniformsGroups=t3e(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}},KZ=class extends Ks{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vi,this.projectionMatrix=new vi,this.projectionMatrixInverse=new vi,this.coordinateSystem=Al,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 Gu=new at,EH=new gn,AH=new gn;let go=class extends KZ{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=LP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(W1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return LP*2*Math.atan(Math.tan(W1*.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){Gu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Gu.x,Gu.y).multiplyScalar(-e/Gu.z),Gu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Gu.x,Gu.y).multiplyScalar(-e/Gu.z)}getViewSize(e,n){return this.getViewBounds(e,EH,AH),n.subVectors(AH,EH)}setViewOffset(e,n,r,i,a,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(W1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const Gm=-90,Wm=1;let a3e=class extends Ks{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new go(Gm,Wm,e,n);i.layers=this.layers,this.add(i);const a=new go(Gm,Wm,e,n);a.layers=this.layers,this.add(a);const o=new go(Gm,Wm,e,n);o.layers=this.layers,this.add(o);const l=new go(Gm,Wm,e,n);l.layers=this.layers,this.add(l);const c=new go(Gm,Wm,e,n);c.layers=this.layers,this.add(c);const u=new go(Gm,Wm,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===Al)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===pS)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},XZ=class extends ll{constructor(e=[],n=ug,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},s3e=class extends Rf{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 XZ(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:`
  95. varying vec3 vWorldDirection;
  96. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  97. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  98. }
  99. void main() {
  100. vWorldDirection = transformDirection( position, modelMatrix );
  101. #include <begin_vertex>
  102. #include <project_vertex>
  103. }
  104. `,fragmentShader:`
  105. uniform sampler2D tEquirect;
  106. varying vec3 vWorldDirection;
  107. #include <common>
  108. void main() {
  109. vec3 direction = normalize( vWorldDirection );
  110. vec2 sampleUV = equirectUv( direction );
  111. gl_FragColor = texture2D( tEquirect, sampleUV );
  112. }
  113. `},i=new _O(5,5,5),a=new lu({name:"CubemapFromEquirect",uniforms:fg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ds,blending:qc});a.uniforms.tEquirect.value=n;const o=new Bl(i,a),l=n.minFilter;return n.minFilter===Xh&&(n.minFilter=wo),new a3e(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}},vb=class extends Ks{constructor(){super(),this.isGroup=!0,this.type="Group"}};const o3e={type:"move"};let zC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new vb,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 vb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new at,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new at),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new vb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new at,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new at),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const v of e.hand.values()){const b=n.getJointPose(v,r),y=this._getHandJoint(u,v);b!==null&&(y.matrix.fromArray(b.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=b.radius),y.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&m>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(o3e)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new vb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},l3e=class extends Ks{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 $d,this.environmentIntensity=1,this.environmentRotation=new $d,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}},c3e=class extends ll{constructor(e=null,n=1,r=1,i,a,o,l,c,u=zs,d=zs,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const BC=new at,u3e=new at,d3e=new vn;let id=class{constructor(e=new at(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=BC.subVectors(r,n).cross(u3e.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(BC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||d3e.getNormalMatrix(e),i=this.coplanarPoint(BC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const wh=new OM,h3e=new gn(.5,.5),j_=new at;let wO=class{constructor(e=new id,n=new id,r=new id,i=new id,a=new id,o=new id){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Al,r=!1){const i=this.planes,a=e.elements,o=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],m=a[6],p=a[7],x=a[8],v=a[9],b=a[10],y=a[11],M=a[12],S=a[13],A=a[14],E=a[15];if(i[0].setComponents(u-o,p-d,y-x,E-M).normalize(),i[1].setComponents(u+o,p+d,y+x,E+M).normalize(),i[2].setComponents(u+l,p+f,y+v,E+S).normalize(),i[3].setComponents(u-l,p-f,y-v,E-S).normalize(),r)i[4].setComponents(c,m,b,A).normalize(),i[5].setComponents(u-c,p-m,y-b,E-A).normalize();else if(i[4].setComponents(u-c,p-m,y-b,E-A).normalize(),n===Al)i[5].setComponents(u+c,p+m,y+b,E+A).normalize();else if(n===pS)i[5].setComponents(c,m,b,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),wh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),wh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(wh)}intersectsSprite(e){wh.center.set(0,0,0);const n=h3e.distanceTo(e.center);return wh.radius=.7071067811865476+n,wh.applyMatrix4(e.matrixWorld),this.intersectsSphere(wh)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(j_.x=i.normal.x>0?e.max.x:e.min.x,j_.y=i.normal.y>0?e.max.y:e.min.y,j_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(j_)<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)}},YZ=class extends Gg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Nn(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 xS=new at,bS=new at,TH=new vi,ib=new yO,P_=new OM,$C=new at,CH=new at;let f3e=class extends Ks{constructor(e=new Xl,n=new YZ){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)xS.fromBufferAttribute(n,i-1),bS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=xS.distanceTo(bS);e.setAttribute("lineDistance",new Jo(r,1))}else nn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),P_.copy(r.boundingSphere),P_.applyMatrix4(i),P_.radius+=a,e.ray.intersectsSphere(P_)===!1)return;TH.copy(i).invert(),ib.copy(e.ray).applyMatrix4(TH);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,m=r.attributes.position;if(d!==null){const p=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let v=p,b=x-1;v<b;v+=u){const y=d.getX(v),M=d.getX(v+1),S=R_(this,e,ib,c,y,M,v);S&&n.push(S)}if(this.isLineLoop){const v=d.getX(x-1),b=d.getX(p),y=R_(this,e,ib,c,v,b,x-1);y&&n.push(y)}}else{const p=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let v=p,b=x-1;v<b;v+=u){const y=R_(this,e,ib,c,v,v+1,v);y&&n.push(y)}if(this.isLineLoop){const v=R_(this,e,ib,c,x-1,p,x-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function R_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(xS.fromBufferAttribute(l,i),bS.fromBufferAttribute(l,a),n.distanceSqToSegment(xS,bS,$C,CH)>r)return;$C.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo($C);if(!(u<e.near||u>e.far))return{distance:u,point:CH.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const kH=new at,jH=new at;let m3e=class extends f3e{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)kH.fromBufferAttribute(n,i),jH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+kH.distanceTo(jH);e.setAttribute("lineDistance",new Jo(r,1))}else nn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},QZ=class extends ll{constructor(e,n,r=jf,i,a,o,l=zs,c=zs,u,d=N0,f=1){if(d!==N0&&d!==E0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:f};super(m,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new bO(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 ZZ extends ll{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let SO=class JZ extends Xl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,m=n/c,p=[],x=[],v=[],b=[];for(let y=0;y<d;y++){const M=y*m-o;for(let S=0;S<u;S++){const A=S*f-a;x.push(A,-M,0),v.push(0,0,1),b.push(S/l),b.push(1-y/c)}}for(let y=0;y<c;y++)for(let M=0;M<l;M++){const S=M+u*y,A=M+u*(y+1),E=M+1+u*(y+1),k=M+1+u*y;p.push(S,A,k),p.push(A,E,k)}this.setIndex(p),this.setAttribute("position",new Jo(x,3)),this.setAttribute("normal",new Jo(v,3)),this.setAttribute("uv",new Jo(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new JZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class p3e extends Gg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Nn(16777215),this.specular=new Nn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=PZ,this.normalScale=new gn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new $d,this.combine=uO,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 g3e=class extends Gg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Mje,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}},x3e=class extends Gg{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}},eJ=class extends Ks{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Nn(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 HC=new vi,PH=new at,RH=new at;let b3e=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new gn(512,512),this.mapType=zl,this.map=null,this.mapPass=null,this.matrix=new vi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new wO,this._frameExtents=new gn(1,1),this._viewportCount=1,this._viewports=[new pi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;PH.setFromMatrixPosition(e.matrixWorld),n.position.copy(PH),RH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(RH),n.updateMatrixWorld(),HC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(HC,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(HC)}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}},tJ=class extends KZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=o,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,o,l,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class y3e extends b3e{constructor(){super(new tJ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class DH extends eJ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ks.DEFAULT_UP),this.updateMatrix(),this.target=new Ks,this.shadow=new y3e}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let v3e=class extends eJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},_3e=class extends go{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},OH=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=Mn(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(Mn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class w3e extends m3e{constructor(e=10,n=10,r=4473924,i=8947848){r=new Nn(r),i=new Nn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let m=0,p=0,x=-l;m<=n;m++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const v=m===a?r:i;v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3}const d=new Xl;d.setAttribute("position",new Jo(c,3)),d.setAttribute("color",new Jo(u,3));const f=new YZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class S3e extends Kf{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){nn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function LH(t,e,n,r){const i=M3e(r);switch(n){case CZ:return t*e;case jZ:return t*e/i.components*i.byteLength;case mO:return t*e/i.components*i.byteLength;case pO:return t*e*2/i.components*i.byteLength;case gO:return t*e*2/i.components*i.byteLength;case kZ:return t*e*3/i.components*i.byteLength;case Xo:return t*e*4/i.components*i.byteLength;case xO:return t*e*4/i.components*i.byteLength;case $1:case H1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case V1:case G1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case cP:case dP:return Math.max(t,16)*Math.max(e,8)/4;case lP:case uP:return Math.max(t,8)*Math.max(e,8)/2;case hP:case fP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case mP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case pP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case gP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case xP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case bP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case yP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case vP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case _P:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case wP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case SP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case MP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case NP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case EP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case AP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case TP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case CP:case kP:case jP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case PP:case RP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case DP:case OP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function M3e(t){switch(t){case zl:case NZ:return{byteLength:1,components:1};case S0:case EZ:case Vg:return{byteLength:2,components:1};case hO:case fO:return{byteLength:2,components:4};case jf:case dO:case Bc:return{byteLength:4,components:1};case AZ:case TZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:cO}}));typeof window<"u"&&(window.__THREE__?nn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=cO);function nJ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function N3e(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,m=t.createBuffer();t.bindBuffer(c,m),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:m,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((p,x)=>p.start-x.start);let m=0;for(let p=1;p<f.length;p++){const x=f[m],v=f[p];v.start<=x.start+x.count+1?x.count=Math.max(x.count,v.start+v.count-x.start):(++m,f[m]=v)}f.length=m+1;for(let p=0,x=f.length;p<x;p++){const v=f[p];t.bufferSubData(u,v.start*d.BYTES_PER_ELEMENT,d,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function o(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:a,update:o}}var E3e=`#ifdef USE_ALPHAHASH
  114. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  115. #endif`,A3e=`#ifdef USE_ALPHAHASH
  116. const float ALPHA_HASH_SCALE = 0.05;
  117. float hash2D( vec2 value ) {
  118. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  119. }
  120. float hash3D( vec3 value ) {
  121. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  122. }
  123. float getAlphaHashThreshold( vec3 position ) {
  124. float maxDeriv = max(
  125. length( dFdx( position.xyz ) ),
  126. length( dFdy( position.xyz ) )
  127. );
  128. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  129. vec2 pixScales = vec2(
  130. exp2( floor( log2( pixScale ) ) ),
  131. exp2( ceil( log2( pixScale ) ) )
  132. );
  133. vec2 alpha = vec2(
  134. hash3D( floor( pixScales.x * position.xyz ) ),
  135. hash3D( floor( pixScales.y * position.xyz ) )
  136. );
  137. float lerpFactor = fract( log2( pixScale ) );
  138. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  139. float a = min( lerpFactor, 1.0 - lerpFactor );
  140. vec3 cases = vec3(
  141. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  142. ( x - 0.5 * a ) / ( 1.0 - a ),
  143. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  144. );
  145. float threshold = ( x < ( 1.0 - a ) )
  146. ? ( ( x < a ) ? cases.x : cases.y )
  147. : cases.z;
  148. return clamp( threshold , 1.0e-6, 1.0 );
  149. }
  150. #endif`,T3e=`#ifdef USE_ALPHAMAP
  151. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  152. #endif`,C3e=`#ifdef USE_ALPHAMAP
  153. uniform sampler2D alphaMap;
  154. #endif`,k3e=`#ifdef USE_ALPHATEST
  155. #ifdef ALPHA_TO_COVERAGE
  156. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  157. if ( diffuseColor.a == 0.0 ) discard;
  158. #else
  159. if ( diffuseColor.a < alphaTest ) discard;
  160. #endif
  161. #endif`,j3e=`#ifdef USE_ALPHATEST
  162. uniform float alphaTest;
  163. #endif`,P3e=`#ifdef USE_AOMAP
  164. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  165. reflectedLight.indirectDiffuse *= ambientOcclusion;
  166. #if defined( USE_CLEARCOAT )
  167. clearcoatSpecularIndirect *= ambientOcclusion;
  168. #endif
  169. #if defined( USE_SHEEN )
  170. sheenSpecularIndirect *= ambientOcclusion;
  171. #endif
  172. #if defined( USE_ENVMAP ) && defined( STANDARD )
  173. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  174. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  175. #endif
  176. #endif`,R3e=`#ifdef USE_AOMAP
  177. uniform sampler2D aoMap;
  178. uniform float aoMapIntensity;
  179. #endif`,D3e=`#ifdef USE_BATCHING
  180. #if ! defined( GL_ANGLE_multi_draw )
  181. #define gl_DrawID _gl_DrawID
  182. uniform int _gl_DrawID;
  183. #endif
  184. uniform highp sampler2D batchingTexture;
  185. uniform highp usampler2D batchingIdTexture;
  186. mat4 getBatchingMatrix( const in float i ) {
  187. int size = textureSize( batchingTexture, 0 ).x;
  188. int j = int( i ) * 4;
  189. int x = j % size;
  190. int y = j / size;
  191. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  192. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  193. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  194. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  195. return mat4( v1, v2, v3, v4 );
  196. }
  197. float getIndirectIndex( const in int i ) {
  198. int size = textureSize( batchingIdTexture, 0 ).x;
  199. int x = i % size;
  200. int y = i / size;
  201. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  202. }
  203. #endif
  204. #ifdef USE_BATCHING_COLOR
  205. uniform sampler2D batchingColorTexture;
  206. vec3 getBatchingColor( const in float i ) {
  207. int size = textureSize( batchingColorTexture, 0 ).x;
  208. int j = int( i );
  209. int x = j % size;
  210. int y = j / size;
  211. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  212. }
  213. #endif`,O3e=`#ifdef USE_BATCHING
  214. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  215. #endif`,L3e=`vec3 transformed = vec3( position );
  216. #ifdef USE_ALPHAHASH
  217. vPosition = vec3( position );
  218. #endif`,I3e=`vec3 objectNormal = vec3( normal );
  219. #ifdef USE_TANGENT
  220. vec3 objectTangent = vec3( tangent.xyz );
  221. #endif`,F3e=`float G_BlinnPhong_Implicit( ) {
  222. return 0.25;
  223. }
  224. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  225. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  226. }
  227. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  228. vec3 halfDir = normalize( lightDir + viewDir );
  229. float dotNH = saturate( dot( normal, halfDir ) );
  230. float dotVH = saturate( dot( viewDir, halfDir ) );
  231. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  232. float G = G_BlinnPhong_Implicit( );
  233. float D = D_BlinnPhong( shininess, dotNH );
  234. return F * ( G * D );
  235. } // validated`,U3e=`#ifdef USE_IRIDESCENCE
  236. const mat3 XYZ_TO_REC709 = mat3(
  237. 3.2404542, -0.9692660, 0.0556434,
  238. -1.5371385, 1.8760108, -0.2040259,
  239. -0.4985314, 0.0415560, 1.0572252
  240. );
  241. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  242. vec3 sqrtF0 = sqrt( fresnel0 );
  243. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  244. }
  245. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  246. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  247. }
  248. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  249. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  250. }
  251. vec3 evalSensitivity( float OPD, vec3 shift ) {
  252. float phase = 2.0 * PI * OPD * 1.0e-9;
  253. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  254. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  255. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  256. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  257. 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 ) );
  258. xyz /= 1.0685e-7;
  259. vec3 rgb = XYZ_TO_REC709 * xyz;
  260. return rgb;
  261. }
  262. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  263. vec3 I;
  264. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  265. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  266. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  267. if ( cosTheta2Sq < 0.0 ) {
  268. return vec3( 1.0 );
  269. }
  270. float cosTheta2 = sqrt( cosTheta2Sq );
  271. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  272. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  273. float T121 = 1.0 - R12;
  274. float phi12 = 0.0;
  275. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  276. float phi21 = PI - phi12;
  277. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  278. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  279. vec3 phi23 = vec3( 0.0 );
  280. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  281. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  282. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  283. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  284. vec3 phi = vec3( phi21 ) + phi23;
  285. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  286. vec3 r123 = sqrt( R123 );
  287. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  288. vec3 C0 = R12 + Rs;
  289. I = C0;
  290. vec3 Cm = Rs - T121;
  291. for ( int m = 1; m <= 2; ++ m ) {
  292. Cm *= r123;
  293. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  294. I += Cm * Sm;
  295. }
  296. return max( I, vec3( 0.0 ) );
  297. }
  298. #endif`,z3e=`#ifdef USE_BUMPMAP
  299. uniform sampler2D bumpMap;
  300. uniform float bumpScale;
  301. vec2 dHdxy_fwd() {
  302. vec2 dSTdx = dFdx( vBumpMapUv );
  303. vec2 dSTdy = dFdy( vBumpMapUv );
  304. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  305. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  306. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  307. return vec2( dBx, dBy );
  308. }
  309. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  310. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  311. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  312. vec3 vN = surf_norm;
  313. vec3 R1 = cross( vSigmaY, vN );
  314. vec3 R2 = cross( vN, vSigmaX );
  315. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  316. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  317. return normalize( abs( fDet ) * surf_norm - vGrad );
  318. }
  319. #endif`,B3e=`#if NUM_CLIPPING_PLANES > 0
  320. vec4 plane;
  321. #ifdef ALPHA_TO_COVERAGE
  322. float distanceToPlane, distanceGradient;
  323. float clipOpacity = 1.0;
  324. #pragma unroll_loop_start
  325. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  326. plane = clippingPlanes[ i ];
  327. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  328. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  329. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  330. if ( clipOpacity == 0.0 ) discard;
  331. }
  332. #pragma unroll_loop_end
  333. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  334. float unionClipOpacity = 1.0;
  335. #pragma unroll_loop_start
  336. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  337. plane = clippingPlanes[ i ];
  338. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  339. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  340. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  341. }
  342. #pragma unroll_loop_end
  343. clipOpacity *= 1.0 - unionClipOpacity;
  344. #endif
  345. diffuseColor.a *= clipOpacity;
  346. if ( diffuseColor.a == 0.0 ) discard;
  347. #else
  348. #pragma unroll_loop_start
  349. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  350. plane = clippingPlanes[ i ];
  351. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  352. }
  353. #pragma unroll_loop_end
  354. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  355. bool clipped = true;
  356. #pragma unroll_loop_start
  357. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  358. plane = clippingPlanes[ i ];
  359. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  360. }
  361. #pragma unroll_loop_end
  362. if ( clipped ) discard;
  363. #endif
  364. #endif
  365. #endif`,$3e=`#if NUM_CLIPPING_PLANES > 0
  366. varying vec3 vClipPosition;
  367. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  368. #endif`,H3e=`#if NUM_CLIPPING_PLANES > 0
  369. varying vec3 vClipPosition;
  370. #endif`,V3e=`#if NUM_CLIPPING_PLANES > 0
  371. vClipPosition = - mvPosition.xyz;
  372. #endif`,G3e=`#if defined( USE_COLOR_ALPHA )
  373. diffuseColor *= vColor;
  374. #elif defined( USE_COLOR )
  375. diffuseColor.rgb *= vColor;
  376. #endif`,W3e=`#if defined( USE_COLOR_ALPHA )
  377. varying vec4 vColor;
  378. #elif defined( USE_COLOR )
  379. varying vec3 vColor;
  380. #endif`,q3e=`#if defined( USE_COLOR_ALPHA )
  381. varying vec4 vColor;
  382. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  383. varying vec3 vColor;
  384. #endif`,K3e=`#if defined( USE_COLOR_ALPHA )
  385. vColor = vec4( 1.0 );
  386. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  387. vColor = vec3( 1.0 );
  388. #endif
  389. #ifdef USE_COLOR
  390. vColor *= color;
  391. #endif
  392. #ifdef USE_INSTANCING_COLOR
  393. vColor.xyz *= instanceColor.xyz;
  394. #endif
  395. #ifdef USE_BATCHING_COLOR
  396. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  397. vColor.xyz *= batchingColor.xyz;
  398. #endif`,X3e=`#define PI 3.141592653589793
  399. #define PI2 6.283185307179586
  400. #define PI_HALF 1.5707963267948966
  401. #define RECIPROCAL_PI 0.3183098861837907
  402. #define RECIPROCAL_PI2 0.15915494309189535
  403. #define EPSILON 1e-6
  404. #ifndef saturate
  405. #define saturate( a ) clamp( a, 0.0, 1.0 )
  406. #endif
  407. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  408. float pow2( const in float x ) { return x*x; }
  409. vec3 pow2( const in vec3 x ) { return x*x; }
  410. float pow3( const in float x ) { return x*x*x; }
  411. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  412. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  413. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  414. highp float rand( const in vec2 uv ) {
  415. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  416. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  417. return fract( sin( sn ) * c );
  418. }
  419. #ifdef HIGH_PRECISION
  420. float precisionSafeLength( vec3 v ) { return length( v ); }
  421. #else
  422. float precisionSafeLength( vec3 v ) {
  423. float maxComponent = max3( abs( v ) );
  424. return length( v / maxComponent ) * maxComponent;
  425. }
  426. #endif
  427. struct IncidentLight {
  428. vec3 color;
  429. vec3 direction;
  430. bool visible;
  431. };
  432. struct ReflectedLight {
  433. vec3 directDiffuse;
  434. vec3 directSpecular;
  435. vec3 indirectDiffuse;
  436. vec3 indirectSpecular;
  437. };
  438. #ifdef USE_ALPHAHASH
  439. varying vec3 vPosition;
  440. #endif
  441. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  442. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  443. }
  444. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  445. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  446. }
  447. bool isPerspectiveMatrix( mat4 m ) {
  448. return m[ 2 ][ 3 ] == - 1.0;
  449. }
  450. vec2 equirectUv( in vec3 dir ) {
  451. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  452. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  453. return vec2( u, v );
  454. }
  455. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  456. return RECIPROCAL_PI * diffuseColor;
  457. }
  458. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  459. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  460. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  461. }
  462. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  463. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  464. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  465. } // validated`,Y3e=`#ifdef ENVMAP_TYPE_CUBE_UV
  466. #define cubeUV_minMipLevel 4.0
  467. #define cubeUV_minTileSize 16.0
  468. float getFace( vec3 direction ) {
  469. vec3 absDirection = abs( direction );
  470. float face = - 1.0;
  471. if ( absDirection.x > absDirection.z ) {
  472. if ( absDirection.x > absDirection.y )
  473. face = direction.x > 0.0 ? 0.0 : 3.0;
  474. else
  475. face = direction.y > 0.0 ? 1.0 : 4.0;
  476. } else {
  477. if ( absDirection.z > absDirection.y )
  478. face = direction.z > 0.0 ? 2.0 : 5.0;
  479. else
  480. face = direction.y > 0.0 ? 1.0 : 4.0;
  481. }
  482. return face;
  483. }
  484. vec2 getUV( vec3 direction, float face ) {
  485. vec2 uv;
  486. if ( face == 0.0 ) {
  487. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  488. } else if ( face == 1.0 ) {
  489. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  490. } else if ( face == 2.0 ) {
  491. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  492. } else if ( face == 3.0 ) {
  493. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  494. } else if ( face == 4.0 ) {
  495. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  496. } else {
  497. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  498. }
  499. return 0.5 * ( uv + 1.0 );
  500. }
  501. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  502. float face = getFace( direction );
  503. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  504. mipInt = max( mipInt, cubeUV_minMipLevel );
  505. float faceSize = exp2( mipInt );
  506. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  507. if ( face > 2.0 ) {
  508. uv.y += faceSize;
  509. face -= 3.0;
  510. }
  511. uv.x += face * faceSize;
  512. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  513. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  514. uv.x *= CUBEUV_TEXEL_WIDTH;
  515. uv.y *= CUBEUV_TEXEL_HEIGHT;
  516. #ifdef texture2DGradEXT
  517. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  518. #else
  519. return texture2D( envMap, uv ).rgb;
  520. #endif
  521. }
  522. #define cubeUV_r0 1.0
  523. #define cubeUV_m0 - 2.0
  524. #define cubeUV_r1 0.8
  525. #define cubeUV_m1 - 1.0
  526. #define cubeUV_r4 0.4
  527. #define cubeUV_m4 2.0
  528. #define cubeUV_r5 0.305
  529. #define cubeUV_m5 3.0
  530. #define cubeUV_r6 0.21
  531. #define cubeUV_m6 4.0
  532. float roughnessToMip( float roughness ) {
  533. float mip = 0.0;
  534. if ( roughness >= cubeUV_r1 ) {
  535. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  536. } else if ( roughness >= cubeUV_r4 ) {
  537. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  538. } else if ( roughness >= cubeUV_r5 ) {
  539. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  540. } else if ( roughness >= cubeUV_r6 ) {
  541. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  542. } else {
  543. mip = - 2.0 * log2( 1.16 * roughness ); }
  544. return mip;
  545. }
  546. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  547. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  548. float mipF = fract( mip );
  549. float mipInt = floor( mip );
  550. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  551. if ( mipF == 0.0 ) {
  552. return vec4( color0, 1.0 );
  553. } else {
  554. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  555. return vec4( mix( color0, color1, mipF ), 1.0 );
  556. }
  557. }
  558. #endif`,Q3e=`vec3 transformedNormal = objectNormal;
  559. #ifdef USE_TANGENT
  560. vec3 transformedTangent = objectTangent;
  561. #endif
  562. #ifdef USE_BATCHING
  563. mat3 bm = mat3( batchingMatrix );
  564. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  565. transformedNormal = bm * transformedNormal;
  566. #ifdef USE_TANGENT
  567. transformedTangent = bm * transformedTangent;
  568. #endif
  569. #endif
  570. #ifdef USE_INSTANCING
  571. mat3 im = mat3( instanceMatrix );
  572. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  573. transformedNormal = im * transformedNormal;
  574. #ifdef USE_TANGENT
  575. transformedTangent = im * transformedTangent;
  576. #endif
  577. #endif
  578. transformedNormal = normalMatrix * transformedNormal;
  579. #ifdef FLIP_SIDED
  580. transformedNormal = - transformedNormal;
  581. #endif
  582. #ifdef USE_TANGENT
  583. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  584. #ifdef FLIP_SIDED
  585. transformedTangent = - transformedTangent;
  586. #endif
  587. #endif`,Z3e=`#ifdef USE_DISPLACEMENTMAP
  588. uniform sampler2D displacementMap;
  589. uniform float displacementScale;
  590. uniform float displacementBias;
  591. #endif`,J3e=`#ifdef USE_DISPLACEMENTMAP
  592. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  593. #endif`,ePe=`#ifdef USE_EMISSIVEMAP
  594. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  595. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  596. emissiveColor = sRGBTransferEOTF( emissiveColor );
  597. #endif
  598. totalEmissiveRadiance *= emissiveColor.rgb;
  599. #endif`,tPe=`#ifdef USE_EMISSIVEMAP
  600. uniform sampler2D emissiveMap;
  601. #endif`,nPe="gl_FragColor = linearToOutputTexel( gl_FragColor );",rPe=`vec4 LinearTransferOETF( in vec4 value ) {
  602. return value;
  603. }
  604. vec4 sRGBTransferEOTF( in vec4 value ) {
  605. 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 );
  606. }
  607. vec4 sRGBTransferOETF( in vec4 value ) {
  608. 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 );
  609. }`,iPe=`#ifdef USE_ENVMAP
  610. #ifdef ENV_WORLDPOS
  611. vec3 cameraToFrag;
  612. if ( isOrthographic ) {
  613. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  614. } else {
  615. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  616. }
  617. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  618. #ifdef ENVMAP_MODE_REFLECTION
  619. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  620. #else
  621. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  622. #endif
  623. #else
  624. vec3 reflectVec = vReflect;
  625. #endif
  626. #ifdef ENVMAP_TYPE_CUBE
  627. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  628. #else
  629. vec4 envColor = vec4( 0.0 );
  630. #endif
  631. #ifdef ENVMAP_BLENDING_MULTIPLY
  632. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  633. #elif defined( ENVMAP_BLENDING_MIX )
  634. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  635. #elif defined( ENVMAP_BLENDING_ADD )
  636. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  637. #endif
  638. #endif`,aPe=`#ifdef USE_ENVMAP
  639. uniform float envMapIntensity;
  640. uniform float flipEnvMap;
  641. uniform mat3 envMapRotation;
  642. #ifdef ENVMAP_TYPE_CUBE
  643. uniform samplerCube envMap;
  644. #else
  645. uniform sampler2D envMap;
  646. #endif
  647. #endif`,sPe=`#ifdef USE_ENVMAP
  648. uniform float reflectivity;
  649. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  650. #define ENV_WORLDPOS
  651. #endif
  652. #ifdef ENV_WORLDPOS
  653. varying vec3 vWorldPosition;
  654. uniform float refractionRatio;
  655. #else
  656. varying vec3 vReflect;
  657. #endif
  658. #endif`,oPe=`#ifdef USE_ENVMAP
  659. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  660. #define ENV_WORLDPOS
  661. #endif
  662. #ifdef ENV_WORLDPOS
  663. varying vec3 vWorldPosition;
  664. #else
  665. varying vec3 vReflect;
  666. uniform float refractionRatio;
  667. #endif
  668. #endif`,lPe=`#ifdef USE_ENVMAP
  669. #ifdef ENV_WORLDPOS
  670. vWorldPosition = worldPosition.xyz;
  671. #else
  672. vec3 cameraToVertex;
  673. if ( isOrthographic ) {
  674. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  675. } else {
  676. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  677. }
  678. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  679. #ifdef ENVMAP_MODE_REFLECTION
  680. vReflect = reflect( cameraToVertex, worldNormal );
  681. #else
  682. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  683. #endif
  684. #endif
  685. #endif`,cPe=`#ifdef USE_FOG
  686. vFogDepth = - mvPosition.z;
  687. #endif`,uPe=`#ifdef USE_FOG
  688. varying float vFogDepth;
  689. #endif`,dPe=`#ifdef USE_FOG
  690. #ifdef FOG_EXP2
  691. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  692. #else
  693. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  694. #endif
  695. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  696. #endif`,hPe=`#ifdef USE_FOG
  697. uniform vec3 fogColor;
  698. varying float vFogDepth;
  699. #ifdef FOG_EXP2
  700. uniform float fogDensity;
  701. #else
  702. uniform float fogNear;
  703. uniform float fogFar;
  704. #endif
  705. #endif`,fPe=`#ifdef USE_GRADIENTMAP
  706. uniform sampler2D gradientMap;
  707. #endif
  708. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  709. float dotNL = dot( normal, lightDirection );
  710. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  711. #ifdef USE_GRADIENTMAP
  712. return vec3( texture2D( gradientMap, coord ).r );
  713. #else
  714. vec2 fw = fwidth( coord ) * 0.5;
  715. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  716. #endif
  717. }`,mPe=`#ifdef USE_LIGHTMAP
  718. uniform sampler2D lightMap;
  719. uniform float lightMapIntensity;
  720. #endif`,pPe=`LambertMaterial material;
  721. material.diffuseColor = diffuseColor.rgb;
  722. material.specularStrength = specularStrength;`,gPe=`varying vec3 vViewPosition;
  723. struct LambertMaterial {
  724. vec3 diffuseColor;
  725. float specularStrength;
  726. };
  727. 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 ) {
  728. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  729. vec3 irradiance = dotNL * directLight.color;
  730. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  731. }
  732. 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 ) {
  733. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  734. }
  735. #define RE_Direct RE_Direct_Lambert
  736. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,xPe=`uniform bool receiveShadow;
  737. uniform vec3 ambientLightColor;
  738. #if defined( USE_LIGHT_PROBES )
  739. uniform vec3 lightProbe[ 9 ];
  740. #endif
  741. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  742. float x = normal.x, y = normal.y, z = normal.z;
  743. vec3 result = shCoefficients[ 0 ] * 0.886227;
  744. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  745. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  746. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  747. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  748. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  749. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  750. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  751. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  752. return result;
  753. }
  754. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  755. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  756. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  757. return irradiance;
  758. }
  759. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  760. vec3 irradiance = ambientLightColor;
  761. return irradiance;
  762. }
  763. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  764. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  765. if ( cutoffDistance > 0.0 ) {
  766. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  767. }
  768. return distanceFalloff;
  769. }
  770. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  771. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  772. }
  773. #if NUM_DIR_LIGHTS > 0
  774. struct DirectionalLight {
  775. vec3 direction;
  776. vec3 color;
  777. };
  778. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  779. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  780. light.color = directionalLight.color;
  781. light.direction = directionalLight.direction;
  782. light.visible = true;
  783. }
  784. #endif
  785. #if NUM_POINT_LIGHTS > 0
  786. struct PointLight {
  787. vec3 position;
  788. vec3 color;
  789. float distance;
  790. float decay;
  791. };
  792. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  793. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  794. vec3 lVector = pointLight.position - geometryPosition;
  795. light.direction = normalize( lVector );
  796. float lightDistance = length( lVector );
  797. light.color = pointLight.color;
  798. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  799. light.visible = ( light.color != vec3( 0.0 ) );
  800. }
  801. #endif
  802. #if NUM_SPOT_LIGHTS > 0
  803. struct SpotLight {
  804. vec3 position;
  805. vec3 direction;
  806. vec3 color;
  807. float distance;
  808. float decay;
  809. float coneCos;
  810. float penumbraCos;
  811. };
  812. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  813. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  814. vec3 lVector = spotLight.position - geometryPosition;
  815. light.direction = normalize( lVector );
  816. float angleCos = dot( light.direction, spotLight.direction );
  817. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  818. if ( spotAttenuation > 0.0 ) {
  819. float lightDistance = length( lVector );
  820. light.color = spotLight.color * spotAttenuation;
  821. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  822. light.visible = ( light.color != vec3( 0.0 ) );
  823. } else {
  824. light.color = vec3( 0.0 );
  825. light.visible = false;
  826. }
  827. }
  828. #endif
  829. #if NUM_RECT_AREA_LIGHTS > 0
  830. struct RectAreaLight {
  831. vec3 color;
  832. vec3 position;
  833. vec3 halfWidth;
  834. vec3 halfHeight;
  835. };
  836. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  837. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  838. #endif
  839. #if NUM_HEMI_LIGHTS > 0
  840. struct HemisphereLight {
  841. vec3 direction;
  842. vec3 skyColor;
  843. vec3 groundColor;
  844. };
  845. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  846. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  847. float dotNL = dot( normal, hemiLight.direction );
  848. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  849. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  850. return irradiance;
  851. }
  852. #endif`,bPe=`#ifdef USE_ENVMAP
  853. vec3 getIBLIrradiance( const in vec3 normal ) {
  854. #ifdef ENVMAP_TYPE_CUBE_UV
  855. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  856. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  857. return PI * envMapColor.rgb * envMapIntensity;
  858. #else
  859. return vec3( 0.0 );
  860. #endif
  861. }
  862. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  863. #ifdef ENVMAP_TYPE_CUBE_UV
  864. vec3 reflectVec = reflect( - viewDir, normal );
  865. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  866. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  867. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  868. return envMapColor.rgb * envMapIntensity;
  869. #else
  870. return vec3( 0.0 );
  871. #endif
  872. }
  873. #ifdef USE_ANISOTROPY
  874. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  875. #ifdef ENVMAP_TYPE_CUBE_UV
  876. vec3 bentNormal = cross( bitangent, viewDir );
  877. bentNormal = normalize( cross( bentNormal, bitangent ) );
  878. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  879. return getIBLRadiance( viewDir, bentNormal, roughness );
  880. #else
  881. return vec3( 0.0 );
  882. #endif
  883. }
  884. #endif
  885. #endif`,yPe=`ToonMaterial material;
  886. material.diffuseColor = diffuseColor.rgb;`,vPe=`varying vec3 vViewPosition;
  887. struct ToonMaterial {
  888. vec3 diffuseColor;
  889. };
  890. 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 ) {
  891. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  892. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  893. }
  894. 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 ) {
  895. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  896. }
  897. #define RE_Direct RE_Direct_Toon
  898. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,_Pe=`BlinnPhongMaterial material;
  899. material.diffuseColor = diffuseColor.rgb;
  900. material.specularColor = specular;
  901. material.specularShininess = shininess;
  902. material.specularStrength = specularStrength;`,wPe=`varying vec3 vViewPosition;
  903. struct BlinnPhongMaterial {
  904. vec3 diffuseColor;
  905. vec3 specularColor;
  906. float specularShininess;
  907. float specularStrength;
  908. };
  909. 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 ) {
  910. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  911. vec3 irradiance = dotNL * directLight.color;
  912. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  913. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  914. }
  915. 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 ) {
  916. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  917. }
  918. #define RE_Direct RE_Direct_BlinnPhong
  919. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,SPe=`PhysicalMaterial material;
  920. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  921. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  922. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  923. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  924. material.roughness = min( material.roughness, 1.0 );
  925. #ifdef IOR
  926. material.ior = ior;
  927. #ifdef USE_SPECULAR
  928. float specularIntensityFactor = specularIntensity;
  929. vec3 specularColorFactor = specularColor;
  930. #ifdef USE_SPECULAR_COLORMAP
  931. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  932. #endif
  933. #ifdef USE_SPECULAR_INTENSITYMAP
  934. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  935. #endif
  936. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  937. #else
  938. float specularIntensityFactor = 1.0;
  939. vec3 specularColorFactor = vec3( 1.0 );
  940. material.specularF90 = 1.0;
  941. #endif
  942. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  943. #else
  944. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  945. material.specularF90 = 1.0;
  946. #endif
  947. #ifdef USE_CLEARCOAT
  948. material.clearcoat = clearcoat;
  949. material.clearcoatRoughness = clearcoatRoughness;
  950. material.clearcoatF0 = vec3( 0.04 );
  951. material.clearcoatF90 = 1.0;
  952. #ifdef USE_CLEARCOATMAP
  953. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  954. #endif
  955. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  956. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  957. #endif
  958. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  959. material.clearcoatRoughness += geometryRoughness;
  960. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  961. #endif
  962. #ifdef USE_DISPERSION
  963. material.dispersion = dispersion;
  964. #endif
  965. #ifdef USE_IRIDESCENCE
  966. material.iridescence = iridescence;
  967. material.iridescenceIOR = iridescenceIOR;
  968. #ifdef USE_IRIDESCENCEMAP
  969. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  970. #endif
  971. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  972. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  973. #else
  974. material.iridescenceThickness = iridescenceThicknessMaximum;
  975. #endif
  976. #endif
  977. #ifdef USE_SHEEN
  978. material.sheenColor = sheenColor;
  979. #ifdef USE_SHEEN_COLORMAP
  980. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  981. #endif
  982. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  983. #ifdef USE_SHEEN_ROUGHNESSMAP
  984. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  985. #endif
  986. #endif
  987. #ifdef USE_ANISOTROPY
  988. #ifdef USE_ANISOTROPYMAP
  989. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  990. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  991. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  992. #else
  993. vec2 anisotropyV = anisotropyVector;
  994. #endif
  995. material.anisotropy = length( anisotropyV );
  996. if( material.anisotropy == 0.0 ) {
  997. anisotropyV = vec2( 1.0, 0.0 );
  998. } else {
  999. anisotropyV /= material.anisotropy;
  1000. material.anisotropy = saturate( material.anisotropy );
  1001. }
  1002. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  1003. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  1004. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  1005. #endif`,MPe=`uniform sampler2D dfgLUT;
  1006. struct PhysicalMaterial {
  1007. vec3 diffuseColor;
  1008. float roughness;
  1009. vec3 specularColor;
  1010. float specularF90;
  1011. float dispersion;
  1012. #ifdef USE_CLEARCOAT
  1013. float clearcoat;
  1014. float clearcoatRoughness;
  1015. vec3 clearcoatF0;
  1016. float clearcoatF90;
  1017. #endif
  1018. #ifdef USE_IRIDESCENCE
  1019. float iridescence;
  1020. float iridescenceIOR;
  1021. float iridescenceThickness;
  1022. vec3 iridescenceFresnel;
  1023. vec3 iridescenceF0;
  1024. #endif
  1025. #ifdef USE_SHEEN
  1026. vec3 sheenColor;
  1027. float sheenRoughness;
  1028. #endif
  1029. #ifdef IOR
  1030. float ior;
  1031. #endif
  1032. #ifdef USE_TRANSMISSION
  1033. float transmission;
  1034. float transmissionAlpha;
  1035. float thickness;
  1036. float attenuationDistance;
  1037. vec3 attenuationColor;
  1038. #endif
  1039. #ifdef USE_ANISOTROPY
  1040. float anisotropy;
  1041. float alphaT;
  1042. vec3 anisotropyT;
  1043. vec3 anisotropyB;
  1044. #endif
  1045. };
  1046. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  1047. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  1048. vec3 sheenSpecularDirect = vec3( 0.0 );
  1049. vec3 sheenSpecularIndirect = vec3(0.0 );
  1050. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  1051. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  1052. float x2 = x * x;
  1053. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  1054. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  1055. }
  1056. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  1057. float a2 = pow2( alpha );
  1058. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  1059. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  1060. return 0.5 / max( gv + gl, EPSILON );
  1061. }
  1062. float D_GGX( const in float alpha, const in float dotNH ) {
  1063. float a2 = pow2( alpha );
  1064. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  1065. return RECIPROCAL_PI * a2 / pow2( denom );
  1066. }
  1067. #ifdef USE_ANISOTROPY
  1068. 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 ) {
  1069. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1070. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1071. float v = 0.5 / ( gv + gl );
  1072. return saturate(v);
  1073. }
  1074. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1075. float a2 = alphaT * alphaB;
  1076. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1077. highp float v2 = dot( v, v );
  1078. float w2 = a2 / v2;
  1079. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1080. }
  1081. #endif
  1082. #ifdef USE_CLEARCOAT
  1083. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1084. vec3 f0 = material.clearcoatF0;
  1085. float f90 = material.clearcoatF90;
  1086. float roughness = material.clearcoatRoughness;
  1087. float alpha = pow2( roughness );
  1088. vec3 halfDir = normalize( lightDir + viewDir );
  1089. float dotNL = saturate( dot( normal, lightDir ) );
  1090. float dotNV = saturate( dot( normal, viewDir ) );
  1091. float dotNH = saturate( dot( normal, halfDir ) );
  1092. float dotVH = saturate( dot( viewDir, halfDir ) );
  1093. vec3 F = F_Schlick( f0, f90, dotVH );
  1094. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1095. float D = D_GGX( alpha, dotNH );
  1096. return F * ( V * D );
  1097. }
  1098. #endif
  1099. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1100. vec3 f0 = material.specularColor;
  1101. float f90 = material.specularF90;
  1102. float roughness = material.roughness;
  1103. float alpha = pow2( roughness );
  1104. vec3 halfDir = normalize( lightDir + viewDir );
  1105. float dotNL = saturate( dot( normal, lightDir ) );
  1106. float dotNV = saturate( dot( normal, viewDir ) );
  1107. float dotNH = saturate( dot( normal, halfDir ) );
  1108. float dotVH = saturate( dot( viewDir, halfDir ) );
  1109. vec3 F = F_Schlick( f0, f90, dotVH );
  1110. #ifdef USE_IRIDESCENCE
  1111. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1112. #endif
  1113. #ifdef USE_ANISOTROPY
  1114. float dotTL = dot( material.anisotropyT, lightDir );
  1115. float dotTV = dot( material.anisotropyT, viewDir );
  1116. float dotTH = dot( material.anisotropyT, halfDir );
  1117. float dotBL = dot( material.anisotropyB, lightDir );
  1118. float dotBV = dot( material.anisotropyB, viewDir );
  1119. float dotBH = dot( material.anisotropyB, halfDir );
  1120. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1121. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1122. #else
  1123. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1124. float D = D_GGX( alpha, dotNH );
  1125. #endif
  1126. return F * ( V * D );
  1127. }
  1128. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1129. const float LUT_SIZE = 64.0;
  1130. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1131. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1132. float dotNV = saturate( dot( N, V ) );
  1133. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1134. uv = uv * LUT_SCALE + LUT_BIAS;
  1135. return uv;
  1136. }
  1137. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1138. float l = length( f );
  1139. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1140. }
  1141. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1142. float x = dot( v1, v2 );
  1143. float y = abs( x );
  1144. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1145. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1146. float v = a / b;
  1147. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1148. return cross( v1, v2 ) * theta_sintheta;
  1149. }
  1150. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1151. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1152. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1153. vec3 lightNormal = cross( v1, v2 );
  1154. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1155. vec3 T1, T2;
  1156. T1 = normalize( V - N * dot( V, N ) );
  1157. T2 = - cross( N, T1 );
  1158. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1159. vec3 coords[ 4 ];
  1160. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1161. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1162. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1163. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1164. coords[ 0 ] = normalize( coords[ 0 ] );
  1165. coords[ 1 ] = normalize( coords[ 1 ] );
  1166. coords[ 2 ] = normalize( coords[ 2 ] );
  1167. coords[ 3 ] = normalize( coords[ 3 ] );
  1168. vec3 vectorFormFactor = vec3( 0.0 );
  1169. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1170. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1171. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1172. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1173. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1174. return vec3( result );
  1175. }
  1176. #if defined( USE_SHEEN )
  1177. float D_Charlie( float roughness, float dotNH ) {
  1178. float alpha = pow2( roughness );
  1179. float invAlpha = 1.0 / alpha;
  1180. float cos2h = dotNH * dotNH;
  1181. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1182. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1183. }
  1184. float V_Neubelt( float dotNV, float dotNL ) {
  1185. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1186. }
  1187. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1188. vec3 halfDir = normalize( lightDir + viewDir );
  1189. float dotNL = saturate( dot( normal, lightDir ) );
  1190. float dotNV = saturate( dot( normal, viewDir ) );
  1191. float dotNH = saturate( dot( normal, halfDir ) );
  1192. float D = D_Charlie( sheenRoughness, dotNH );
  1193. float V = V_Neubelt( dotNV, dotNL );
  1194. return sheenColor * ( D * V );
  1195. }
  1196. #endif
  1197. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1198. float dotNV = saturate( dot( normal, viewDir ) );
  1199. float r2 = roughness * roughness;
  1200. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1201. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1202. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1203. return saturate( DG * RECIPROCAL_PI );
  1204. }
  1205. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1206. float dotNV = saturate( dot( normal, viewDir ) );
  1207. vec2 uv = vec2( roughness, dotNV );
  1208. return texture2D( dfgLUT, uv ).rg;
  1209. }
  1210. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1211. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1212. return specularColor * fab.x + specularF90 * fab.y;
  1213. }
  1214. #ifdef USE_IRIDESCENCE
  1215. 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 ) {
  1216. #else
  1217. 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 ) {
  1218. #endif
  1219. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1220. #ifdef USE_IRIDESCENCE
  1221. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1222. #else
  1223. vec3 Fr = specularColor;
  1224. #endif
  1225. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1226. float Ess = fab.x + fab.y;
  1227. float Ems = 1.0 - Ess;
  1228. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1229. singleScatter += FssEss;
  1230. multiScatter += Fms * Ems;
  1231. }
  1232. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1233. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1234. float dotNL = saturate( dot( normal, lightDir ) );
  1235. float dotNV = saturate( dot( normal, viewDir ) );
  1236. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1237. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1238. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1239. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1240. float Ess_V = dfgV.x + dfgV.y;
  1241. float Ess_L = dfgL.x + dfgL.y;
  1242. float Ems_V = 1.0 - Ess_V;
  1243. float Ems_L = 1.0 - Ess_L;
  1244. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1245. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1246. float compensationFactor = Ems_V * Ems_L;
  1247. vec3 multiScatter = Fms * compensationFactor;
  1248. return singleScatter + multiScatter;
  1249. }
  1250. #if NUM_RECT_AREA_LIGHTS > 0
  1251. 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 ) {
  1252. vec3 normal = geometryNormal;
  1253. vec3 viewDir = geometryViewDir;
  1254. vec3 position = geometryPosition;
  1255. vec3 lightPos = rectAreaLight.position;
  1256. vec3 halfWidth = rectAreaLight.halfWidth;
  1257. vec3 halfHeight = rectAreaLight.halfHeight;
  1258. vec3 lightColor = rectAreaLight.color;
  1259. float roughness = material.roughness;
  1260. vec3 rectCoords[ 4 ];
  1261. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1262. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1263. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1264. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1265. vec4 t1 = texture2D( ltc_1, uv );
  1266. vec4 t2 = texture2D( ltc_2, uv );
  1267. mat3 mInv = mat3(
  1268. vec3( t1.x, 0, t1.y ),
  1269. vec3( 0, 1, 0 ),
  1270. vec3( t1.z, 0, t1.w )
  1271. );
  1272. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1273. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1274. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1275. }
  1276. #endif
  1277. 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 ) {
  1278. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1279. vec3 irradiance = dotNL * directLight.color;
  1280. #ifdef USE_CLEARCOAT
  1281. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1282. vec3 ccIrradiance = dotNLcc * directLight.color;
  1283. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1284. #endif
  1285. #ifdef USE_SHEEN
  1286. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1287. #endif
  1288. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1289. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1290. }
  1291. 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 ) {
  1292. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1293. }
  1294. 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) {
  1295. #ifdef USE_CLEARCOAT
  1296. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1297. #endif
  1298. #ifdef USE_SHEEN
  1299. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1300. #endif
  1301. vec3 singleScattering = vec3( 0.0 );
  1302. vec3 multiScattering = vec3( 0.0 );
  1303. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1304. #ifdef USE_IRIDESCENCE
  1305. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1306. #else
  1307. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1308. #endif
  1309. vec3 totalScattering = singleScattering + multiScattering;
  1310. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1311. reflectedLight.indirectSpecular += radiance * singleScattering;
  1312. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1313. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1314. }
  1315. #define RE_Direct RE_Direct_Physical
  1316. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1317. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1318. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1319. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1320. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1321. }`,NPe=`
  1322. vec3 geometryPosition = - vViewPosition;
  1323. vec3 geometryNormal = normal;
  1324. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1325. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1326. #ifdef USE_CLEARCOAT
  1327. geometryClearcoatNormal = clearcoatNormal;
  1328. #endif
  1329. #ifdef USE_IRIDESCENCE
  1330. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1331. if ( material.iridescenceThickness == 0.0 ) {
  1332. material.iridescence = 0.0;
  1333. } else {
  1334. material.iridescence = saturate( material.iridescence );
  1335. }
  1336. if ( material.iridescence > 0.0 ) {
  1337. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1338. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1339. }
  1340. #endif
  1341. IncidentLight directLight;
  1342. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1343. PointLight pointLight;
  1344. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1345. PointLightShadow pointLightShadow;
  1346. #endif
  1347. #pragma unroll_loop_start
  1348. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1349. pointLight = pointLights[ i ];
  1350. getPointLightInfo( pointLight, geometryPosition, directLight );
  1351. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1352. pointLightShadow = pointLightShadows[ i ];
  1353. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1354. #endif
  1355. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1356. }
  1357. #pragma unroll_loop_end
  1358. #endif
  1359. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1360. SpotLight spotLight;
  1361. vec4 spotColor;
  1362. vec3 spotLightCoord;
  1363. bool inSpotLightMap;
  1364. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1365. SpotLightShadow spotLightShadow;
  1366. #endif
  1367. #pragma unroll_loop_start
  1368. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1369. spotLight = spotLights[ i ];
  1370. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1371. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1372. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1373. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1374. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1375. #else
  1376. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1377. #endif
  1378. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1379. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1380. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1381. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1382. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1383. #endif
  1384. #undef SPOT_LIGHT_MAP_INDEX
  1385. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1386. spotLightShadow = spotLightShadows[ i ];
  1387. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1388. #endif
  1389. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1390. }
  1391. #pragma unroll_loop_end
  1392. #endif
  1393. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1394. DirectionalLight directionalLight;
  1395. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1396. DirectionalLightShadow directionalLightShadow;
  1397. #endif
  1398. #pragma unroll_loop_start
  1399. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1400. directionalLight = directionalLights[ i ];
  1401. getDirectionalLightInfo( directionalLight, directLight );
  1402. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1403. directionalLightShadow = directionalLightShadows[ i ];
  1404. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1405. #endif
  1406. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1407. }
  1408. #pragma unroll_loop_end
  1409. #endif
  1410. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1411. RectAreaLight rectAreaLight;
  1412. #pragma unroll_loop_start
  1413. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1414. rectAreaLight = rectAreaLights[ i ];
  1415. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1416. }
  1417. #pragma unroll_loop_end
  1418. #endif
  1419. #if defined( RE_IndirectDiffuse )
  1420. vec3 iblIrradiance = vec3( 0.0 );
  1421. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1422. #if defined( USE_LIGHT_PROBES )
  1423. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1424. #endif
  1425. #if ( NUM_HEMI_LIGHTS > 0 )
  1426. #pragma unroll_loop_start
  1427. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1428. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1429. }
  1430. #pragma unroll_loop_end
  1431. #endif
  1432. #endif
  1433. #if defined( RE_IndirectSpecular )
  1434. vec3 radiance = vec3( 0.0 );
  1435. vec3 clearcoatRadiance = vec3( 0.0 );
  1436. #endif`,EPe=`#if defined( RE_IndirectDiffuse )
  1437. #ifdef USE_LIGHTMAP
  1438. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1439. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1440. irradiance += lightMapIrradiance;
  1441. #endif
  1442. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1443. iblIrradiance += getIBLIrradiance( geometryNormal );
  1444. #endif
  1445. #endif
  1446. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1447. #ifdef USE_ANISOTROPY
  1448. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1449. #else
  1450. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1451. #endif
  1452. #ifdef USE_CLEARCOAT
  1453. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1454. #endif
  1455. #endif`,APe=`#if defined( RE_IndirectDiffuse )
  1456. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1457. #endif
  1458. #if defined( RE_IndirectSpecular )
  1459. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1460. #endif`,TPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1461. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1462. #endif`,CPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1463. uniform float logDepthBufFC;
  1464. varying float vFragDepth;
  1465. varying float vIsPerspective;
  1466. #endif`,kPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1467. varying float vFragDepth;
  1468. varying float vIsPerspective;
  1469. #endif`,jPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1470. vFragDepth = 1.0 + gl_Position.w;
  1471. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1472. #endif`,PPe=`#ifdef USE_MAP
  1473. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1474. #ifdef DECODE_VIDEO_TEXTURE
  1475. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1476. #endif
  1477. diffuseColor *= sampledDiffuseColor;
  1478. #endif`,RPe=`#ifdef USE_MAP
  1479. uniform sampler2D map;
  1480. #endif`,DPe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1481. #if defined( USE_POINTS_UV )
  1482. vec2 uv = vUv;
  1483. #else
  1484. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1485. #endif
  1486. #endif
  1487. #ifdef USE_MAP
  1488. diffuseColor *= texture2D( map, uv );
  1489. #endif
  1490. #ifdef USE_ALPHAMAP
  1491. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1492. #endif`,OPe=`#if defined( USE_POINTS_UV )
  1493. varying vec2 vUv;
  1494. #else
  1495. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1496. uniform mat3 uvTransform;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_MAP
  1500. uniform sampler2D map;
  1501. #endif
  1502. #ifdef USE_ALPHAMAP
  1503. uniform sampler2D alphaMap;
  1504. #endif`,LPe=`float metalnessFactor = metalness;
  1505. #ifdef USE_METALNESSMAP
  1506. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1507. metalnessFactor *= texelMetalness.b;
  1508. #endif`,IPe=`#ifdef USE_METALNESSMAP
  1509. uniform sampler2D metalnessMap;
  1510. #endif`,FPe=`#ifdef USE_INSTANCING_MORPH
  1511. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1512. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1513. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1514. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1515. }
  1516. #endif`,UPe=`#if defined( USE_MORPHCOLORS )
  1517. vColor *= morphTargetBaseInfluence;
  1518. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1519. #if defined( USE_COLOR_ALPHA )
  1520. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1521. #elif defined( USE_COLOR )
  1522. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1523. #endif
  1524. }
  1525. #endif`,zPe=`#ifdef USE_MORPHNORMALS
  1526. objectNormal *= morphTargetBaseInfluence;
  1527. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1528. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1529. }
  1530. #endif`,BPe=`#ifdef USE_MORPHTARGETS
  1531. #ifndef USE_INSTANCING_MORPH
  1532. uniform float morphTargetBaseInfluence;
  1533. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1534. #endif
  1535. uniform sampler2DArray morphTargetsTexture;
  1536. uniform ivec2 morphTargetsTextureSize;
  1537. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1538. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1539. int y = texelIndex / morphTargetsTextureSize.x;
  1540. int x = texelIndex - y * morphTargetsTextureSize.x;
  1541. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1542. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1543. }
  1544. #endif`,$Pe=`#ifdef USE_MORPHTARGETS
  1545. transformed *= morphTargetBaseInfluence;
  1546. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1547. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1548. }
  1549. #endif`,HPe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1550. #ifdef FLAT_SHADED
  1551. vec3 fdx = dFdx( vViewPosition );
  1552. vec3 fdy = dFdy( vViewPosition );
  1553. vec3 normal = normalize( cross( fdx, fdy ) );
  1554. #else
  1555. vec3 normal = normalize( vNormal );
  1556. #ifdef DOUBLE_SIDED
  1557. normal *= faceDirection;
  1558. #endif
  1559. #endif
  1560. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1561. #ifdef USE_TANGENT
  1562. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1563. #else
  1564. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1565. #if defined( USE_NORMALMAP )
  1566. vNormalMapUv
  1567. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1568. vClearcoatNormalMapUv
  1569. #else
  1570. vUv
  1571. #endif
  1572. );
  1573. #endif
  1574. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1575. tbn[0] *= faceDirection;
  1576. tbn[1] *= faceDirection;
  1577. #endif
  1578. #endif
  1579. #ifdef USE_CLEARCOAT_NORMALMAP
  1580. #ifdef USE_TANGENT
  1581. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1582. #else
  1583. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1584. #endif
  1585. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1586. tbn2[0] *= faceDirection;
  1587. tbn2[1] *= faceDirection;
  1588. #endif
  1589. #endif
  1590. vec3 nonPerturbedNormal = normal;`,VPe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1591. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1592. #ifdef FLIP_SIDED
  1593. normal = - normal;
  1594. #endif
  1595. #ifdef DOUBLE_SIDED
  1596. normal = normal * faceDirection;
  1597. #endif
  1598. normal = normalize( normalMatrix * normal );
  1599. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1600. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1601. mapN.xy *= normalScale;
  1602. normal = normalize( tbn * mapN );
  1603. #elif defined( USE_BUMPMAP )
  1604. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1605. #endif`,GPe=`#ifndef FLAT_SHADED
  1606. varying vec3 vNormal;
  1607. #ifdef USE_TANGENT
  1608. varying vec3 vTangent;
  1609. varying vec3 vBitangent;
  1610. #endif
  1611. #endif`,WPe=`#ifndef FLAT_SHADED
  1612. varying vec3 vNormal;
  1613. #ifdef USE_TANGENT
  1614. varying vec3 vTangent;
  1615. varying vec3 vBitangent;
  1616. #endif
  1617. #endif`,qPe=`#ifndef FLAT_SHADED
  1618. vNormal = normalize( transformedNormal );
  1619. #ifdef USE_TANGENT
  1620. vTangent = normalize( transformedTangent );
  1621. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1622. #endif
  1623. #endif`,KPe=`#ifdef USE_NORMALMAP
  1624. uniform sampler2D normalMap;
  1625. uniform vec2 normalScale;
  1626. #endif
  1627. #ifdef USE_NORMALMAP_OBJECTSPACE
  1628. uniform mat3 normalMatrix;
  1629. #endif
  1630. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1631. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1632. vec3 q0 = dFdx( eye_pos.xyz );
  1633. vec3 q1 = dFdy( eye_pos.xyz );
  1634. vec2 st0 = dFdx( uv.st );
  1635. vec2 st1 = dFdy( uv.st );
  1636. vec3 N = surf_norm;
  1637. vec3 q1perp = cross( q1, N );
  1638. vec3 q0perp = cross( N, q0 );
  1639. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1640. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1641. float det = max( dot( T, T ), dot( B, B ) );
  1642. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1643. return mat3( T * scale, B * scale, N );
  1644. }
  1645. #endif`,XPe=`#ifdef USE_CLEARCOAT
  1646. vec3 clearcoatNormal = nonPerturbedNormal;
  1647. #endif`,YPe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1648. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1649. clearcoatMapN.xy *= clearcoatNormalScale;
  1650. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1651. #endif`,QPe=`#ifdef USE_CLEARCOATMAP
  1652. uniform sampler2D clearcoatMap;
  1653. #endif
  1654. #ifdef USE_CLEARCOAT_NORMALMAP
  1655. uniform sampler2D clearcoatNormalMap;
  1656. uniform vec2 clearcoatNormalScale;
  1657. #endif
  1658. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1659. uniform sampler2D clearcoatRoughnessMap;
  1660. #endif`,ZPe=`#ifdef USE_IRIDESCENCEMAP
  1661. uniform sampler2D iridescenceMap;
  1662. #endif
  1663. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1664. uniform sampler2D iridescenceThicknessMap;
  1665. #endif`,JPe=`#ifdef OPAQUE
  1666. diffuseColor.a = 1.0;
  1667. #endif
  1668. #ifdef USE_TRANSMISSION
  1669. diffuseColor.a *= material.transmissionAlpha;
  1670. #endif
  1671. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,eRe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1672. return normalize( normal ) * 0.5 + 0.5;
  1673. }
  1674. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1675. return 2.0 * rgb.xyz - 1.0;
  1676. }
  1677. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1678. const float Inv255 = 1. / 255.;
  1679. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1680. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1681. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1682. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1683. vec4 packDepthToRGBA( const in float v ) {
  1684. if( v <= 0.0 )
  1685. return vec4( 0., 0., 0., 0. );
  1686. if( v >= 1.0 )
  1687. return vec4( 1., 1., 1., 1. );
  1688. float vuf;
  1689. float af = modf( v * PackFactors.a, vuf );
  1690. float bf = modf( vuf * ShiftRight8, vuf );
  1691. float gf = modf( vuf * ShiftRight8, vuf );
  1692. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1693. }
  1694. vec3 packDepthToRGB( const in float v ) {
  1695. if( v <= 0.0 )
  1696. return vec3( 0., 0., 0. );
  1697. if( v >= 1.0 )
  1698. return vec3( 1., 1., 1. );
  1699. float vuf;
  1700. float bf = modf( v * PackFactors.b, vuf );
  1701. float gf = modf( vuf * ShiftRight8, vuf );
  1702. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1703. }
  1704. vec2 packDepthToRG( const in float v ) {
  1705. if( v <= 0.0 )
  1706. return vec2( 0., 0. );
  1707. if( v >= 1.0 )
  1708. return vec2( 1., 1. );
  1709. float vuf;
  1710. float gf = modf( v * 256., vuf );
  1711. return vec2( vuf * Inv255, gf );
  1712. }
  1713. float unpackRGBAToDepth( const in vec4 v ) {
  1714. return dot( v, UnpackFactors4 );
  1715. }
  1716. float unpackRGBToDepth( const in vec3 v ) {
  1717. return dot( v, UnpackFactors3 );
  1718. }
  1719. float unpackRGToDepth( const in vec2 v ) {
  1720. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1721. }
  1722. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1723. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1724. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1725. }
  1726. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1727. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1728. }
  1729. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1730. return ( viewZ + near ) / ( near - far );
  1731. }
  1732. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1733. return depth * ( near - far ) - near;
  1734. }
  1735. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1736. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1737. }
  1738. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1739. return ( near * far ) / ( ( far - near ) * depth - far );
  1740. }`,tRe=`#ifdef PREMULTIPLIED_ALPHA
  1741. gl_FragColor.rgb *= gl_FragColor.a;
  1742. #endif`,nRe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1743. #ifdef USE_BATCHING
  1744. mvPosition = batchingMatrix * mvPosition;
  1745. #endif
  1746. #ifdef USE_INSTANCING
  1747. mvPosition = instanceMatrix * mvPosition;
  1748. #endif
  1749. mvPosition = modelViewMatrix * mvPosition;
  1750. gl_Position = projectionMatrix * mvPosition;`,rRe=`#ifdef DITHERING
  1751. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1752. #endif`,iRe=`#ifdef DITHERING
  1753. vec3 dithering( vec3 color ) {
  1754. float grid_position = rand( gl_FragCoord.xy );
  1755. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1756. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1757. return color + dither_shift_RGB;
  1758. }
  1759. #endif`,aRe=`float roughnessFactor = roughness;
  1760. #ifdef USE_ROUGHNESSMAP
  1761. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1762. roughnessFactor *= texelRoughness.g;
  1763. #endif`,sRe=`#ifdef USE_ROUGHNESSMAP
  1764. uniform sampler2D roughnessMap;
  1765. #endif`,oRe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1766. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1767. #endif
  1768. #if NUM_SPOT_LIGHT_MAPS > 0
  1769. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1770. #endif
  1771. #ifdef USE_SHADOWMAP
  1772. #if NUM_DIR_LIGHT_SHADOWS > 0
  1773. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1774. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1775. struct DirectionalLightShadow {
  1776. float shadowIntensity;
  1777. float shadowBias;
  1778. float shadowNormalBias;
  1779. float shadowRadius;
  1780. vec2 shadowMapSize;
  1781. };
  1782. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1783. #endif
  1784. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1785. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1786. struct SpotLightShadow {
  1787. float shadowIntensity;
  1788. float shadowBias;
  1789. float shadowNormalBias;
  1790. float shadowRadius;
  1791. vec2 shadowMapSize;
  1792. };
  1793. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1794. #endif
  1795. #if NUM_POINT_LIGHT_SHADOWS > 0
  1796. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1797. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1798. struct PointLightShadow {
  1799. float shadowIntensity;
  1800. float shadowBias;
  1801. float shadowNormalBias;
  1802. float shadowRadius;
  1803. vec2 shadowMapSize;
  1804. float shadowCameraNear;
  1805. float shadowCameraFar;
  1806. };
  1807. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1808. #endif
  1809. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1810. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1811. #ifdef USE_REVERSED_DEPTH_BUFFER
  1812. return step( depth, compare );
  1813. #else
  1814. return step( compare, depth );
  1815. #endif
  1816. }
  1817. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1818. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1819. }
  1820. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1821. float occlusion = 1.0;
  1822. vec2 distribution = texture2DDistribution( shadow, uv );
  1823. #ifdef USE_REVERSED_DEPTH_BUFFER
  1824. float hard_shadow = step( distribution.x, compare );
  1825. #else
  1826. float hard_shadow = step( compare, distribution.x );
  1827. #endif
  1828. if ( hard_shadow != 1.0 ) {
  1829. float distance = compare - distribution.x;
  1830. float variance = max( 0.00000, distribution.y * distribution.y );
  1831. 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 );
  1832. }
  1833. return occlusion;
  1834. }
  1835. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1836. float shadow = 1.0;
  1837. shadowCoord.xyz /= shadowCoord.w;
  1838. shadowCoord.z += shadowBias;
  1839. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1840. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1841. if ( frustumTest ) {
  1842. #if defined( SHADOWMAP_TYPE_PCF )
  1843. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1844. float dx0 = - texelSize.x * shadowRadius;
  1845. float dy0 = - texelSize.y * shadowRadius;
  1846. float dx1 = + texelSize.x * shadowRadius;
  1847. float dy1 = + texelSize.y * shadowRadius;
  1848. float dx2 = dx0 / 2.0;
  1849. float dy2 = dy0 / 2.0;
  1850. float dx3 = dx1 / 2.0;
  1851. float dy3 = dy1 / 2.0;
  1852. shadow = (
  1853. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1854. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1855. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1856. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1857. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1858. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1859. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1860. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1861. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1862. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1863. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1864. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1865. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1866. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1867. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1868. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1869. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1870. ) * ( 1.0 / 17.0 );
  1871. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1872. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1873. float dx = texelSize.x;
  1874. float dy = texelSize.y;
  1875. vec2 uv = shadowCoord.xy;
  1876. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1877. uv -= f * texelSize;
  1878. shadow = (
  1879. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1880. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1881. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1882. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1883. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1884. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1885. f.x ) +
  1886. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1887. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1888. f.x ) +
  1889. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1890. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1891. f.y ) +
  1892. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1893. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1894. f.y ) +
  1895. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1896. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1897. f.x ),
  1898. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1899. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1900. f.x ),
  1901. f.y )
  1902. ) * ( 1.0 / 9.0 );
  1903. #elif defined( SHADOWMAP_TYPE_VSM )
  1904. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1905. #else
  1906. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1907. #endif
  1908. }
  1909. return mix( 1.0, shadow, shadowIntensity );
  1910. }
  1911. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1912. vec3 absV = abs( v );
  1913. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1914. absV *= scaleToCube;
  1915. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1916. vec2 planar = v.xy;
  1917. float almostATexel = 1.5 * texelSizeY;
  1918. float almostOne = 1.0 - almostATexel;
  1919. if ( absV.z >= almostOne ) {
  1920. if ( v.z > 0.0 )
  1921. planar.x = 4.0 - v.x;
  1922. } else if ( absV.x >= almostOne ) {
  1923. float signX = sign( v.x );
  1924. planar.x = v.z * signX + 2.0 * signX;
  1925. } else if ( absV.y >= almostOne ) {
  1926. float signY = sign( v.y );
  1927. planar.x = v.x + 2.0 * signY + 2.0;
  1928. planar.y = v.z * signY - 2.0;
  1929. }
  1930. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1931. }
  1932. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1933. float shadow = 1.0;
  1934. vec3 lightToPosition = shadowCoord.xyz;
  1935. float lightToPositionLength = length( lightToPosition );
  1936. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1937. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1938. vec3 bd3D = normalize( lightToPosition );
  1939. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1940. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1941. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1942. shadow = (
  1943. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1944. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1945. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1946. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1947. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1948. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1949. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1950. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1951. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1952. ) * ( 1.0 / 9.0 );
  1953. #else
  1954. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1955. #endif
  1956. }
  1957. return mix( 1.0, shadow, shadowIntensity );
  1958. }
  1959. #endif`,lRe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1960. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1961. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1962. #endif
  1963. #ifdef USE_SHADOWMAP
  1964. #if NUM_DIR_LIGHT_SHADOWS > 0
  1965. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1966. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1967. struct DirectionalLightShadow {
  1968. float shadowIntensity;
  1969. float shadowBias;
  1970. float shadowNormalBias;
  1971. float shadowRadius;
  1972. vec2 shadowMapSize;
  1973. };
  1974. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1975. #endif
  1976. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1977. struct SpotLightShadow {
  1978. float shadowIntensity;
  1979. float shadowBias;
  1980. float shadowNormalBias;
  1981. float shadowRadius;
  1982. vec2 shadowMapSize;
  1983. };
  1984. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1985. #endif
  1986. #if NUM_POINT_LIGHT_SHADOWS > 0
  1987. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1988. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1989. struct PointLightShadow {
  1990. float shadowIntensity;
  1991. float shadowBias;
  1992. float shadowNormalBias;
  1993. float shadowRadius;
  1994. vec2 shadowMapSize;
  1995. float shadowCameraNear;
  1996. float shadowCameraFar;
  1997. };
  1998. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1999. #endif
  2000. #endif`,cRe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  2001. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  2002. vec4 shadowWorldPosition;
  2003. #endif
  2004. #if defined( USE_SHADOWMAP )
  2005. #if NUM_DIR_LIGHT_SHADOWS > 0
  2006. #pragma unroll_loop_start
  2007. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2008. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  2009. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  2010. }
  2011. #pragma unroll_loop_end
  2012. #endif
  2013. #if NUM_POINT_LIGHT_SHADOWS > 0
  2014. #pragma unroll_loop_start
  2015. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2016. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  2017. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  2018. }
  2019. #pragma unroll_loop_end
  2020. #endif
  2021. #endif
  2022. #if NUM_SPOT_LIGHT_COORDS > 0
  2023. #pragma unroll_loop_start
  2024. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  2025. shadowWorldPosition = worldPosition;
  2026. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  2027. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  2028. #endif
  2029. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  2030. }
  2031. #pragma unroll_loop_end
  2032. #endif`,uRe=`float getShadowMask() {
  2033. float shadow = 1.0;
  2034. #ifdef USE_SHADOWMAP
  2035. #if NUM_DIR_LIGHT_SHADOWS > 0
  2036. DirectionalLightShadow directionalLight;
  2037. #pragma unroll_loop_start
  2038. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2039. directionalLight = directionalLightShadows[ i ];
  2040. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  2041. }
  2042. #pragma unroll_loop_end
  2043. #endif
  2044. #if NUM_SPOT_LIGHT_SHADOWS > 0
  2045. SpotLightShadow spotLight;
  2046. #pragma unroll_loop_start
  2047. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  2048. spotLight = spotLightShadows[ i ];
  2049. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  2050. }
  2051. #pragma unroll_loop_end
  2052. #endif
  2053. #if NUM_POINT_LIGHT_SHADOWS > 0
  2054. PointLightShadow pointLight;
  2055. #pragma unroll_loop_start
  2056. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2057. pointLight = pointLightShadows[ i ];
  2058. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  2059. }
  2060. #pragma unroll_loop_end
  2061. #endif
  2062. #endif
  2063. return shadow;
  2064. }`,dRe=`#ifdef USE_SKINNING
  2065. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  2066. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  2067. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  2068. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  2069. #endif`,hRe=`#ifdef USE_SKINNING
  2070. uniform mat4 bindMatrix;
  2071. uniform mat4 bindMatrixInverse;
  2072. uniform highp sampler2D boneTexture;
  2073. mat4 getBoneMatrix( const in float i ) {
  2074. int size = textureSize( boneTexture, 0 ).x;
  2075. int j = int( i ) * 4;
  2076. int x = j % size;
  2077. int y = j / size;
  2078. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  2079. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2080. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2081. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2082. return mat4( v1, v2, v3, v4 );
  2083. }
  2084. #endif`,fRe=`#ifdef USE_SKINNING
  2085. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2086. vec4 skinned = vec4( 0.0 );
  2087. skinned += boneMatX * skinVertex * skinWeight.x;
  2088. skinned += boneMatY * skinVertex * skinWeight.y;
  2089. skinned += boneMatZ * skinVertex * skinWeight.z;
  2090. skinned += boneMatW * skinVertex * skinWeight.w;
  2091. transformed = ( bindMatrixInverse * skinned ).xyz;
  2092. #endif`,mRe=`#ifdef USE_SKINNING
  2093. mat4 skinMatrix = mat4( 0.0 );
  2094. skinMatrix += skinWeight.x * boneMatX;
  2095. skinMatrix += skinWeight.y * boneMatY;
  2096. skinMatrix += skinWeight.z * boneMatZ;
  2097. skinMatrix += skinWeight.w * boneMatW;
  2098. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2099. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2100. #ifdef USE_TANGENT
  2101. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2102. #endif
  2103. #endif`,pRe=`float specularStrength;
  2104. #ifdef USE_SPECULARMAP
  2105. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2106. specularStrength = texelSpecular.r;
  2107. #else
  2108. specularStrength = 1.0;
  2109. #endif`,gRe=`#ifdef USE_SPECULARMAP
  2110. uniform sampler2D specularMap;
  2111. #endif`,xRe=`#if defined( TONE_MAPPING )
  2112. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2113. #endif`,bRe=`#ifndef saturate
  2114. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2115. #endif
  2116. uniform float toneMappingExposure;
  2117. vec3 LinearToneMapping( vec3 color ) {
  2118. return saturate( toneMappingExposure * color );
  2119. }
  2120. vec3 ReinhardToneMapping( vec3 color ) {
  2121. color *= toneMappingExposure;
  2122. return saturate( color / ( vec3( 1.0 ) + color ) );
  2123. }
  2124. vec3 CineonToneMapping( vec3 color ) {
  2125. color *= toneMappingExposure;
  2126. color = max( vec3( 0.0 ), color - 0.004 );
  2127. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2128. }
  2129. vec3 RRTAndODTFit( vec3 v ) {
  2130. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2131. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2132. return a / b;
  2133. }
  2134. vec3 ACESFilmicToneMapping( vec3 color ) {
  2135. const mat3 ACESInputMat = mat3(
  2136. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2137. vec3( 0.04823, 0.01566, 0.83777 )
  2138. );
  2139. const mat3 ACESOutputMat = mat3(
  2140. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2141. vec3( -0.07367, -0.00605, 1.07602 )
  2142. );
  2143. color *= toneMappingExposure / 0.6;
  2144. color = ACESInputMat * color;
  2145. color = RRTAndODTFit( color );
  2146. color = ACESOutputMat * color;
  2147. return saturate( color );
  2148. }
  2149. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2150. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2151. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2152. vec3( - 0.0728, - 0.0083, 1.1187 )
  2153. );
  2154. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2155. vec3( 0.6274, 0.0691, 0.0164 ),
  2156. vec3( 0.3293, 0.9195, 0.0880 ),
  2157. vec3( 0.0433, 0.0113, 0.8956 )
  2158. );
  2159. vec3 agxDefaultContrastApprox( vec3 x ) {
  2160. vec3 x2 = x * x;
  2161. vec3 x4 = x2 * x2;
  2162. return + 15.5 * x4 * x2
  2163. - 40.14 * x4 * x
  2164. + 31.96 * x4
  2165. - 6.868 * x2 * x
  2166. + 0.4298 * x2
  2167. + 0.1191 * x
  2168. - 0.00232;
  2169. }
  2170. vec3 AgXToneMapping( vec3 color ) {
  2171. const mat3 AgXInsetMatrix = mat3(
  2172. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2173. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2174. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2175. );
  2176. const mat3 AgXOutsetMatrix = mat3(
  2177. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2178. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2179. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2180. );
  2181. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2182. color *= toneMappingExposure;
  2183. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2184. color = AgXInsetMatrix * color;
  2185. color = max( color, 1e-10 ); color = log2( color );
  2186. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2187. color = clamp( color, 0.0, 1.0 );
  2188. color = agxDefaultContrastApprox( color );
  2189. color = AgXOutsetMatrix * color;
  2190. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2191. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2192. color = clamp( color, 0.0, 1.0 );
  2193. return color;
  2194. }
  2195. vec3 NeutralToneMapping( vec3 color ) {
  2196. const float StartCompression = 0.8 - 0.04;
  2197. const float Desaturation = 0.15;
  2198. color *= toneMappingExposure;
  2199. float x = min( color.r, min( color.g, color.b ) );
  2200. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2201. color -= offset;
  2202. float peak = max( color.r, max( color.g, color.b ) );
  2203. if ( peak < StartCompression ) return color;
  2204. float d = 1. - StartCompression;
  2205. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2206. color *= newPeak / peak;
  2207. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2208. return mix( color, vec3( newPeak ), g );
  2209. }
  2210. vec3 CustomToneMapping( vec3 color ) { return color; }`,yRe=`#ifdef USE_TRANSMISSION
  2211. material.transmission = transmission;
  2212. material.transmissionAlpha = 1.0;
  2213. material.thickness = thickness;
  2214. material.attenuationDistance = attenuationDistance;
  2215. material.attenuationColor = attenuationColor;
  2216. #ifdef USE_TRANSMISSIONMAP
  2217. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2218. #endif
  2219. #ifdef USE_THICKNESSMAP
  2220. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2221. #endif
  2222. vec3 pos = vWorldPosition;
  2223. vec3 v = normalize( cameraPosition - pos );
  2224. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2225. vec4 transmitted = getIBLVolumeRefraction(
  2226. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2227. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2228. material.attenuationColor, material.attenuationDistance );
  2229. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2230. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2231. #endif`,vRe=`#ifdef USE_TRANSMISSION
  2232. uniform float transmission;
  2233. uniform float thickness;
  2234. uniform float attenuationDistance;
  2235. uniform vec3 attenuationColor;
  2236. #ifdef USE_TRANSMISSIONMAP
  2237. uniform sampler2D transmissionMap;
  2238. #endif
  2239. #ifdef USE_THICKNESSMAP
  2240. uniform sampler2D thicknessMap;
  2241. #endif
  2242. uniform vec2 transmissionSamplerSize;
  2243. uniform sampler2D transmissionSamplerMap;
  2244. uniform mat4 modelMatrix;
  2245. uniform mat4 projectionMatrix;
  2246. varying vec3 vWorldPosition;
  2247. float w0( float a ) {
  2248. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2249. }
  2250. float w1( float a ) {
  2251. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2252. }
  2253. float w2( float a ){
  2254. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2255. }
  2256. float w3( float a ) {
  2257. return ( 1.0 / 6.0 ) * ( a * a * a );
  2258. }
  2259. float g0( float a ) {
  2260. return w0( a ) + w1( a );
  2261. }
  2262. float g1( float a ) {
  2263. return w2( a ) + w3( a );
  2264. }
  2265. float h0( float a ) {
  2266. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2267. }
  2268. float h1( float a ) {
  2269. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2270. }
  2271. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2272. uv = uv * texelSize.zw + 0.5;
  2273. vec2 iuv = floor( uv );
  2274. vec2 fuv = fract( uv );
  2275. float g0x = g0( fuv.x );
  2276. float g1x = g1( fuv.x );
  2277. float h0x = h0( fuv.x );
  2278. float h1x = h1( fuv.x );
  2279. float h0y = h0( fuv.y );
  2280. float h1y = h1( fuv.y );
  2281. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2282. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2283. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2284. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2285. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2286. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2287. }
  2288. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2289. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2290. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2291. vec2 fLodSizeInv = 1.0 / fLodSize;
  2292. vec2 cLodSizeInv = 1.0 / cLodSize;
  2293. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2294. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2295. return mix( fSample, cSample, fract( lod ) );
  2296. }
  2297. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2298. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2299. vec3 modelScale;
  2300. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2301. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2302. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2303. return normalize( refractionVector ) * thickness * modelScale;
  2304. }
  2305. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2306. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2307. }
  2308. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2309. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2310. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2311. }
  2312. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2313. if ( isinf( attenuationDistance ) ) {
  2314. return vec3( 1.0 );
  2315. } else {
  2316. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2317. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2318. }
  2319. }
  2320. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2321. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2322. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2323. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2324. vec4 transmittedLight;
  2325. vec3 transmittance;
  2326. #ifdef USE_DISPERSION
  2327. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2328. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2329. for ( int i = 0; i < 3; i ++ ) {
  2330. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2331. vec3 refractedRayExit = position + transmissionRay;
  2332. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2333. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2334. refractionCoords += 1.0;
  2335. refractionCoords /= 2.0;
  2336. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2337. transmittedLight[ i ] = transmissionSample[ i ];
  2338. transmittedLight.a += transmissionSample.a;
  2339. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2340. }
  2341. transmittedLight.a /= 3.0;
  2342. #else
  2343. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2344. vec3 refractedRayExit = position + transmissionRay;
  2345. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2346. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2347. refractionCoords += 1.0;
  2348. refractionCoords /= 2.0;
  2349. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2350. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2351. #endif
  2352. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2353. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2354. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2355. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2356. }
  2357. #endif`,_Re=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2358. varying vec2 vUv;
  2359. #endif
  2360. #ifdef USE_MAP
  2361. varying vec2 vMapUv;
  2362. #endif
  2363. #ifdef USE_ALPHAMAP
  2364. varying vec2 vAlphaMapUv;
  2365. #endif
  2366. #ifdef USE_LIGHTMAP
  2367. varying vec2 vLightMapUv;
  2368. #endif
  2369. #ifdef USE_AOMAP
  2370. varying vec2 vAoMapUv;
  2371. #endif
  2372. #ifdef USE_BUMPMAP
  2373. varying vec2 vBumpMapUv;
  2374. #endif
  2375. #ifdef USE_NORMALMAP
  2376. varying vec2 vNormalMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. varying vec2 vEmissiveMapUv;
  2380. #endif
  2381. #ifdef USE_METALNESSMAP
  2382. varying vec2 vMetalnessMapUv;
  2383. #endif
  2384. #ifdef USE_ROUGHNESSMAP
  2385. varying vec2 vRoughnessMapUv;
  2386. #endif
  2387. #ifdef USE_ANISOTROPYMAP
  2388. varying vec2 vAnisotropyMapUv;
  2389. #endif
  2390. #ifdef USE_CLEARCOATMAP
  2391. varying vec2 vClearcoatMapUv;
  2392. #endif
  2393. #ifdef USE_CLEARCOAT_NORMALMAP
  2394. varying vec2 vClearcoatNormalMapUv;
  2395. #endif
  2396. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2397. varying vec2 vClearcoatRoughnessMapUv;
  2398. #endif
  2399. #ifdef USE_IRIDESCENCEMAP
  2400. varying vec2 vIridescenceMapUv;
  2401. #endif
  2402. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2403. varying vec2 vIridescenceThicknessMapUv;
  2404. #endif
  2405. #ifdef USE_SHEEN_COLORMAP
  2406. varying vec2 vSheenColorMapUv;
  2407. #endif
  2408. #ifdef USE_SHEEN_ROUGHNESSMAP
  2409. varying vec2 vSheenRoughnessMapUv;
  2410. #endif
  2411. #ifdef USE_SPECULARMAP
  2412. varying vec2 vSpecularMapUv;
  2413. #endif
  2414. #ifdef USE_SPECULAR_COLORMAP
  2415. varying vec2 vSpecularColorMapUv;
  2416. #endif
  2417. #ifdef USE_SPECULAR_INTENSITYMAP
  2418. varying vec2 vSpecularIntensityMapUv;
  2419. #endif
  2420. #ifdef USE_TRANSMISSIONMAP
  2421. uniform mat3 transmissionMapTransform;
  2422. varying vec2 vTransmissionMapUv;
  2423. #endif
  2424. #ifdef USE_THICKNESSMAP
  2425. uniform mat3 thicknessMapTransform;
  2426. varying vec2 vThicknessMapUv;
  2427. #endif`,wRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2428. varying vec2 vUv;
  2429. #endif
  2430. #ifdef USE_MAP
  2431. uniform mat3 mapTransform;
  2432. varying vec2 vMapUv;
  2433. #endif
  2434. #ifdef USE_ALPHAMAP
  2435. uniform mat3 alphaMapTransform;
  2436. varying vec2 vAlphaMapUv;
  2437. #endif
  2438. #ifdef USE_LIGHTMAP
  2439. uniform mat3 lightMapTransform;
  2440. varying vec2 vLightMapUv;
  2441. #endif
  2442. #ifdef USE_AOMAP
  2443. uniform mat3 aoMapTransform;
  2444. varying vec2 vAoMapUv;
  2445. #endif
  2446. #ifdef USE_BUMPMAP
  2447. uniform mat3 bumpMapTransform;
  2448. varying vec2 vBumpMapUv;
  2449. #endif
  2450. #ifdef USE_NORMALMAP
  2451. uniform mat3 normalMapTransform;
  2452. varying vec2 vNormalMapUv;
  2453. #endif
  2454. #ifdef USE_DISPLACEMENTMAP
  2455. uniform mat3 displacementMapTransform;
  2456. varying vec2 vDisplacementMapUv;
  2457. #endif
  2458. #ifdef USE_EMISSIVEMAP
  2459. uniform mat3 emissiveMapTransform;
  2460. varying vec2 vEmissiveMapUv;
  2461. #endif
  2462. #ifdef USE_METALNESSMAP
  2463. uniform mat3 metalnessMapTransform;
  2464. varying vec2 vMetalnessMapUv;
  2465. #endif
  2466. #ifdef USE_ROUGHNESSMAP
  2467. uniform mat3 roughnessMapTransform;
  2468. varying vec2 vRoughnessMapUv;
  2469. #endif
  2470. #ifdef USE_ANISOTROPYMAP
  2471. uniform mat3 anisotropyMapTransform;
  2472. varying vec2 vAnisotropyMapUv;
  2473. #endif
  2474. #ifdef USE_CLEARCOATMAP
  2475. uniform mat3 clearcoatMapTransform;
  2476. varying vec2 vClearcoatMapUv;
  2477. #endif
  2478. #ifdef USE_CLEARCOAT_NORMALMAP
  2479. uniform mat3 clearcoatNormalMapTransform;
  2480. varying vec2 vClearcoatNormalMapUv;
  2481. #endif
  2482. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2483. uniform mat3 clearcoatRoughnessMapTransform;
  2484. varying vec2 vClearcoatRoughnessMapUv;
  2485. #endif
  2486. #ifdef USE_SHEEN_COLORMAP
  2487. uniform mat3 sheenColorMapTransform;
  2488. varying vec2 vSheenColorMapUv;
  2489. #endif
  2490. #ifdef USE_SHEEN_ROUGHNESSMAP
  2491. uniform mat3 sheenRoughnessMapTransform;
  2492. varying vec2 vSheenRoughnessMapUv;
  2493. #endif
  2494. #ifdef USE_IRIDESCENCEMAP
  2495. uniform mat3 iridescenceMapTransform;
  2496. varying vec2 vIridescenceMapUv;
  2497. #endif
  2498. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2499. uniform mat3 iridescenceThicknessMapTransform;
  2500. varying vec2 vIridescenceThicknessMapUv;
  2501. #endif
  2502. #ifdef USE_SPECULARMAP
  2503. uniform mat3 specularMapTransform;
  2504. varying vec2 vSpecularMapUv;
  2505. #endif
  2506. #ifdef USE_SPECULAR_COLORMAP
  2507. uniform mat3 specularColorMapTransform;
  2508. varying vec2 vSpecularColorMapUv;
  2509. #endif
  2510. #ifdef USE_SPECULAR_INTENSITYMAP
  2511. uniform mat3 specularIntensityMapTransform;
  2512. varying vec2 vSpecularIntensityMapUv;
  2513. #endif
  2514. #ifdef USE_TRANSMISSIONMAP
  2515. uniform mat3 transmissionMapTransform;
  2516. varying vec2 vTransmissionMapUv;
  2517. #endif
  2518. #ifdef USE_THICKNESSMAP
  2519. uniform mat3 thicknessMapTransform;
  2520. varying vec2 vThicknessMapUv;
  2521. #endif`,SRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2522. vUv = vec3( uv, 1 ).xy;
  2523. #endif
  2524. #ifdef USE_MAP
  2525. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2526. #endif
  2527. #ifdef USE_ALPHAMAP
  2528. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2529. #endif
  2530. #ifdef USE_LIGHTMAP
  2531. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2532. #endif
  2533. #ifdef USE_AOMAP
  2534. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2535. #endif
  2536. #ifdef USE_BUMPMAP
  2537. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2538. #endif
  2539. #ifdef USE_NORMALMAP
  2540. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2541. #endif
  2542. #ifdef USE_DISPLACEMENTMAP
  2543. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2544. #endif
  2545. #ifdef USE_EMISSIVEMAP
  2546. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2547. #endif
  2548. #ifdef USE_METALNESSMAP
  2549. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2550. #endif
  2551. #ifdef USE_ROUGHNESSMAP
  2552. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2553. #endif
  2554. #ifdef USE_ANISOTROPYMAP
  2555. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2556. #endif
  2557. #ifdef USE_CLEARCOATMAP
  2558. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2559. #endif
  2560. #ifdef USE_CLEARCOAT_NORMALMAP
  2561. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2562. #endif
  2563. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2564. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2565. #endif
  2566. #ifdef USE_IRIDESCENCEMAP
  2567. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2568. #endif
  2569. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2570. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2571. #endif
  2572. #ifdef USE_SHEEN_COLORMAP
  2573. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2574. #endif
  2575. #ifdef USE_SHEEN_ROUGHNESSMAP
  2576. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2577. #endif
  2578. #ifdef USE_SPECULARMAP
  2579. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2580. #endif
  2581. #ifdef USE_SPECULAR_COLORMAP
  2582. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2583. #endif
  2584. #ifdef USE_SPECULAR_INTENSITYMAP
  2585. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2586. #endif
  2587. #ifdef USE_TRANSMISSIONMAP
  2588. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2589. #endif
  2590. #ifdef USE_THICKNESSMAP
  2591. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2592. #endif`,MRe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2593. vec4 worldPosition = vec4( transformed, 1.0 );
  2594. #ifdef USE_BATCHING
  2595. worldPosition = batchingMatrix * worldPosition;
  2596. #endif
  2597. #ifdef USE_INSTANCING
  2598. worldPosition = instanceMatrix * worldPosition;
  2599. #endif
  2600. worldPosition = modelMatrix * worldPosition;
  2601. #endif`;const NRe=`varying vec2 vUv;
  2602. uniform mat3 uvTransform;
  2603. void main() {
  2604. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2605. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2606. }`,ERe=`uniform sampler2D t2D;
  2607. uniform float backgroundIntensity;
  2608. varying vec2 vUv;
  2609. void main() {
  2610. vec4 texColor = texture2D( t2D, vUv );
  2611. #ifdef DECODE_VIDEO_TEXTURE
  2612. 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 );
  2613. #endif
  2614. texColor.rgb *= backgroundIntensity;
  2615. gl_FragColor = texColor;
  2616. #include <tonemapping_fragment>
  2617. #include <colorspace_fragment>
  2618. }`,ARe=`varying vec3 vWorldDirection;
  2619. #include <common>
  2620. void main() {
  2621. vWorldDirection = transformDirection( position, modelMatrix );
  2622. #include <begin_vertex>
  2623. #include <project_vertex>
  2624. gl_Position.z = gl_Position.w;
  2625. }`,TRe=`#ifdef ENVMAP_TYPE_CUBE
  2626. uniform samplerCube envMap;
  2627. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2628. uniform sampler2D envMap;
  2629. #endif
  2630. uniform float flipEnvMap;
  2631. uniform float backgroundBlurriness;
  2632. uniform float backgroundIntensity;
  2633. uniform mat3 backgroundRotation;
  2634. varying vec3 vWorldDirection;
  2635. #include <cube_uv_reflection_fragment>
  2636. void main() {
  2637. #ifdef ENVMAP_TYPE_CUBE
  2638. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2639. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2640. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2641. #else
  2642. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2643. #endif
  2644. texColor.rgb *= backgroundIntensity;
  2645. gl_FragColor = texColor;
  2646. #include <tonemapping_fragment>
  2647. #include <colorspace_fragment>
  2648. }`,CRe=`varying vec3 vWorldDirection;
  2649. #include <common>
  2650. void main() {
  2651. vWorldDirection = transformDirection( position, modelMatrix );
  2652. #include <begin_vertex>
  2653. #include <project_vertex>
  2654. gl_Position.z = gl_Position.w;
  2655. }`,kRe=`uniform samplerCube tCube;
  2656. uniform float tFlip;
  2657. uniform float opacity;
  2658. varying vec3 vWorldDirection;
  2659. void main() {
  2660. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2661. gl_FragColor = texColor;
  2662. gl_FragColor.a *= opacity;
  2663. #include <tonemapping_fragment>
  2664. #include <colorspace_fragment>
  2665. }`,jRe=`#include <common>
  2666. #include <batching_pars_vertex>
  2667. #include <uv_pars_vertex>
  2668. #include <displacementmap_pars_vertex>
  2669. #include <morphtarget_pars_vertex>
  2670. #include <skinning_pars_vertex>
  2671. #include <logdepthbuf_pars_vertex>
  2672. #include <clipping_planes_pars_vertex>
  2673. varying vec2 vHighPrecisionZW;
  2674. void main() {
  2675. #include <uv_vertex>
  2676. #include <batching_vertex>
  2677. #include <skinbase_vertex>
  2678. #include <morphinstance_vertex>
  2679. #ifdef USE_DISPLACEMENTMAP
  2680. #include <beginnormal_vertex>
  2681. #include <morphnormal_vertex>
  2682. #include <skinnormal_vertex>
  2683. #endif
  2684. #include <begin_vertex>
  2685. #include <morphtarget_vertex>
  2686. #include <skinning_vertex>
  2687. #include <displacementmap_vertex>
  2688. #include <project_vertex>
  2689. #include <logdepthbuf_vertex>
  2690. #include <clipping_planes_vertex>
  2691. vHighPrecisionZW = gl_Position.zw;
  2692. }`,PRe=`#if DEPTH_PACKING == 3200
  2693. uniform float opacity;
  2694. #endif
  2695. #include <common>
  2696. #include <packing>
  2697. #include <uv_pars_fragment>
  2698. #include <map_pars_fragment>
  2699. #include <alphamap_pars_fragment>
  2700. #include <alphatest_pars_fragment>
  2701. #include <alphahash_pars_fragment>
  2702. #include <logdepthbuf_pars_fragment>
  2703. #include <clipping_planes_pars_fragment>
  2704. varying vec2 vHighPrecisionZW;
  2705. void main() {
  2706. vec4 diffuseColor = vec4( 1.0 );
  2707. #include <clipping_planes_fragment>
  2708. #if DEPTH_PACKING == 3200
  2709. diffuseColor.a = opacity;
  2710. #endif
  2711. #include <map_fragment>
  2712. #include <alphamap_fragment>
  2713. #include <alphatest_fragment>
  2714. #include <alphahash_fragment>
  2715. #include <logdepthbuf_fragment>
  2716. #ifdef USE_REVERSED_DEPTH_BUFFER
  2717. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2718. #else
  2719. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2720. #endif
  2721. #if DEPTH_PACKING == 3200
  2722. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2723. #elif DEPTH_PACKING == 3201
  2724. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2725. #elif DEPTH_PACKING == 3202
  2726. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2727. #elif DEPTH_PACKING == 3203
  2728. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2729. #endif
  2730. }`,RRe=`#define DISTANCE
  2731. varying vec3 vWorldPosition;
  2732. #include <common>
  2733. #include <batching_pars_vertex>
  2734. #include <uv_pars_vertex>
  2735. #include <displacementmap_pars_vertex>
  2736. #include <morphtarget_pars_vertex>
  2737. #include <skinning_pars_vertex>
  2738. #include <clipping_planes_pars_vertex>
  2739. void main() {
  2740. #include <uv_vertex>
  2741. #include <batching_vertex>
  2742. #include <skinbase_vertex>
  2743. #include <morphinstance_vertex>
  2744. #ifdef USE_DISPLACEMENTMAP
  2745. #include <beginnormal_vertex>
  2746. #include <morphnormal_vertex>
  2747. #include <skinnormal_vertex>
  2748. #endif
  2749. #include <begin_vertex>
  2750. #include <morphtarget_vertex>
  2751. #include <skinning_vertex>
  2752. #include <displacementmap_vertex>
  2753. #include <project_vertex>
  2754. #include <worldpos_vertex>
  2755. #include <clipping_planes_vertex>
  2756. vWorldPosition = worldPosition.xyz;
  2757. }`,DRe=`#define DISTANCE
  2758. uniform vec3 referencePosition;
  2759. uniform float nearDistance;
  2760. uniform float farDistance;
  2761. varying vec3 vWorldPosition;
  2762. #include <common>
  2763. #include <packing>
  2764. #include <uv_pars_fragment>
  2765. #include <map_pars_fragment>
  2766. #include <alphamap_pars_fragment>
  2767. #include <alphatest_pars_fragment>
  2768. #include <alphahash_pars_fragment>
  2769. #include <clipping_planes_pars_fragment>
  2770. void main () {
  2771. vec4 diffuseColor = vec4( 1.0 );
  2772. #include <clipping_planes_fragment>
  2773. #include <map_fragment>
  2774. #include <alphamap_fragment>
  2775. #include <alphatest_fragment>
  2776. #include <alphahash_fragment>
  2777. float dist = length( vWorldPosition - referencePosition );
  2778. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2779. dist = saturate( dist );
  2780. gl_FragColor = packDepthToRGBA( dist );
  2781. }`,ORe=`varying vec3 vWorldDirection;
  2782. #include <common>
  2783. void main() {
  2784. vWorldDirection = transformDirection( position, modelMatrix );
  2785. #include <begin_vertex>
  2786. #include <project_vertex>
  2787. }`,LRe=`uniform sampler2D tEquirect;
  2788. varying vec3 vWorldDirection;
  2789. #include <common>
  2790. void main() {
  2791. vec3 direction = normalize( vWorldDirection );
  2792. vec2 sampleUV = equirectUv( direction );
  2793. gl_FragColor = texture2D( tEquirect, sampleUV );
  2794. #include <tonemapping_fragment>
  2795. #include <colorspace_fragment>
  2796. }`,IRe=`uniform float scale;
  2797. attribute float lineDistance;
  2798. varying float vLineDistance;
  2799. #include <common>
  2800. #include <uv_pars_vertex>
  2801. #include <color_pars_vertex>
  2802. #include <fog_pars_vertex>
  2803. #include <morphtarget_pars_vertex>
  2804. #include <logdepthbuf_pars_vertex>
  2805. #include <clipping_planes_pars_vertex>
  2806. void main() {
  2807. vLineDistance = scale * lineDistance;
  2808. #include <uv_vertex>
  2809. #include <color_vertex>
  2810. #include <morphinstance_vertex>
  2811. #include <morphcolor_vertex>
  2812. #include <begin_vertex>
  2813. #include <morphtarget_vertex>
  2814. #include <project_vertex>
  2815. #include <logdepthbuf_vertex>
  2816. #include <clipping_planes_vertex>
  2817. #include <fog_vertex>
  2818. }`,FRe=`uniform vec3 diffuse;
  2819. uniform float opacity;
  2820. uniform float dashSize;
  2821. uniform float totalSize;
  2822. varying float vLineDistance;
  2823. #include <common>
  2824. #include <color_pars_fragment>
  2825. #include <uv_pars_fragment>
  2826. #include <map_pars_fragment>
  2827. #include <fog_pars_fragment>
  2828. #include <logdepthbuf_pars_fragment>
  2829. #include <clipping_planes_pars_fragment>
  2830. void main() {
  2831. vec4 diffuseColor = vec4( diffuse, opacity );
  2832. #include <clipping_planes_fragment>
  2833. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2834. discard;
  2835. }
  2836. vec3 outgoingLight = vec3( 0.0 );
  2837. #include <logdepthbuf_fragment>
  2838. #include <map_fragment>
  2839. #include <color_fragment>
  2840. outgoingLight = diffuseColor.rgb;
  2841. #include <opaque_fragment>
  2842. #include <tonemapping_fragment>
  2843. #include <colorspace_fragment>
  2844. #include <fog_fragment>
  2845. #include <premultiplied_alpha_fragment>
  2846. }`,URe=`#include <common>
  2847. #include <batching_pars_vertex>
  2848. #include <uv_pars_vertex>
  2849. #include <envmap_pars_vertex>
  2850. #include <color_pars_vertex>
  2851. #include <fog_pars_vertex>
  2852. #include <morphtarget_pars_vertex>
  2853. #include <skinning_pars_vertex>
  2854. #include <logdepthbuf_pars_vertex>
  2855. #include <clipping_planes_pars_vertex>
  2856. void main() {
  2857. #include <uv_vertex>
  2858. #include <color_vertex>
  2859. #include <morphinstance_vertex>
  2860. #include <morphcolor_vertex>
  2861. #include <batching_vertex>
  2862. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2863. #include <beginnormal_vertex>
  2864. #include <morphnormal_vertex>
  2865. #include <skinbase_vertex>
  2866. #include <skinnormal_vertex>
  2867. #include <defaultnormal_vertex>
  2868. #endif
  2869. #include <begin_vertex>
  2870. #include <morphtarget_vertex>
  2871. #include <skinning_vertex>
  2872. #include <project_vertex>
  2873. #include <logdepthbuf_vertex>
  2874. #include <clipping_planes_vertex>
  2875. #include <worldpos_vertex>
  2876. #include <envmap_vertex>
  2877. #include <fog_vertex>
  2878. }`,zRe=`uniform vec3 diffuse;
  2879. uniform float opacity;
  2880. #ifndef FLAT_SHADED
  2881. varying vec3 vNormal;
  2882. #endif
  2883. #include <common>
  2884. #include <dithering_pars_fragment>
  2885. #include <color_pars_fragment>
  2886. #include <uv_pars_fragment>
  2887. #include <map_pars_fragment>
  2888. #include <alphamap_pars_fragment>
  2889. #include <alphatest_pars_fragment>
  2890. #include <alphahash_pars_fragment>
  2891. #include <aomap_pars_fragment>
  2892. #include <lightmap_pars_fragment>
  2893. #include <envmap_common_pars_fragment>
  2894. #include <envmap_pars_fragment>
  2895. #include <fog_pars_fragment>
  2896. #include <specularmap_pars_fragment>
  2897. #include <logdepthbuf_pars_fragment>
  2898. #include <clipping_planes_pars_fragment>
  2899. void main() {
  2900. vec4 diffuseColor = vec4( diffuse, opacity );
  2901. #include <clipping_planes_fragment>
  2902. #include <logdepthbuf_fragment>
  2903. #include <map_fragment>
  2904. #include <color_fragment>
  2905. #include <alphamap_fragment>
  2906. #include <alphatest_fragment>
  2907. #include <alphahash_fragment>
  2908. #include <specularmap_fragment>
  2909. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2910. #ifdef USE_LIGHTMAP
  2911. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2912. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2913. #else
  2914. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2915. #endif
  2916. #include <aomap_fragment>
  2917. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2918. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2919. #include <envmap_fragment>
  2920. #include <opaque_fragment>
  2921. #include <tonemapping_fragment>
  2922. #include <colorspace_fragment>
  2923. #include <fog_fragment>
  2924. #include <premultiplied_alpha_fragment>
  2925. #include <dithering_fragment>
  2926. }`,BRe=`#define LAMBERT
  2927. varying vec3 vViewPosition;
  2928. #include <common>
  2929. #include <batching_pars_vertex>
  2930. #include <uv_pars_vertex>
  2931. #include <displacementmap_pars_vertex>
  2932. #include <envmap_pars_vertex>
  2933. #include <color_pars_vertex>
  2934. #include <fog_pars_vertex>
  2935. #include <normal_pars_vertex>
  2936. #include <morphtarget_pars_vertex>
  2937. #include <skinning_pars_vertex>
  2938. #include <shadowmap_pars_vertex>
  2939. #include <logdepthbuf_pars_vertex>
  2940. #include <clipping_planes_pars_vertex>
  2941. void main() {
  2942. #include <uv_vertex>
  2943. #include <color_vertex>
  2944. #include <morphinstance_vertex>
  2945. #include <morphcolor_vertex>
  2946. #include <batching_vertex>
  2947. #include <beginnormal_vertex>
  2948. #include <morphnormal_vertex>
  2949. #include <skinbase_vertex>
  2950. #include <skinnormal_vertex>
  2951. #include <defaultnormal_vertex>
  2952. #include <normal_vertex>
  2953. #include <begin_vertex>
  2954. #include <morphtarget_vertex>
  2955. #include <skinning_vertex>
  2956. #include <displacementmap_vertex>
  2957. #include <project_vertex>
  2958. #include <logdepthbuf_vertex>
  2959. #include <clipping_planes_vertex>
  2960. vViewPosition = - mvPosition.xyz;
  2961. #include <worldpos_vertex>
  2962. #include <envmap_vertex>
  2963. #include <shadowmap_vertex>
  2964. #include <fog_vertex>
  2965. }`,$Re=`#define LAMBERT
  2966. uniform vec3 diffuse;
  2967. uniform vec3 emissive;
  2968. uniform float opacity;
  2969. #include <common>
  2970. #include <packing>
  2971. #include <dithering_pars_fragment>
  2972. #include <color_pars_fragment>
  2973. #include <uv_pars_fragment>
  2974. #include <map_pars_fragment>
  2975. #include <alphamap_pars_fragment>
  2976. #include <alphatest_pars_fragment>
  2977. #include <alphahash_pars_fragment>
  2978. #include <aomap_pars_fragment>
  2979. #include <lightmap_pars_fragment>
  2980. #include <emissivemap_pars_fragment>
  2981. #include <envmap_common_pars_fragment>
  2982. #include <envmap_pars_fragment>
  2983. #include <fog_pars_fragment>
  2984. #include <bsdfs>
  2985. #include <lights_pars_begin>
  2986. #include <normal_pars_fragment>
  2987. #include <lights_lambert_pars_fragment>
  2988. #include <shadowmap_pars_fragment>
  2989. #include <bumpmap_pars_fragment>
  2990. #include <normalmap_pars_fragment>
  2991. #include <specularmap_pars_fragment>
  2992. #include <logdepthbuf_pars_fragment>
  2993. #include <clipping_planes_pars_fragment>
  2994. void main() {
  2995. vec4 diffuseColor = vec4( diffuse, opacity );
  2996. #include <clipping_planes_fragment>
  2997. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2998. vec3 totalEmissiveRadiance = emissive;
  2999. #include <logdepthbuf_fragment>
  3000. #include <map_fragment>
  3001. #include <color_fragment>
  3002. #include <alphamap_fragment>
  3003. #include <alphatest_fragment>
  3004. #include <alphahash_fragment>
  3005. #include <specularmap_fragment>
  3006. #include <normal_fragment_begin>
  3007. #include <normal_fragment_maps>
  3008. #include <emissivemap_fragment>
  3009. #include <lights_lambert_fragment>
  3010. #include <lights_fragment_begin>
  3011. #include <lights_fragment_maps>
  3012. #include <lights_fragment_end>
  3013. #include <aomap_fragment>
  3014. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3015. #include <envmap_fragment>
  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. }`,HRe=`#define MATCAP
  3023. varying vec3 vViewPosition;
  3024. #include <common>
  3025. #include <batching_pars_vertex>
  3026. #include <uv_pars_vertex>
  3027. #include <color_pars_vertex>
  3028. #include <displacementmap_pars_vertex>
  3029. #include <fog_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 <color_vertex>
  3038. #include <morphinstance_vertex>
  3039. #include <morphcolor_vertex>
  3040. #include <batching_vertex>
  3041. #include <beginnormal_vertex>
  3042. #include <morphnormal_vertex>
  3043. #include <skinbase_vertex>
  3044. #include <skinnormal_vertex>
  3045. #include <defaultnormal_vertex>
  3046. #include <normal_vertex>
  3047. #include <begin_vertex>
  3048. #include <morphtarget_vertex>
  3049. #include <skinning_vertex>
  3050. #include <displacementmap_vertex>
  3051. #include <project_vertex>
  3052. #include <logdepthbuf_vertex>
  3053. #include <clipping_planes_vertex>
  3054. #include <fog_vertex>
  3055. vViewPosition = - mvPosition.xyz;
  3056. }`,VRe=`#define MATCAP
  3057. uniform vec3 diffuse;
  3058. uniform float opacity;
  3059. uniform sampler2D matcap;
  3060. varying vec3 vViewPosition;
  3061. #include <common>
  3062. #include <dithering_pars_fragment>
  3063. #include <color_pars_fragment>
  3064. #include <uv_pars_fragment>
  3065. #include <map_pars_fragment>
  3066. #include <alphamap_pars_fragment>
  3067. #include <alphatest_pars_fragment>
  3068. #include <alphahash_pars_fragment>
  3069. #include <fog_pars_fragment>
  3070. #include <normal_pars_fragment>
  3071. #include <bumpmap_pars_fragment>
  3072. #include <normalmap_pars_fragment>
  3073. #include <logdepthbuf_pars_fragment>
  3074. #include <clipping_planes_pars_fragment>
  3075. void main() {
  3076. vec4 diffuseColor = vec4( diffuse, opacity );
  3077. #include <clipping_planes_fragment>
  3078. #include <logdepthbuf_fragment>
  3079. #include <map_fragment>
  3080. #include <color_fragment>
  3081. #include <alphamap_fragment>
  3082. #include <alphatest_fragment>
  3083. #include <alphahash_fragment>
  3084. #include <normal_fragment_begin>
  3085. #include <normal_fragment_maps>
  3086. vec3 viewDir = normalize( vViewPosition );
  3087. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3088. vec3 y = cross( viewDir, x );
  3089. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3090. #ifdef USE_MATCAP
  3091. vec4 matcapColor = texture2D( matcap, uv );
  3092. #else
  3093. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3094. #endif
  3095. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3096. #include <opaque_fragment>
  3097. #include <tonemapping_fragment>
  3098. #include <colorspace_fragment>
  3099. #include <fog_fragment>
  3100. #include <premultiplied_alpha_fragment>
  3101. #include <dithering_fragment>
  3102. }`,GRe=`#define NORMAL
  3103. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3104. varying vec3 vViewPosition;
  3105. #endif
  3106. #include <common>
  3107. #include <batching_pars_vertex>
  3108. #include <uv_pars_vertex>
  3109. #include <displacementmap_pars_vertex>
  3110. #include <normal_pars_vertex>
  3111. #include <morphtarget_pars_vertex>
  3112. #include <skinning_pars_vertex>
  3113. #include <logdepthbuf_pars_vertex>
  3114. #include <clipping_planes_pars_vertex>
  3115. void main() {
  3116. #include <uv_vertex>
  3117. #include <batching_vertex>
  3118. #include <beginnormal_vertex>
  3119. #include <morphinstance_vertex>
  3120. #include <morphnormal_vertex>
  3121. #include <skinbase_vertex>
  3122. #include <skinnormal_vertex>
  3123. #include <defaultnormal_vertex>
  3124. #include <normal_vertex>
  3125. #include <begin_vertex>
  3126. #include <morphtarget_vertex>
  3127. #include <skinning_vertex>
  3128. #include <displacementmap_vertex>
  3129. #include <project_vertex>
  3130. #include <logdepthbuf_vertex>
  3131. #include <clipping_planes_vertex>
  3132. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3133. vViewPosition = - mvPosition.xyz;
  3134. #endif
  3135. }`,WRe=`#define NORMAL
  3136. uniform float opacity;
  3137. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3138. varying vec3 vViewPosition;
  3139. #endif
  3140. #include <packing>
  3141. #include <uv_pars_fragment>
  3142. #include <normal_pars_fragment>
  3143. #include <bumpmap_pars_fragment>
  3144. #include <normalmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3149. #include <clipping_planes_fragment>
  3150. #include <logdepthbuf_fragment>
  3151. #include <normal_fragment_begin>
  3152. #include <normal_fragment_maps>
  3153. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3154. #ifdef OPAQUE
  3155. gl_FragColor.a = 1.0;
  3156. #endif
  3157. }`,qRe=`#define PHONG
  3158. varying vec3 vViewPosition;
  3159. #include <common>
  3160. #include <batching_pars_vertex>
  3161. #include <uv_pars_vertex>
  3162. #include <displacementmap_pars_vertex>
  3163. #include <envmap_pars_vertex>
  3164. #include <color_pars_vertex>
  3165. #include <fog_pars_vertex>
  3166. #include <normal_pars_vertex>
  3167. #include <morphtarget_pars_vertex>
  3168. #include <skinning_pars_vertex>
  3169. #include <shadowmap_pars_vertex>
  3170. #include <logdepthbuf_pars_vertex>
  3171. #include <clipping_planes_pars_vertex>
  3172. void main() {
  3173. #include <uv_vertex>
  3174. #include <color_vertex>
  3175. #include <morphcolor_vertex>
  3176. #include <batching_vertex>
  3177. #include <beginnormal_vertex>
  3178. #include <morphinstance_vertex>
  3179. #include <morphnormal_vertex>
  3180. #include <skinbase_vertex>
  3181. #include <skinnormal_vertex>
  3182. #include <defaultnormal_vertex>
  3183. #include <normal_vertex>
  3184. #include <begin_vertex>
  3185. #include <morphtarget_vertex>
  3186. #include <skinning_vertex>
  3187. #include <displacementmap_vertex>
  3188. #include <project_vertex>
  3189. #include <logdepthbuf_vertex>
  3190. #include <clipping_planes_vertex>
  3191. vViewPosition = - mvPosition.xyz;
  3192. #include <worldpos_vertex>
  3193. #include <envmap_vertex>
  3194. #include <shadowmap_vertex>
  3195. #include <fog_vertex>
  3196. }`,KRe=`#define PHONG
  3197. uniform vec3 diffuse;
  3198. uniform vec3 emissive;
  3199. uniform vec3 specular;
  3200. uniform float shininess;
  3201. uniform float opacity;
  3202. #include <common>
  3203. #include <packing>
  3204. #include <dithering_pars_fragment>
  3205. #include <color_pars_fragment>
  3206. #include <uv_pars_fragment>
  3207. #include <map_pars_fragment>
  3208. #include <alphamap_pars_fragment>
  3209. #include <alphatest_pars_fragment>
  3210. #include <alphahash_pars_fragment>
  3211. #include <aomap_pars_fragment>
  3212. #include <lightmap_pars_fragment>
  3213. #include <emissivemap_pars_fragment>
  3214. #include <envmap_common_pars_fragment>
  3215. #include <envmap_pars_fragment>
  3216. #include <fog_pars_fragment>
  3217. #include <bsdfs>
  3218. #include <lights_pars_begin>
  3219. #include <normal_pars_fragment>
  3220. #include <lights_phong_pars_fragment>
  3221. #include <shadowmap_pars_fragment>
  3222. #include <bumpmap_pars_fragment>
  3223. #include <normalmap_pars_fragment>
  3224. #include <specularmap_pars_fragment>
  3225. #include <logdepthbuf_pars_fragment>
  3226. #include <clipping_planes_pars_fragment>
  3227. void main() {
  3228. vec4 diffuseColor = vec4( diffuse, opacity );
  3229. #include <clipping_planes_fragment>
  3230. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3231. vec3 totalEmissiveRadiance = emissive;
  3232. #include <logdepthbuf_fragment>
  3233. #include <map_fragment>
  3234. #include <color_fragment>
  3235. #include <alphamap_fragment>
  3236. #include <alphatest_fragment>
  3237. #include <alphahash_fragment>
  3238. #include <specularmap_fragment>
  3239. #include <normal_fragment_begin>
  3240. #include <normal_fragment_maps>
  3241. #include <emissivemap_fragment>
  3242. #include <lights_phong_fragment>
  3243. #include <lights_fragment_begin>
  3244. #include <lights_fragment_maps>
  3245. #include <lights_fragment_end>
  3246. #include <aomap_fragment>
  3247. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3248. #include <envmap_fragment>
  3249. #include <opaque_fragment>
  3250. #include <tonemapping_fragment>
  3251. #include <colorspace_fragment>
  3252. #include <fog_fragment>
  3253. #include <premultiplied_alpha_fragment>
  3254. #include <dithering_fragment>
  3255. }`,XRe=`#define STANDARD
  3256. varying vec3 vViewPosition;
  3257. #ifdef USE_TRANSMISSION
  3258. varying vec3 vWorldPosition;
  3259. #endif
  3260. #include <common>
  3261. #include <batching_pars_vertex>
  3262. #include <uv_pars_vertex>
  3263. #include <displacementmap_pars_vertex>
  3264. #include <color_pars_vertex>
  3265. #include <fog_pars_vertex>
  3266. #include <normal_pars_vertex>
  3267. #include <morphtarget_pars_vertex>
  3268. #include <skinning_pars_vertex>
  3269. #include <shadowmap_pars_vertex>
  3270. #include <logdepthbuf_pars_vertex>
  3271. #include <clipping_planes_pars_vertex>
  3272. void main() {
  3273. #include <uv_vertex>
  3274. #include <color_vertex>
  3275. #include <morphinstance_vertex>
  3276. #include <morphcolor_vertex>
  3277. #include <batching_vertex>
  3278. #include <beginnormal_vertex>
  3279. #include <morphnormal_vertex>
  3280. #include <skinbase_vertex>
  3281. #include <skinnormal_vertex>
  3282. #include <defaultnormal_vertex>
  3283. #include <normal_vertex>
  3284. #include <begin_vertex>
  3285. #include <morphtarget_vertex>
  3286. #include <skinning_vertex>
  3287. #include <displacementmap_vertex>
  3288. #include <project_vertex>
  3289. #include <logdepthbuf_vertex>
  3290. #include <clipping_planes_vertex>
  3291. vViewPosition = - mvPosition.xyz;
  3292. #include <worldpos_vertex>
  3293. #include <shadowmap_vertex>
  3294. #include <fog_vertex>
  3295. #ifdef USE_TRANSMISSION
  3296. vWorldPosition = worldPosition.xyz;
  3297. #endif
  3298. }`,YRe=`#define STANDARD
  3299. #ifdef PHYSICAL
  3300. #define IOR
  3301. #define USE_SPECULAR
  3302. #endif
  3303. uniform vec3 diffuse;
  3304. uniform vec3 emissive;
  3305. uniform float roughness;
  3306. uniform float metalness;
  3307. uniform float opacity;
  3308. #ifdef IOR
  3309. uniform float ior;
  3310. #endif
  3311. #ifdef USE_SPECULAR
  3312. uniform float specularIntensity;
  3313. uniform vec3 specularColor;
  3314. #ifdef USE_SPECULAR_COLORMAP
  3315. uniform sampler2D specularColorMap;
  3316. #endif
  3317. #ifdef USE_SPECULAR_INTENSITYMAP
  3318. uniform sampler2D specularIntensityMap;
  3319. #endif
  3320. #endif
  3321. #ifdef USE_CLEARCOAT
  3322. uniform float clearcoat;
  3323. uniform float clearcoatRoughness;
  3324. #endif
  3325. #ifdef USE_DISPERSION
  3326. uniform float dispersion;
  3327. #endif
  3328. #ifdef USE_IRIDESCENCE
  3329. uniform float iridescence;
  3330. uniform float iridescenceIOR;
  3331. uniform float iridescenceThicknessMinimum;
  3332. uniform float iridescenceThicknessMaximum;
  3333. #endif
  3334. #ifdef USE_SHEEN
  3335. uniform vec3 sheenColor;
  3336. uniform float sheenRoughness;
  3337. #ifdef USE_SHEEN_COLORMAP
  3338. uniform sampler2D sheenColorMap;
  3339. #endif
  3340. #ifdef USE_SHEEN_ROUGHNESSMAP
  3341. uniform sampler2D sheenRoughnessMap;
  3342. #endif
  3343. #endif
  3344. #ifdef USE_ANISOTROPY
  3345. uniform vec2 anisotropyVector;
  3346. #ifdef USE_ANISOTROPYMAP
  3347. uniform sampler2D anisotropyMap;
  3348. #endif
  3349. #endif
  3350. varying vec3 vViewPosition;
  3351. #include <common>
  3352. #include <packing>
  3353. #include <dithering_pars_fragment>
  3354. #include <color_pars_fragment>
  3355. #include <uv_pars_fragment>
  3356. #include <map_pars_fragment>
  3357. #include <alphamap_pars_fragment>
  3358. #include <alphatest_pars_fragment>
  3359. #include <alphahash_pars_fragment>
  3360. #include <aomap_pars_fragment>
  3361. #include <lightmap_pars_fragment>
  3362. #include <emissivemap_pars_fragment>
  3363. #include <iridescence_fragment>
  3364. #include <cube_uv_reflection_fragment>
  3365. #include <envmap_common_pars_fragment>
  3366. #include <envmap_physical_pars_fragment>
  3367. #include <fog_pars_fragment>
  3368. #include <lights_pars_begin>
  3369. #include <normal_pars_fragment>
  3370. #include <lights_physical_pars_fragment>
  3371. #include <transmission_pars_fragment>
  3372. #include <shadowmap_pars_fragment>
  3373. #include <bumpmap_pars_fragment>
  3374. #include <normalmap_pars_fragment>
  3375. #include <clearcoat_pars_fragment>
  3376. #include <iridescence_pars_fragment>
  3377. #include <roughnessmap_pars_fragment>
  3378. #include <metalnessmap_pars_fragment>
  3379. #include <logdepthbuf_pars_fragment>
  3380. #include <clipping_planes_pars_fragment>
  3381. void main() {
  3382. vec4 diffuseColor = vec4( diffuse, opacity );
  3383. #include <clipping_planes_fragment>
  3384. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3385. vec3 totalEmissiveRadiance = emissive;
  3386. #include <logdepthbuf_fragment>
  3387. #include <map_fragment>
  3388. #include <color_fragment>
  3389. #include <alphamap_fragment>
  3390. #include <alphatest_fragment>
  3391. #include <alphahash_fragment>
  3392. #include <roughnessmap_fragment>
  3393. #include <metalnessmap_fragment>
  3394. #include <normal_fragment_begin>
  3395. #include <normal_fragment_maps>
  3396. #include <clearcoat_normal_fragment_begin>
  3397. #include <clearcoat_normal_fragment_maps>
  3398. #include <emissivemap_fragment>
  3399. #include <lights_physical_fragment>
  3400. #include <lights_fragment_begin>
  3401. #include <lights_fragment_maps>
  3402. #include <lights_fragment_end>
  3403. #include <aomap_fragment>
  3404. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3405. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3406. #include <transmission_fragment>
  3407. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3408. #ifdef USE_SHEEN
  3409. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3410. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3411. #endif
  3412. #ifdef USE_CLEARCOAT
  3413. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3414. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3415. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3416. #endif
  3417. #include <opaque_fragment>
  3418. #include <tonemapping_fragment>
  3419. #include <colorspace_fragment>
  3420. #include <fog_fragment>
  3421. #include <premultiplied_alpha_fragment>
  3422. #include <dithering_fragment>
  3423. }`,QRe=`#define TOON
  3424. varying vec3 vViewPosition;
  3425. #include <common>
  3426. #include <batching_pars_vertex>
  3427. #include <uv_pars_vertex>
  3428. #include <displacementmap_pars_vertex>
  3429. #include <color_pars_vertex>
  3430. #include <fog_pars_vertex>
  3431. #include <normal_pars_vertex>
  3432. #include <morphtarget_pars_vertex>
  3433. #include <skinning_pars_vertex>
  3434. #include <shadowmap_pars_vertex>
  3435. #include <logdepthbuf_pars_vertex>
  3436. #include <clipping_planes_pars_vertex>
  3437. void main() {
  3438. #include <uv_vertex>
  3439. #include <color_vertex>
  3440. #include <morphinstance_vertex>
  3441. #include <morphcolor_vertex>
  3442. #include <batching_vertex>
  3443. #include <beginnormal_vertex>
  3444. #include <morphnormal_vertex>
  3445. #include <skinbase_vertex>
  3446. #include <skinnormal_vertex>
  3447. #include <defaultnormal_vertex>
  3448. #include <normal_vertex>
  3449. #include <begin_vertex>
  3450. #include <morphtarget_vertex>
  3451. #include <skinning_vertex>
  3452. #include <displacementmap_vertex>
  3453. #include <project_vertex>
  3454. #include <logdepthbuf_vertex>
  3455. #include <clipping_planes_vertex>
  3456. vViewPosition = - mvPosition.xyz;
  3457. #include <worldpos_vertex>
  3458. #include <shadowmap_vertex>
  3459. #include <fog_vertex>
  3460. }`,ZRe=`#define TOON
  3461. uniform vec3 diffuse;
  3462. uniform vec3 emissive;
  3463. uniform float opacity;
  3464. #include <common>
  3465. #include <packing>
  3466. #include <dithering_pars_fragment>
  3467. #include <color_pars_fragment>
  3468. #include <uv_pars_fragment>
  3469. #include <map_pars_fragment>
  3470. #include <alphamap_pars_fragment>
  3471. #include <alphatest_pars_fragment>
  3472. #include <alphahash_pars_fragment>
  3473. #include <aomap_pars_fragment>
  3474. #include <lightmap_pars_fragment>
  3475. #include <emissivemap_pars_fragment>
  3476. #include <gradientmap_pars_fragment>
  3477. #include <fog_pars_fragment>
  3478. #include <bsdfs>
  3479. #include <lights_pars_begin>
  3480. #include <normal_pars_fragment>
  3481. #include <lights_toon_pars_fragment>
  3482. #include <shadowmap_pars_fragment>
  3483. #include <bumpmap_pars_fragment>
  3484. #include <normalmap_pars_fragment>
  3485. #include <logdepthbuf_pars_fragment>
  3486. #include <clipping_planes_pars_fragment>
  3487. void main() {
  3488. vec4 diffuseColor = vec4( diffuse, opacity );
  3489. #include <clipping_planes_fragment>
  3490. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3491. vec3 totalEmissiveRadiance = emissive;
  3492. #include <logdepthbuf_fragment>
  3493. #include <map_fragment>
  3494. #include <color_fragment>
  3495. #include <alphamap_fragment>
  3496. #include <alphatest_fragment>
  3497. #include <alphahash_fragment>
  3498. #include <normal_fragment_begin>
  3499. #include <normal_fragment_maps>
  3500. #include <emissivemap_fragment>
  3501. #include <lights_toon_fragment>
  3502. #include <lights_fragment_begin>
  3503. #include <lights_fragment_maps>
  3504. #include <lights_fragment_end>
  3505. #include <aomap_fragment>
  3506. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3507. #include <opaque_fragment>
  3508. #include <tonemapping_fragment>
  3509. #include <colorspace_fragment>
  3510. #include <fog_fragment>
  3511. #include <premultiplied_alpha_fragment>
  3512. #include <dithering_fragment>
  3513. }`,JRe=`uniform float size;
  3514. uniform float scale;
  3515. #include <common>
  3516. #include <color_pars_vertex>
  3517. #include <fog_pars_vertex>
  3518. #include <morphtarget_pars_vertex>
  3519. #include <logdepthbuf_pars_vertex>
  3520. #include <clipping_planes_pars_vertex>
  3521. #ifdef USE_POINTS_UV
  3522. varying vec2 vUv;
  3523. uniform mat3 uvTransform;
  3524. #endif
  3525. void main() {
  3526. #ifdef USE_POINTS_UV
  3527. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3528. #endif
  3529. #include <color_vertex>
  3530. #include <morphinstance_vertex>
  3531. #include <morphcolor_vertex>
  3532. #include <begin_vertex>
  3533. #include <morphtarget_vertex>
  3534. #include <project_vertex>
  3535. gl_PointSize = size;
  3536. #ifdef USE_SIZEATTENUATION
  3537. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3538. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3539. #endif
  3540. #include <logdepthbuf_vertex>
  3541. #include <clipping_planes_vertex>
  3542. #include <worldpos_vertex>
  3543. #include <fog_vertex>
  3544. }`,eDe=`uniform vec3 diffuse;
  3545. uniform float opacity;
  3546. #include <common>
  3547. #include <color_pars_fragment>
  3548. #include <map_particle_pars_fragment>
  3549. #include <alphatest_pars_fragment>
  3550. #include <alphahash_pars_fragment>
  3551. #include <fog_pars_fragment>
  3552. #include <logdepthbuf_pars_fragment>
  3553. #include <clipping_planes_pars_fragment>
  3554. void main() {
  3555. vec4 diffuseColor = vec4( diffuse, opacity );
  3556. #include <clipping_planes_fragment>
  3557. vec3 outgoingLight = vec3( 0.0 );
  3558. #include <logdepthbuf_fragment>
  3559. #include <map_particle_fragment>
  3560. #include <color_fragment>
  3561. #include <alphatest_fragment>
  3562. #include <alphahash_fragment>
  3563. outgoingLight = diffuseColor.rgb;
  3564. #include <opaque_fragment>
  3565. #include <tonemapping_fragment>
  3566. #include <colorspace_fragment>
  3567. #include <fog_fragment>
  3568. #include <premultiplied_alpha_fragment>
  3569. }`,tDe=`#include <common>
  3570. #include <batching_pars_vertex>
  3571. #include <fog_pars_vertex>
  3572. #include <morphtarget_pars_vertex>
  3573. #include <skinning_pars_vertex>
  3574. #include <logdepthbuf_pars_vertex>
  3575. #include <shadowmap_pars_vertex>
  3576. void main() {
  3577. #include <batching_vertex>
  3578. #include <beginnormal_vertex>
  3579. #include <morphinstance_vertex>
  3580. #include <morphnormal_vertex>
  3581. #include <skinbase_vertex>
  3582. #include <skinnormal_vertex>
  3583. #include <defaultnormal_vertex>
  3584. #include <begin_vertex>
  3585. #include <morphtarget_vertex>
  3586. #include <skinning_vertex>
  3587. #include <project_vertex>
  3588. #include <logdepthbuf_vertex>
  3589. #include <worldpos_vertex>
  3590. #include <shadowmap_vertex>
  3591. #include <fog_vertex>
  3592. }`,nDe=`uniform vec3 color;
  3593. uniform float opacity;
  3594. #include <common>
  3595. #include <packing>
  3596. #include <fog_pars_fragment>
  3597. #include <bsdfs>
  3598. #include <lights_pars_begin>
  3599. #include <logdepthbuf_pars_fragment>
  3600. #include <shadowmap_pars_fragment>
  3601. #include <shadowmask_pars_fragment>
  3602. void main() {
  3603. #include <logdepthbuf_fragment>
  3604. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3605. #include <tonemapping_fragment>
  3606. #include <colorspace_fragment>
  3607. #include <fog_fragment>
  3608. }`,rDe=`uniform float rotation;
  3609. uniform vec2 center;
  3610. #include <common>
  3611. #include <uv_pars_vertex>
  3612. #include <fog_pars_vertex>
  3613. #include <logdepthbuf_pars_vertex>
  3614. #include <clipping_planes_pars_vertex>
  3615. void main() {
  3616. #include <uv_vertex>
  3617. vec4 mvPosition = modelViewMatrix[ 3 ];
  3618. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3619. #ifndef USE_SIZEATTENUATION
  3620. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3621. if ( isPerspective ) scale *= - mvPosition.z;
  3622. #endif
  3623. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3624. vec2 rotatedPosition;
  3625. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3626. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3627. mvPosition.xy += rotatedPosition;
  3628. gl_Position = projectionMatrix * mvPosition;
  3629. #include <logdepthbuf_vertex>
  3630. #include <clipping_planes_vertex>
  3631. #include <fog_vertex>
  3632. }`,iDe=`uniform vec3 diffuse;
  3633. uniform float opacity;
  3634. #include <common>
  3635. #include <uv_pars_fragment>
  3636. #include <map_pars_fragment>
  3637. #include <alphamap_pars_fragment>
  3638. #include <alphatest_pars_fragment>
  3639. #include <alphahash_pars_fragment>
  3640. #include <fog_pars_fragment>
  3641. #include <logdepthbuf_pars_fragment>
  3642. #include <clipping_planes_pars_fragment>
  3643. void main() {
  3644. vec4 diffuseColor = vec4( diffuse, opacity );
  3645. #include <clipping_planes_fragment>
  3646. vec3 outgoingLight = vec3( 0.0 );
  3647. #include <logdepthbuf_fragment>
  3648. #include <map_fragment>
  3649. #include <alphamap_fragment>
  3650. #include <alphatest_fragment>
  3651. #include <alphahash_fragment>
  3652. outgoingLight = diffuseColor.rgb;
  3653. #include <opaque_fragment>
  3654. #include <tonemapping_fragment>
  3655. #include <colorspace_fragment>
  3656. #include <fog_fragment>
  3657. }`,mn={alphahash_fragment:E3e,alphahash_pars_fragment:A3e,alphamap_fragment:T3e,alphamap_pars_fragment:C3e,alphatest_fragment:k3e,alphatest_pars_fragment:j3e,aomap_fragment:P3e,aomap_pars_fragment:R3e,batching_pars_vertex:D3e,batching_vertex:O3e,begin_vertex:L3e,beginnormal_vertex:I3e,bsdfs:F3e,iridescence_fragment:U3e,bumpmap_pars_fragment:z3e,clipping_planes_fragment:B3e,clipping_planes_pars_fragment:$3e,clipping_planes_pars_vertex:H3e,clipping_planes_vertex:V3e,color_fragment:G3e,color_pars_fragment:W3e,color_pars_vertex:q3e,color_vertex:K3e,common:X3e,cube_uv_reflection_fragment:Y3e,defaultnormal_vertex:Q3e,displacementmap_pars_vertex:Z3e,displacementmap_vertex:J3e,emissivemap_fragment:ePe,emissivemap_pars_fragment:tPe,colorspace_fragment:nPe,colorspace_pars_fragment:rPe,envmap_fragment:iPe,envmap_common_pars_fragment:aPe,envmap_pars_fragment:sPe,envmap_pars_vertex:oPe,envmap_physical_pars_fragment:bPe,envmap_vertex:lPe,fog_vertex:cPe,fog_pars_vertex:uPe,fog_fragment:dPe,fog_pars_fragment:hPe,gradientmap_pars_fragment:fPe,lightmap_pars_fragment:mPe,lights_lambert_fragment:pPe,lights_lambert_pars_fragment:gPe,lights_pars_begin:xPe,lights_toon_fragment:yPe,lights_toon_pars_fragment:vPe,lights_phong_fragment:_Pe,lights_phong_pars_fragment:wPe,lights_physical_fragment:SPe,lights_physical_pars_fragment:MPe,lights_fragment_begin:NPe,lights_fragment_maps:EPe,lights_fragment_end:APe,logdepthbuf_fragment:TPe,logdepthbuf_pars_fragment:CPe,logdepthbuf_pars_vertex:kPe,logdepthbuf_vertex:jPe,map_fragment:PPe,map_pars_fragment:RPe,map_particle_fragment:DPe,map_particle_pars_fragment:OPe,metalnessmap_fragment:LPe,metalnessmap_pars_fragment:IPe,morphinstance_vertex:FPe,morphcolor_vertex:UPe,morphnormal_vertex:zPe,morphtarget_pars_vertex:BPe,morphtarget_vertex:$Pe,normal_fragment_begin:HPe,normal_fragment_maps:VPe,normal_pars_fragment:GPe,normal_pars_vertex:WPe,normal_vertex:qPe,normalmap_pars_fragment:KPe,clearcoat_normal_fragment_begin:XPe,clearcoat_normal_fragment_maps:YPe,clearcoat_pars_fragment:QPe,iridescence_pars_fragment:ZPe,opaque_fragment:JPe,packing:eRe,premultiplied_alpha_fragment:tRe,project_vertex:nRe,dithering_fragment:rRe,dithering_pars_fragment:iRe,roughnessmap_fragment:aRe,roughnessmap_pars_fragment:sRe,shadowmap_pars_fragment:oRe,shadowmap_pars_vertex:lRe,shadowmap_vertex:cRe,shadowmask_pars_fragment:uRe,skinbase_vertex:dRe,skinning_pars_vertex:hRe,skinning_vertex:fRe,skinnormal_vertex:mRe,specularmap_fragment:pRe,specularmap_pars_fragment:gRe,tonemapping_fragment:xRe,tonemapping_pars_fragment:bRe,transmission_fragment:yRe,transmission_pars_fragment:vRe,uv_pars_fragment:_Re,uv_pars_vertex:wRe,uv_vertex:SRe,worldpos_vertex:MRe,background_vert:NRe,background_frag:ERe,backgroundCube_vert:ARe,backgroundCube_frag:TRe,cube_vert:CRe,cube_frag:kRe,depth_vert:jRe,depth_frag:PRe,distanceRGBA_vert:RRe,distanceRGBA_frag:DRe,equirect_vert:ORe,equirect_frag:LRe,linedashed_vert:IRe,linedashed_frag:FRe,meshbasic_vert:URe,meshbasic_frag:zRe,meshlambert_vert:BRe,meshlambert_frag:$Re,meshmatcap_vert:HRe,meshmatcap_frag:VRe,meshnormal_vert:GRe,meshnormal_frag:WRe,meshphong_vert:qRe,meshphong_frag:KRe,meshphysical_vert:XRe,meshphysical_frag:YRe,meshtoon_vert:QRe,meshtoon_frag:ZRe,points_vert:JRe,points_frag:eDe,shadow_vert:tDe,shadow_frag:nDe,sprite_vert:rDe,sprite_frag:iDe},jt={common:{diffuse:{value:new Nn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new vn}},envmap:{envMap:{value:null},envMapRotation:{value:new vn},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 vn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new vn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new vn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new vn},normalScale:{value:new gn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new vn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new vn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new vn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new vn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Nn(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 Nn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0},uvTransform:{value:new vn}},sprite:{diffuse:{value:new Nn(16777215)},opacity:{value:1},center:{value:new gn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}}},wl={basic:{uniforms:La([jt.common,jt.specularmap,jt.envmap,jt.aomap,jt.lightmap,jt.fog]),vertexShader:mn.meshbasic_vert,fragmentShader:mn.meshbasic_frag},lambert:{uniforms:La([jt.common,jt.specularmap,jt.envmap,jt.aomap,jt.lightmap,jt.emissivemap,jt.bumpmap,jt.normalmap,jt.displacementmap,jt.fog,jt.lights,{emissive:{value:new Nn(0)}}]),vertexShader:mn.meshlambert_vert,fragmentShader:mn.meshlambert_frag},phong:{uniforms:La([jt.common,jt.specularmap,jt.envmap,jt.aomap,jt.lightmap,jt.emissivemap,jt.bumpmap,jt.normalmap,jt.displacementmap,jt.fog,jt.lights,{emissive:{value:new Nn(0)},specular:{value:new Nn(1118481)},shininess:{value:30}}]),vertexShader:mn.meshphong_vert,fragmentShader:mn.meshphong_frag},standard:{uniforms:La([jt.common,jt.envmap,jt.aomap,jt.lightmap,jt.emissivemap,jt.bumpmap,jt.normalmap,jt.displacementmap,jt.roughnessmap,jt.metalnessmap,jt.fog,jt.lights,{emissive:{value:new Nn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:mn.meshphysical_vert,fragmentShader:mn.meshphysical_frag},toon:{uniforms:La([jt.common,jt.aomap,jt.lightmap,jt.emissivemap,jt.bumpmap,jt.normalmap,jt.displacementmap,jt.gradientmap,jt.fog,jt.lights,{emissive:{value:new Nn(0)}}]),vertexShader:mn.meshtoon_vert,fragmentShader:mn.meshtoon_frag},matcap:{uniforms:La([jt.common,jt.bumpmap,jt.normalmap,jt.displacementmap,jt.fog,{matcap:{value:null}}]),vertexShader:mn.meshmatcap_vert,fragmentShader:mn.meshmatcap_frag},points:{uniforms:La([jt.points,jt.fog]),vertexShader:mn.points_vert,fragmentShader:mn.points_frag},dashed:{uniforms:La([jt.common,jt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:mn.linedashed_vert,fragmentShader:mn.linedashed_frag},depth:{uniforms:La([jt.common,jt.displacementmap]),vertexShader:mn.depth_vert,fragmentShader:mn.depth_frag},normal:{uniforms:La([jt.common,jt.bumpmap,jt.normalmap,jt.displacementmap,{opacity:{value:1}}]),vertexShader:mn.meshnormal_vert,fragmentShader:mn.meshnormal_frag},sprite:{uniforms:La([jt.sprite,jt.fog]),vertexShader:mn.sprite_vert,fragmentShader:mn.sprite_frag},background:{uniforms:{uvTransform:{value:new vn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:mn.background_vert,fragmentShader:mn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new vn}},vertexShader:mn.backgroundCube_vert,fragmentShader:mn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:mn.cube_vert,fragmentShader:mn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:mn.equirect_vert,fragmentShader:mn.equirect_frag},distanceRGBA:{uniforms:La([jt.common,jt.displacementmap,{referencePosition:{value:new at},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:mn.distanceRGBA_vert,fragmentShader:mn.distanceRGBA_frag},shadow:{uniforms:La([jt.lights,jt.fog,{color:{value:new Nn(0)},opacity:{value:1}}]),vertexShader:mn.shadow_vert,fragmentShader:mn.shadow_frag}};wl.physical={uniforms:La([wl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new vn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new vn},clearcoatNormalScale:{value:new gn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new vn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new vn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new vn},sheen:{value:0},sheenColor:{value:new Nn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new vn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new vn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new vn},transmissionSamplerSize:{value:new gn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new vn},attenuationDistance:{value:0},attenuationColor:{value:new Nn(0)},specularColor:{value:new Nn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new vn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new vn},anisotropyVector:{value:new gn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new vn}}]),vertexShader:mn.meshphysical_vert,fragmentShader:mn.meshphysical_frag};const D_={r:0,b:0,g:0},Sh=new $d,aDe=new vi;function sDe(t,e,n,r,i,a,o){const l=new Nn(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function x(S){let A=S.isScene===!0?S.background:null;return A&&A.isTexture&&(A=(S.backgroundBlurriness>0?n:e).get(A)),A}function v(S){let A=!1;const E=x(S);E===null?y(l,c):E&&E.isColor&&(y(E,1),A=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,o):k==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function b(S,A){const E=x(A);E&&(E.isCubeTexture||E.mapping===DM)?(d===void 0&&(d=new Bl(new _O(1,1,1),new lu({name:"BackgroundCubeMaterial",uniforms:fg(wl.backgroundCube.uniforms),vertexShader:wl.backgroundCube.vertexShader,fragmentShader:wl.backgroundCube.fragmentShader,side:ds,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,C,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Sh.copy(A.backgroundRotation),Sh.x*=-1,Sh.y*=-1,Sh.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Sh.y*=-1,Sh.z*=-1),d.material.uniforms.envMap.value=E,d.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(aDe.makeRotationFromEuler(Sh)),d.material.toneMapped=In.getTransfer(E.colorSpace)!==sr,(f!==E||m!==E.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=E,m=E.version,p=t.toneMapping),d.layers.enableAll(),S.unshift(d,d.geometry,d.material,0,0,null)):E&&E.isTexture&&(u===void 0&&(u=new Bl(new SO(2,2),new lu({name:"BackgroundMaterial",uniforms:fg(wl.background.uniforms),vertexShader:wl.background.vertexShader,fragmentShader:wl.background.fragmentShader,side:Bd,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=E,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=In.getTransfer(E.colorSpace)!==sr,E.matrixAutoUpdate===!0&&E.updateMatrix(),u.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||m!==E.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=E,m=E.version,p=t.toneMapping),u.layers.enableAll(),S.unshift(u,u.geometry,u.material,0,0,null))}function y(S,A){S.getRGB(D_,qZ(t)),r.buffers.color.setClear(D_.r,D_.g,D_.b,A,o)}function M(){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(S,A=1){l.set(S),c=A,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(S){c=S,y(l,c)},render:v,addToRenderList:b,dispose:M}}function oDe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let a=i,o=!1;function l(P,F,I,X,D){let K=!1;const Y=f(X,I,F);a!==Y&&(a=Y,u(a.object)),K=p(P,X,I,D),K&&x(P,X,I,D),D!==null&&e.update(D,t.ELEMENT_ARRAY_BUFFER),(K||o)&&(o=!1,A(P,F,I,X),D!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function c(){return t.createVertexArray()}function u(P){return t.bindVertexArray(P)}function d(P){return t.deleteVertexArray(P)}function f(P,F,I){const X=I.wireframe===!0;let D=r[P.id];D===void 0&&(D={},r[P.id]=D);let K=D[F.id];K===void 0&&(K={},D[F.id]=K);let Y=K[X];return Y===void 0&&(Y=m(c()),K[X]=Y),Y}function m(P){const F=[],I=[],X=[];for(let D=0;D<n;D++)F[D]=0,I[D]=0,X[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:I,attributeDivisors:X,object:P,attributes:{},index:null}}function p(P,F,I,X){const D=a.attributes,K=F.attributes;let Y=0;const q=I.getAttributes();for(const Z in q)if(q[Z].location>=0){const ie=D[Z];let U=K[Z];if(U===void 0&&(Z==="instanceMatrix"&&P.instanceMatrix&&(U=P.instanceMatrix),Z==="instanceColor"&&P.instanceColor&&(U=P.instanceColor)),ie===void 0||ie.attribute!==U||U&&ie.data!==U.data)return!0;Y++}return a.attributesNum!==Y||a.index!==X}function x(P,F,I,X){const D={},K=F.attributes;let Y=0;const q=I.getAttributes();for(const Z in q)if(q[Z].location>=0){let ie=K[Z];ie===void 0&&(Z==="instanceMatrix"&&P.instanceMatrix&&(ie=P.instanceMatrix),Z==="instanceColor"&&P.instanceColor&&(ie=P.instanceColor));const U={};U.attribute=ie,ie&&ie.data&&(U.data=ie.data),D[Z]=U,Y++}a.attributes=D,a.attributesNum=Y,a.index=X}function v(){const P=a.newAttributes;for(let F=0,I=P.length;F<I;F++)P[F]=0}function b(P){y(P,0)}function y(P,F){const I=a.newAttributes,X=a.enabledAttributes,D=a.attributeDivisors;I[P]=1,X[P]===0&&(t.enableVertexAttribArray(P),X[P]=1),D[P]!==F&&(t.vertexAttribDivisor(P,F),D[P]=F)}function M(){const P=a.newAttributes,F=a.enabledAttributes;for(let I=0,X=F.length;I<X;I++)F[I]!==P[I]&&(t.disableVertexAttribArray(I),F[I]=0)}function S(P,F,I,X,D,K,Y){Y===!0?t.vertexAttribIPointer(P,F,I,D,K):t.vertexAttribPointer(P,F,I,X,D,K)}function A(P,F,I,X){v();const D=X.attributes,K=I.getAttributes(),Y=F.defaultAttributeValues;for(const q in K){const Z=K[q];if(Z.location>=0){let re=D[q];if(re===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&(re=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&(re=P.instanceColor)),re!==void 0){const ie=re.normalized,U=re.itemSize,G=e.get(re);if(G===void 0)continue;const ee=G.buffer,ne=G.type,se=G.bytesPerElement,de=ne===t.INT||ne===t.UNSIGNED_INT||re.gpuType===dO;if(re.isInterleavedBufferAttribute){const he=re.data,Ee=he.stride,ge=re.offset;if(he.isInstancedInterleavedBuffer){for(let Ne=0;Ne<Z.locationSize;Ne++)y(Z.location+Ne,he.meshPerAttribute);P.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=he.meshPerAttribute*he.count)}else for(let Ne=0;Ne<Z.locationSize;Ne++)b(Z.location+Ne);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let Ne=0;Ne<Z.locationSize;Ne++)S(Z.location+Ne,U/Z.locationSize,ne,ie,Ee*se,(ge+U/Z.locationSize*Ne)*se,de)}else{if(re.isInstancedBufferAttribute){for(let he=0;he<Z.locationSize;he++)y(Z.location+he,re.meshPerAttribute);P.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let he=0;he<Z.locationSize;he++)b(Z.location+he);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let he=0;he<Z.locationSize;he++)S(Z.location+he,U/Z.locationSize,ne,ie,U*se,U/Z.locationSize*he*se,de)}}else if(Y!==void 0){const ie=Y[q];if(ie!==void 0)switch(ie.length){case 2:t.vertexAttrib2fv(Z.location,ie);break;case 3:t.vertexAttrib3fv(Z.location,ie);break;case 4:t.vertexAttrib4fv(Z.location,ie);break;default:t.vertexAttrib1fv(Z.location,ie)}}}}M()}function E(){R();for(const P in r){const F=r[P];for(const I in F){const X=F[I];for(const D in X)d(X[D].object),delete X[D];delete F[I]}delete r[P]}}function k(P){if(r[P.id]===void 0)return;const F=r[P.id];for(const I in F){const X=F[I];for(const D in X)d(X[D].object),delete X[D];delete F[I]}delete r[P.id]}function C(P){for(const F in r){const I=r[F];if(I[P.id]===void 0)continue;const X=I[P.id];for(const D in X)d(X[D].object),delete X[D];delete I[P.id]}}function R(){T(),o=!0,a!==i&&(a=i,u(a.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:R,resetDefaultState:T,dispose:E,releaseStatesOfGeometry:k,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:b,disableUnusedAttributes:M}}function lDe(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function o(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let p=0;for(let x=0;x<f;x++)p+=d[x];n.update(p,r,1)}function c(u,d,f,m){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)o(u[x],d[x],m[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,m,0,f);let x=0;for(let v=0;v<f;v++)x+=d[v]*m[v];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function cDe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(C){return!(C!==Xo&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(C){const R=C===Vg&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==zl&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Bc&&!R)}function c(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="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&&(nn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,m=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),M=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),S=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),E=x>0,k=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:m,maxTextures:p,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:b,maxAttributes:y,maxVertexUniforms:M,maxVaryings:S,maxFragmentUniforms:A,vertexTextures:E,maxSamples:k}}function uDe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new id,l=new vn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const x=f.clippingPlanes,v=f.clipIntersection,b=f.clipShadows,y=t.get(f);if(!i||x===null||x.length===0||a&&!b)a?d(null):u();else{const M=a?0:r,S=M*4;let A=y.clippingState||null;c.value=A,A=d(x,m,S,p);for(let E=0;E!==S;++E)A[E]=n[E];y.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=M}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,x){const v=f!==null?f.length:0;let b=null;if(v!==0){if(b=c.value,x!==!0||b===null){const y=p+v*4,M=m.matrixWorldInverse;l.getNormalMatrix(M),(b===null||b.length<y)&&(b=new Float32Array(y));for(let S=0,A=p;S!==v;++S,A+=4)o.copy(f[S]).applyMatrix4(M,l),o.normal.toArray(b,A),b[A+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,b}}function dDe(t){let e=new WeakMap;function n(o,l){return l===iP?o.mapping=ug:l===aP&&(o.mapping=dg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===iP||l===aP)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 s3e(c.height);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const pd=4,IH=[.125,.215,.35,.446,.526,.582],Ih=20,hDe=256,ab=new tJ,FH=new Nn;let VC=null,GC=0,WC=0,qC=!1;const fDe=new at;let UH=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:o=256,position:l=fDe}=a;VC=this._renderer.getRenderTarget(),GC=this._renderer.getActiveCubeFace(),WC=this._renderer.getActiveMipmapLevel(),qC=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=$H(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=BH(),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(VC,GC,WC),this._renderer.xr.enabled=qC,e.scissorTest=!1,qm(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===ug||e.mapping===dg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),VC=this._renderer.getRenderTarget(),GC=this._renderer.getActiveCubeFace(),WC=this._renderer.getActiveMipmapLevel(),qC=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:wo,minFilter:wo,generateMipmaps:!1,type:Vg,format:Xo,colorSpace:hg,depthBuffer:!1},i=zH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=zH(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=mDe(a)),this._blurMaterial=gDe(a,e,n),this._ggxMaterial=pDe(a,e,n)}return i}_compileMaterial(e){const n=new Bl(new Xl,e);this._renderer.compile(n,ab)}_sceneToCubeUV(e,n,r,i,a){const c=new go(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,p=f.toneMapping;f.getClearColor(FH),f.toneMapping=Ed,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Bl(new _O,new vO({name:"PMREM.Background",side:ds,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,b=v.material;let y=!1;const M=e.background;M?M.isColor&&(b.color.copy(M),e.background=null,y=!0):(b.color.copy(FH),y=!0);for(let S=0;S<6;S++){const A=S%3;A===0?(c.up.set(0,u[S],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[S],a.y,a.z)):A===1?(c.up.set(0,0,u[S]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[S],a.z)):(c.up.set(0,u[S],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[S]));const E=this._cubeSize;qm(i,A*E,S>2?E:0,E,E),f.setRenderTarget(i),y&&f.render(v,c),f.render(e,c)}f.toneMapping=p,f.autoClear=m,e.background=M}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===ug||e.mapping===dg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=$H()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=BH());const a=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;qm(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,ab)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),m=.05+u*.95,p=f*m,{_lodMax:x}=this,v=this._sizeLods[r],b=3*v*(r>x-pd?r-x+pd:0),y=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,qm(a,b,y,3*v,2*v),i.setRenderTarget(a),i.render(l,ab),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,qm(e,b,y,3*v,2*v),i.setRenderTarget(e),i.render(l,ab)}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&ai("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const m=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Ih-1),v=a/x,b=isFinite(a)?1+Math.floor(d*v):Ih;b>Ih&&nn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Ih}`);const y=[];let M=0;for(let C=0;C<Ih;++C){const R=C/v,T=Math.exp(-R*R/2);y.push(T),C===0?M+=T:C<b&&(M+=2*T)}for(let C=0;C<y.length;C++)y[C]=y[C]/M;m.envMap.value=e.texture,m.samples.value=b,m.weights.value=y,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:S}=this;m.dTheta.value=x,m.mipInt.value=S-r;const A=this._sizeLods[i],E=3*A*(i>S-pd?i-S+pd:0),k=4*(this._cubeSize-A);qm(n,E,k,3*A,2*A),c.setRenderTarget(n),c.render(f,ab)}};function mDe(t){const e=[],n=[],r=[];let i=t;const a=t-pd+1+IH.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-pd?c=IH[o-t+pd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,v=3,b=2,y=1,M=new Float32Array(v*x*p),S=new Float32Array(b*x*p),A=new Float32Array(y*x*p);for(let k=0;k<p;k++){const C=k%3*2/3-1,R=k>2?0:-1,T=[C,R,0,C+2/3,R,0,C+2/3,R+1,0,C,R,0,C+2/3,R+1,0,C,R+1,0];M.set(T,v*x*k),S.set(m,b*x*k);const P=[k,k,k,k,k,k];A.set(P,y*x*k)}const E=new Xl;E.setAttribute("position",new So(M,v)),E.setAttribute("uv",new So(S,b)),E.setAttribute("faceIndex",new So(A,y)),r.push(new Bl(E,null)),i>pd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function zH(t,e,n){const r=new Rf(t,e,n);return r.texture.mapping=DM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function qm(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function pDe(t,e,n){return new lu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:hDe,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:LM(),fragmentShader:`
  3658. precision highp float;
  3659. precision highp int;
  3660. varying vec3 vOutputDirection;
  3661. uniform sampler2D envMap;
  3662. uniform float roughness;
  3663. uniform float mipInt;
  3664. #define ENVMAP_TYPE_CUBE_UV
  3665. #include <cube_uv_reflection_fragment>
  3666. #define PI 3.14159265359
  3667. // Van der Corput radical inverse
  3668. float radicalInverse_VdC(uint bits) {
  3669. bits = (bits << 16u) | (bits >> 16u);
  3670. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3671. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3672. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3673. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3674. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3675. }
  3676. // Hammersley sequence
  3677. vec2 hammersley(uint i, uint N) {
  3678. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3679. }
  3680. // GGX VNDF importance sampling (Eric Heitz 2018)
  3681. // "Sampling the GGX Distribution of Visible Normals"
  3682. // https://jcgt.org/published/0007/04/01/
  3683. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3684. float alpha = roughness * roughness;
  3685. // Section 3.2: Transform view direction to hemisphere configuration
  3686. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3687. // Section 4.1: Orthonormal basis
  3688. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3689. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3690. vec3 T2 = cross(Vh, T1);
  3691. // Section 4.2: Parameterization of projected area
  3692. float r = sqrt(Xi.x);
  3693. float phi = 2.0 * PI * Xi.y;
  3694. float t1 = r * cos(phi);
  3695. float t2 = r * sin(phi);
  3696. float s = 0.5 * (1.0 + Vh.z);
  3697. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3698. // Section 4.3: Reprojection onto hemisphere
  3699. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3700. // Section 3.4: Transform back to ellipsoid configuration
  3701. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3702. }
  3703. void main() {
  3704. vec3 N = normalize(vOutputDirection);
  3705. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3706. vec3 prefilteredColor = vec3(0.0);
  3707. float totalWeight = 0.0;
  3708. // For very low roughness, just sample the environment directly
  3709. if (roughness < 0.001) {
  3710. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3711. return;
  3712. }
  3713. // Tangent space basis for VNDF sampling
  3714. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3715. vec3 tangent = normalize(cross(up, N));
  3716. vec3 bitangent = cross(N, tangent);
  3717. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3718. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3719. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3720. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3721. // Transform H back to world space
  3722. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3723. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3724. float NdotL = max(dot(N, L), 0.0);
  3725. if(NdotL > 0.0) {
  3726. // Sample environment at fixed mip level
  3727. // VNDF importance sampling handles the distribution filtering
  3728. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3729. // Weight by NdotL for the split-sum approximation
  3730. // VNDF PDF naturally accounts for the visible microfacet distribution
  3731. prefilteredColor += sampleColor * NdotL;
  3732. totalWeight += NdotL;
  3733. }
  3734. }
  3735. if (totalWeight > 0.0) {
  3736. prefilteredColor = prefilteredColor / totalWeight;
  3737. }
  3738. gl_FragColor = vec4(prefilteredColor, 1.0);
  3739. }
  3740. `,blending:qc,depthTest:!1,depthWrite:!1})}function gDe(t,e,n){const r=new Float32Array(Ih),i=new at(0,1,0);return new lu({name:"SphericalGaussianBlur",defines:{n:Ih,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:LM(),fragmentShader:`
  3741. precision mediump float;
  3742. precision mediump int;
  3743. varying vec3 vOutputDirection;
  3744. uniform sampler2D envMap;
  3745. uniform int samples;
  3746. uniform float weights[ n ];
  3747. uniform bool latitudinal;
  3748. uniform float dTheta;
  3749. uniform float mipInt;
  3750. uniform vec3 poleAxis;
  3751. #define ENVMAP_TYPE_CUBE_UV
  3752. #include <cube_uv_reflection_fragment>
  3753. vec3 getSample( float theta, vec3 axis ) {
  3754. float cosTheta = cos( theta );
  3755. // Rodrigues' axis-angle rotation
  3756. vec3 sampleDirection = vOutputDirection * cosTheta
  3757. + cross( axis, vOutputDirection ) * sin( theta )
  3758. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3759. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3760. }
  3761. void main() {
  3762. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3763. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3764. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3765. }
  3766. axis = normalize( axis );
  3767. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3768. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3769. for ( int i = 1; i < n; i++ ) {
  3770. if ( i >= samples ) {
  3771. break;
  3772. }
  3773. float theta = dTheta * float( i );
  3774. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3775. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3776. }
  3777. }
  3778. `,blending:qc,depthTest:!1,depthWrite:!1})}function BH(){return new lu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:LM(),fragmentShader:`
  3779. precision mediump float;
  3780. precision mediump int;
  3781. varying vec3 vOutputDirection;
  3782. uniform sampler2D envMap;
  3783. #include <common>
  3784. void main() {
  3785. vec3 outputDirection = normalize( vOutputDirection );
  3786. vec2 uv = equirectUv( outputDirection );
  3787. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3788. }
  3789. `,blending:qc,depthTest:!1,depthWrite:!1})}function $H(){return new lu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:LM(),fragmentShader:`
  3790. precision mediump float;
  3791. precision mediump int;
  3792. uniform float flipEnvMap;
  3793. varying vec3 vOutputDirection;
  3794. uniform samplerCube envMap;
  3795. void main() {
  3796. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3797. }
  3798. `,blending:qc,depthTest:!1,depthWrite:!1})}function LM(){return`
  3799. precision mediump float;
  3800. precision mediump int;
  3801. attribute float faceIndex;
  3802. varying vec3 vOutputDirection;
  3803. // RH coordinate system; PMREM face-indexing convention
  3804. vec3 getDirection( vec2 uv, float face ) {
  3805. uv = 2.0 * uv - 1.0;
  3806. vec3 direction = vec3( uv, 1.0 );
  3807. if ( face == 0.0 ) {
  3808. direction = direction.zyx; // ( 1, v, u ) pos x
  3809. } else if ( face == 1.0 ) {
  3810. direction = direction.xzy;
  3811. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3812. } else if ( face == 2.0 ) {
  3813. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3814. } else if ( face == 3.0 ) {
  3815. direction = direction.zyx;
  3816. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3817. } else if ( face == 4.0 ) {
  3818. direction = direction.xzy;
  3819. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3820. } else if ( face == 5.0 ) {
  3821. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3822. }
  3823. return direction;
  3824. }
  3825. void main() {
  3826. vOutputDirection = getDirection( uv, faceIndex );
  3827. gl_Position = vec4( position, 1.0 );
  3828. }
  3829. `}function xDe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===iP||c===aP,d=c===ug||c===dg;if(u||d){let f=e.get(l);const m=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return n===null&&(n=new UH(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new UH(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function bDe(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&&A0("WebGLRenderer: "+r+" extension not supported."),i}}}function yDe(t,e,n,r){const i={},a=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);m.removeEventListener("dispose",o),delete i[m.id];const p=a.get(m);p&&(e.remove(p),a.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const p in m)e.update(m[p],t.ARRAY_BUFFER)}function u(f){const m=[],p=f.index,x=f.attributes.position;let v=0;if(p!==null){const M=p.array;v=p.version;for(let S=0,A=M.length;S<A;S+=3){const E=M[S+0],k=M[S+1],C=M[S+2];m.push(E,k,k,C,C,E)}}else if(x!==void 0){const M=x.array;v=x.version;for(let S=0,A=M.length/3-1;S<A;S+=3){const E=S+0,k=S+1,C=S+2;m.push(E,k,k,C,C,E)}}else return;const b=new(DZ(m)?VZ:HZ)(m,1);b.version=v;const y=a.get(f);y&&e.remove(y),a.set(f,b)}function d(f){const m=a.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function vDe(t,e,n){let r;function i(m){r=m}let a,o;function l(m){a=m.type,o=m.bytesPerElement}function c(m,p){t.drawElements(r,p,a,m*o),n.update(p,r,1)}function u(m,p,x){x!==0&&(t.drawElementsInstanced(r,p,a,m*o,x),n.update(p,r,x))}function d(m,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,m,0,x);let b=0;for(let y=0;y<x;y++)b+=p[y];n.update(b,r,1)}function f(m,p,x,v){if(x===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let y=0;y<m.length;y++)u(m[y]/o,p[y],v[y]);else{b.multiDrawElementsInstancedWEBGL(r,p,0,a,m,0,v,0,x);let y=0;for(let M=0;M<x;M++)y+=p[M]*v[M];n.update(y,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function _De(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:ai("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 wDe(t,e,n){const r=new WeakMap,i=new pi;function a(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let m=r.get(l);if(m===void 0||m.count!==f){let P=function(){R.dispose(),r.delete(l),l.removeEventListener("dispose",P)};var p=P;m!==void 0&&m.texture.dispose();const x=l.morphAttributes.position!==void 0,v=l.morphAttributes.normal!==void 0,b=l.morphAttributes.color!==void 0,y=l.morphAttributes.position||[],M=l.morphAttributes.normal||[],S=l.morphAttributes.color||[];let A=0;x===!0&&(A=1),v===!0&&(A=2),b===!0&&(A=3);let E=l.attributes.position.count*A,k=1;E>e.maxTextureSize&&(k=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const C=new Float32Array(E*k*4*f),R=new UZ(C,E,k,f);R.type=Bc,R.needsUpdate=!0;const T=A*4;for(let F=0;F<f;F++){const I=y[F],X=M[F],D=S[F],K=E*k*4*F;for(let Y=0;Y<I.count;Y++){const q=Y*T;x===!0&&(i.fromBufferAttribute(I,Y),C[K+q+0]=i.x,C[K+q+1]=i.y,C[K+q+2]=i.z,C[K+q+3]=0),v===!0&&(i.fromBufferAttribute(X,Y),C[K+q+4]=i.x,C[K+q+5]=i.y,C[K+q+6]=i.z,C[K+q+7]=0),b===!0&&(i.fromBufferAttribute(D,Y),C[K+q+8]=i.x,C[K+q+9]=i.y,C[K+q+10]=i.z,C[K+q+11]=D.itemSize===4?i.w:1)}}m={count:f,texture:R,size:new gn(E,k)},r.set(l,m),l.addEventListener("dispose",P)}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 v=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}return{update:a}}function SDe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}const rJ=new ll,HH=new QZ(1,1),iJ=new UZ,aJ=new Hje,sJ=new XZ,VH=[],GH=[],WH=new Float32Array(16),qH=new Float32Array(9),KH=new Float32Array(4);function Wg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=VH[i];if(a===void 0&&(a=new Float32Array(i),VH[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ai(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 Ti(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function IM(t,e){let n=GH[e];n===void 0&&(n=new Int32Array(e),GH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function MDe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function NDe(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(Ai(n,e))return;t.uniform2fv(this.addr,e),Ti(n,e)}}function EDe(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(Ai(n,e))return;t.uniform3fv(this.addr,e),Ti(n,e)}}function ADe(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(Ai(n,e))return;t.uniform4fv(this.addr,e),Ti(n,e)}}function TDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;KH.set(r),t.uniformMatrix2fv(this.addr,!1,KH),Ti(n,r)}}function CDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;qH.set(r),t.uniformMatrix3fv(this.addr,!1,qH),Ti(n,r)}}function kDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;WH.set(r),t.uniformMatrix4fv(this.addr,!1,WH),Ti(n,r)}}function jDe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function PDe(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(Ai(n,e))return;t.uniform2iv(this.addr,e),Ti(n,e)}}function RDe(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(Ai(n,e))return;t.uniform3iv(this.addr,e),Ti(n,e)}}function DDe(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(Ai(n,e))return;t.uniform4iv(this.addr,e),Ti(n,e)}}function ODe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function LDe(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(Ai(n,e))return;t.uniform2uiv(this.addr,e),Ti(n,e)}}function IDe(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(Ai(n,e))return;t.uniform3uiv(this.addr,e),Ti(n,e)}}function FDe(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(Ai(n,e))return;t.uniform4uiv(this.addr,e),Ti(n,e)}}function UDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(HH.compareFunction=RZ,a=HH):a=rJ,n.setTexture2D(e||a,i)}function zDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||aJ,i)}function BDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||sJ,i)}function $De(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||iJ,i)}function HDe(t){switch(t){case 5126:return MDe;case 35664:return NDe;case 35665:return EDe;case 35666:return ADe;case 35674:return TDe;case 35675:return CDe;case 35676:return kDe;case 5124:case 35670:return jDe;case 35667:case 35671:return PDe;case 35668:case 35672:return RDe;case 35669:case 35673:return DDe;case 5125:return ODe;case 36294:return LDe;case 36295:return IDe;case 36296:return FDe;case 35678:case 36198:case 36298:case 36306:case 35682:return UDe;case 35679:case 36299:case 36307:return zDe;case 35680:case 36300:case 36308:case 36293:return BDe;case 36289:case 36303:case 36311:case 36292:return $De}}function VDe(t,e){t.uniform1fv(this.addr,e)}function GDe(t,e){const n=Wg(e,this.size,2);t.uniform2fv(this.addr,n)}function WDe(t,e){const n=Wg(e,this.size,3);t.uniform3fv(this.addr,n)}function qDe(t,e){const n=Wg(e,this.size,4);t.uniform4fv(this.addr,n)}function KDe(t,e){const n=Wg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function XDe(t,e){const n=Wg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function YDe(t,e){const n=Wg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function QDe(t,e){t.uniform1iv(this.addr,e)}function ZDe(t,e){t.uniform2iv(this.addr,e)}function JDe(t,e){t.uniform3iv(this.addr,e)}function e4e(t,e){t.uniform4iv(this.addr,e)}function t4e(t,e){t.uniform1uiv(this.addr,e)}function n4e(t,e){t.uniform2uiv(this.addr,e)}function r4e(t,e){t.uniform3uiv(this.addr,e)}function i4e(t,e){t.uniform4uiv(this.addr,e)}function a4e(t,e,n){const r=this.cache,i=e.length,a=IM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||rJ,a[o])}function s4e(t,e,n){const r=this.cache,i=e.length,a=IM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||aJ,a[o])}function o4e(t,e,n){const r=this.cache,i=e.length,a=IM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||sJ,a[o])}function l4e(t,e,n){const r=this.cache,i=e.length,a=IM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||iJ,a[o])}function c4e(t){switch(t){case 5126:return VDe;case 35664:return GDe;case 35665:return WDe;case 35666:return qDe;case 35674:return KDe;case 35675:return XDe;case 35676:return YDe;case 5124:case 35670:return QDe;case 35667:case 35671:return ZDe;case 35668:case 35672:return JDe;case 35669:case 35673:return e4e;case 5125:return t4e;case 36294:return n4e;case 36295:return r4e;case 36296:return i4e;case 35678:case 36198:case 36298:case 36306:case 35682:return a4e;case 35679:case 36299:case 36307:return s4e;case 35680:case 36300:case 36308:case 36293:return o4e;case 36289:case 36303:case 36311:case 36292:return l4e}}let u4e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=HDe(n.type)}},d4e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=c4e(n.type)}},h4e=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}};const KC=/(\w+)(\])?(\[|\.)?/g;function XH(t,e){t.seq.push(e),t.map[e.id]=e}function f4e(t,e,n){const r=t.name,i=r.length;for(KC.lastIndex=0;;){const a=KC.exec(r),o=KC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){XH(n,u===void 0?new u4e(l,t,e):new d4e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new h4e(l),XH(n,f)),n=f}}}let X1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);f4e(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function YH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const m4e=37297;let p4e=0;function g4e(t,e){const n=t.split(`
  3830. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  3831. `)}const QH=new vn;function x4e(t){In._getMatrix(QH,In.workingColorSpace,t);const e=`mat3( ${QH.elements.map(n=>n.toFixed(4))} )`;switch(In.getTransfer(t)){case mS:return[e,"LinearTransferOETF"];case sr:return[e,"sRGBTransferOETF"];default:return nn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function ZH(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
  3832. `+a+`
  3833. `+g4e(t.getShaderSource(e),l)}else return a}function b4e(t,e){const n=x4e(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3834. `)}function y4e(t,e){let n;switch(e){case gje:n="Linear";break;case xje:n="Reinhard";break;case bje:n="Cineon";break;case yje:n="ACESFilmic";break;case _je:n="AgX";break;case wje:n="Neutral";break;case vje:n="Custom";break;default:nn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const O_=new at;function v4e(){In.getLuminanceCoefficients(O_);const t=O_.x.toFixed(4),e=O_.y.toFixed(4),n=O_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3835. `)}function _4e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(_b).join(`
  3836. `)}function w4e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3837. `)}function S4e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function _b(t){return t!==""}function JH(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 eV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const M4e=/^[ \t]*#include +<([\w\d./]+)>/gm;function FP(t){return t.replace(M4e,E4e)}const N4e=new Map;function E4e(t,e){let n=mn[e];if(n===void 0){const r=N4e.get(e);if(r!==void 0)n=mn[r],nn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return FP(n)}const A4e=/#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 tV(t){return t.replace(A4e,T4e)}function T4e(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function nV(t){let e=`precision ${t.precision} float;
  3838. precision ${t.precision} int;
  3839. precision ${t.precision} sampler2D;
  3840. precision ${t.precision} samplerCube;
  3841. precision ${t.precision} sampler3D;
  3842. precision ${t.precision} sampler2DArray;
  3843. precision ${t.precision} sampler2DShadow;
  3844. precision ${t.precision} samplerCubeShadow;
  3845. precision ${t.precision} sampler2DArrayShadow;
  3846. precision ${t.precision} isampler2D;
  3847. precision ${t.precision} isampler3D;
  3848. precision ${t.precision} isamplerCube;
  3849. precision ${t.precision} isampler2DArray;
  3850. precision ${t.precision} usampler2D;
  3851. precision ${t.precision} usampler3D;
  3852. precision ${t.precision} usamplerCube;
  3853. precision ${t.precision} usampler2DArray;
  3854. `;return t.precision==="highp"?e+=`
  3855. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3856. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3857. #define LOW_PRECISION`),e}function C4e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===SZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Xke?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Tc&&(e="SHADOWMAP_TYPE_VSM"),e}function k4e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case ug:case dg:e="ENVMAP_TYPE_CUBE";break;case DM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function j4e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case dg:e="ENVMAP_MODE_REFRACTION";break}return e}function P4e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case uO:e="ENVMAP_BLENDING_MULTIPLY";break;case mje:e="ENVMAP_BLENDING_MIX";break;case pje:e="ENVMAP_BLENDING_ADD";break}return e}function R4e(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 D4e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=C4e(n),u=k4e(n),d=j4e(n),f=P4e(n),m=R4e(n),p=_4e(n),x=w4e(a),v=i.createProgram();let b,y,M=n.glslVersion?"#version "+n.glslVersion+`
  3858. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(_b).join(`
  3859. `),b.length>0&&(b+=`
  3860. `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(_b).join(`
  3861. `),y.length>0&&(y+=`
  3862. `)):(b=[nV(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",`
  3863. `].filter(_b).join(`
  3864. `),y=[nV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Ed?"#define TONE_MAPPING":"",n.toneMapping!==Ed?mn.tonemapping_pars_fragment:"",n.toneMapping!==Ed?y4e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",mn.colorspace_pars_fragment,b4e("linearToOutputTexel",n.outputColorSpace),v4e(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3865. `].filter(_b).join(`
  3866. `)),o=FP(o),o=JH(o,n),o=eV(o,n),l=FP(l),l=JH(l,n),l=eV(l,n),o=tV(o),l=tV(l),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
  3867. `,b=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3868. `)+`
  3869. `+b,y=["#define varying in",n.glslVersion===cH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===cH?"":"#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(`
  3870. `)+`
  3871. `+y);const S=M+b+o,A=M+y+l,E=YH(i,i.VERTEX_SHADER,S),k=YH(i,i.FRAGMENT_SHADER,A);i.attachShader(v,E),i.attachShader(v,k),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function C(F){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(v)||"",X=i.getShaderInfoLog(E)||"",D=i.getShaderInfoLog(k)||"",K=I.trim(),Y=X.trim(),q=D.trim();let Z=!0,re=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(Z=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,E,k);else{const ie=ZH(i,E,"vertex"),U=ZH(i,k,"fragment");ai("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  3872. Material Name: `+F.name+`
  3873. Material Type: `+F.type+`
  3874. Program Info Log: `+K+`
  3875. `+ie+`
  3876. `+U)}else K!==""?nn("WebGLProgram: Program Info Log:",K):(Y===""||q==="")&&(re=!1);re&&(F.diagnostics={runnable:Z,programLog:K,vertexShader:{log:Y,prefix:b},fragmentShader:{log:q,prefix:y}})}i.deleteShader(E),i.deleteShader(k),R=new X1(i,v),T=S4e(i,v)}let R;this.getUniforms=function(){return R===void 0&&C(this),R};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(v,m4e)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=p4e++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=E,this.fragmentShader=k,this}let O4e=0,L4e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new I4e(e),n.set(e,r)),r}},I4e=class{constructor(e){this.id=O4e++,this.code=e,this.usedTimes=0}};function F4e(t,e,n,r,i,a,o){const l=new BZ,c=new L4e,u=new Set,d=[],f=i.logarithmicDepthBuffer,m=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(T){return u.add(T),T===0?"uv":`uv${T}`}function b(T,P,F,I,X){const D=I.fog,K=X.geometry,Y=T.isMeshStandardMaterial?I.environment:null,q=(T.isMeshStandardMaterial?n:e).get(T.envMap||Y),Z=q&&q.mapping===DM?q.image.height:null,re=x[T.type];T.precision!==null&&(p=i.getMaxPrecision(T.precision),p!==T.precision&&nn("WebGLProgram.getParameters:",T.precision,"not supported, using",p,"instead."));const ie=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,U=ie!==void 0?ie.length:0;let G=0;K.morphAttributes.position!==void 0&&(G=1),K.morphAttributes.normal!==void 0&&(G=2),K.morphAttributes.color!==void 0&&(G=3);let ee,ne,se,de;if(re){const Ct=wl[re];ee=Ct.vertexShader,ne=Ct.fragmentShader}else ee=T.vertexShader,ne=T.fragmentShader,c.update(T),se=c.getVertexShaderID(T),de=c.getFragmentShaderID(T);const he=t.getRenderTarget(),Ee=t.state.buffers.depth.getReversed(),ge=X.isInstancedMesh===!0,Ne=X.isBatchedMesh===!0,Re=!!T.map,te=!!T.matcap,Je=!!q,B=!!T.aoMap,H=!!T.lightMap,W=!!T.bumpMap,z=!!T.normalMap,V=!!T.displacementMap,Q=!!T.emissiveMap,Te=!!T.metalnessMap,ke=!!T.roughnessMap,Ae=T.anisotropy>0,$=T.clearcoat>0,L=T.dispersion>0,oe=T.iridescence>0,ce=T.sheen>0,xe=T.transmission>0,ve=Ae&&!!T.anisotropyMap,_e=$&&!!T.clearcoatMap,Ie=$&&!!T.clearcoatNormalMap,We=$&&!!T.clearcoatRoughnessMap,ht=oe&&!!T.iridescenceMap,qe=oe&&!!T.iridescenceThicknessMap,me=ce&&!!T.sheenColorMap,rt=ce&&!!T.sheenRoughnessMap,Xe=!!T.specularMap,nt=!!T.specularColorMap,ut=!!T.specularIntensityMap,ae=xe&&!!T.transmissionMap,$e=xe&&!!T.thicknessMap,ye=!!T.gradientMap,Be=!!T.alphaMap,De=T.alphaTest>0,we=!!T.alphaHash,Ve=!!T.extensions;let dt=Ed;T.toneMapped&&(he===null||he.isXRRenderTarget===!0)&&(dt=t.toneMapping);const Tt={shaderID:re,shaderType:T.type,shaderName:T.name,vertexShader:ee,fragmentShader:ne,defines:T.defines,customVertexShaderID:se,customFragmentShaderID:de,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:p,batching:Ne,batchingColor:Ne&&X._colorsTexture!==null,instancing:ge,instancingColor:ge&&X.instanceColor!==null,instancingMorph:ge&&X.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:he===null?t.outputColorSpace:he.isXRRenderTarget===!0?he.texture.colorSpace:hg,alphaToCoverage:!!T.alphaToCoverage,map:Re,matcap:te,envMap:Je,envMapMode:Je&&q.mapping,envMapCubeUVHeight:Z,aoMap:B,lightMap:H,bumpMap:W,normalMap:z,displacementMap:m&&V,emissiveMap:Q,normalMapObjectSpace:z&&T.normalMapType===Eje,normalMapTangentSpace:z&&T.normalMapType===PZ,metalnessMap:Te,roughnessMap:ke,anisotropy:Ae,anisotropyMap:ve,clearcoat:$,clearcoatMap:_e,clearcoatNormalMap:Ie,clearcoatRoughnessMap:We,dispersion:L,iridescence:oe,iridescenceMap:ht,iridescenceThicknessMap:qe,sheen:ce,sheenColorMap:me,sheenRoughnessMap:rt,specularMap:Xe,specularColorMap:nt,specularIntensityMap:ut,transmission:xe,transmissionMap:ae,thicknessMap:$e,gradientMap:ye,opaque:T.transparent===!1&&T.blending===zp&&T.alphaToCoverage===!1,alphaMap:Be,alphaTest:De,alphaHash:we,combine:T.combine,mapUv:Re&&v(T.map.channel),aoMapUv:B&&v(T.aoMap.channel),lightMapUv:H&&v(T.lightMap.channel),bumpMapUv:W&&v(T.bumpMap.channel),normalMapUv:z&&v(T.normalMap.channel),displacementMapUv:V&&v(T.displacementMap.channel),emissiveMapUv:Q&&v(T.emissiveMap.channel),metalnessMapUv:Te&&v(T.metalnessMap.channel),roughnessMapUv:ke&&v(T.roughnessMap.channel),anisotropyMapUv:ve&&v(T.anisotropyMap.channel),clearcoatMapUv:_e&&v(T.clearcoatMap.channel),clearcoatNormalMapUv:Ie&&v(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:We&&v(T.clearcoatRoughnessMap.channel),iridescenceMapUv:ht&&v(T.iridescenceMap.channel),iridescenceThicknessMapUv:qe&&v(T.iridescenceThicknessMap.channel),sheenColorMapUv:me&&v(T.sheenColorMap.channel),sheenRoughnessMapUv:rt&&v(T.sheenRoughnessMap.channel),specularMapUv:Xe&&v(T.specularMap.channel),specularColorMapUv:nt&&v(T.specularColorMap.channel),specularIntensityMapUv:ut&&v(T.specularIntensityMap.channel),transmissionMapUv:ae&&v(T.transmissionMap.channel),thicknessMapUv:$e&&v(T.thicknessMap.channel),alphaMapUv:Be&&v(T.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(z||Ae),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:X.isPoints===!0&&!!K.attributes.uv&&(Re||Be),fog:!!D,useFog:T.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:T.flatShading===!0&&T.wireframe===!1,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ee,skinning:X.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:G,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:dt,decodeVideoTexture:Re&&T.map.isVideoTexture===!0&&In.getTransfer(T.map.colorSpace)===sr,decodeVideoTextureEmissive:Q&&T.emissiveMap.isVideoTexture===!0&&In.getTransfer(T.emissiveMap.colorSpace)===sr,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Sl,flipSided:T.side===ds,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:Ve&&T.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ve&&T.extensions.multiDraw===!0||Ne)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return Tt.vertexUv1s=u.has(1),Tt.vertexUv2s=u.has(2),Tt.vertexUv3s=u.has(3),u.clear(),Tt}function y(T){const P=[];if(T.shaderID?P.push(T.shaderID):(P.push(T.customVertexShaderID),P.push(T.customFragmentShaderID)),T.defines!==void 0)for(const F in T.defines)P.push(F),P.push(T.defines[F]);return T.isRawShaderMaterial===!1&&(M(P,T),S(P,T),P.push(t.outputColorSpace)),P.push(T.customProgramCacheKey),P.join()}function M(T,P){T.push(P.precision),T.push(P.outputColorSpace),T.push(P.envMapMode),T.push(P.envMapCubeUVHeight),T.push(P.mapUv),T.push(P.alphaMapUv),T.push(P.lightMapUv),T.push(P.aoMapUv),T.push(P.bumpMapUv),T.push(P.normalMapUv),T.push(P.displacementMapUv),T.push(P.emissiveMapUv),T.push(P.metalnessMapUv),T.push(P.roughnessMapUv),T.push(P.anisotropyMapUv),T.push(P.clearcoatMapUv),T.push(P.clearcoatNormalMapUv),T.push(P.clearcoatRoughnessMapUv),T.push(P.iridescenceMapUv),T.push(P.iridescenceThicknessMapUv),T.push(P.sheenColorMapUv),T.push(P.sheenRoughnessMapUv),T.push(P.specularMapUv),T.push(P.specularColorMapUv),T.push(P.specularIntensityMapUv),T.push(P.transmissionMapUv),T.push(P.thicknessMapUv),T.push(P.combine),T.push(P.fogExp2),T.push(P.sizeAttenuation),T.push(P.morphTargetsCount),T.push(P.morphAttributeCount),T.push(P.numDirLights),T.push(P.numPointLights),T.push(P.numSpotLights),T.push(P.numSpotLightMaps),T.push(P.numHemiLights),T.push(P.numRectAreaLights),T.push(P.numDirLightShadows),T.push(P.numPointLightShadows),T.push(P.numSpotLightShadows),T.push(P.numSpotLightShadowsWithMaps),T.push(P.numLightProbes),T.push(P.shadowMapType),T.push(P.toneMapping),T.push(P.numClippingPlanes),T.push(P.numClipIntersection),T.push(P.depthPacking)}function S(T,P){l.disableAll(),P.supportsVertexTextures&&l.enable(0),P.instancing&&l.enable(1),P.instancingColor&&l.enable(2),P.instancingMorph&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),P.dispersion&&l.enable(20),P.batchingColor&&l.enable(21),P.gradientMap&&l.enable(22),T.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.reversedDepthBuffer&&l.enable(4),P.skinning&&l.enable(5),P.morphTargets&&l.enable(6),P.morphNormals&&l.enable(7),P.morphColors&&l.enable(8),P.premultipliedAlpha&&l.enable(9),P.shadowMapEnabled&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),P.decodeVideoTextureEmissive&&l.enable(20),P.alphaToCoverage&&l.enable(21),T.push(l.mask)}function A(T){const P=x[T.type];let F;if(P){const I=wl[P];F=n3e.clone(I.uniforms)}else F=T.uniforms;return F}function E(T,P){let F;for(let I=0,X=d.length;I<X;I++){const D=d[I];if(D.cacheKey===P){F=D,++F.usedTimes;break}}return F===void 0&&(F=new D4e(t,P,T,a),d.push(F)),F}function k(T){if(--T.usedTimes===0){const P=d.indexOf(T);d[P]=d[d.length-1],d.pop(),T.destroy()}}function C(T){c.remove(T)}function R(){c.dispose()}return{getParameters:b,getProgramCacheKey:y,getUniforms:A,acquireProgram:E,releaseProgram:k,releaseShaderCache:C,programs:d,dispose:R}}function U4e(){let t=new WeakMap;function e(o){return t.has(o)}function n(o){let l=t.get(o);return l===void 0&&(l={},t.set(o,l)),l}function r(o){t.delete(o)}function i(o,l,c){t.get(o)[l]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function z4e(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 rV(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 iV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,m,p,x,v,b){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:m,material:p,groupOrder:x,renderOrder:f.renderOrder,z:v,group:b},t[e]=y):(y.id=f.id,y.object=f,y.geometry=m,y.material=p,y.groupOrder=x,y.renderOrder=f.renderOrder,y.z=v,y.group=b),e++,y}function l(f,m,p,x,v,b){const y=o(f,m,p,x,v,b);p.transmission>0?r.push(y):p.transparent===!0?i.push(y):n.push(y)}function c(f,m,p,x,v,b){const y=o(f,m,p,x,v,b);p.transmission>0?r.unshift(y):p.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,m){n.length>1&&n.sort(f||z4e),r.length>1&&r.sort(m||rV),i.length>1&&i.sort(m||rV)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function B4e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new iV,t.set(r,[o])):i>=a.length?(o=new iV,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function $4e(){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 at,color:new Nn};break;case"SpotLight":n={position:new at,direction:new at,color:new Nn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new at,color:new Nn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new at,skyColor:new Nn,groundColor:new Nn};break;case"RectAreaLight":n={color:new Nn,position:new at,halfWidth:new at,halfHeight:new at};break}return t[e.id]=n,n}}}function H4e(){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 gn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let V4e=0;function G4e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function W4e(t){const e=new $4e,n=H4e(),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 at);const i=new at,a=new vi,o=new vi;function l(u){let d=0,f=0,m=0;for(let T=0;T<9;T++)r.probe[T].set(0,0,0);let p=0,x=0,v=0,b=0,y=0,M=0,S=0,A=0,E=0,k=0,C=0;u.sort(G4e);for(let T=0,P=u.length;T<P;T++){const F=u[T],I=F.color,X=F.intensity,D=F.distance,K=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=I.r*X,f+=I.g*X,m+=I.b*X;else if(F.isLightProbe){for(let Y=0;Y<9;Y++)r.probe[Y].addScaledVector(F.sh.coefficients[Y],X);C++}else if(F.isDirectionalLight){const Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const q=F.shadow,Z=n.get(F);Z.shadowIntensity=q.intensity,Z.shadowBias=q.bias,Z.shadowNormalBias=q.normalBias,Z.shadowRadius=q.radius,Z.shadowMapSize=q.mapSize,r.directionalShadow[p]=Z,r.directionalShadowMap[p]=K,r.directionalShadowMatrix[p]=F.shadow.matrix,M++}r.directional[p]=Y,p++}else if(F.isSpotLight){const Y=e.get(F);Y.position.setFromMatrixPosition(F.matrixWorld),Y.color.copy(I).multiplyScalar(X),Y.distance=D,Y.coneCos=Math.cos(F.angle),Y.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),Y.decay=F.decay,r.spot[v]=Y;const q=F.shadow;if(F.map&&(r.spotLightMap[E]=F.map,E++,q.updateMatrices(F),F.castShadow&&k++),r.spotLightMatrix[v]=q.matrix,F.castShadow){const Z=n.get(F);Z.shadowIntensity=q.intensity,Z.shadowBias=q.bias,Z.shadowNormalBias=q.normalBias,Z.shadowRadius=q.radius,Z.shadowMapSize=q.mapSize,r.spotShadow[v]=Z,r.spotShadowMap[v]=K,A++}v++}else if(F.isRectAreaLight){const Y=e.get(F);Y.color.copy(I).multiplyScalar(X),Y.halfWidth.set(F.width*.5,0,0),Y.halfHeight.set(0,F.height*.5,0),r.rectArea[b]=Y,b++}else if(F.isPointLight){const Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity),Y.distance=F.distance,Y.decay=F.decay,F.castShadow){const q=F.shadow,Z=n.get(F);Z.shadowIntensity=q.intensity,Z.shadowBias=q.bias,Z.shadowNormalBias=q.normalBias,Z.shadowRadius=q.radius,Z.shadowMapSize=q.mapSize,Z.shadowCameraNear=q.camera.near,Z.shadowCameraFar=q.camera.far,r.pointShadow[x]=Z,r.pointShadowMap[x]=K,r.pointShadowMatrix[x]=F.shadow.matrix,S++}r.point[x]=Y,x++}else if(F.isHemisphereLight){const Y=e.get(F);Y.skyColor.copy(F.color).multiplyScalar(X),Y.groundColor.copy(F.groundColor).multiplyScalar(X),r.hemi[y]=Y,y++}}b>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=jt.LTC_FLOAT_1,r.rectAreaLTC2=jt.LTC_FLOAT_2):(r.rectAreaLTC1=jt.LTC_HALF_1,r.rectAreaLTC2=jt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const R=r.hash;(R.directionalLength!==p||R.pointLength!==x||R.spotLength!==v||R.rectAreaLength!==b||R.hemiLength!==y||R.numDirectionalShadows!==M||R.numPointShadows!==S||R.numSpotShadows!==A||R.numSpotMaps!==E||R.numLightProbes!==C)&&(r.directional.length=p,r.spot.length=v,r.rectArea.length=b,r.point.length=x,r.hemi.length=y,r.directionalShadow.length=M,r.directionalShadowMap.length=M,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=M,r.pointShadowMatrix.length=S,r.spotLightMatrix.length=A+E-k,r.spotLightMap.length=E,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=C,R.directionalLength=p,R.pointLength=x,R.spotLength=v,R.rectAreaLength=b,R.hemiLength=y,R.numDirectionalShadows=M,R.numPointShadows=S,R.numSpotShadows=A,R.numSpotMaps=E,R.numLightProbes=C,r.version=V4e++)}function c(u,d){let f=0,m=0,p=0,x=0,v=0;const b=d.matrixWorldInverse;for(let y=0,M=u.length;y<M;y++){const S=u[y];if(S.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),f++}else if(S.isSpotLight){const A=r.spot[p];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(b),A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),p++}else if(S.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(b),o.identity(),a.copy(S.matrixWorld),a.premultiply(b),o.extractRotation(a),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(o),A.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){const A=r.point[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(b),m++}else if(S.isHemisphereLight){const A=r.hemi[v];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(b),v++}}}return{setup:l,setupView:c,state:r}}function aV(t){const e=new W4e(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function o(d){r.push(d)}function l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function q4e(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new aV(t),e.set(i,[l])):a>=o.length?(l=new aV(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const K4e=`void main() {
  3877. gl_Position = vec4( position, 1.0 );
  3878. }`,X4e=`uniform sampler2D shadow_pass;
  3879. uniform vec2 resolution;
  3880. uniform float radius;
  3881. #include <packing>
  3882. void main() {
  3883. const float samples = float( VSM_SAMPLES );
  3884. float mean = 0.0;
  3885. float squared_mean = 0.0;
  3886. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3887. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3888. for ( float i = 0.0; i < samples; i ++ ) {
  3889. float uvOffset = uvStart + i * uvStride;
  3890. #ifdef HORIZONTAL_PASS
  3891. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3892. mean += distribution.x;
  3893. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3894. #else
  3895. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3896. mean += depth;
  3897. squared_mean += depth * depth;
  3898. #endif
  3899. }
  3900. mean = mean / samples;
  3901. squared_mean = squared_mean / samples;
  3902. float std_dev = sqrt( squared_mean - mean * mean );
  3903. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3904. }`;function Y4e(t,e,n){let r=new wO;const i=new gn,a=new gn,o=new pi,l=new g3e({depthPacking:Nje}),c=new x3e,u={},d=n.maxTextureSize,f={[Bd]:ds,[ds]:Bd,[Sl]:Sl},m=new lu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new gn},radius:{value:4}},vertexShader:K4e,fragmentShader:X4e}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const x=new Xl;x.setAttribute("position",new So(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Bl(x,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=SZ;let y=this.type;this.render=function(k,C,R){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||k.length===0)return;const T=t.getRenderTarget(),P=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),I=t.state;I.setBlending(qc),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const X=y!==Tc&&this.type===Tc,D=y===Tc&&this.type!==Tc;for(let K=0,Y=k.length;K<Y;K++){const q=k[K],Z=q.shadow;if(Z===void 0){nn("WebGLShadowMap:",q,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;i.copy(Z.mapSize);const re=Z.getFrameExtents();if(i.multiply(re),a.copy(Z.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/re.x),i.x=a.x*re.x,Z.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/re.y),i.y=a.y*re.y,Z.mapSize.y=a.y)),Z.map===null||X===!0||D===!0){const U=this.type!==Tc?{minFilter:zs,magFilter:zs}:{};Z.map!==null&&Z.map.dispose(),Z.map=new Rf(i.x,i.y,U),Z.map.texture.name=q.name+".shadowMap",Z.camera.updateProjectionMatrix()}t.setRenderTarget(Z.map),t.clear();const ie=Z.getViewportCount();for(let U=0;U<ie;U++){const G=Z.getViewport(U);o.set(a.x*G.x,a.y*G.y,a.x*G.z,a.y*G.w),I.viewport(o),Z.updateMatrices(q,U),r=Z.getFrustum(),A(C,R,Z.camera,q,this.type)}Z.isPointLightShadow!==!0&&this.type===Tc&&M(Z,R),Z.needsUpdate=!1}y=this.type,b.needsUpdate=!1,t.setRenderTarget(T,P,F)};function M(k,C){const R=e.update(v);m.defines.VSM_SAMPLES!==k.blurSamples&&(m.defines.VSM_SAMPLES=k.blurSamples,p.defines.VSM_SAMPLES=k.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new Rf(i.x,i.y)),m.uniforms.shadow_pass.value=k.map.texture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(C,null,R,m,v,null),p.uniforms.shadow_pass.value=k.mapPass.texture,p.uniforms.resolution.value=k.mapSize,p.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(C,null,R,p,v,null)}function S(k,C,R,T){let P=null;const F=R.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(F!==void 0)P=F;else if(P=R.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const I=P.uuid,X=C.uuid;let D=u[I];D===void 0&&(D={},u[I]=D);let K=D[X];K===void 0&&(K=P.clone(),D[X]=K,C.addEventListener("dispose",E)),P=K}if(P.visible=C.visible,P.wireframe=C.wireframe,T===Tc?P.side=C.shadowSide!==null?C.shadowSide:C.side:P.side=C.shadowSide!==null?C.shadowSide:f[C.side],P.alphaMap=C.alphaMap,P.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,P.map=C.map,P.clipShadows=C.clipShadows,P.clippingPlanes=C.clippingPlanes,P.clipIntersection=C.clipIntersection,P.displacementMap=C.displacementMap,P.displacementScale=C.displacementScale,P.displacementBias=C.displacementBias,P.wireframeLinewidth=C.wireframeLinewidth,P.linewidth=C.linewidth,R.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const I=t.properties.get(P);I.light=R}return P}function A(k,C,R,T,P){if(k.visible===!1)return;if(k.layers.test(C.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&P===Tc)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,k.matrixWorld);const X=e.update(k),D=k.material;if(Array.isArray(D)){const K=X.groups;for(let Y=0,q=K.length;Y<q;Y++){const Z=K[Y],re=D[Z.materialIndex];if(re&&re.visible){const ie=S(k,re,T,P);k.onBeforeShadow(t,k,C,R,X,ie,Z),t.renderBufferDirect(R,null,X,ie,k,Z),k.onAfterShadow(t,k,C,R,X,ie,Z)}}}else if(D.visible){const K=S(k,D,T,P);k.onBeforeShadow(t,k,C,R,X,K,null),t.renderBufferDirect(R,null,X,K,k,null),k.onAfterShadow(t,k,C,R,X,K,null)}}const I=k.children;for(let X=0,D=I.length;X<D;X++)A(I[X],C,R,T,P)}function E(k){k.target.removeEventListener("dispose",E);for(const R in u){const T=u[R],P=k.target.uuid;P in T&&(T[P].dispose(),delete T[P])}}}const Q4e={[Q3]:Z3,[J3]:nP,[eP]:rP,[cg]:tP,[Z3]:Q3,[nP]:J3,[rP]:eP,[tP]:cg};function Z4e(t,e){function n(){let ae=!1;const $e=new pi;let ye=null;const Be=new pi(0,0,0,0);return{setMask:function(De){ye!==De&&!ae&&(t.colorMask(De,De,De,De),ye=De)},setLocked:function(De){ae=De},setClear:function(De,we,Ve,dt,Tt){Tt===!0&&(De*=dt,we*=dt,Ve*=dt),$e.set(De,we,Ve,dt),Be.equals($e)===!1&&(t.clearColor(De,we,Ve,dt),Be.copy($e))},reset:function(){ae=!1,ye=null,Be.set(-1,0,0,0)}}}function r(){let ae=!1,$e=!1,ye=null,Be=null,De=null;return{setReversed:function(we){if($e!==we){const Ve=e.get("EXT_clip_control");we?Ve.clipControlEXT(Ve.LOWER_LEFT_EXT,Ve.ZERO_TO_ONE_EXT):Ve.clipControlEXT(Ve.LOWER_LEFT_EXT,Ve.NEGATIVE_ONE_TO_ONE_EXT),$e=we;const dt=De;De=null,this.setClear(dt)}},getReversed:function(){return $e},setTest:function(we){we?he(t.DEPTH_TEST):Ee(t.DEPTH_TEST)},setMask:function(we){ye!==we&&!ae&&(t.depthMask(we),ye=we)},setFunc:function(we){if($e&&(we=Q4e[we]),Be!==we){switch(we){case Q3:t.depthFunc(t.NEVER);break;case Z3:t.depthFunc(t.ALWAYS);break;case J3:t.depthFunc(t.LESS);break;case cg:t.depthFunc(t.LEQUAL);break;case eP:t.depthFunc(t.EQUAL);break;case tP:t.depthFunc(t.GEQUAL);break;case nP:t.depthFunc(t.GREATER);break;case rP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Be=we}},setLocked:function(we){ae=we},setClear:function(we){De!==we&&($e&&(we=1-we),t.clearDepth(we),De=we)},reset:function(){ae=!1,ye=null,Be=null,De=null,$e=!1}}}function i(){let ae=!1,$e=null,ye=null,Be=null,De=null,we=null,Ve=null,dt=null,Tt=null;return{setTest:function(Ct){ae||(Ct?he(t.STENCIL_TEST):Ee(t.STENCIL_TEST))},setMask:function(Ct){$e!==Ct&&!ae&&(t.stencilMask(Ct),$e=Ct)},setFunc:function(Ct,Xt,Pt){(ye!==Ct||Be!==Xt||De!==Pt)&&(t.stencilFunc(Ct,Xt,Pt),ye=Ct,Be=Xt,De=Pt)},setOp:function(Ct,Xt,Pt){(we!==Ct||Ve!==Xt||dt!==Pt)&&(t.stencilOp(Ct,Xt,Pt),we=Ct,Ve=Xt,dt=Pt)},setLocked:function(Ct){ae=Ct},setClear:function(Ct){Tt!==Ct&&(t.clearStencil(Ct),Tt=Ct)},reset:function(){ae=!1,$e=null,ye=null,Be=null,De=null,we=null,Ve=null,dt=null,Tt=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},m=new WeakMap,p=[],x=null,v=!1,b=null,y=null,M=null,S=null,A=null,E=null,k=null,C=new Nn(0,0,0),R=0,T=!1,P=null,F=null,I=null,X=null,D=null;const K=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(Z)[1]),Y=q>=1):Z.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=q>=2);let re=null,ie={};const U=t.getParameter(t.SCISSOR_BOX),G=t.getParameter(t.VIEWPORT),ee=new pi().fromArray(U),ne=new pi().fromArray(G);function se(ae,$e,ye,Be){const De=new Uint8Array(4),we=t.createTexture();t.bindTexture(ae,we),t.texParameteri(ae,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ae,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ve=0;Ve<ye;Ve++)ae===t.TEXTURE_3D||ae===t.TEXTURE_2D_ARRAY?t.texImage3D($e,0,t.RGBA,1,1,Be,0,t.RGBA,t.UNSIGNED_BYTE,De):t.texImage2D($e+Ve,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,De);return we}const de={};de[t.TEXTURE_2D]=se(t.TEXTURE_2D,t.TEXTURE_2D,1),de[t.TEXTURE_CUBE_MAP]=se(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),de[t.TEXTURE_2D_ARRAY]=se(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),de[t.TEXTURE_3D]=se(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),he(t.DEPTH_TEST),o.setFunc(cg),W(!1),z(rH),he(t.CULL_FACE),B(qc);function he(ae){d[ae]!==!0&&(t.enable(ae),d[ae]=!0)}function Ee(ae){d[ae]!==!1&&(t.disable(ae),d[ae]=!1)}function ge(ae,$e){return f[ae]!==$e?(t.bindFramebuffer(ae,$e),f[ae]=$e,ae===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=$e),ae===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=$e),!0):!1}function Ne(ae,$e){let ye=p,Be=!1;if(ae){ye=m.get($e),ye===void 0&&(ye=[],m.set($e,ye));const De=ae.textures;if(ye.length!==De.length||ye[0]!==t.COLOR_ATTACHMENT0){for(let we=0,Ve=De.length;we<Ve;we++)ye[we]=t.COLOR_ATTACHMENT0+we;ye.length=De.length,Be=!0}}else ye[0]!==t.BACK&&(ye[0]=t.BACK,Be=!0);Be&&t.drawBuffers(ye)}function Re(ae){return x!==ae?(t.useProgram(ae),x=ae,!0):!1}const te={[Lh]:t.FUNC_ADD,[Qke]:t.FUNC_SUBTRACT,[Zke]:t.FUNC_REVERSE_SUBTRACT};te[Jke]=t.MIN,te[eje]=t.MAX;const Je={[tje]:t.ZERO,[nje]:t.ONE,[rje]:t.SRC_COLOR,[X3]:t.SRC_ALPHA,[cje]:t.SRC_ALPHA_SATURATE,[oje]:t.DST_COLOR,[aje]:t.DST_ALPHA,[ije]:t.ONE_MINUS_SRC_COLOR,[Y3]:t.ONE_MINUS_SRC_ALPHA,[lje]:t.ONE_MINUS_DST_COLOR,[sje]:t.ONE_MINUS_DST_ALPHA,[uje]:t.CONSTANT_COLOR,[dje]:t.ONE_MINUS_CONSTANT_COLOR,[hje]:t.CONSTANT_ALPHA,[fje]:t.ONE_MINUS_CONSTANT_ALPHA};function B(ae,$e,ye,Be,De,we,Ve,dt,Tt,Ct){if(ae===qc){v===!0&&(Ee(t.BLEND),v=!1);return}if(v===!1&&(he(t.BLEND),v=!0),ae!==Yke){if(ae!==b||Ct!==T){if((y!==Lh||A!==Lh)&&(t.blendEquation(t.FUNC_ADD),y=Lh,A=Lh),Ct)switch(ae){case zp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case iH:t.blendFunc(t.ONE,t.ONE);break;case aH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case sH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:ai("WebGLState: Invalid blending: ",ae);break}else switch(ae){case zp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case iH:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case aH:ai("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case sH:ai("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ai("WebGLState: Invalid blending: ",ae);break}M=null,S=null,E=null,k=null,C.set(0,0,0),R=0,b=ae,T=Ct}return}De=De||$e,we=we||ye,Ve=Ve||Be,($e!==y||De!==A)&&(t.blendEquationSeparate(te[$e],te[De]),y=$e,A=De),(ye!==M||Be!==S||we!==E||Ve!==k)&&(t.blendFuncSeparate(Je[ye],Je[Be],Je[we],Je[Ve]),M=ye,S=Be,E=we,k=Ve),(dt.equals(C)===!1||Tt!==R)&&(t.blendColor(dt.r,dt.g,dt.b,Tt),C.copy(dt),R=Tt),b=ae,T=!1}function H(ae,$e){ae.side===Sl?Ee(t.CULL_FACE):he(t.CULL_FACE);let ye=ae.side===ds;$e&&(ye=!ye),W(ye),ae.blending===zp&&ae.transparent===!1?B(qc):B(ae.blending,ae.blendEquation,ae.blendSrc,ae.blendDst,ae.blendEquationAlpha,ae.blendSrcAlpha,ae.blendDstAlpha,ae.blendColor,ae.blendAlpha,ae.premultipliedAlpha),o.setFunc(ae.depthFunc),o.setTest(ae.depthTest),o.setMask(ae.depthWrite),a.setMask(ae.colorWrite);const Be=ae.stencilWrite;l.setTest(Be),Be&&(l.setMask(ae.stencilWriteMask),l.setFunc(ae.stencilFunc,ae.stencilRef,ae.stencilFuncMask),l.setOp(ae.stencilFail,ae.stencilZFail,ae.stencilZPass)),Q(ae.polygonOffset,ae.polygonOffsetFactor,ae.polygonOffsetUnits),ae.alphaToCoverage===!0?he(t.SAMPLE_ALPHA_TO_COVERAGE):Ee(t.SAMPLE_ALPHA_TO_COVERAGE)}function W(ae){P!==ae&&(ae?t.frontFace(t.CW):t.frontFace(t.CCW),P=ae)}function z(ae){ae!==qke?(he(t.CULL_FACE),ae!==F&&(ae===rH?t.cullFace(t.BACK):ae===Kke?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ee(t.CULL_FACE),F=ae}function V(ae){ae!==I&&(Y&&t.lineWidth(ae),I=ae)}function Q(ae,$e,ye){ae?(he(t.POLYGON_OFFSET_FILL),(X!==$e||D!==ye)&&(t.polygonOffset($e,ye),X=$e,D=ye)):Ee(t.POLYGON_OFFSET_FILL)}function Te(ae){ae?he(t.SCISSOR_TEST):Ee(t.SCISSOR_TEST)}function ke(ae){ae===void 0&&(ae=t.TEXTURE0+K-1),re!==ae&&(t.activeTexture(ae),re=ae)}function Ae(ae,$e,ye){ye===void 0&&(re===null?ye=t.TEXTURE0+K-1:ye=re);let Be=ie[ye];Be===void 0&&(Be={type:void 0,texture:void 0},ie[ye]=Be),(Be.type!==ae||Be.texture!==$e)&&(re!==ye&&(t.activeTexture(ye),re=ye),t.bindTexture(ae,$e||de[ae]),Be.type=ae,Be.texture=$e)}function $(){const ae=ie[re];ae!==void 0&&ae.type!==void 0&&(t.bindTexture(ae.type,null),ae.type=void 0,ae.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function oe(){try{t.compressedTexImage3D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function ce(){try{t.texSubImage2D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function xe(){try{t.texSubImage3D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function ve(){try{t.compressedTexSubImage2D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function _e(){try{t.compressedTexSubImage3D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function Ie(){try{t.texStorage2D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function We(){try{t.texStorage3D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function ht(){try{t.texImage2D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function qe(){try{t.texImage3D(...arguments)}catch(ae){ae("WebGLState:",ae)}}function me(ae){ee.equals(ae)===!1&&(t.scissor(ae.x,ae.y,ae.z,ae.w),ee.copy(ae))}function rt(ae){ne.equals(ae)===!1&&(t.viewport(ae.x,ae.y,ae.z,ae.w),ne.copy(ae))}function Xe(ae,$e){let ye=u.get($e);ye===void 0&&(ye=new WeakMap,u.set($e,ye));let Be=ye.get(ae);Be===void 0&&(Be=t.getUniformBlockIndex($e,ae.name),ye.set(ae,Be))}function nt(ae,$e){const Be=u.get($e).get(ae);c.get($e)!==Be&&(t.uniformBlockBinding($e,Be,ae.__bindingPointIndex),c.set($e,Be))}function ut(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),o.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},re=null,ie={},f={},m=new WeakMap,p=[],x=null,v=!1,b=null,y=null,M=null,S=null,A=null,E=null,k=null,C=new Nn(0,0,0),R=0,T=!1,P=null,F=null,I=null,X=null,D=null,ee.set(0,0,t.canvas.width,t.canvas.height),ne.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:he,disable:Ee,bindFramebuffer:ge,drawBuffers:Ne,useProgram:Re,setBlending:B,setMaterial:H,setFlipSided:W,setCullFace:z,setLineWidth:V,setPolygonOffset:Q,setScissorTest:Te,activeTexture:ke,bindTexture:Ae,unbindTexture:$,compressedTexImage2D:L,compressedTexImage3D:oe,texImage2D:ht,texImage3D:qe,updateUBOMapping:Xe,uniformBlockBinding:nt,texStorage2D:Ie,texStorage3D:We,texSubImage2D:ce,texSubImage3D:xe,compressedTexSubImage2D:ve,compressedTexSubImage3D:_e,scissor:me,viewport:rt,reset:ut}}function J4e(t,e,n,r,i,a,o){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new gn,d=new WeakMap;let f;const m=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x($,L){return p?new OffscreenCanvas($,L):gS("canvas")}function v($,L,oe){let ce=1;const xe=Ae($);if((xe.width>oe||xe.height>oe)&&(ce=oe/Math.max(xe.width,xe.height)),ce<1)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap||typeof VideoFrame<"u"&&$ instanceof VideoFrame){const ve=Math.floor(ce*xe.width),_e=Math.floor(ce*xe.height);f===void 0&&(f=x(ve,_e));const Ie=L?x(ve,_e):f;return Ie.width=ve,Ie.height=_e,Ie.getContext("2d").drawImage($,0,0,ve,_e),nn("WebGLRenderer: Texture has been resized from ("+xe.width+"x"+xe.height+") to ("+ve+"x"+_e+")."),Ie}else return"data"in $&&nn("WebGLRenderer: Image in DataTexture is too big ("+xe.width+"x"+xe.height+")."),$;return $}function b($){return $.generateMipmaps}function y($){t.generateMipmap($)}function M($){return $.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:$.isWebGL3DRenderTarget?t.TEXTURE_3D:$.isWebGLArrayRenderTarget||$.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function S($,L,oe,ce,xe=!1){if($!==null){if(t[$]!==void 0)return t[$];nn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ve=L;if(L===t.RED&&(oe===t.FLOAT&&(ve=t.R32F),oe===t.HALF_FLOAT&&(ve=t.R16F),oe===t.UNSIGNED_BYTE&&(ve=t.R8)),L===t.RED_INTEGER&&(oe===t.UNSIGNED_BYTE&&(ve=t.R8UI),oe===t.UNSIGNED_SHORT&&(ve=t.R16UI),oe===t.UNSIGNED_INT&&(ve=t.R32UI),oe===t.BYTE&&(ve=t.R8I),oe===t.SHORT&&(ve=t.R16I),oe===t.INT&&(ve=t.R32I)),L===t.RG&&(oe===t.FLOAT&&(ve=t.RG32F),oe===t.HALF_FLOAT&&(ve=t.RG16F),oe===t.UNSIGNED_BYTE&&(ve=t.RG8)),L===t.RG_INTEGER&&(oe===t.UNSIGNED_BYTE&&(ve=t.RG8UI),oe===t.UNSIGNED_SHORT&&(ve=t.RG16UI),oe===t.UNSIGNED_INT&&(ve=t.RG32UI),oe===t.BYTE&&(ve=t.RG8I),oe===t.SHORT&&(ve=t.RG16I),oe===t.INT&&(ve=t.RG32I)),L===t.RGB_INTEGER&&(oe===t.UNSIGNED_BYTE&&(ve=t.RGB8UI),oe===t.UNSIGNED_SHORT&&(ve=t.RGB16UI),oe===t.UNSIGNED_INT&&(ve=t.RGB32UI),oe===t.BYTE&&(ve=t.RGB8I),oe===t.SHORT&&(ve=t.RGB16I),oe===t.INT&&(ve=t.RGB32I)),L===t.RGBA_INTEGER&&(oe===t.UNSIGNED_BYTE&&(ve=t.RGBA8UI),oe===t.UNSIGNED_SHORT&&(ve=t.RGBA16UI),oe===t.UNSIGNED_INT&&(ve=t.RGBA32UI),oe===t.BYTE&&(ve=t.RGBA8I),oe===t.SHORT&&(ve=t.RGBA16I),oe===t.INT&&(ve=t.RGBA32I)),L===t.RGB&&(oe===t.UNSIGNED_INT_5_9_9_9_REV&&(ve=t.RGB9_E5),oe===t.UNSIGNED_INT_10F_11F_11F_REV&&(ve=t.R11F_G11F_B10F)),L===t.RGBA){const _e=xe?mS:In.getTransfer(ce);oe===t.FLOAT&&(ve=t.RGBA32F),oe===t.HALF_FLOAT&&(ve=t.RGBA16F),oe===t.UNSIGNED_BYTE&&(ve=_e===sr?t.SRGB8_ALPHA8:t.RGBA8),oe===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),oe===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function A($,L){let oe;return $?L===null||L===jf||L===M0?oe=t.DEPTH24_STENCIL8:L===Bc?oe=t.DEPTH32F_STENCIL8:L===S0&&(oe=t.DEPTH24_STENCIL8,nn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===jf||L===M0?oe=t.DEPTH_COMPONENT24:L===Bc?oe=t.DEPTH_COMPONENT32F:L===S0&&(oe=t.DEPTH_COMPONENT16),oe}function E($,L){return b($)===!0||$.isFramebufferTexture&&$.minFilter!==zs&&$.minFilter!==wo?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function k($){const L=$.target;L.removeEventListener("dispose",k),R(L),L.isVideoTexture&&d.delete(L)}function C($){const L=$.target;L.removeEventListener("dispose",C),P(L)}function R($){const L=r.get($);if(L.__webglInit===void 0)return;const oe=$.source,ce=m.get(oe);if(ce){const xe=ce[L.__cacheKey];xe.usedTimes--,xe.usedTimes===0&&T($),Object.keys(ce).length===0&&m.delete(oe)}r.remove($)}function T($){const L=r.get($);t.deleteTexture(L.__webglTexture);const oe=$.source,ce=m.get(oe);delete ce[L.__cacheKey],o.memory.textures--}function P($){const L=r.get($);if($.depthTexture&&($.depthTexture.dispose(),r.remove($.depthTexture)),$.isWebGLCubeRenderTarget)for(let ce=0;ce<6;ce++){if(Array.isArray(L.__webglFramebuffer[ce]))for(let xe=0;xe<L.__webglFramebuffer[ce].length;xe++)t.deleteFramebuffer(L.__webglFramebuffer[ce][xe]);else t.deleteFramebuffer(L.__webglFramebuffer[ce]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ce])}else{if(Array.isArray(L.__webglFramebuffer))for(let ce=0;ce<L.__webglFramebuffer.length;ce++)t.deleteFramebuffer(L.__webglFramebuffer[ce]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ce=0;ce<L.__webglColorRenderbuffer.length;ce++)L.__webglColorRenderbuffer[ce]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ce]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const oe=$.textures;for(let ce=0,xe=oe.length;ce<xe;ce++){const ve=r.get(oe[ce]);ve.__webglTexture&&(t.deleteTexture(ve.__webglTexture),o.memory.textures--),r.remove(oe[ce])}r.remove($)}let F=0;function I(){F=0}function X(){const $=F;return $>=i.maxTextures&&nn("WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+i.maxTextures),F+=1,$}function D($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function K($,L){const oe=r.get($);if($.isVideoTexture&&Te($),$.isRenderTargetTexture===!1&&$.isExternalTexture!==!0&&$.version>0&&oe.__version!==$.version){const ce=$.image;if(ce===null)nn("WebGLRenderer: Texture marked for update but no image data found.");else if(ce.complete===!1)nn("WebGLRenderer: Texture marked for update but image is incomplete");else{de(oe,$,L);return}}else $.isExternalTexture&&(oe.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,oe.__webglTexture,t.TEXTURE0+L)}function Y($,L){const oe=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&oe.__version!==$.version){de(oe,$,L);return}else $.isExternalTexture&&(oe.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,oe.__webglTexture,t.TEXTURE0+L)}function q($,L){const oe=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&oe.__version!==$.version){de(oe,$,L);return}n.bindTexture(t.TEXTURE_3D,oe.__webglTexture,t.TEXTURE0+L)}function Z($,L){const oe=r.get($);if($.version>0&&oe.__version!==$.version){he(oe,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,oe.__webglTexture,t.TEXTURE0+L)}const re={[sP]:t.REPEAT,[zc]:t.CLAMP_TO_EDGE,[oP]:t.MIRRORED_REPEAT},ie={[zs]:t.NEAREST,[Sje]:t.NEAREST_MIPMAP_NEAREST,[m_]:t.NEAREST_MIPMAP_LINEAR,[wo]:t.LINEAR,[bC]:t.LINEAR_MIPMAP_NEAREST,[Xh]:t.LINEAR_MIPMAP_LINEAR},U={[Aje]:t.NEVER,[Rje]:t.ALWAYS,[Tje]:t.LESS,[RZ]:t.LEQUAL,[Cje]:t.EQUAL,[Pje]:t.GEQUAL,[kje]:t.GREATER,[jje]:t.NOTEQUAL};function G($,L){if(L.type===Bc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===wo||L.magFilter===bC||L.magFilter===m_||L.magFilter===Xh||L.minFilter===wo||L.minFilter===bC||L.minFilter===m_||L.minFilter===Xh)&&nn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri($,t.TEXTURE_WRAP_S,re[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,re[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,re[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,ie[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,ie[L.minFilter]),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,U[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===zs||L.minFilter!==m_&&L.minFilter!==Xh||L.type===Bc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const oe=e.get("EXT_texture_filter_anisotropic");t.texParameterf($,oe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ee($,L){let oe=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",k));const ce=L.source;let xe=m.get(ce);xe===void 0&&(xe={},m.set(ce,xe));const ve=D(L);if(ve!==$.__cacheKey){xe[ve]===void 0&&(xe[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,oe=!0),xe[ve].usedTimes++;const _e=xe[$.__cacheKey];_e!==void 0&&(xe[$.__cacheKey].usedTimes--,_e.usedTimes===0&&T(L)),$.__cacheKey=ve,$.__webglTexture=xe[ve].texture}return oe}function ne($,L,oe){return Math.floor(Math.floor($/oe)/L)}function se($,L,oe,ce){const ve=$.updateRanges;if(ve.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,oe,ce,L.data);else{ve.sort((qe,me)=>qe.start-me.start);let _e=0;for(let qe=1;qe<ve.length;qe++){const me=ve[_e],rt=ve[qe],Xe=me.start+me.count,nt=ne(rt.start,L.width,4),ut=ne(me.start,L.width,4);rt.start<=Xe+1&&nt===ut&&ne(rt.start+rt.count-1,L.width,4)===nt?me.count=Math.max(me.count,rt.start+rt.count-me.start):(++_e,ve[_e]=rt)}ve.length=_e+1;const Ie=t.getParameter(t.UNPACK_ROW_LENGTH),We=t.getParameter(t.UNPACK_SKIP_PIXELS),ht=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let qe=0,me=ve.length;qe<me;qe++){const rt=ve[qe],Xe=Math.floor(rt.start/4),nt=Math.ceil(rt.count/4),ut=Xe%L.width,ae=Math.floor(Xe/L.width),$e=nt,ye=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ut),t.pixelStorei(t.UNPACK_SKIP_ROWS,ae),n.texSubImage2D(t.TEXTURE_2D,0,ut,ae,$e,ye,oe,ce,L.data)}$.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ie),t.pixelStorei(t.UNPACK_SKIP_PIXELS,We),t.pixelStorei(t.UNPACK_SKIP_ROWS,ht)}}function de($,L,oe){let ce=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ce=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ce=t.TEXTURE_3D);const xe=ee($,L),ve=L.source;n.bindTexture(ce,$.__webglTexture,t.TEXTURE0+oe);const _e=r.get(ve);if(ve.version!==_e.__version||xe===!0){n.activeTexture(t.TEXTURE0+oe);const Ie=In.getPrimaries(In.workingColorSpace),We=L.colorSpace===dd?null:In.getPrimaries(L.colorSpace),ht=L.colorSpace===dd||Ie===We?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,ht);let qe=v(L.image,!1,i.maxTextureSize);qe=ke(L,qe);const me=a.convert(L.format,L.colorSpace),rt=a.convert(L.type);let Xe=S(L.internalFormat,me,rt,L.colorSpace,L.isVideoTexture);G(ce,L);let nt;const ut=L.mipmaps,ae=L.isVideoTexture!==!0,$e=_e.__version===void 0||xe===!0,ye=ve.dataReady,Be=E(L,qe);if(L.isDepthTexture)Xe=A(L.format===E0,L.type),$e&&(ae?n.texStorage2D(t.TEXTURE_2D,1,Xe,qe.width,qe.height):n.texImage2D(t.TEXTURE_2D,0,Xe,qe.width,qe.height,0,me,rt,null));else if(L.isDataTexture)if(ut.length>0){ae&&$e&&n.texStorage2D(t.TEXTURE_2D,Be,Xe,ut[0].width,ut[0].height);for(let De=0,we=ut.length;De<we;De++)nt=ut[De],ae?ye&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,nt.width,nt.height,me,rt,nt.data):n.texImage2D(t.TEXTURE_2D,De,Xe,nt.width,nt.height,0,me,rt,nt.data);L.generateMipmaps=!1}else ae?($e&&n.texStorage2D(t.TEXTURE_2D,Be,Xe,qe.width,qe.height),ye&&se(L,qe,me,rt)):n.texImage2D(t.TEXTURE_2D,0,Xe,qe.width,qe.height,0,me,rt,qe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ae&&$e&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Be,Xe,ut[0].width,ut[0].height,qe.depth);for(let De=0,we=ut.length;De<we;De++)if(nt=ut[De],L.format!==Xo)if(me!==null)if(ae){if(ye)if(L.layerUpdates.size>0){const Ve=LH(nt.width,nt.height,L.format,L.type);for(const dt of L.layerUpdates){const Tt=nt.data.subarray(dt*Ve/nt.data.BYTES_PER_ELEMENT,(dt+1)*Ve/nt.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,dt,nt.width,nt.height,1,me,Tt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,0,nt.width,nt.height,qe.depth,me,nt.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,De,Xe,nt.width,nt.height,qe.depth,0,nt.data,0,0);else nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ae?ye&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,0,nt.width,nt.height,qe.depth,me,rt,nt.data):n.texImage3D(t.TEXTURE_2D_ARRAY,De,Xe,nt.width,nt.height,qe.depth,0,me,rt,nt.data)}else{ae&&$e&&n.texStorage2D(t.TEXTURE_2D,Be,Xe,ut[0].width,ut[0].height);for(let De=0,we=ut.length;De<we;De++)nt=ut[De],L.format!==Xo?me!==null?ae?ye&&n.compressedTexSubImage2D(t.TEXTURE_2D,De,0,0,nt.width,nt.height,me,nt.data):n.compressedTexImage2D(t.TEXTURE_2D,De,Xe,nt.width,nt.height,0,nt.data):nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ae?ye&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,nt.width,nt.height,me,rt,nt.data):n.texImage2D(t.TEXTURE_2D,De,Xe,nt.width,nt.height,0,me,rt,nt.data)}else if(L.isDataArrayTexture)if(ae){if($e&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Be,Xe,qe.width,qe.height,qe.depth),ye)if(L.layerUpdates.size>0){const De=LH(qe.width,qe.height,L.format,L.type);for(const we of L.layerUpdates){const Ve=qe.data.subarray(we*De/qe.data.BYTES_PER_ELEMENT,(we+1)*De/qe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,we,qe.width,qe.height,1,me,rt,Ve)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,qe.width,qe.height,qe.depth,me,rt,qe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Xe,qe.width,qe.height,qe.depth,0,me,rt,qe.data);else if(L.isData3DTexture)ae?($e&&n.texStorage3D(t.TEXTURE_3D,Be,Xe,qe.width,qe.height,qe.depth),ye&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,qe.width,qe.height,qe.depth,me,rt,qe.data)):n.texImage3D(t.TEXTURE_3D,0,Xe,qe.width,qe.height,qe.depth,0,me,rt,qe.data);else if(L.isFramebufferTexture){if($e)if(ae)n.texStorage2D(t.TEXTURE_2D,Be,Xe,qe.width,qe.height);else{let De=qe.width,we=qe.height;for(let Ve=0;Ve<Be;Ve++)n.texImage2D(t.TEXTURE_2D,Ve,Xe,De,we,0,me,rt,null),De>>=1,we>>=1}}else if(ut.length>0){if(ae&&$e){const De=Ae(ut[0]);n.texStorage2D(t.TEXTURE_2D,Be,Xe,De.width,De.height)}for(let De=0,we=ut.length;De<we;De++)nt=ut[De],ae?ye&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,me,rt,nt):n.texImage2D(t.TEXTURE_2D,De,Xe,me,rt,nt);L.generateMipmaps=!1}else if(ae){if($e){const De=Ae(qe);n.texStorage2D(t.TEXTURE_2D,Be,Xe,De.width,De.height)}ye&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,me,rt,qe)}else n.texImage2D(t.TEXTURE_2D,0,Xe,me,rt,qe);b(L)&&y(ce),_e.__version=ve.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function he($,L,oe){if(L.image.length!==6)return;const ce=ee($,L),xe=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+oe);const ve=r.get(xe);if(xe.version!==ve.__version||ce===!0){n.activeTexture(t.TEXTURE0+oe);const _e=In.getPrimaries(In.workingColorSpace),Ie=L.colorSpace===dd?null:In.getPrimaries(L.colorSpace),We=L.colorSpace===dd||_e===Ie?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,We);const ht=L.isCompressedTexture||L.image[0].isCompressedTexture,qe=L.image[0]&&L.image[0].isDataTexture,me=[];for(let we=0;we<6;we++)!ht&&!qe?me[we]=v(L.image[we],!0,i.maxCubemapSize):me[we]=qe?L.image[we].image:L.image[we],me[we]=ke(L,me[we]);const rt=me[0],Xe=a.convert(L.format,L.colorSpace),nt=a.convert(L.type),ut=S(L.internalFormat,Xe,nt,L.colorSpace),ae=L.isVideoTexture!==!0,$e=ve.__version===void 0||ce===!0,ye=xe.dataReady;let Be=E(L,rt);G(t.TEXTURE_CUBE_MAP,L);let De;if(ht){ae&&$e&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Be,ut,rt.width,rt.height);for(let we=0;we<6;we++){De=me[we].mipmaps;for(let Ve=0;Ve<De.length;Ve++){const dt=De[Ve];L.format!==Xo?Xe!==null?ae?ye&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve,0,0,dt.width,dt.height,Xe,dt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve,ut,dt.width,dt.height,0,dt.data):nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ae?ye&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve,0,0,dt.width,dt.height,Xe,nt,dt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve,ut,dt.width,dt.height,0,Xe,nt,dt.data)}}}else{if(De=L.mipmaps,ae&&$e){De.length>0&&Be++;const we=Ae(me[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Be,ut,we.width,we.height)}for(let we=0;we<6;we++)if(qe){ae?ye&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,me[we].width,me[we].height,Xe,nt,me[we].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ut,me[we].width,me[we].height,0,Xe,nt,me[we].data);for(let Ve=0;Ve<De.length;Ve++){const Tt=De[Ve].image[we].image;ae?ye&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve+1,0,0,Tt.width,Tt.height,Xe,nt,Tt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve+1,ut,Tt.width,Tt.height,0,Xe,nt,Tt.data)}}else{ae?ye&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,Xe,nt,me[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ut,Xe,nt,me[we]);for(let Ve=0;Ve<De.length;Ve++){const dt=De[Ve];ae?ye&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve+1,0,0,Xe,nt,dt.image[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve+1,ut,Xe,nt,dt.image[we])}}}b(L)&&y(t.TEXTURE_CUBE_MAP),ve.__version=xe.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Ee($,L,oe,ce,xe,ve){const _e=a.convert(oe.format,oe.colorSpace),Ie=a.convert(oe.type),We=S(oe.internalFormat,_e,Ie,oe.colorSpace),ht=r.get(L),qe=r.get(oe);if(qe.__renderTarget=L,!ht.__hasExternalTextures){const me=Math.max(1,L.width>>ve),rt=Math.max(1,L.height>>ve);xe===t.TEXTURE_3D||xe===t.TEXTURE_2D_ARRAY?n.texImage3D(xe,ve,We,me,rt,L.depth,0,_e,Ie,null):n.texImage2D(xe,ve,We,me,rt,0,_e,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Q(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ce,xe,qe.__webglTexture,0,V(L)):(xe===t.TEXTURE_2D||xe>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&xe<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ce,xe,qe.__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ge($,L,oe){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer){const ce=L.depthTexture,xe=ce&&ce.isDepthTexture?ce.type:null,ve=A(L.stencilBuffer,xe),_e=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=V(L);Q(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ie,ve,L.width,L.height):oe?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ie,ve,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ve,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,$)}else{const ce=L.textures;for(let xe=0;xe<ce.length;xe++){const ve=ce[xe],_e=a.convert(ve.format,ve.colorSpace),Ie=a.convert(ve.type),We=S(ve.internalFormat,_e,Ie,ve.colorSpace),ht=V(L);oe&&Q(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ht,We,L.width,L.height):Q(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ht,We,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,We,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ne($,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ce=r.get(L.depthTexture);ce.__renderTarget=L,(!ce.__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),K(L.depthTexture,0);const xe=ce.__webglTexture,ve=V(L);if(L.depthTexture.format===N0)Q(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,xe,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,xe,0);else if(L.depthTexture.format===E0)Q(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,xe,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,xe,0);else throw new Error("Unknown depthTexture format")}function Re($){const L=r.get($),oe=$.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==$.depthTexture){const ce=$.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ce){const xe=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ce.removeEventListener("dispose",xe)};ce.addEventListener("dispose",xe),L.__depthDisposeCallback=xe}L.__boundDepthTexture=ce}if($.depthTexture&&!L.__autoAllocateDepthBuffer){if(oe)throw new Error("target.depthTexture not supported in Cube render targets");const ce=$.texture.mipmaps;ce&&ce.length>0?Ne(L.__webglFramebuffer[0],$):Ne(L.__webglFramebuffer,$)}else if(oe){L.__webglDepthbuffer=[];for(let ce=0;ce<6;ce++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ce]),L.__webglDepthbuffer[ce]===void 0)L.__webglDepthbuffer[ce]=t.createRenderbuffer(),ge(L.__webglDepthbuffer[ce],$,!1);else{const xe=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=L.__webglDepthbuffer[ce];t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,xe,t.RENDERBUFFER,ve)}}else{const ce=$.texture.mipmaps;if(ce&&ce.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),ge(L.__webglDepthbuffer,$,!1);else{const xe=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,xe,t.RENDERBUFFER,ve)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function te($,L,oe){const ce=r.get($);L!==void 0&&Ee(ce.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),oe!==void 0&&Re($)}function Je($){const L=$.texture,oe=r.get($),ce=r.get(L);$.addEventListener("dispose",C);const xe=$.textures,ve=$.isWebGLCubeRenderTarget===!0,_e=xe.length>1;if(_e||(ce.__webglTexture===void 0&&(ce.__webglTexture=t.createTexture()),ce.__version=L.version,o.memory.textures++),ve){oe.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(L.mipmaps&&L.mipmaps.length>0){oe.__webglFramebuffer[Ie]=[];for(let We=0;We<L.mipmaps.length;We++)oe.__webglFramebuffer[Ie][We]=t.createFramebuffer()}else oe.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){oe.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)oe.__webglFramebuffer[Ie]=t.createFramebuffer()}else oe.__webglFramebuffer=t.createFramebuffer();if(_e)for(let Ie=0,We=xe.length;Ie<We;Ie++){const ht=r.get(xe[Ie]);ht.__webglTexture===void 0&&(ht.__webglTexture=t.createTexture(),o.memory.textures++)}if($.samples>0&&Q($)===!1){oe.__webglMultisampledFramebuffer=t.createFramebuffer(),oe.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,oe.__webglMultisampledFramebuffer);for(let Ie=0;Ie<xe.length;Ie++){const We=xe[Ie];oe.__webglColorRenderbuffer[Ie]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,oe.__webglColorRenderbuffer[Ie]);const ht=a.convert(We.format,We.colorSpace),qe=a.convert(We.type),me=S(We.internalFormat,ht,qe,We.colorSpace,$.isXRRenderTarget===!0),rt=V($);t.renderbufferStorageMultisample(t.RENDERBUFFER,rt,me,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ie,t.RENDERBUFFER,oe.__webglColorRenderbuffer[Ie])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(oe.__webglDepthRenderbuffer=t.createRenderbuffer(),ge(oe.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ve){n.bindTexture(t.TEXTURE_CUBE_MAP,ce.__webglTexture),G(t.TEXTURE_CUBE_MAP,L);for(let Ie=0;Ie<6;Ie++)if(L.mipmaps&&L.mipmaps.length>0)for(let We=0;We<L.mipmaps.length;We++)Ee(oe.__webglFramebuffer[Ie][We],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,We);else Ee(oe.__webglFramebuffer[Ie],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);b(L)&&y(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(_e){for(let Ie=0,We=xe.length;Ie<We;Ie++){const ht=xe[Ie],qe=r.get(ht);let me=t.TEXTURE_2D;($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(me=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(me,qe.__webglTexture),G(me,ht),Ee(oe.__webglFramebuffer,$,ht,t.COLOR_ATTACHMENT0+Ie,me,0),b(ht)&&y(me)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(Ie=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ie,ce.__webglTexture),G(Ie,L),L.mipmaps&&L.mipmaps.length>0)for(let We=0;We<L.mipmaps.length;We++)Ee(oe.__webglFramebuffer[We],$,L,t.COLOR_ATTACHMENT0,Ie,We);else Ee(oe.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,Ie,0);b(L)&&y(Ie),n.unbindTexture()}$.depthBuffer&&Re($)}function B($){const L=$.textures;for(let oe=0,ce=L.length;oe<ce;oe++){const xe=L[oe];if(b(xe)){const ve=M($),_e=r.get(xe).__webglTexture;n.bindTexture(ve,_e),y(ve),n.unbindTexture()}}}const H=[],W=[];function z($){if($.samples>0){if(Q($)===!1){const L=$.textures,oe=$.width,ce=$.height;let xe=t.COLOR_BUFFER_BIT;const ve=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,_e=r.get($),Ie=L.length>1;if(Ie)for(let ht=0;ht<L.length;ht++)n.bindFramebuffer(t.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,_e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer);const We=$.texture.mipmaps;We&&We.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,_e.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let ht=0;ht<L.length;ht++){if($.resolveDepthBuffer&&($.depthBuffer&&(xe|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&$.resolveStencilBuffer&&(xe|=t.STENCIL_BUFFER_BIT)),Ie){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,_e.__webglColorRenderbuffer[ht]);const qe=r.get(L[ht]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,qe,0)}t.blitFramebuffer(0,0,oe,ce,0,0,oe,ce,xe,t.NEAREST),c===!0&&(H.length=0,W.length=0,H.push(t.COLOR_ATTACHMENT0+ht),$.depthBuffer&&$.resolveDepthBuffer===!1&&(H.push(ve),W.push(ve),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,W)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ie)for(let ht=0;ht<L.length;ht++){n.bindFramebuffer(t.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.RENDERBUFFER,_e.__webglColorRenderbuffer[ht]);const qe=r.get(L[ht]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,_e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.TEXTURE_2D,qe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}else if($.depthBuffer&&$.resolveDepthBuffer===!1&&c){const L=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function V($){return Math.min(i.maxSamples,$.samples)}function Q($){const L=r.get($);return $.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Te($){const L=o.render.frame;d.get($)!==L&&(d.set($,L),$.update())}function ke($,L){const oe=$.colorSpace,ce=$.format,xe=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||oe!==hg&&oe!==dd&&(In.getTransfer(oe)===sr?(ce!==Xo||xe!==zl)&&nn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ai("WebGLTextures: Unsupported texture color space:",oe)),L}function Ae($){return typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement?(u.width=$.naturalWidth||$.width,u.height=$.naturalHeight||$.height):typeof VideoFrame<"u"&&$ instanceof VideoFrame?(u.width=$.displayWidth,u.height=$.displayHeight):(u.width=$.width,u.height=$.height),u}this.allocateTextureUnit=X,this.resetTextureUnits=I,this.setTexture2D=K,this.setTexture2DArray=Y,this.setTexture3D=q,this.setTextureCube=Z,this.rebindTextures=te,this.setupRenderTarget=Je,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=z,this.setupDepthRenderbuffer=Re,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=Q}function eOe(t,e){function n(r,i=dd){let a;const o=In.getTransfer(i);if(r===zl)return t.UNSIGNED_BYTE;if(r===hO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===fO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===AZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===TZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===NZ)return t.BYTE;if(r===EZ)return t.SHORT;if(r===S0)return t.UNSIGNED_SHORT;if(r===dO)return t.INT;if(r===jf)return t.UNSIGNED_INT;if(r===Bc)return t.FLOAT;if(r===Vg)return t.HALF_FLOAT;if(r===CZ)return t.ALPHA;if(r===kZ)return t.RGB;if(r===Xo)return t.RGBA;if(r===N0)return t.DEPTH_COMPONENT;if(r===E0)return t.DEPTH_STENCIL;if(r===jZ)return t.RED;if(r===mO)return t.RED_INTEGER;if(r===pO)return t.RG;if(r===gO)return t.RG_INTEGER;if(r===xO)return t.RGBA_INTEGER;if(r===$1||r===H1||r===V1||r===G1)if(o===sr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===$1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===H1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===V1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===G1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===$1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===H1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===V1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===G1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===lP||r===cP||r===uP||r===dP)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===lP)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===cP)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===uP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===dP)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===hP||r===fP||r===mP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===hP||r===fP)return o===sr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===mP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===pP||r===gP||r===xP||r===bP||r===yP||r===vP||r===_P||r===wP||r===SP||r===MP||r===NP||r===EP||r===AP||r===TP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===pP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===gP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===xP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===bP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===yP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===vP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===_P)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===wP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===SP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===MP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===NP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===EP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===AP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===TP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===CP||r===kP||r===jP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===CP)return o===sr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===kP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===jP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===PP||r===RP||r===DP||r===OP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===PP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===RP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===DP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===OP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===M0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const tOe=`
  3905. void main() {
  3906. gl_Position = vec4( position, 1.0 );
  3907. }`,nOe=`
  3908. uniform sampler2DArray depthColor;
  3909. uniform float depthWidth;
  3910. uniform float depthHeight;
  3911. void main() {
  3912. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3913. if ( coord.x >= 1.0 ) {
  3914. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3915. } else {
  3916. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3917. }
  3918. }`;class rOe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new ZZ(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 lu({vertexShader:tOe,fragmentShader:nOe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Bl(new SO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let iOe=class extends Kf{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,m=null,p=null,x=null;const v=typeof XRWebGLBinding<"u",b=new rOe,y={},M=n.getContextAttributes();let S=null,A=null;const E=[],k=[],C=new gn;let R=null;const T=new go;T.viewport=new pi;const P=new go;P.viewport=new pi;const F=[T,P],I=new _3e;let X=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(de){let he=E[de];return he===void 0&&(he=new zC,E[de]=he),he.getTargetRaySpace()},this.getControllerGrip=function(de){let he=E[de];return he===void 0&&(he=new zC,E[de]=he),he.getGripSpace()},this.getHand=function(de){let he=E[de];return he===void 0&&(he=new zC,E[de]=he),he.getHandSpace()};function K(de){const he=k.indexOf(de.inputSource);if(he===-1)return;const Ee=E[he];Ee!==void 0&&(Ee.update(de.inputSource,de.frame,u||o),Ee.dispatchEvent({type:de.type,data:de.inputSource}))}function Y(){i.removeEventListener("select",K),i.removeEventListener("selectstart",K),i.removeEventListener("selectend",K),i.removeEventListener("squeeze",K),i.removeEventListener("squeezestart",K),i.removeEventListener("squeezeend",K),i.removeEventListener("end",Y),i.removeEventListener("inputsourceschange",q);for(let de=0;de<E.length;de++){const he=k[de];he!==null&&(k[de]=null,E[de].disconnect(he))}X=null,D=null,b.reset();for(const de in y)delete y[de];e.setRenderTarget(S),p=null,m=null,f=null,i=null,A=null,se.stop(),r.isPresenting=!1,e.setPixelRatio(R),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(de){a=de,r.isPresenting===!0&&nn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(de){l=de,r.isPresenting===!0&&nn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(de){u=de},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f===null&&v&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(de){if(i=de,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",K),i.addEventListener("selectstart",K),i.addEventListener("selectend",K),i.addEventListener("squeeze",K),i.addEventListener("squeezestart",K),i.addEventListener("squeezeend",K),i.addEventListener("end",Y),i.addEventListener("inputsourceschange",q),M.xrCompatible!==!0&&await n.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(C),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ee=null,ge=null,Ne=null;M.depth&&(Ne=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ee=M.stencil?E0:N0,ge=M.stencil?M0:jf);const Re={colorFormat:n.RGBA8,depthFormat:Ne,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(Re),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),A=new Rf(m.textureWidth,m.textureHeight,{format:Xo,type:zl,depthTexture:new QZ(m.textureWidth,m.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,Ee),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Ee={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Ee),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),A=new Rf(p.framebufferWidth,p.framebufferHeight,{format:Xo,type:zl,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),se.setContext(i),se.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function q(de){for(let he=0;he<de.removed.length;he++){const Ee=de.removed[he],ge=k.indexOf(Ee);ge>=0&&(k[ge]=null,E[ge].disconnect(Ee))}for(let he=0;he<de.added.length;he++){const Ee=de.added[he];let ge=k.indexOf(Ee);if(ge===-1){for(let Re=0;Re<E.length;Re++)if(Re>=k.length){k.push(Ee),ge=Re;break}else if(k[Re]===null){k[Re]=Ee,ge=Re;break}if(ge===-1)break}const Ne=E[ge];Ne&&Ne.connect(Ee)}}const Z=new at,re=new at;function ie(de,he,Ee){Z.setFromMatrixPosition(he.matrixWorld),re.setFromMatrixPosition(Ee.matrixWorld);const ge=Z.distanceTo(re),Ne=he.projectionMatrix.elements,Re=Ee.projectionMatrix.elements,te=Ne[14]/(Ne[10]-1),Je=Ne[14]/(Ne[10]+1),B=(Ne[9]+1)/Ne[5],H=(Ne[9]-1)/Ne[5],W=(Ne[8]-1)/Ne[0],z=(Re[8]+1)/Re[0],V=te*W,Q=te*z,Te=ge/(-W+z),ke=Te*-W;if(he.matrixWorld.decompose(de.position,de.quaternion,de.scale),de.translateX(ke),de.translateZ(Te),de.matrixWorld.compose(de.position,de.quaternion,de.scale),de.matrixWorldInverse.copy(de.matrixWorld).invert(),Ne[10]===-1)de.projectionMatrix.copy(he.projectionMatrix),de.projectionMatrixInverse.copy(he.projectionMatrixInverse);else{const Ae=te+Te,$=Je+Te,L=V-ke,oe=Q+(ge-ke),ce=B*Je/$*Ae,xe=H*Je/$*Ae;de.projectionMatrix.makePerspective(L,oe,ce,xe,Ae,$),de.projectionMatrixInverse.copy(de.projectionMatrix).invert()}}function U(de,he){he===null?de.matrixWorld.copy(de.matrix):de.matrixWorld.multiplyMatrices(he.matrixWorld,de.matrix),de.matrixWorldInverse.copy(de.matrixWorld).invert()}this.updateCamera=function(de){if(i===null)return;let he=de.near,Ee=de.far;b.texture!==null&&(b.depthNear>0&&(he=b.depthNear),b.depthFar>0&&(Ee=b.depthFar)),I.near=P.near=T.near=he,I.far=P.far=T.far=Ee,(X!==I.near||D!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),X=I.near,D=I.far),I.layers.mask=de.layers.mask|6,T.layers.mask=I.layers.mask&3,P.layers.mask=I.layers.mask&5;const ge=de.parent,Ne=I.cameras;U(I,ge);for(let Re=0;Re<Ne.length;Re++)U(Ne[Re],ge);Ne.length===2?ie(I,T,P):I.projectionMatrix.copy(T.projectionMatrix),G(de,I,ge)};function G(de,he,Ee){Ee===null?de.matrix.copy(he.matrixWorld):(de.matrix.copy(Ee.matrixWorld),de.matrix.invert(),de.matrix.multiply(he.matrixWorld)),de.matrix.decompose(de.position,de.quaternion,de.scale),de.updateMatrixWorld(!0),de.projectionMatrix.copy(he.projectionMatrix),de.projectionMatrixInverse.copy(he.projectionMatrixInverse),de.isPerspectiveCamera&&(de.fov=LP*2*Math.atan(1/de.projectionMatrix.elements[5]),de.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(de){c=de,m!==null&&(m.fixedFoveation=de),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=de)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(I)},this.getCameraTexture=function(de){return y[de]};let ee=null;function ne(de,he){if(d=he.getViewerPose(u||o),x=he,d!==null){const Ee=d.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let ge=!1;Ee.length!==I.cameras.length&&(I.cameras.length=0,ge=!0);for(let Je=0;Je<Ee.length;Je++){const B=Ee[Je];let H=null;if(p!==null)H=p.getViewport(B);else{const z=f.getViewSubImage(m,B);H=z.viewport,Je===0&&(e.setRenderTargetTextures(A,z.colorTexture,z.depthStencilTexture),e.setRenderTarget(A))}let W=F[Je];W===void 0&&(W=new go,W.layers.enable(Je),W.viewport=new pi,F[Je]=W),W.matrix.fromArray(B.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray(B.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(H.x,H.y,H.width,H.height),Je===0&&(I.matrix.copy(W.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),ge===!0&&I.cameras.push(W)}const Ne=i.enabledFeatures;if(Ne&&Ne.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const Je=f.getDepthInformation(Ee[0]);Je&&Je.isValid&&Je.texture&&b.init(Je,i.renderState)}if(Ne&&Ne.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let Je=0;Je<Ee.length;Je++){const B=Ee[Je].camera;if(B){let H=y[B];H||(H=new ZZ,y[B]=H);const W=f.getCameraImage(B);H.sourceTexture=W}}}}for(let Ee=0;Ee<E.length;Ee++){const ge=k[Ee],Ne=E[Ee];ge!==null&&Ne!==void 0&&Ne.update(ge,he,u||o)}ee&&ee(de,he),he.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:he}),x=null}const se=new nJ;se.setAnimationLoop(ne),this.setAnimationLoop=function(de){ee=de},this.dispose=function(){}}};const Mh=new $d,aOe=new vi;function sOe(t,e){function n(b,y){b.matrixAutoUpdate===!0&&b.updateMatrix(),y.value.copy(b.matrix)}function r(b,y){y.color.getRGB(b.fogColor.value,qZ(t)),y.isFog?(b.fogNear.value=y.near,b.fogFar.value=y.far):y.isFogExp2&&(b.fogDensity.value=y.density)}function i(b,y,M,S,A){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(b,y):y.isMeshToonMaterial?(a(b,y),f(b,y)):y.isMeshPhongMaterial?(a(b,y),d(b,y)):y.isMeshStandardMaterial?(a(b,y),m(b,y),y.isMeshPhysicalMaterial&&p(b,y,A)):y.isMeshMatcapMaterial?(a(b,y),x(b,y)):y.isMeshDepthMaterial?a(b,y):y.isMeshDistanceMaterial?(a(b,y),v(b,y)):y.isMeshNormalMaterial?a(b,y):y.isLineBasicMaterial?(o(b,y),y.isLineDashedMaterial&&l(b,y)):y.isPointsMaterial?c(b,y,M,S):y.isSpriteMaterial?u(b,y):y.isShadowMaterial?(b.color.value.copy(y.color),b.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(b,y){b.opacity.value=y.opacity,y.color&&b.diffuse.value.copy(y.color),y.emissive&&b.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(b.map.value=y.map,n(y.map,b.mapTransform)),y.alphaMap&&(b.alphaMap.value=y.alphaMap,n(y.alphaMap,b.alphaMapTransform)),y.bumpMap&&(b.bumpMap.value=y.bumpMap,n(y.bumpMap,b.bumpMapTransform),b.bumpScale.value=y.bumpScale,y.side===ds&&(b.bumpScale.value*=-1)),y.normalMap&&(b.normalMap.value=y.normalMap,n(y.normalMap,b.normalMapTransform),b.normalScale.value.copy(y.normalScale),y.side===ds&&b.normalScale.value.negate()),y.displacementMap&&(b.displacementMap.value=y.displacementMap,n(y.displacementMap,b.displacementMapTransform),b.displacementScale.value=y.displacementScale,b.displacementBias.value=y.displacementBias),y.emissiveMap&&(b.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,b.emissiveMapTransform)),y.specularMap&&(b.specularMap.value=y.specularMap,n(y.specularMap,b.specularMapTransform)),y.alphaTest>0&&(b.alphaTest.value=y.alphaTest);const M=e.get(y),S=M.envMap,A=M.envMapRotation;S&&(b.envMap.value=S,Mh.copy(A),Mh.x*=-1,Mh.y*=-1,Mh.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Mh.y*=-1,Mh.z*=-1),b.envMapRotation.value.setFromMatrix4(aOe.makeRotationFromEuler(Mh)),b.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=y.reflectivity,b.ior.value=y.ior,b.refractionRatio.value=y.refractionRatio),y.lightMap&&(b.lightMap.value=y.lightMap,b.lightMapIntensity.value=y.lightMapIntensity,n(y.lightMap,b.lightMapTransform)),y.aoMap&&(b.aoMap.value=y.aoMap,b.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,b.aoMapTransform))}function o(b,y){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,y.map&&(b.map.value=y.map,n(y.map,b.mapTransform))}function l(b,y){b.dashSize.value=y.dashSize,b.totalSize.value=y.dashSize+y.gapSize,b.scale.value=y.scale}function c(b,y,M,S){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,b.size.value=y.size*M,b.scale.value=S*.5,y.map&&(b.map.value=y.map,n(y.map,b.uvTransform)),y.alphaMap&&(b.alphaMap.value=y.alphaMap,n(y.alphaMap,b.alphaMapTransform)),y.alphaTest>0&&(b.alphaTest.value=y.alphaTest)}function u(b,y){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,b.rotation.value=y.rotation,y.map&&(b.map.value=y.map,n(y.map,b.mapTransform)),y.alphaMap&&(b.alphaMap.value=y.alphaMap,n(y.alphaMap,b.alphaMapTransform)),y.alphaTest>0&&(b.alphaTest.value=y.alphaTest)}function d(b,y){b.specular.value.copy(y.specular),b.shininess.value=Math.max(y.shininess,1e-4)}function f(b,y){y.gradientMap&&(b.gradientMap.value=y.gradientMap)}function m(b,y){b.metalness.value=y.metalness,y.metalnessMap&&(b.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,b.metalnessMapTransform)),b.roughness.value=y.roughness,y.roughnessMap&&(b.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,b.roughnessMapTransform)),y.envMap&&(b.envMapIntensity.value=y.envMapIntensity)}function p(b,y,M){b.ior.value=y.ior,y.sheen>0&&(b.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),b.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(b.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,b.sheenColorMapTransform)),y.sheenRoughnessMap&&(b.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,b.sheenRoughnessMapTransform))),y.clearcoat>0&&(b.clearcoat.value=y.clearcoat,b.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(b.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,b.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(b.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===ds&&b.clearcoatNormalScale.value.negate())),y.dispersion>0&&(b.dispersion.value=y.dispersion),y.iridescence>0&&(b.iridescence.value=y.iridescence,b.iridescenceIOR.value=y.iridescenceIOR,b.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(b.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,b.iridescenceMapTransform)),y.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),y.transmission>0&&(b.transmission.value=y.transmission,b.transmissionSamplerMap.value=M.texture,b.transmissionSamplerSize.value.set(M.width,M.height),y.transmissionMap&&(b.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,b.transmissionMapTransform)),b.thickness.value=y.thickness,y.thicknessMap&&(b.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=y.attenuationDistance,b.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(b.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(b.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=y.specularIntensity,b.specularColor.value.copy(y.specularColor),y.specularColorMap&&(b.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,b.specularColorMapTransform)),y.specularIntensityMap&&(b.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,y){y.matcap&&(b.matcap.value=y.matcap)}function v(b,y){const M=e.get(y).light;b.referencePosition.value.setFromMatrixPosition(M.matrixWorld),b.nearDistance.value=M.shadow.camera.near,b.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function oOe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const A=S.program;r.uniformBlockBinding(M,A)}function u(M,S){let A=i[M.id];A===void 0&&(x(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",b));const E=S.program;r.updateUBOMapping(M,E);const k=e.render.frame;a[M.id]!==k&&(m(M),a[M.id]=k)}function d(M){const S=f();M.__bindingPointIndex=S;const A=t.createBuffer(),E=M.__size,k=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,E,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let M=0;M<l;M++)if(o.indexOf(M)===-1)return o.push(M),M;return ai("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(M){const S=i[M.id],A=M.uniforms,E=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,C=A.length;k<C;k++){const R=Array.isArray(A[k])?A[k]:[A[k]];for(let T=0,P=R.length;T<P;T++){const F=R[T];if(p(F,k,T,E)===!0){const I=F.__offset,X=Array.isArray(F.value)?F.value:[F.value];let D=0;for(let K=0;K<X.length;K++){const Y=X[K],q=v(Y);typeof Y=="number"||typeof Y=="boolean"?(F.__data[0]=Y,t.bufferSubData(t.UNIFORM_BUFFER,I+D,F.__data)):Y.isMatrix3?(F.__data[0]=Y.elements[0],F.__data[1]=Y.elements[1],F.__data[2]=Y.elements[2],F.__data[3]=0,F.__data[4]=Y.elements[3],F.__data[5]=Y.elements[4],F.__data[6]=Y.elements[5],F.__data[7]=0,F.__data[8]=Y.elements[6],F.__data[9]=Y.elements[7],F.__data[10]=Y.elements[8],F.__data[11]=0):(Y.toArray(F.__data,D),D+=q.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,I,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(M,S,A,E){const k=M.value,C=S+"_"+A;if(E[C]===void 0)return typeof k=="number"||typeof k=="boolean"?E[C]=k:E[C]=k.clone(),!0;{const R=E[C];if(typeof k=="number"||typeof k=="boolean"){if(R!==k)return E[C]=k,!0}else if(R.equals(k)===!1)return R.copy(k),!0}return!1}function x(M){const S=M.uniforms;let A=0;const E=16;for(let C=0,R=S.length;C<R;C++){const T=Array.isArray(S[C])?S[C]:[S[C]];for(let P=0,F=T.length;P<F;P++){const I=T[P],X=Array.isArray(I.value)?I.value:[I.value];for(let D=0,K=X.length;D<K;D++){const Y=X[D],q=v(Y),Z=A%E,re=Z%q.boundary,ie=Z+re;A+=re,ie!==0&&E-ie<q.storage&&(A+=E-ie),I.__data=new Float32Array(q.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=q.storage}}}const k=A%E;return k>0&&(A+=E-k),M.__size=A,M.__cache={},this}function v(M){const S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?nn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):nn("WebGLRenderer: Unsupported uniform value type.",M),S}function b(M){const S=M.target;S.removeEventListener("dispose",b);const A=o.indexOf(S.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function y(){for(const M in i)t.deleteBuffer(i[M]);o=[],i={},a={}}return{bind:c,update:u,dispose:y}}const lOe=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 yc=null;function cOe(){return yc===null&&(yc=new c3e(lOe,32,32,pO,Vg),yc.minFilter=wo,yc.magFilter=wo,yc.wrapS=zc,yc.wrapT=zc,yc.generateMipmaps=!1,yc.needsUpdate=!0),yc}let uOe=class{constructor(e={}){const{canvas:n=Dje(),context:r=null,depth:i=!0,stencil:a=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:m=!1}=e;this.isWebGLRenderer=!0;let p;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=r.getContextAttributes().alpha}else p=o;const x=new Set([xO,gO,mO]),v=new Set([zl,jf,S0,M0,hO,fO]),b=new Uint32Array(4),y=new Int32Array(4);let M=null,S=null;const A=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ed,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let C=!1;this._outputColorSpace=fo;let R=0,T=0,P=null,F=-1,I=null;const X=new pi,D=new pi;let K=null;const Y=new Nn(0);let q=0,Z=n.width,re=n.height,ie=1,U=null,G=null;const ee=new pi(0,0,Z,re),ne=new pi(0,0,Z,re);let se=!1;const de=new wO;let he=!1,Ee=!1;const ge=new vi,Ne=new at,Re=new pi,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Je=!1;function B(){return P===null?ie:1}let H=r;function W(le,Se){return n.getContext(le,Se)}try{const le={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${cO}`),n.addEventListener("webglcontextlost",De,!1),n.addEventListener("webglcontextrestored",we,!1),n.addEventListener("webglcontextcreationerror",Ve,!1),H===null){const Se="webgl2";if(H=W(Se,le),H===null)throw W(Se)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(le){throw le("WebGLRenderer: "+le.message),le}let z,V,Q,Te,ke,Ae,$,L,oe,ce,xe,ve,_e,Ie,We,ht,qe,me,rt,Xe,nt,ut,ae,$e;function ye(){z=new bDe(H),z.init(),ut=new eOe(H,z),V=new cDe(H,z,e,ut),Q=new Z4e(H,z),V.reversedDepthBuffer&&m&&Q.buffers.depth.setReversed(!0),Te=new _De(H),ke=new U4e,Ae=new J4e(H,z,Q,ke,V,ut,Te),$=new dDe(k),L=new xDe(k),oe=new N3e(H),ae=new oDe(H,oe),ce=new yDe(H,oe,Te,ae),xe=new SDe(H,ce,oe,Te),rt=new wDe(H,V,Ae),ht=new uDe(ke),ve=new F4e(k,$,L,z,V,ae,ht),_e=new sOe(k,ke),Ie=new B4e,We=new q4e(z),me=new sDe(k,$,L,Q,xe,p,c),qe=new Y4e(k,xe,V),$e=new oOe(H,Te,V,Q),Xe=new lDe(H,z,Te),nt=new vDe(H,z,Te),Te.programs=ve.programs,k.capabilities=V,k.extensions=z,k.properties=ke,k.renderLists=Ie,k.shadowMap=qe,k.state=Q,k.info=Te}ye();const Be=new iOe(k,H);this.xr=Be,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const le=z.get("WEBGL_lose_context");le&&le.loseContext()},this.forceContextRestore=function(){const le=z.get("WEBGL_lose_context");le&&le.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(le){le!==void 0&&(ie=le,this.setSize(Z,re,!1))},this.getSize=function(le){return le.set(Z,re)},this.setSize=function(le,Se,Le=!0){if(Be.isPresenting){nn("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=le,re=Se,n.width=Math.floor(le*ie),n.height=Math.floor(Se*ie),Le===!0&&(n.style.width=le+"px",n.style.height=Se+"px"),this.setViewport(0,0,le,Se)},this.getDrawingBufferSize=function(le){return le.set(Z*ie,re*ie).floor()},this.setDrawingBufferSize=function(le,Se,Le){Z=le,re=Se,ie=Le,n.width=Math.floor(le*Le),n.height=Math.floor(Se*Le),this.setViewport(0,0,le,Se)},this.getCurrentViewport=function(le){return le.copy(X)},this.getViewport=function(le){return le.copy(ee)},this.setViewport=function(le,Se,Le,Oe){le.isVector4?ee.set(le.x,le.y,le.z,le.w):ee.set(le,Se,Le,Oe),Q.viewport(X.copy(ee).multiplyScalar(ie).round())},this.getScissor=function(le){return le.copy(ne)},this.setScissor=function(le,Se,Le,Oe){le.isVector4?ne.set(le.x,le.y,le.z,le.w):ne.set(le,Se,Le,Oe),Q.scissor(D.copy(ne).multiplyScalar(ie).round())},this.getScissorTest=function(){return se},this.setScissorTest=function(le){Q.setScissorTest(se=le)},this.setOpaqueSort=function(le){U=le},this.setTransparentSort=function(le){G=le},this.getClearColor=function(le){return le.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor(...arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha(...arguments)},this.clear=function(le=!0,Se=!0,Le=!0){let Oe=0;if(le){let Pe=!1;if(P!==null){const ct=P.texture.format;Pe=x.has(ct)}if(Pe){const ct=P.texture.type,vt=v.has(ct),Et=me.getClearColor(),_t=me.getClearAlpha(),yt=Et.r,be=Et.g,st=Et.b;vt?(b[0]=yt,b[1]=be,b[2]=st,b[3]=_t,H.clearBufferuiv(H.COLOR,0,b)):(y[0]=yt,y[1]=be,y[2]=st,y[3]=_t,H.clearBufferiv(H.COLOR,0,y))}else Oe|=H.COLOR_BUFFER_BIT}Se&&(Oe|=H.DEPTH_BUFFER_BIT),Le&&(Oe|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(Oe)},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",De,!1),n.removeEventListener("webglcontextrestored",we,!1),n.removeEventListener("webglcontextcreationerror",Ve,!1),me.dispose(),Ie.dispose(),We.dispose(),ke.dispose(),$.dispose(),L.dispose(),xe.dispose(),ae.dispose(),$e.dispose(),ve.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",bn),Be.removeEventListener("sessionend",Kn),zn.stop()};function De(le){le.preventDefault(),dH("WebGLRenderer: Context Lost."),C=!0}function we(){dH("WebGLRenderer: Context Restored."),C=!1;const le=Te.autoReset,Se=qe.enabled,Le=qe.autoUpdate,Oe=qe.needsUpdate,Pe=qe.type;ye(),Te.autoReset=le,qe.enabled=Se,qe.autoUpdate=Le,qe.needsUpdate=Oe,qe.type=Pe}function Ve(le){ai("WebGLRenderer: A WebGL context could not be created. Reason: ",le.statusMessage)}function dt(le){const Se=le.target;Se.removeEventListener("dispose",dt),Tt(Se)}function Tt(le){Ct(le),ke.remove(le)}function Ct(le){const Se=ke.get(le).programs;Se!==void 0&&(Se.forEach(function(Le){ve.releaseProgram(Le)}),le.isShaderMaterial&&ve.releaseShaderCache(le))}this.renderBufferDirect=function(le,Se,Le,Oe,Pe,ct){Se===null&&(Se=te);const vt=Pe.isMesh&&Pe.matrixWorld.determinant()<0,Et=ue(le,Se,Le,Oe,Pe);Q.setMaterial(Oe,vt);let _t=Le.index,yt=1;if(Oe.wireframe===!0){if(_t=ce.getWireframeAttribute(Le),_t===void 0)return;yt=2}const be=Le.drawRange,st=Le.attributes.position;let zt=be.start*yt,Ot=(be.start+be.count)*yt;ct!==null&&(zt=Math.max(zt,ct.start*yt),Ot=Math.min(Ot,(ct.start+ct.count)*yt)),_t!==null?(zt=Math.max(zt,0),Ot=Math.min(Ot,_t.count)):st!=null&&(zt=Math.max(zt,0),Ot=Math.min(Ot,st.count));const tn=Ot-zt;if(tn<0||tn===1/0)return;ae.setup(Pe,Oe,Et,Le,_t);let sn,$t=Xe;if(_t!==null&&(sn=oe.get(_t),$t=nt,$t.setIndex(sn)),Pe.isMesh)Oe.wireframe===!0?(Q.setLineWidth(Oe.wireframeLinewidth*B()),$t.setMode(H.LINES)):$t.setMode(H.TRIANGLES);else if(Pe.isLine){let Ht=Oe.linewidth;Ht===void 0&&(Ht=1),Q.setLineWidth(Ht*B()),Pe.isLineSegments?$t.setMode(H.LINES):Pe.isLineLoop?$t.setMode(H.LINE_LOOP):$t.setMode(H.LINE_STRIP)}else Pe.isPoints?$t.setMode(H.POINTS):Pe.isSprite&&$t.setMode(H.TRIANGLES);if(Pe.isBatchedMesh)if(Pe._multiDrawInstances!==null)A0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),$t.renderMultiDrawInstances(Pe._multiDrawStarts,Pe._multiDrawCounts,Pe._multiDrawCount,Pe._multiDrawInstances);else if(z.get("WEBGL_multi_draw"))$t.renderMultiDraw(Pe._multiDrawStarts,Pe._multiDrawCounts,Pe._multiDrawCount);else{const Ht=Pe._multiDrawStarts,on=Pe._multiDrawCounts,cn=Pe._multiDrawCount,Hr=_t?oe.get(_t).bytesPerElement:1,ti=ke.get(Oe).currentProgram.getUniforms();for(let Gn=0;Gn<cn;Gn++)ti.setValue(H,"_gl_DrawID",Gn),$t.render(Ht[Gn]/Hr,on[Gn])}else if(Pe.isInstancedMesh)$t.renderInstances(zt,tn,Pe.count);else if(Le.isInstancedBufferGeometry){const Ht=Le._maxInstanceCount!==void 0?Le._maxInstanceCount:1/0,on=Math.min(Le.instanceCount,Ht);$t.renderInstances(zt,tn,on)}else $t.render(zt,tn)};function Xt(le,Se,Le){le.transparent===!0&&le.side===Sl&&le.forceSinglePass===!1?(le.side=ds,le.needsUpdate=!0,bt(le,Se,Le),le.side=Bd,le.needsUpdate=!0,bt(le,Se,Le),le.side=Sl):bt(le,Se,Le)}this.compile=function(le,Se,Le=null){Le===null&&(Le=le),S=We.get(Le),S.init(Se),E.push(S),Le.traverseVisible(function(Pe){Pe.isLight&&Pe.layers.test(Se.layers)&&(S.pushLight(Pe),Pe.castShadow&&S.pushShadow(Pe))}),le!==Le&&le.traverseVisible(function(Pe){Pe.isLight&&Pe.layers.test(Se.layers)&&(S.pushLight(Pe),Pe.castShadow&&S.pushShadow(Pe))}),S.setupLights();const Oe=new Set;return le.traverse(function(Pe){if(!(Pe.isMesh||Pe.isPoints||Pe.isLine||Pe.isSprite))return;const ct=Pe.material;if(ct)if(Array.isArray(ct))for(let vt=0;vt<ct.length;vt++){const Et=ct[vt];Xt(Et,Le,Pe),Oe.add(Et)}else Xt(ct,Le,Pe),Oe.add(ct)}),S=E.pop(),Oe},this.compileAsync=function(le,Se,Le=null){const Oe=this.compile(le,Se,Le);return new Promise(Pe=>{function ct(){if(Oe.forEach(function(vt){ke.get(vt).currentProgram.isReady()&&Oe.delete(vt)}),Oe.size===0){Pe(le);return}setTimeout(ct,10)}z.get("KHR_parallel_shader_compile")!==null?ct():setTimeout(ct,10)})};let Pt=null;function an(le){Pt&&Pt(le)}function bn(){zn.stop()}function Kn(){zn.start()}const zn=new nJ;zn.setAnimationLoop(an),typeof self<"u"&&zn.setContext(self),this.setAnimationLoop=function(le){Pt=le,Be.setAnimationLoop(le),le===null?zn.stop():zn.start()},Be.addEventListener("sessionstart",bn),Be.addEventListener("sessionend",Kn),this.render=function(le,Se){if(Se!==void 0&&Se.isCamera!==!0){ai("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),Se.parent===null&&Se.matrixWorldAutoUpdate===!0&&Se.updateMatrixWorld(),Be.enabled===!0&&Be.isPresenting===!0&&(Be.cameraAutoUpdate===!0&&Be.updateCamera(Se),Se=Be.getCamera()),le.isScene===!0&&le.onBeforeRender(k,le,Se,P),S=We.get(le,E.length),S.init(Se),E.push(S),ge.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),de.setFromProjectionMatrix(ge,Al,Se.reversedDepth),Ee=this.localClippingEnabled,he=ht.init(this.clippingPlanes,Ee),M=Ie.get(le,A.length),M.init(),A.push(M),Be.enabled===!0&&Be.isPresenting===!0){const ct=k.xr.getDepthSensingMesh();ct!==null&&Vn(ct,Se,-1/0,k.sortObjects)}Vn(le,Se,0,k.sortObjects),M.finish(),k.sortObjects===!0&&M.sort(U,G),Je=Be.enabled===!1||Be.isPresenting===!1||Be.hasDepthSensing()===!1,Je&&me.addToRenderList(M,le),this.info.render.frame++,he===!0&&ht.beginShadows();const Le=S.state.shadowsArray;qe.render(Le,le,Se),he===!0&&ht.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=M.opaque,Pe=M.transmissive;if(S.setupLights(),Se.isArrayCamera){const ct=Se.cameras;if(Pe.length>0)for(let vt=0,Et=ct.length;vt<Et;vt++){const _t=ct[vt];$r(Oe,Pe,le,_t)}Je&&me.render(le);for(let vt=0,Et=ct.length;vt<Et;vt++){const _t=ct[vt];_r(M,le,_t,_t.viewport)}}else Pe.length>0&&$r(Oe,Pe,le,Se),Je&&me.render(le),_r(M,le,Se);P!==null&&T===0&&(Ae.updateMultisampleRenderTarget(P),Ae.updateRenderTargetMipmap(P)),le.isScene===!0&&le.onAfterRender(k,le,Se),ae.resetDefaultState(),F=-1,I=null,E.pop(),E.length>0?(S=E[E.length-1],he===!0&&ht.setGlobalState(k.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?M=A[A.length-1]:M=null};function Vn(le,Se,Le,Oe){if(le.visible===!1)return;if(le.layers.test(Se.layers)){if(le.isGroup)Le=le.renderOrder;else if(le.isLOD)le.autoUpdate===!0&&le.update(Se);else if(le.isLight)S.pushLight(le),le.castShadow&&S.pushShadow(le);else if(le.isSprite){if(!le.frustumCulled||de.intersectsSprite(le)){Oe&&Re.setFromMatrixPosition(le.matrixWorld).applyMatrix4(ge);const vt=xe.update(le),Et=le.material;Et.visible&&M.push(le,vt,Et,Le,Re.z,null)}}else if((le.isMesh||le.isLine||le.isPoints)&&(!le.frustumCulled||de.intersectsObject(le))){const vt=xe.update(le),Et=le.material;if(Oe&&(le.boundingSphere!==void 0?(le.boundingSphere===null&&le.computeBoundingSphere(),Re.copy(le.boundingSphere.center)):(vt.boundingSphere===null&&vt.computeBoundingSphere(),Re.copy(vt.boundingSphere.center)),Re.applyMatrix4(le.matrixWorld).applyMatrix4(ge)),Array.isArray(Et)){const _t=vt.groups;for(let yt=0,be=_t.length;yt<be;yt++){const st=_t[yt],zt=Et[st.materialIndex];zt&&zt.visible&&M.push(le,vt,zt,Le,Re.z,st)}}else Et.visible&&M.push(le,vt,Et,Le,Re.z,null)}}const ct=le.children;for(let vt=0,Et=ct.length;vt<Et;vt++)Vn(ct[vt],Se,Le,Oe)}function _r(le,Se,Le,Oe){const{opaque:Pe,transmissive:ct,transparent:vt}=le;S.setupLightsView(Le),he===!0&&ht.setGlobalState(k.clippingPlanes,Le),Oe&&Q.viewport(X.copy(Oe)),Pe.length>0&&Tr(Pe,Se,Le),ct.length>0&&Tr(ct,Se,Le),vt.length>0&&Tr(vt,Se,Le),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function $r(le,Se,Le,Oe){if((Le.isScene===!0?Le.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[Oe.id]===void 0&&(S.state.transmissionRenderTarget[Oe.id]=new Rf(1,1,{generateMipmaps:!0,type:z.has("EXT_color_buffer_half_float")||z.has("EXT_color_buffer_float")?Vg:zl,minFilter:Xh,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:In.workingColorSpace}));const ct=S.state.transmissionRenderTarget[Oe.id],vt=Oe.viewport||X;ct.setSize(vt.z*k.transmissionResolutionScale,vt.w*k.transmissionResolutionScale);const Et=k.getRenderTarget(),_t=k.getActiveCubeFace(),yt=k.getActiveMipmapLevel();k.setRenderTarget(ct),k.getClearColor(Y),q=k.getClearAlpha(),q<1&&k.setClearColor(16777215,.5),k.clear(),Je&&me.render(Le);const be=k.toneMapping;k.toneMapping=Ed;const st=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),S.setupLightsView(Oe),he===!0&&ht.setGlobalState(k.clippingPlanes,Oe),Tr(le,Le,Oe),Ae.updateMultisampleRenderTarget(ct),Ae.updateRenderTargetMipmap(ct),z.has("WEBGL_multisampled_render_to_texture")===!1){let zt=!1;for(let Ot=0,tn=Se.length;Ot<tn;Ot++){const sn=Se[Ot],{object:$t,geometry:Ht,material:on,group:cn}=sn;if(on.side===Sl&&$t.layers.test(Oe.layers)){const Hr=on.side;on.side=ds,on.needsUpdate=!0,hr($t,Le,Oe,Ht,on,cn),on.side=Hr,on.needsUpdate=!0,zt=!0}}zt===!0&&(Ae.updateMultisampleRenderTarget(ct),Ae.updateRenderTargetMipmap(ct))}k.setRenderTarget(Et,_t,yt),k.setClearColor(Y,q),st!==void 0&&(Oe.viewport=st),k.toneMapping=be}function Tr(le,Se,Le){const Oe=Se.isScene===!0?Se.overrideMaterial:null;for(let Pe=0,ct=le.length;Pe<ct;Pe++){const vt=le[Pe],{object:Et,geometry:_t,group:yt}=vt;let be=vt.material;be.allowOverride===!0&&Oe!==null&&(be=Oe),Et.layers.test(Le.layers)&&hr(Et,Se,Le,_t,be,yt)}}function hr(le,Se,Le,Oe,Pe,ct){le.onBeforeRender(k,Se,Le,Oe,Pe,ct),le.modelViewMatrix.multiplyMatrices(Le.matrixWorldInverse,le.matrixWorld),le.normalMatrix.getNormalMatrix(le.modelViewMatrix),Pe.onBeforeRender(k,Se,Le,Oe,le,ct),Pe.transparent===!0&&Pe.side===Sl&&Pe.forceSinglePass===!1?(Pe.side=ds,Pe.needsUpdate=!0,k.renderBufferDirect(Le,Se,Oe,Pe,le,ct),Pe.side=Bd,Pe.needsUpdate=!0,k.renderBufferDirect(Le,Se,Oe,Pe,le,ct),Pe.side=Sl):k.renderBufferDirect(Le,Se,Oe,Pe,le,ct),le.onAfterRender(k,Se,Le,Oe,Pe,ct)}function bt(le,Se,Le){Se.isScene!==!0&&(Se=te);const Oe=ke.get(le),Pe=S.state.lights,ct=S.state.shadowsArray,vt=Pe.state.version,Et=ve.getParameters(le,Pe.state,ct,Se,Le),_t=ve.getProgramCacheKey(Et);let yt=Oe.programs;Oe.environment=le.isMeshStandardMaterial?Se.environment:null,Oe.fog=Se.fog,Oe.envMap=(le.isMeshStandardMaterial?L:$).get(le.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&le.envMap===null?Se.environmentRotation:le.envMapRotation,yt===void 0&&(le.addEventListener("dispose",dt),yt=new Map,Oe.programs=yt);let be=yt.get(_t);if(be!==void 0){if(Oe.currentProgram===be&&Oe.lightsStateVersion===vt)return yn(le,Et),be}else Et.uniforms=ve.getUniforms(le),le.onBeforeCompile(Et,k),be=ve.acquireProgram(Et,_t),yt.set(_t,be),Oe.uniforms=Et.uniforms;const st=Oe.uniforms;return(!le.isShaderMaterial&&!le.isRawShaderMaterial||le.clipping===!0)&&(st.clippingPlanes=ht.uniform),yn(le,Et),Oe.needsLights=Ye(le),Oe.lightsStateVersion=vt,Oe.needsLights&&(st.ambientLightColor.value=Pe.state.ambient,st.lightProbe.value=Pe.state.probe,st.directionalLights.value=Pe.state.directional,st.directionalLightShadows.value=Pe.state.directionalShadow,st.spotLights.value=Pe.state.spot,st.spotLightShadows.value=Pe.state.spotShadow,st.rectAreaLights.value=Pe.state.rectArea,st.ltc_1.value=Pe.state.rectAreaLTC1,st.ltc_2.value=Pe.state.rectAreaLTC2,st.pointLights.value=Pe.state.point,st.pointLightShadows.value=Pe.state.pointShadow,st.hemisphereLights.value=Pe.state.hemi,st.directionalShadowMap.value=Pe.state.directionalShadowMap,st.directionalShadowMatrix.value=Pe.state.directionalShadowMatrix,st.spotShadowMap.value=Pe.state.spotShadowMap,st.spotLightMatrix.value=Pe.state.spotLightMatrix,st.spotLightMap.value=Pe.state.spotLightMap,st.pointShadowMap.value=Pe.state.pointShadowMap,st.pointShadowMatrix.value=Pe.state.pointShadowMatrix),Oe.currentProgram=be,Oe.uniformsList=null,be}function Yt(le){if(le.uniformsList===null){const Se=le.currentProgram.getUniforms();le.uniformsList=X1.seqWithValue(Se.seq,le.uniforms)}return le.uniformsList}function yn(le,Se){const Le=ke.get(le);Le.outputColorSpace=Se.outputColorSpace,Le.batching=Se.batching,Le.batchingColor=Se.batchingColor,Le.instancing=Se.instancing,Le.instancingColor=Se.instancingColor,Le.instancingMorph=Se.instancingMorph,Le.skinning=Se.skinning,Le.morphTargets=Se.morphTargets,Le.morphNormals=Se.morphNormals,Le.morphColors=Se.morphColors,Le.morphTargetsCount=Se.morphTargetsCount,Le.numClippingPlanes=Se.numClippingPlanes,Le.numIntersection=Se.numClipIntersection,Le.vertexAlphas=Se.vertexAlphas,Le.vertexTangents=Se.vertexTangents,Le.toneMapping=Se.toneMapping}function ue(le,Se,Le,Oe,Pe){Se.isScene!==!0&&(Se=te),Ae.resetTextureUnits();const ct=Se.fog,vt=Oe.isMeshStandardMaterial?Se.environment:null,Et=P===null?k.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:hg,_t=(Oe.isMeshStandardMaterial?L:$).get(Oe.envMap||vt),yt=Oe.vertexColors===!0&&!!Le.attributes.color&&Le.attributes.color.itemSize===4,be=!!Le.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),st=!!Le.morphAttributes.position,zt=!!Le.morphAttributes.normal,Ot=!!Le.morphAttributes.color;let tn=Ed;Oe.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(tn=k.toneMapping);const sn=Le.morphAttributes.position||Le.morphAttributes.normal||Le.morphAttributes.color,$t=sn!==void 0?sn.length:0,Ht=ke.get(Oe),on=S.state.lights;if(he===!0&&(Ee===!0||le!==I)){const Fi=le===I&&Oe.id===F;ht.setState(Oe,le,Fi)}let cn=!1;Oe.version===Ht.__version?(Ht.needsLights&&Ht.lightsStateVersion!==on.state.version||Ht.outputColorSpace!==Et||Pe.isBatchedMesh&&Ht.batching===!1||!Pe.isBatchedMesh&&Ht.batching===!0||Pe.isBatchedMesh&&Ht.batchingColor===!0&&Pe.colorTexture===null||Pe.isBatchedMesh&&Ht.batchingColor===!1&&Pe.colorTexture!==null||Pe.isInstancedMesh&&Ht.instancing===!1||!Pe.isInstancedMesh&&Ht.instancing===!0||Pe.isSkinnedMesh&&Ht.skinning===!1||!Pe.isSkinnedMesh&&Ht.skinning===!0||Pe.isInstancedMesh&&Ht.instancingColor===!0&&Pe.instanceColor===null||Pe.isInstancedMesh&&Ht.instancingColor===!1&&Pe.instanceColor!==null||Pe.isInstancedMesh&&Ht.instancingMorph===!0&&Pe.morphTexture===null||Pe.isInstancedMesh&&Ht.instancingMorph===!1&&Pe.morphTexture!==null||Ht.envMap!==_t||Oe.fog===!0&&Ht.fog!==ct||Ht.numClippingPlanes!==void 0&&(Ht.numClippingPlanes!==ht.numPlanes||Ht.numIntersection!==ht.numIntersection)||Ht.vertexAlphas!==yt||Ht.vertexTangents!==be||Ht.morphTargets!==st||Ht.morphNormals!==zt||Ht.morphColors!==Ot||Ht.toneMapping!==tn||Ht.morphTargetsCount!==$t)&&(cn=!0):(cn=!0,Ht.__version=Oe.version);let Hr=Ht.currentProgram;cn===!0&&(Hr=bt(Oe,Se,Pe));let ti=!1,Gn=!1,Ro=!1;const Xn=Hr.getUniforms(),Ii=Ht.uniforms;if(Q.useProgram(Hr.program)&&(ti=!0,Gn=!0,Ro=!0),Oe.id!==F&&(F=Oe.id,Gn=!0),ti||I!==le){Q.buffers.depth.getReversed()&&le.reversedDepth!==!0&&(le._reversedDepth=!0,le.updateProjectionMatrix()),Xn.setValue(H,"projectionMatrix",le.projectionMatrix),Xn.setValue(H,"viewMatrix",le.matrixWorldInverse);const na=Xn.map.cameraPosition;na!==void 0&&na.setValue(H,Ne.setFromMatrixPosition(le.matrixWorld)),V.logarithmicDepthBuffer&&Xn.setValue(H,"logDepthBufFC",2/(Math.log(le.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&Xn.setValue(H,"isOrthographic",le.isOrthographicCamera===!0),I!==le&&(I=le,Gn=!0,Ro=!0)}if(Pe.isSkinnedMesh){Xn.setOptional(H,Pe,"bindMatrix"),Xn.setOptional(H,Pe,"bindMatrixInverse");const Fi=Pe.skeleton;Fi&&(Fi.boneTexture===null&&Fi.computeBoneTexture(),Xn.setValue(H,"boneTexture",Fi.boneTexture,Ae))}Pe.isBatchedMesh&&(Xn.setOptional(H,Pe,"batchingTexture"),Xn.setValue(H,"batchingTexture",Pe._matricesTexture,Ae),Xn.setOptional(H,Pe,"batchingIdTexture"),Xn.setValue(H,"batchingIdTexture",Pe._indirectTexture,Ae),Xn.setOptional(H,Pe,"batchingColorTexture"),Pe._colorsTexture!==null&&Xn.setValue(H,"batchingColorTexture",Pe._colorsTexture,Ae));const wi=Le.morphAttributes;if((wi.position!==void 0||wi.normal!==void 0||wi.color!==void 0)&&rt.update(Pe,Le,Hr),(Gn||Ht.receiveShadow!==Pe.receiveShadow)&&(Ht.receiveShadow=Pe.receiveShadow,Xn.setValue(H,"receiveShadow",Pe.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(Ii.envMap.value=_t,Ii.flipEnvMap.value=_t.isCubeTexture&&_t.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&Se.environment!==null&&(Ii.envMapIntensity.value=Se.environmentIntensity),Ii.dfgLUT!==void 0&&(Ii.dfgLUT.value=cOe()),Gn&&(Xn.setValue(H,"toneMappingExposure",k.toneMappingExposure),Ht.needsLights&&ze(Ii,Ro),ct&&Oe.fog===!0&&_e.refreshFogUniforms(Ii,ct),_e.refreshMaterialUniforms(Ii,Oe,ie,re,S.state.transmissionRenderTarget[le.id]),X1.upload(H,Yt(Ht),Ii,Ae)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(X1.upload(H,Yt(Ht),Ii,Ae),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&Xn.setValue(H,"center",Pe.center),Xn.setValue(H,"modelViewMatrix",Pe.modelViewMatrix),Xn.setValue(H,"normalMatrix",Pe.normalMatrix),Xn.setValue(H,"modelMatrix",Pe.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const Fi=Oe.uniformsGroups;for(let na=0,cl=Fi.length;na<cl;na++){const Yl=Fi[na];$e.update(Yl,Hr),$e.bind(Yl,Hr)}}return Hr}function ze(le,Se){le.ambientLightColor.needsUpdate=Se,le.lightProbe.needsUpdate=Se,le.directionalLights.needsUpdate=Se,le.directionalLightShadows.needsUpdate=Se,le.pointLights.needsUpdate=Se,le.pointLightShadows.needsUpdate=Se,le.spotLights.needsUpdate=Se,le.spotLightShadows.needsUpdate=Se,le.rectAreaLights.needsUpdate=Se,le.hemisphereLights.needsUpdate=Se}function Ye(le){return le.isMeshLambertMaterial||le.isMeshToonMaterial||le.isMeshPhongMaterial||le.isMeshStandardMaterial||le.isShadowMaterial||le.isShaderMaterial&&le.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(le,Se,Le){const Oe=ke.get(le);Oe.__autoAllocateDepthBuffer=le.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),ke.get(le.texture).__webglTexture=Se,ke.get(le.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:Le,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(le,Se){const Le=ke.get(le);Le.__webglFramebuffer=Se,Le.__useDefaultFramebuffer=Se===void 0};const Ke=H.createFramebuffer();this.setRenderTarget=function(le,Se=0,Le=0){P=le,R=Se,T=Le;let Oe=!0,Pe=null,ct=!1,vt=!1;if(le){const _t=ke.get(le);if(_t.__useDefaultFramebuffer!==void 0)Q.bindFramebuffer(H.FRAMEBUFFER,null),Oe=!1;else if(_t.__webglFramebuffer===void 0)Ae.setupRenderTarget(le);else if(_t.__hasExternalTextures)Ae.rebindTextures(le,ke.get(le.texture).__webglTexture,ke.get(le.depthTexture).__webglTexture);else if(le.depthBuffer){const st=le.depthTexture;if(_t.__boundDepthTexture!==st){if(st!==null&&ke.has(st)&&(le.width!==st.image.width||le.height!==st.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ae.setupDepthRenderbuffer(le)}}const yt=le.texture;(yt.isData3DTexture||yt.isDataArrayTexture||yt.isCompressedArrayTexture)&&(vt=!0);const be=ke.get(le).__webglFramebuffer;le.isWebGLCubeRenderTarget?(Array.isArray(be[Se])?Pe=be[Se][Le]:Pe=be[Se],ct=!0):le.samples>0&&Ae.useMultisampledRTT(le)===!1?Pe=ke.get(le).__webglMultisampledFramebuffer:Array.isArray(be)?Pe=be[Le]:Pe=be,X.copy(le.viewport),D.copy(le.scissor),K=le.scissorTest}else X.copy(ee).multiplyScalar(ie).floor(),D.copy(ne).multiplyScalar(ie).floor(),K=se;if(Le!==0&&(Pe=Ke),Q.bindFramebuffer(H.FRAMEBUFFER,Pe)&&Oe&&Q.drawBuffers(le,Pe),Q.viewport(X),Q.scissor(D),Q.setScissorTest(K),ct){const _t=ke.get(le.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+Se,_t.__webglTexture,Le)}else if(vt){const _t=Se;for(let yt=0;yt<le.textures.length;yt++){const be=ke.get(le.textures[yt]);H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+yt,be.__webglTexture,Le,_t)}}else if(le!==null&&Le!==0){const _t=ke.get(le.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,_t.__webglTexture,Le)}F=-1},this.readRenderTargetPixels=function(le,Se,Le,Oe,Pe,ct,vt,Et=0){if(!(le&&le.isWebGLRenderTarget)){ai("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _t=ke.get(le).__webglFramebuffer;if(le.isWebGLCubeRenderTarget&&vt!==void 0&&(_t=_t[vt]),_t){Q.bindFramebuffer(H.FRAMEBUFFER,_t);try{const yt=le.textures[Et],be=yt.format,st=yt.type;if(!V.textureFormatReadable(be)){ai("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!V.textureTypeReadable(st)){ai("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Se>=0&&Se<=le.width-Oe&&Le>=0&&Le<=le.height-Pe&&(le.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Et),H.readPixels(Se,Le,Oe,Pe,ut.convert(be),ut.convert(st),ct))}finally{const yt=P!==null?ke.get(P).__webglFramebuffer:null;Q.bindFramebuffer(H.FRAMEBUFFER,yt)}}},this.readRenderTargetPixelsAsync=async function(le,Se,Le,Oe,Pe,ct,vt,Et=0){if(!(le&&le.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let _t=ke.get(le).__webglFramebuffer;if(le.isWebGLCubeRenderTarget&&vt!==void 0&&(_t=_t[vt]),_t)if(Se>=0&&Se<=le.width-Oe&&Le>=0&&Le<=le.height-Pe){Q.bindFramebuffer(H.FRAMEBUFFER,_t);const yt=le.textures[Et],be=yt.format,st=yt.type;if(!V.textureFormatReadable(be))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!V.textureTypeReadable(st))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const zt=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,zt),H.bufferData(H.PIXEL_PACK_BUFFER,ct.byteLength,H.STREAM_READ),le.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Et),H.readPixels(Se,Le,Oe,Pe,ut.convert(be),ut.convert(st),0);const Ot=P!==null?ke.get(P).__webglFramebuffer:null;Q.bindFramebuffer(H.FRAMEBUFFER,Ot);const tn=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await Oje(H,tn,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,zt),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,ct),H.deleteBuffer(zt),H.deleteSync(tn),ct}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(le,Se=null,Le=0){const Oe=Math.pow(2,-Le),Pe=Math.floor(le.image.width*Oe),ct=Math.floor(le.image.height*Oe),vt=Se!==null?Se.x:0,Et=Se!==null?Se.y:0;Ae.setTexture2D(le,0),H.copyTexSubImage2D(H.TEXTURE_2D,Le,0,0,vt,Et,Pe,ct),Q.unbindTexture()};const Qe=H.createFramebuffer(),Nt=H.createFramebuffer();this.copyTextureToTexture=function(le,Se,Le=null,Oe=null,Pe=0,ct=null){ct===null&&(Pe!==0?(A0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ct=Pe,Pe=0):ct=0);let vt,Et,_t,yt,be,st,zt,Ot,tn;const sn=le.isCompressedTexture?le.mipmaps[ct]:le.image;if(Le!==null)vt=Le.max.x-Le.min.x,Et=Le.max.y-Le.min.y,_t=Le.isBox3?Le.max.z-Le.min.z:1,yt=Le.min.x,be=Le.min.y,st=Le.isBox3?Le.min.z:0;else{const wi=Math.pow(2,-Pe);vt=Math.floor(sn.width*wi),Et=Math.floor(sn.height*wi),le.isDataArrayTexture?_t=sn.depth:le.isData3DTexture?_t=Math.floor(sn.depth*wi):_t=1,yt=0,be=0,st=0}Oe!==null?(zt=Oe.x,Ot=Oe.y,tn=Oe.z):(zt=0,Ot=0,tn=0);const $t=ut.convert(Se.format),Ht=ut.convert(Se.type);let on;Se.isData3DTexture?(Ae.setTexture3D(Se,0),on=H.TEXTURE_3D):Se.isDataArrayTexture||Se.isCompressedArrayTexture?(Ae.setTexture2DArray(Se,0),on=H.TEXTURE_2D_ARRAY):(Ae.setTexture2D(Se,0),on=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,Se.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Se.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,Se.unpackAlignment);const cn=H.getParameter(H.UNPACK_ROW_LENGTH),Hr=H.getParameter(H.UNPACK_IMAGE_HEIGHT),ti=H.getParameter(H.UNPACK_SKIP_PIXELS),Gn=H.getParameter(H.UNPACK_SKIP_ROWS),Ro=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,sn.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,sn.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,yt),H.pixelStorei(H.UNPACK_SKIP_ROWS,be),H.pixelStorei(H.UNPACK_SKIP_IMAGES,st);const Xn=le.isDataArrayTexture||le.isData3DTexture,Ii=Se.isDataArrayTexture||Se.isData3DTexture;if(le.isDepthTexture){const wi=ke.get(le),Fi=ke.get(Se),na=ke.get(wi.__renderTarget),cl=ke.get(Fi.__renderTarget);Q.bindFramebuffer(H.READ_FRAMEBUFFER,na.__webglFramebuffer),Q.bindFramebuffer(H.DRAW_FRAMEBUFFER,cl.__webglFramebuffer);for(let Yl=0;Yl<_t;Yl++)Xn&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,ke.get(le).__webglTexture,Pe,st+Yl),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,ke.get(Se).__webglTexture,ct,tn+Yl)),H.blitFramebuffer(yt,be,vt,Et,zt,Ot,vt,Et,H.DEPTH_BUFFER_BIT,H.NEAREST);Q.bindFramebuffer(H.READ_FRAMEBUFFER,null),Q.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(Pe!==0||le.isRenderTargetTexture||ke.has(le)){const wi=ke.get(le),Fi=ke.get(Se);Q.bindFramebuffer(H.READ_FRAMEBUFFER,Qe),Q.bindFramebuffer(H.DRAW_FRAMEBUFFER,Nt);for(let na=0;na<_t;na++)Xn?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,wi.__webglTexture,Pe,st+na):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,wi.__webglTexture,Pe),Ii?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Fi.__webglTexture,ct,tn+na):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Fi.__webglTexture,ct),Pe!==0?H.blitFramebuffer(yt,be,vt,Et,zt,Ot,vt,Et,H.COLOR_BUFFER_BIT,H.NEAREST):Ii?H.copyTexSubImage3D(on,ct,zt,Ot,tn+na,yt,be,vt,Et):H.copyTexSubImage2D(on,ct,zt,Ot,yt,be,vt,Et);Q.bindFramebuffer(H.READ_FRAMEBUFFER,null),Q.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Ii?le.isDataTexture||le.isData3DTexture?H.texSubImage3D(on,ct,zt,Ot,tn,vt,Et,_t,$t,Ht,sn.data):Se.isCompressedArrayTexture?H.compressedTexSubImage3D(on,ct,zt,Ot,tn,vt,Et,_t,$t,sn.data):H.texSubImage3D(on,ct,zt,Ot,tn,vt,Et,_t,$t,Ht,sn):le.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,ct,zt,Ot,vt,Et,$t,Ht,sn.data):le.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,ct,zt,Ot,sn.width,sn.height,$t,sn.data):H.texSubImage2D(H.TEXTURE_2D,ct,zt,Ot,vt,Et,$t,Ht,sn);H.pixelStorei(H.UNPACK_ROW_LENGTH,cn),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,Hr),H.pixelStorei(H.UNPACK_SKIP_PIXELS,ti),H.pixelStorei(H.UNPACK_SKIP_ROWS,Gn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,Ro),ct===0&&Se.generateMipmaps&&H.generateMipmap(on),Q.unbindTexture()},this.initRenderTarget=function(le){ke.get(le).__webglFramebuffer===void 0&&Ae.setupRenderTarget(le)},this.initTexture=function(le){le.isCubeTexture?Ae.setTextureCube(le,0):le.isData3DTexture?Ae.setTexture3D(le,0):le.isDataArrayTexture||le.isCompressedArrayTexture?Ae.setTexture2DArray(le,0):Ae.setTexture2D(le,0),Q.unbindTexture()},this.resetState=function(){R=0,T=0,P=null,Q.reset(),ae.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Al}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=In._getDrawingBufferColorSpace(e),n.unpackColorSpace=In._getUnpackColorSpace()}};const sV={type:"change"},MO={type:"start"},oJ={type:"end"},L_=new yO,oV=new id,dOe=Math.cos(70*Ije.DEG2RAD),Mi=new at,rs=2*Math.PI,cr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},XC=1e-6;class hOe extends S3e{constructor(e,n=null){super(e,n),this.state=cr.NONE,this.target=new at,this.cursor=new at,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:Up.ROTATE,MIDDLE:Up.DOLLY,RIGHT:Up.PAN},this.touches={ONE:kp.ROTATE,TWO:kp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new at,this._lastQuaternion=new Pf,this._lastTargetPosition=new at,this._quat=new Pf().setFromUnitVectors(e.up,new at(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new OH,this._sphericalDelta=new OH,this._scale=1,this._panOffset=new at,this._rotateStart=new gn,this._rotateEnd=new gn,this._rotateDelta=new gn,this._panStart=new gn,this._panEnd=new gn,this._panDelta=new gn,this._dollyStart=new gn,this._dollyEnd=new gn,this._dollyDelta=new gn,this._dollyDirection=new at,this._mouse=new gn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mOe.bind(this),this._onPointerDown=fOe.bind(this),this._onPointerUp=pOe.bind(this),this._onContextMenu=wOe.bind(this),this._onMouseWheel=bOe.bind(this),this._onKeyDown=yOe.bind(this),this._onTouchStart=vOe.bind(this),this._onTouchMove=_Oe.bind(this),this._onMouseDown=gOe.bind(this),this._onMouseMove=xOe.bind(this),this._interceptControlDown=SOe.bind(this),this._interceptControlUp=MOe.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(sV),this.update(),this.state=cr.NONE}update(e=null){const n=this.object.position;Mi.copy(n).sub(this.target),Mi.applyQuaternion(this._quat),this._spherical.setFromVector3(Mi),this.autoRotate&&this.state===cr.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+=rs:r>Math.PI&&(r-=rs),i<-Math.PI?i+=rs:i>Math.PI&&(i-=rs),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(Mi.setFromSpherical(this._spherical),Mi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Mi),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=Mi.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new at(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new at(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Mi.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):(L_.origin.copy(this.object.position),L_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(L_.direction))<dOe?this.object.lookAt(this.target):(oV.setFromNormalAndCoplanarPoint(this.object.up,this.target),L_.intersectPlane(oV,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>XC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>XC||this._lastTargetPosition.distanceToSquared(this.target)>XC?(this.dispatchEvent(sV),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?rs/60*this.autoRotateSpeed*e:rs/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){Mi.setFromMatrixColumn(n,0),Mi.multiplyScalar(-e),this._panOffset.add(Mi)}_panUp(e,n){this.screenSpacePanning===!0?Mi.setFromMatrixColumn(n,1):(Mi.setFromMatrixColumn(n,0),Mi.crossVectors(this.object.up,Mi)),Mi.multiplyScalar(e),this._panOffset.add(Mi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Mi.copy(i).sub(this.target);let a=Mi.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(rs*this._rotateDelta.x/n.clientHeight),this._rotateUp(rs*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(rs*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(-rs*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(rs*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(-rs*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(rs*this._rotateDelta.x/n.clientHeight),this._rotateUp(rs*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new gn,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 fOe(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 mOe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function pOe(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(oJ),this.state=cr.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 gOe(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 Up.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=cr.DOLLY;break;case Up.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=cr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=cr.ROTATE}break;case Up.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=cr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=cr.PAN}break;default:this.state=cr.NONE}this.state!==cr.NONE&&this.dispatchEvent(MO)}function xOe(t){switch(this.state){case cr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case cr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function bOe(t){this.enabled===!1||this.enableZoom===!1||this.state!==cr.NONE||(t.preventDefault(),this.dispatchEvent(MO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(oJ))}function yOe(t){this.enabled!==!1&&this._handleKeyDown(t)}function vOe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case kp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=cr.TOUCH_ROTATE;break;case kp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=cr.TOUCH_PAN;break;default:this.state=cr.NONE}break;case 2:switch(this.touches.TWO){case kp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=cr.TOUCH_DOLLY_PAN;break;case kp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=cr.TOUCH_DOLLY_ROTATE;break;default:this.state=cr.NONE}break;default:this.state=cr.NONE}this.state!==cr.NONE&&this.dispatchEvent(MO)}function _Oe(t){switch(this._trackPointer(t),this.state){case cr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case cr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case cr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case cr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=cr.NONE}}function wOe(t){this.enabled!==!1&&t.preventDefault()}function SOe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function MOe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function NOe(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},o={},l=t[0].morphTargetsRelative,c=new Xl;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let m=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.attributes[p]),m++}if(m!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,p,d),u+=p}}if(n){let d=0;const f=[];for(let m=0;m<t.length;++m){const p=t[m].index;for(let x=0;x<p.count;++x)f.push(p.getX(x)+d);d+=t[m].attributes.position.count}c.setIndex(f)}for(const d in a){const f=lV(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let m=0;m<f;++m){const p=[];for(let v=0;v<o[d].length;++v)p.push(o[d][v][m]);const x=lV(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function lV(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const o=new e(a),l=new So(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let m=0,p=d.count;m<p;m++)for(let x=0;x<n;x++){const v=d.getComponent(m,x);l.setComponent(m+f,x,v)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function I_(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 YC={exports:{}};var cV;function EOe(){return cV||(cV=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof I_=="function"&&I_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var v=r[u][1][x];return o(v||x)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof I_=="function"&&I_,c=0;c<a.length;c++)o(a[c]);return o})({1:[function(n,r,i){var a=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,m,p,x,v,b=[],y=0,M=c.length,S=M,A=a.getTypeOf(c)!=="string";y<c.length;)S=M-y,f=A?(u=c[y++],d=y<M?c[y++]:0,y<M?c[y++]:0):(u=c.charCodeAt(y++),d=y<M?c.charCodeAt(y++):0,y<M?c.charCodeAt(y++):0),m=u>>2,p=(3&u)<<4|d>>4,x=1<S?(15&d)<<2|f>>6:64,v=2<S?63&f:64,b.push(l.charAt(m)+l.charAt(p)+l.charAt(x)+l.charAt(v));return b.join("")},i.decode=function(c){var u,d,f,m,p,x,v=0,b=0,y="data:";if(c.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var M,S=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&S--,c.charAt(c.length-2)===l.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(M=o.uint8array?new Uint8Array(0|S):new Array(0|S);v<c.length;)u=l.indexOf(c.charAt(v++))<<2|(m=l.indexOf(c.charAt(v++)))>>4,d=(15&m)<<4|(p=l.indexOf(c.charAt(v++)))>>2,f=(3&p)<<6|(x=l.indexOf(c.charAt(v++))),M[b++]=u,p!==64&&(M[b++]=d),x!==64&&(M[b++]=f);return M}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,m,p,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,m){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(m)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),o=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?(function(u,d,f,m){var p=o,x=m+f;u^=-1;for(var v=m;v<x;v++)u=u>>>8^p[255&(u^d[v])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var p=o,x=m+f;u^=-1;for(var v=m;v<x;v++)u=u>>>8^p[255&(u^d.charCodeAt(v))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,m){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=m,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(m){f.push({data:m,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(p,x){var v,b="";for(v=0;v<x;v++)b+=String.fromCharCode(255&p),p>>>=8;return b}function o(p,x,v,b,y,M){var S,A,E=p.file,k=p.compression,C=M!==u.utf8encode,R=l.transformTo("string",M(E.name)),T=l.transformTo("string",u.utf8encode(E.name)),P=E.comment,F=l.transformTo("string",M(P)),I=l.transformTo("string",u.utf8encode(P)),X=T.length!==E.name.length,D=I.length!==P.length,K="",Y="",q="",Z=E.dir,re=E.date,ie={crc32:0,compressedSize:0,uncompressedSize:0};x&&!v||(ie.crc32=p.crc32,ie.compressedSize=p.compressedSize,ie.uncompressedSize=p.uncompressedSize);var U=0;x&&(U|=8),C||!X&&!D||(U|=2048);var G=0,ee=0;Z&&(G|=16),y==="UNIX"?(ee=798,G|=(function(se,de){var he=se;return se||(he=de?16893:33204),(65535&he)<<16})(E.unixPermissions,Z)):(ee=20,G|=(function(se){return 63&(se||0)})(E.dosPermissions)),S=re.getUTCHours(),S<<=6,S|=re.getUTCMinutes(),S<<=5,S|=re.getUTCSeconds()/2,A=re.getUTCFullYear()-1980,A<<=4,A|=re.getUTCMonth()+1,A<<=5,A|=re.getUTCDate(),X&&(Y=a(1,1)+a(d(R),4)+T,K+="up"+a(Y.length,2)+Y),D&&(q=a(1,1)+a(d(F),4)+I,K+="uc"+a(q.length,2)+q);var ne="";return ne+=`
  3919. \0`,ne+=a(U,2),ne+=k.magic,ne+=a(S,2),ne+=a(A,2),ne+=a(ie.crc32,4),ne+=a(ie.compressedSize,4),ne+=a(ie.uncompressedSize,4),ne+=a(R.length,2),ne+=a(K.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ne+R+K,dirRecord:f.CENTRAL_FILE_HEADER+a(ee,2)+ne+a(F.length,2)+"\0\0\0\0"+a(G,4)+a(b,4)+R+K+F}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(p,x,v,b){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=v,this.encodeFileName=b,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(p){var x=p.meta.percent||0,v=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:v?(x+100*(v-b-1))/v:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var v=o(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,v=o(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),x)this.push({data:(function(b){return f.DATA_DESCRIPTOR+a(b.crc32,4)+a(b.compressedSize,4)+a(b.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var v=this.bytesWritten-p,b=(function(y,M,S,A,E){var k=l.transformTo("string",E(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(y,2)+a(y,2)+a(M,4)+a(S,4)+a(k.length,2)+k})(this.dirRecords.length,v,p,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(v){x.processChunk(v)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(v){x.error(v)}),this},m.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var v=0;v<x.length;v++)try{x[v].error(p)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(m,p){f++;var x=(function(M,S){var A=M||S,E=a[A];if(!E)throw new Error(A+" is not a valid compression method !");return E})(p.options.compression,c.compression),v=p.options.compressionOptions||c.compressionOptions||{},b=p.dir,y=p.date;p._compressWorker(x,v).withStreamInfo("file",{name:m,dir:b,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(m){d.error(m)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new a;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(o,l){return new a().loadAsync(o,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(m){return new o.Promise(function(p,x){var v=m.decompressed.getContentWorker().pipe(new u);v.on("error",function(b){x(b)}).on("end",function(){v.streamInfo.crc32!==m.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(m,p){var x=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(m)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(v){var b=new c(p);return b.load(v),b}).then(function(v){var b=[o.Promise.resolve(v)],y=v.files;if(p.checkCRC32)for(var M=0;M<y.length;M++)b.push(f(y[M]));return o.Promise.all(b)}).then(function(v){for(var b=v.shift(),y=b.files,M=0;M<y.length;M++){var S=y[M],A=S.fileNameStr,E=a.resolve(S.fileNameStr);x.file(E,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:p.createFolders}),S.dir||(x.file(E).unsafeOriginalName=A)}return b.zipComment.length&&(x.comment=b.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function o(l,c,u){a.call(this,c),this._helper=l;var d=this;l.on("data",function(f,m){d.push(f)||d._helper.pause(),u&&u(m)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,a),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,o);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,o)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var o=new Buffer(a);return o.fill(0),o},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(E,k,C){var R,T=l.getTypeOf(k),P=l.extend(C||{},d);P.date=P.date||new Date,P.compression!==null&&(P.compression=P.compression.toUpperCase()),typeof P.unixPermissions=="string"&&(P.unixPermissions=parseInt(P.unixPermissions,8)),P.unixPermissions&&16384&P.unixPermissions&&(P.dir=!0),P.dosPermissions&&16&P.dosPermissions&&(P.dir=!0),P.dir&&(E=y(E)),P.createFolders&&(R=b(E))&&M.call(this,R,!0);var F=T==="string"&&P.binary===!1&&P.base64===!1;C&&C.binary!==void 0||(P.binary=!F),(k instanceof f&&k.uncompressedSize===0||P.dir||!k||k.length===0)&&(P.base64=!1,P.binary=!0,k="",P.compression="STORE",T="string");var I=null;I=k instanceof f||k instanceof c?k:x.isNode&&x.isStream(k)?new v(E,k):l.prepareContent(E,k,P.binary,P.optimizedBinaryString,P.base64);var X=new m(E,I,P);this.files[E]=X}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),m=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),b=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var k=E.lastIndexOf("/");return 0<k?E.substring(0,k):""},y=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},M=function(E,k){return k=k!==void 0?k:d.createFolders,E=y(E),this.files[E]||a.call(this,E,null,{dir:!0,createFolders:k}),this.files[E]};function S(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var k,C,R;for(k in this.files)R=this.files[k],(C=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&E(C,R)},filter:function(E){var k=[];return this.forEach(function(C,R){E(C,R)&&k.push(R)}),k},file:function(E,k,C){if(arguments.length!==1)return E=this.root+E,a.call(this,E,k,C),this;if(S(E)){var R=E;return this.filter(function(P,F){return!F.dir&&R.test(P)})}var T=this.files[this.root+E];return T&&!T.dir?T:null},folder:function(E){if(!E)return this;if(S(E))return this.filter(function(T,P){return P.dir&&E.test(T)});var k=this.root+E,C=M.call(this,k),R=this.clone();return R.root=C.name,R},remove:function(E){E=this.root+E;var k=this.files[E];if(k||(E.slice(-1)!=="/"&&(E+="/"),k=this.files[E]),k&&!k.dir)delete this.files[E];else for(var C=this.filter(function(T,P){return P.name.slice(0,E.length)===E}),R=0;R<C.length;R++)delete this.files[C[R].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var k,C={};try{if((C=l.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var R=C.comment||this.comment||"";k=p.generateWorker(this,C,R)}catch(T){(k=new c("error")).error(T)}return new u(k,C.type||"string",C.mimeType)},generateAsync:function(E,k){return this.generateInternalStream(E).accumulate(k)},generateNodeStream:function(E,k){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(k)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===d&&this.data[m+3]===f)return m-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.readData(4);return c===m[0]&&u===m[1]&&d===m[2]&&f===m[3]},o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var m=a.getTypeOf(f);return a.checkSupport(m),m!=="string"||o.uint8array?m==="nodebuffer"?new u(f):o.uint8array?new d(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),o=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),o=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.inherits(l,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(x,v){return new d.Promise(function(b,y){var M=[],S=x._internalType,A=x._outputType,E=x._mimeType;x.on("data",function(k,C){M.push(k),v&&v(C)}).on("error",function(k){M=[],y(k)}).on("end",function(){try{var k=(function(C,R,T){switch(C){case"blob":return a.newBlob(a.transformTo("arraybuffer",R),T);case"base64":return c.encode(R);default:return a.transformTo(C,R)}})(A,(function(C,R){var T,P=0,F=null,I=0;for(T=0;T<R.length;T++)I+=R[T].length;switch(C){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(F=new Uint8Array(I),T=0;T<R.length;T++)F.set(R[T],P),P+=R[T].length;return F;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+C+"'")}})(S,M),E);b(k)}catch(C){y(C)}M=[]}).resume()})}function p(x,v,b){var y=v;switch(v){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=v,this._mimeType=b,a.checkSupport(y),this._worker=x.pipe(new o(y)),x.lock()}catch(M){this._worker=new l("error"),this._worker.error(M)}}p.prototype={accumulate:function(x){return m(this,x)},on:function(x,v){var b=this;return x==="data"?this._worker.on(x,function(y){v.call(b,y.data,y.meta)}):this._worker.on(x,function(){a.delay(v,arguments,b)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(a),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var a=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function m(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(x){var v,b,y,M,S,A=x.length,E=0;for(M=0;M<A;M++)(64512&(b=x.charCodeAt(M)))==55296&&M+1<A&&(64512&(y=x.charCodeAt(M+1)))==56320&&(b=65536+(b-55296<<10)+(y-56320),M++),E+=b<128?1:b<2048?2:b<65536?3:4;for(v=o.uint8array?new Uint8Array(E):new Array(E),M=S=0;S<E;M++)(64512&(b=x.charCodeAt(M)))==55296&&M+1<A&&(64512&(y=x.charCodeAt(M+1)))==56320&&(b=65536+(b-55296<<10)+(y-56320),M++),b<128?v[S++]=b:(b<2048?v[S++]=192|b>>>6:(b<65536?v[S++]=224|b>>>12:(v[S++]=240|b>>>18,v[S++]=128|b>>>12&63),v[S++]=128|b>>>6&63),v[S++]=128|63&b);return v})(p)},i.utf8decode=function(p){return o.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var v,b,y,M,S=x.length,A=new Array(2*S);for(v=b=0;v<S;)if((y=x[v++])<128)A[b++]=y;else if(4<(M=u[y]))A[b++]=65533,v+=M-1;else{for(y&=M===2?31:M===3?15:7;1<M&&v<S;)y=y<<6|63&x[v++],M--;1<M?A[b++]=65533:y<65536?A[b++]=y:(y-=65536,A[b++]=55296|y>>10&1023,A[b++]=56320|1023&y)}return A.length!==b&&(A.subarray?A=A.subarray(0,b):A.length=b),a.applyFromCharCode(A)})(p=a.transformTo(o.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var x=a.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var v=x;(x=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),x.set(v,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var b=(function(M,S){var A;for((S=S||M.length)>M.length&&(S=M.length),A=S-1;0<=A&&(192&M[A])==128;)A--;return A<0||A===0?S:A+u[M[A]]>S?A:S})(x),y=x;b!==x.length&&(o.uint8array?(y=x.subarray(0,b),this.leftOver=x.subarray(b,x.length)):(y=x.slice(0,b),this.leftOver=x.slice(b,x.length))),this.push({data:i.utf8decode(y),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(m,c),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(v){return v}function d(v,b){for(var y=0;y<v.length;++y)b[y]=255&v.charCodeAt(y);return b}n("setimmediate"),i.newBlob=function(v,b){i.checkSupport("blob");try{return new Blob([v],{type:b})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(v),y.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,b,y){var M=[],S=0,A=v.length;if(A<=y)return String.fromCharCode.apply(null,v);for(;S<A;)b==="array"||b==="nodebuffer"?M.push(String.fromCharCode.apply(null,v.slice(S,Math.min(S+y,A)))):M.push(String.fromCharCode.apply(null,v.subarray(S,Math.min(S+y,A)))),S+=y;return M.join("")},stringifyByChar:function(v){for(var b="",y=0;y<v.length;y++)b+=String.fromCharCode(v[y]);return b},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function m(v){var b=65536,y=i.getTypeOf(v),M=!0;if(y==="uint8array"?M=f.applyCanBeUsed.uint8array:y==="nodebuffer"&&(M=f.applyCanBeUsed.nodebuffer),M)for(;1<b;)try{return f.stringifyByChunk(v,y,b)}catch{b=Math.floor(b/2)}return f.stringifyByChar(v)}function p(v,b){for(var y=0;y<v.length;y++)b[y]=v[y];return b}i.applyFromCharCode=m;var x={};x.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return x.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,l.allocBuffer(v.length))}},x.array={string:m,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(v)}},x.arraybuffer={string:function(v){return m(new Uint8Array(v))},array:function(v){return p(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(new Uint8Array(v))}},x.uint8array={string:m,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return l.newBufferFrom(v)}},x.nodebuffer={string:m,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return x.nodebuffer.uint8array(v).buffer},uint8array:function(v){return p(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,b){if(b=b||"",!v)return b;i.checkSupport(v);var y=i.getTypeOf(b);return x[y][v](b)},i.resolve=function(v){for(var b=v.split("/"),y=[],M=0;M<b.length;M++){var S=b[M];S==="."||S===""&&M!==0&&M!==b.length-1||(S===".."?y.pop():y.push(S))}return y.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(v)?"nodebuffer":a.uint8array&&v instanceof Uint8Array?"uint8array":a.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!a[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var b,y,M="";for(y=0;y<(v||"").length;y++)M+="\\x"+((b=v.charCodeAt(y))<16?"0":"")+b.toString(16).toUpperCase();return M},i.delay=function(v,b,y){setImmediate(function(){v.apply(y||null,b||[])})},i.inherits=function(v,b){function y(){}y.prototype=b.prototype,v.prototype=new y},i.extend=function(){var v,b,y={};for(v=0;v<arguments.length;v++)for(b in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],b)&&y[b]===void 0&&(y[b]=arguments[v][b]);return y},i.prepareContent=function(v,b,y,M,S){return c.Promise.resolve(b).then(function(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,k){var C=new FileReader;C.onload=function(R){E(R.target.result)},C.onerror=function(R){k(R.target.error)},C.readAsArrayBuffer(A)}):A}).then(function(A){var E=i.getTypeOf(A);return E?(E==="arraybuffer"?A=i.transformTo("uint8array",A):E==="string"&&(S?A=o.decode(A):y&&M!==!0&&(A=(function(k){return d(k,a.uint8array?new Uint8Array(k.length):new Array(k.length))})(A))),A):c.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(m)+", expected "+o.pretty(f)+")")}},isSignature:function(f,m){var p=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===m;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),m=u.uint8array?"uint8array":"array",p=o.transformTo(m,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,m,p,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,m;for(f=0;f<this.files.length;f++)m=this.files[f],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var m=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=m-p;if(0<x)this.isSignature(m,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function m(p,x){this.options=p,this.loadOptions=x}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,v;if(p.skip(22),this.fileNameLength=p.readInt(2),v=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(v),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 y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===b)return d[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,v,b,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)x=p.readInt(2),v=p.readInt(2),b=p.readData(v),this.extraFields[x]={id:x,length:v,value:b};p.setIndex(y)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var v=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var y=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(x,v,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=v,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var v=null,b="string";try{if(!x)throw new Error("No output type specified.");var y=(b=x.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),v=this._decompressWorker();var M=!this._dataBinary;M&&!y&&(v=v.pipe(new c.Utf8EncodeWorker)),!M&&y&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(S){(v=new d("error")).error(S)}return new o(v,b,"")},async:function(x,v){return this.internalStream(x).accumulate(v)},nodeStream:function(x,v){return this.internalStream(x||"nodebuffer").toNodejsStream(v)},_compressWorker:function(x,v){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,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)a.prototype[f[p]]=m;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var o,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)o="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var v=a.document.createElement("script");v.onreadystatechange=function(){x(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(x,0)};else{var m=new a.MessageChannel;m.port1.onmessage=x,o=function(){m.port2.postMessage(0)}}var p=[];function x(){var v,b;l=!0;for(var y=p.length;y;){for(b=p,p=[],v=-1;++v<y;)b[v]();y=p.length}l=!1}r.exports=function(v){p.push(v)!==1||l||o()}}).call(this,typeof Gv<"u"?Gv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==o&&v(this,y)}function m(y,M,S){this.promise=y,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function p(y,M,S){a(function(){var A;try{A=M(S)}catch(E){return l.reject(y,E)}A===y?l.reject(y,new TypeError("Cannot resolve promise with itself")):l.resolve(y,A)})}function x(y){var M=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof M=="function")return function(){M.apply(y,arguments)}}function v(y,M){var S=!1;function A(C){S||(S=!0,l.reject(y,C))}function E(C){S||(S=!0,l.resolve(y,C))}var k=b(function(){M(E,A)});k.status==="error"&&A(k.value)}function b(y,M){var S={};try{S.value=y(M),S.status="success"}catch(A){S.status="error",S.value=A}return S}(r.exports=f).prototype.finally=function(y){if(typeof y!="function")return this;var M=this.constructor;return this.then(function(S){return M.resolve(y()).then(function(){return S})},function(S){return M.resolve(y()).then(function(){throw S})})},f.prototype.catch=function(y){return this.then(null,y)},f.prototype.then=function(y,M){if(typeof y!="function"&&this.state===u||typeof M!="function"&&this.state===c)return this;var S=new this.constructor(o);return this.state!==d?p(S,this.state===u?y:M,this.outcome):this.queue.push(new m(S,y,M)),S},m.prototype.callFulfilled=function(y){l.resolve(this.promise,y)},m.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},m.prototype.callRejected=function(y){l.reject(this.promise,y)},m.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},l.resolve=function(y,M){var S=b(x,M);if(S.status==="error")return l.reject(y,S.value);var A=S.value;if(A)v(y,A);else{y.state=u,y.outcome=M;for(var E=-1,k=y.queue.length;++E<k;)y.queue[E].callFulfilled(M)}return y},l.reject=function(y,M){y.state=c,y.outcome=M;for(var S=-1,A=y.queue.length;++S<A;)y.queue[S].callRejected(M);return y},f.resolve=function(y){return y instanceof this?y:l.resolve(new this(o),y)},f.reject=function(y){var M=new this(o);return l.reject(M,y)},f.all=function(y){var M=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=y.length,A=!1;if(!S)return this.resolve([]);for(var E=new Array(S),k=0,C=-1,R=new this(o);++C<S;)T(y[C],C);return R;function T(P,F){M.resolve(P).then(function(I){E[F]=I,++k!==S||A||(A=!0,l.resolve(R,E))},function(I){A||(A=!0,l.reject(R,I))})}},f.race=function(y){var M=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=y.length,A=!1;if(!S)return this.resolve([]);for(var E=-1,k=new this(o);++E<S;)C=y[E],M.resolve(C).then(function(R){A||(A=!0,l.resolve(k,R))},function(R){A||(A=!0,l.reject(k,R))});var C;return k}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,m=-1,p=0,x=8;function v(y){if(!(this instanceof v))return new v(y);this.options=o.assign({level:m,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var M=this.options;M.raw&&0<M.windowBits?M.windowBits=-M.windowBits:M.gzip&&0<M.windowBits&&M.windowBits<16&&(M.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var S=a.deflateInit2(this.strm,M.level,M.method,M.windowBits,M.memLevel,M.strategy);if(S!==f)throw new Error(c[S]);if(M.header&&a.deflateSetHeader(this.strm,M.header),M.dictionary){var A;if(A=typeof M.dictionary=="string"?l.string2buf(M.dictionary):d.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(S=a.deflateSetDictionary(this.strm,A))!==f)throw new Error(c[S]);this._dict_set=!0}}function b(y,M){var S=new v(M);if(S.push(y,!0),S.err)throw S.msg||c[S.err];return S.result}v.prototype.push=function(y,M){var S,A,E=this.strm,k=this.options.chunkSize;if(this.ended)return!1;A=M===~~M?M:M===!0?4:0,typeof y=="string"?E.input=l.string2buf(y):d.call(y)==="[object ArrayBuffer]"?E.input=new Uint8Array(y):E.input=y,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(k),E.next_out=0,E.avail_out=k),(S=a.deflate(E,A))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(E.output,E.next_out))):this.onData(o.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&S!==1);return A===4?(S=a.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===f):A!==2||(this.onEnd(f),!(E.avail_out=0))},v.prototype.onData=function(y){this.chunks.push(y)},v.prototype.onEnd=function(y){y===f&&(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.Deflate=v,i.deflate=b,i.deflateRaw=function(y,M){return(M=M||{}).raw=!0,b(y,M)},i.gzip=function(y,M){return(M=M||{}).gzip=!0,b(y,M)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),m=Object.prototype.toString;function p(v){if(!(this instanceof p))return new p(v);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},v||{});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)||v&&v.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 y=a.inflateInit2(this.strm,b.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(v,b){var y=new p(b);if(y.push(v,!0),y.err)throw y.msg||u[y.err];return y.result}p.prototype.push=function(v,b){var y,M,S,A,E,k,C=this.strm,R=this.options.chunkSize,T=this.options.dictionary,P=!1;if(this.ended)return!1;M=b===~~b?b:b===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?C.input=l.binstring2buf(v):m.call(v)==="[object ArrayBuffer]"?C.input=new Uint8Array(v):C.input=v,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new o.Buf8(R),C.next_out=0,C.avail_out=R),(y=a.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&T&&(k=typeof T=="string"?l.string2buf(T):m.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,y=a.inflateSetDictionary(this.strm,k)),y===c.Z_BUF_ERROR&&P===!0&&(y=c.Z_OK,P=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&y!==c.Z_STREAM_END&&(C.avail_in!==0||M!==c.Z_FINISH&&M!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=l.utf8border(C.output,C.next_out),A=C.next_out-S,E=l.buf2string(C.output,S),C.next_out=A,C.avail_out=R-A,A&&o.arraySet(C.output,C.output,S,A,0),this.onData(E)):this.onData(o.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(P=!0)}while((0<C.avail_in||C.avail_out===0)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(M=c.Z_FINISH),M===c.Z_FINISH?(y=a.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):M!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.avail_out=0))},p.prototype.onData=function(v){this.chunks.push(v)},p.prototype.onEnd=function(v){v===c.Z_OK&&(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.Inflate=p,i.inflate=x,i.inflateRaw=function(v,b){return(b=b||{}).raw=!0,x(v,b)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,m){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),m);else for(var p=0;p<f;p++)c[m+p]=u[d+p]},flattenChunks:function(c){var u,d,f,m,p,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)p=c[u],x.set(p,m),m+=p.length;return x}},l={arraySet:function(c,u,d,f,m){for(var p=0;p<f;p++)c[m+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,m){if(m<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,m));for(var p="",x=0;x<m;x++)p+=String.fromCharCode(f[x]);return p}c[254]=c[254]=1,i.string2buf=function(f){var m,p,x,v,b,y=f.length,M=0;for(v=0;v<y;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<y&&(64512&(x=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),M+=p<128?1:p<2048?2:p<65536?3:4;for(m=new a.Buf8(M),v=b=0;b<M;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<y&&(64512&(x=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),p<128?m[b++]=p:(p<2048?m[b++]=192|p>>>6:(p<65536?m[b++]=224|p>>>12:(m[b++]=240|p>>>18,m[b++]=128|p>>>12&63),m[b++]=128|p>>>6&63),m[b++]=128|63&p);return m},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var m=new a.Buf8(f.length),p=0,x=m.length;p<x;p++)m[p]=f.charCodeAt(p);return m},i.buf2string=function(f,m){var p,x,v,b,y=m||f.length,M=new Array(2*y);for(p=x=0;p<y;)if((v=f[p++])<128)M[x++]=v;else if(4<(b=c[v]))M[x++]=65533,p+=b-1;else{for(v&=b===2?31:b===3?15:7;1<b&&p<y;)v=v<<6|63&f[p++],b--;1<b?M[x++]=65533:v<65536?M[x++]=v:(v-=65536,M[x++]=55296|v>>10&1023,M[x++]=56320|1023&v)}return d(M,x)},i.utf8border=function(f,m){var p;for((m=m||f.length)>f.length&&(m=f.length),p=m-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?m:p+c[f[p]]>m?p:m}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,o,l,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var a=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l,c,u){var d=a,f=u+c;o^=-1;for(var m=u;m<f;m++)o=o>>>8^d[255&(o^l[m])];return-1^o}},{}],46:[function(n,r,i){var a,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,m=4,p=0,x=-2,v=-1,b=4,y=2,M=8,S=9,A=286,E=30,k=19,C=2*A+1,R=15,T=3,P=258,F=P+T+1,I=42,X=113,D=1,K=2,Y=3,q=4;function Z(B,H){return B.msg=d[H],H}function re(B){return(B<<1)-(4<B?9:0)}function ie(B){for(var H=B.length;0<=--H;)B[H]=0}function U(B){var H=B.state,W=H.pending;W>B.avail_out&&(W=B.avail_out),W!==0&&(o.arraySet(B.output,H.pending_buf,H.pending_out,W,B.next_out),B.next_out+=W,H.pending_out+=W,B.total_out+=W,B.avail_out-=W,H.pending-=W,H.pending===0&&(H.pending_out=0))}function G(B,H){l._tr_flush_block(B,0<=B.block_start?B.block_start:-1,B.strstart-B.block_start,H),B.block_start=B.strstart,U(B.strm)}function ee(B,H){B.pending_buf[B.pending++]=H}function ne(B,H){B.pending_buf[B.pending++]=H>>>8&255,B.pending_buf[B.pending++]=255&H}function se(B,H){var W,z,V=B.max_chain_length,Q=B.strstart,Te=B.prev_length,ke=B.nice_match,Ae=B.strstart>B.w_size-F?B.strstart-(B.w_size-F):0,$=B.window,L=B.w_mask,oe=B.prev,ce=B.strstart+P,xe=$[Q+Te-1],ve=$[Q+Te];B.prev_length>=B.good_match&&(V>>=2),ke>B.lookahead&&(ke=B.lookahead);do if($[(W=H)+Te]===ve&&$[W+Te-1]===xe&&$[W]===$[Q]&&$[++W]===$[Q+1]){Q+=2,W++;do;while($[++Q]===$[++W]&&$[++Q]===$[++W]&&$[++Q]===$[++W]&&$[++Q]===$[++W]&&$[++Q]===$[++W]&&$[++Q]===$[++W]&&$[++Q]===$[++W]&&$[++Q]===$[++W]&&Q<ce);if(z=P-(ce-Q),Q=ce-P,Te<z){if(B.match_start=H,ke<=(Te=z))break;xe=$[Q+Te-1],ve=$[Q+Te]}}while((H=oe[H&L])>Ae&&--V!=0);return Te<=B.lookahead?Te:B.lookahead}function de(B){var H,W,z,V,Q,Te,ke,Ae,$,L,oe=B.w_size;do{if(V=B.window_size-B.lookahead-B.strstart,B.strstart>=oe+(oe-F)){for(o.arraySet(B.window,B.window,oe,oe,0),B.match_start-=oe,B.strstart-=oe,B.block_start-=oe,H=W=B.hash_size;z=B.head[--H],B.head[H]=oe<=z?z-oe:0,--W;);for(H=W=oe;z=B.prev[--H],B.prev[H]=oe<=z?z-oe:0,--W;);V+=oe}if(B.strm.avail_in===0)break;if(Te=B.strm,ke=B.window,Ae=B.strstart+B.lookahead,$=V,L=void 0,L=Te.avail_in,$<L&&(L=$),W=L===0?0:(Te.avail_in-=L,o.arraySet(ke,Te.input,Te.next_in,L,Ae),Te.state.wrap===1?Te.adler=c(Te.adler,ke,L,Ae):Te.state.wrap===2&&(Te.adler=u(Te.adler,ke,L,Ae)),Te.next_in+=L,Te.total_in+=L,L),B.lookahead+=W,B.lookahead+B.insert>=T)for(Q=B.strstart-B.insert,B.ins_h=B.window[Q],B.ins_h=(B.ins_h<<B.hash_shift^B.window[Q+1])&B.hash_mask;B.insert&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[Q+T-1])&B.hash_mask,B.prev[Q&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=Q,Q++,B.insert--,!(B.lookahead+B.insert<T)););}while(B.lookahead<F&&B.strm.avail_in!==0)}function he(B,H){for(var W,z;;){if(B.lookahead<F){if(de(B),B.lookahead<F&&H===f)return D;if(B.lookahead===0)break}if(W=0,B.lookahead>=T&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+T-1])&B.hash_mask,W=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),W!==0&&B.strstart-W<=B.w_size-F&&(B.match_length=se(B,W)),B.match_length>=T)if(z=l._tr_tally(B,B.strstart-B.match_start,B.match_length-T),B.lookahead-=B.match_length,B.match_length<=B.max_lazy_match&&B.lookahead>=T){for(B.match_length--;B.strstart++,B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+T-1])&B.hash_mask,W=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart,--B.match_length!=0;);B.strstart++}else B.strstart+=B.match_length,B.match_length=0,B.ins_h=B.window[B.strstart],B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+1])&B.hash_mask;else z=l._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++;if(z&&(G(B,!1),B.strm.avail_out===0))return D}return B.insert=B.strstart<T-1?B.strstart:T-1,H===m?(G(B,!0),B.strm.avail_out===0?Y:q):B.last_lit&&(G(B,!1),B.strm.avail_out===0)?D:K}function Ee(B,H){for(var W,z,V;;){if(B.lookahead<F){if(de(B),B.lookahead<F&&H===f)return D;if(B.lookahead===0)break}if(W=0,B.lookahead>=T&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+T-1])&B.hash_mask,W=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),B.prev_length=B.match_length,B.prev_match=B.match_start,B.match_length=T-1,W!==0&&B.prev_length<B.max_lazy_match&&B.strstart-W<=B.w_size-F&&(B.match_length=se(B,W),B.match_length<=5&&(B.strategy===1||B.match_length===T&&4096<B.strstart-B.match_start)&&(B.match_length=T-1)),B.prev_length>=T&&B.match_length<=B.prev_length){for(V=B.strstart+B.lookahead-T,z=l._tr_tally(B,B.strstart-1-B.prev_match,B.prev_length-T),B.lookahead-=B.prev_length-1,B.prev_length-=2;++B.strstart<=V&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+T-1])&B.hash_mask,W=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),--B.prev_length!=0;);if(B.match_available=0,B.match_length=T-1,B.strstart++,z&&(G(B,!1),B.strm.avail_out===0))return D}else if(B.match_available){if((z=l._tr_tally(B,0,B.window[B.strstart-1]))&&G(B,!1),B.strstart++,B.lookahead--,B.strm.avail_out===0)return D}else B.match_available=1,B.strstart++,B.lookahead--}return B.match_available&&(z=l._tr_tally(B,0,B.window[B.strstart-1]),B.match_available=0),B.insert=B.strstart<T-1?B.strstart:T-1,H===m?(G(B,!0),B.strm.avail_out===0?Y:q):B.last_lit&&(G(B,!1),B.strm.avail_out===0)?D:K}function ge(B,H,W,z,V){this.good_length=B,this.max_lazy=H,this.nice_length=W,this.max_chain=z,this.func=V}function Ne(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=M,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*C),this.dyn_dtree=new o.Buf16(2*(2*E+1)),this.bl_tree=new o.Buf16(2*(2*k+1)),ie(this.dyn_ltree),ie(this.dyn_dtree),ie(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(R+1),this.heap=new o.Buf16(2*A+1),ie(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*A+1),ie(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 Re(B){var H;return B&&B.state?(B.total_in=B.total_out=0,B.data_type=y,(H=B.state).pending=0,H.pending_out=0,H.wrap<0&&(H.wrap=-H.wrap),H.status=H.wrap?I:X,B.adler=H.wrap===2?0:1,H.last_flush=f,l._tr_init(H),p):Z(B,x)}function te(B){var H=Re(B);return H===p&&(function(W){W.window_size=2*W.w_size,ie(W.head),W.max_lazy_match=a[W.level].max_lazy,W.good_match=a[W.level].good_length,W.nice_match=a[W.level].nice_length,W.max_chain_length=a[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=T-1,W.match_available=0,W.ins_h=0})(B.state),H}function Je(B,H,W,z,V,Q){if(!B)return x;var Te=1;if(H===v&&(H=6),z<0?(Te=0,z=-z):15<z&&(Te=2,z-=16),V<1||S<V||W!==M||z<8||15<z||H<0||9<H||Q<0||b<Q)return Z(B,x);z===8&&(z=9);var ke=new Ne;return(B.state=ke).strm=B,ke.wrap=Te,ke.gzhead=null,ke.w_bits=z,ke.w_size=1<<ke.w_bits,ke.w_mask=ke.w_size-1,ke.hash_bits=V+7,ke.hash_size=1<<ke.hash_bits,ke.hash_mask=ke.hash_size-1,ke.hash_shift=~~((ke.hash_bits+T-1)/T),ke.window=new o.Buf8(2*ke.w_size),ke.head=new o.Buf16(ke.hash_size),ke.prev=new o.Buf16(ke.w_size),ke.lit_bufsize=1<<V+6,ke.pending_buf_size=4*ke.lit_bufsize,ke.pending_buf=new o.Buf8(ke.pending_buf_size),ke.d_buf=1*ke.lit_bufsize,ke.l_buf=3*ke.lit_bufsize,ke.level=H,ke.strategy=Q,ke.method=W,te(B)}a=[new ge(0,0,0,0,function(B,H){var W=65535;for(W>B.pending_buf_size-5&&(W=B.pending_buf_size-5);;){if(B.lookahead<=1){if(de(B),B.lookahead===0&&H===f)return D;if(B.lookahead===0)break}B.strstart+=B.lookahead,B.lookahead=0;var z=B.block_start+W;if((B.strstart===0||B.strstart>=z)&&(B.lookahead=B.strstart-z,B.strstart=z,G(B,!1),B.strm.avail_out===0)||B.strstart-B.block_start>=B.w_size-F&&(G(B,!1),B.strm.avail_out===0))return D}return B.insert=0,H===m?(G(B,!0),B.strm.avail_out===0?Y:q):(B.strstart>B.block_start&&(G(B,!1),B.strm.avail_out),D)}),new ge(4,4,8,4,he),new ge(4,5,16,8,he),new ge(4,6,32,32,he),new ge(4,4,16,16,Ee),new ge(8,16,32,32,Ee),new ge(8,16,128,128,Ee),new ge(8,32,128,256,Ee),new ge(32,128,258,1024,Ee),new ge(32,258,258,4096,Ee)],i.deflateInit=function(B,H){return Je(B,H,M,15,8,0)},i.deflateInit2=Je,i.deflateReset=te,i.deflateResetKeep=Re,i.deflateSetHeader=function(B,H){return B&&B.state?B.state.wrap!==2?x:(B.state.gzhead=H,p):x},i.deflate=function(B,H){var W,z,V,Q;if(!B||!B.state||5<H||H<0)return B?Z(B,x):x;if(z=B.state,!B.output||!B.input&&B.avail_in!==0||z.status===666&&H!==m)return Z(B,B.avail_out===0?-5:x);if(z.strm=B,W=z.last_flush,z.last_flush=H,z.status===I)if(z.wrap===2)B.adler=0,ee(z,31),ee(z,139),ee(z,8),z.gzhead?(ee(z,(z.gzhead.text?1:0)+(z.gzhead.hcrc?2:0)+(z.gzhead.extra?4:0)+(z.gzhead.name?8:0)+(z.gzhead.comment?16:0)),ee(z,255&z.gzhead.time),ee(z,z.gzhead.time>>8&255),ee(z,z.gzhead.time>>16&255),ee(z,z.gzhead.time>>24&255),ee(z,z.level===9?2:2<=z.strategy||z.level<2?4:0),ee(z,255&z.gzhead.os),z.gzhead.extra&&z.gzhead.extra.length&&(ee(z,255&z.gzhead.extra.length),ee(z,z.gzhead.extra.length>>8&255)),z.gzhead.hcrc&&(B.adler=u(B.adler,z.pending_buf,z.pending,0)),z.gzindex=0,z.status=69):(ee(z,0),ee(z,0),ee(z,0),ee(z,0),ee(z,0),ee(z,z.level===9?2:2<=z.strategy||z.level<2?4:0),ee(z,3),z.status=X);else{var Te=M+(z.w_bits-8<<4)<<8;Te|=(2<=z.strategy||z.level<2?0:z.level<6?1:z.level===6?2:3)<<6,z.strstart!==0&&(Te|=32),Te+=31-Te%31,z.status=X,ne(z,Te),z.strstart!==0&&(ne(z,B.adler>>>16),ne(z,65535&B.adler)),B.adler=1}if(z.status===69)if(z.gzhead.extra){for(V=z.pending;z.gzindex<(65535&z.gzhead.extra.length)&&(z.pending!==z.pending_buf_size||(z.gzhead.hcrc&&z.pending>V&&(B.adler=u(B.adler,z.pending_buf,z.pending-V,V)),U(B),V=z.pending,z.pending!==z.pending_buf_size));)ee(z,255&z.gzhead.extra[z.gzindex]),z.gzindex++;z.gzhead.hcrc&&z.pending>V&&(B.adler=u(B.adler,z.pending_buf,z.pending-V,V)),z.gzindex===z.gzhead.extra.length&&(z.gzindex=0,z.status=73)}else z.status=73;if(z.status===73)if(z.gzhead.name){V=z.pending;do{if(z.pending===z.pending_buf_size&&(z.gzhead.hcrc&&z.pending>V&&(B.adler=u(B.adler,z.pending_buf,z.pending-V,V)),U(B),V=z.pending,z.pending===z.pending_buf_size)){Q=1;break}Q=z.gzindex<z.gzhead.name.length?255&z.gzhead.name.charCodeAt(z.gzindex++):0,ee(z,Q)}while(Q!==0);z.gzhead.hcrc&&z.pending>V&&(B.adler=u(B.adler,z.pending_buf,z.pending-V,V)),Q===0&&(z.gzindex=0,z.status=91)}else z.status=91;if(z.status===91)if(z.gzhead.comment){V=z.pending;do{if(z.pending===z.pending_buf_size&&(z.gzhead.hcrc&&z.pending>V&&(B.adler=u(B.adler,z.pending_buf,z.pending-V,V)),U(B),V=z.pending,z.pending===z.pending_buf_size)){Q=1;break}Q=z.gzindex<z.gzhead.comment.length?255&z.gzhead.comment.charCodeAt(z.gzindex++):0,ee(z,Q)}while(Q!==0);z.gzhead.hcrc&&z.pending>V&&(B.adler=u(B.adler,z.pending_buf,z.pending-V,V)),Q===0&&(z.status=103)}else z.status=103;if(z.status===103&&(z.gzhead.hcrc?(z.pending+2>z.pending_buf_size&&U(B),z.pending+2<=z.pending_buf_size&&(ee(z,255&B.adler),ee(z,B.adler>>8&255),B.adler=0,z.status=X)):z.status=X),z.pending!==0){if(U(B),B.avail_out===0)return z.last_flush=-1,p}else if(B.avail_in===0&&re(H)<=re(W)&&H!==m)return Z(B,-5);if(z.status===666&&B.avail_in!==0)return Z(B,-5);if(B.avail_in!==0||z.lookahead!==0||H!==f&&z.status!==666){var ke=z.strategy===2?(function(Ae,$){for(var L;;){if(Ae.lookahead===0&&(de(Ae),Ae.lookahead===0)){if($===f)return D;break}if(Ae.match_length=0,L=l._tr_tally(Ae,0,Ae.window[Ae.strstart]),Ae.lookahead--,Ae.strstart++,L&&(G(Ae,!1),Ae.strm.avail_out===0))return D}return Ae.insert=0,$===m?(G(Ae,!0),Ae.strm.avail_out===0?Y:q):Ae.last_lit&&(G(Ae,!1),Ae.strm.avail_out===0)?D:K})(z,H):z.strategy===3?(function(Ae,$){for(var L,oe,ce,xe,ve=Ae.window;;){if(Ae.lookahead<=P){if(de(Ae),Ae.lookahead<=P&&$===f)return D;if(Ae.lookahead===0)break}if(Ae.match_length=0,Ae.lookahead>=T&&0<Ae.strstart&&(oe=ve[ce=Ae.strstart-1])===ve[++ce]&&oe===ve[++ce]&&oe===ve[++ce]){xe=Ae.strstart+P;do;while(oe===ve[++ce]&&oe===ve[++ce]&&oe===ve[++ce]&&oe===ve[++ce]&&oe===ve[++ce]&&oe===ve[++ce]&&oe===ve[++ce]&&oe===ve[++ce]&&ce<xe);Ae.match_length=P-(xe-ce),Ae.match_length>Ae.lookahead&&(Ae.match_length=Ae.lookahead)}if(Ae.match_length>=T?(L=l._tr_tally(Ae,1,Ae.match_length-T),Ae.lookahead-=Ae.match_length,Ae.strstart+=Ae.match_length,Ae.match_length=0):(L=l._tr_tally(Ae,0,Ae.window[Ae.strstart]),Ae.lookahead--,Ae.strstart++),L&&(G(Ae,!1),Ae.strm.avail_out===0))return D}return Ae.insert=0,$===m?(G(Ae,!0),Ae.strm.avail_out===0?Y:q):Ae.last_lit&&(G(Ae,!1),Ae.strm.avail_out===0)?D:K})(z,H):a[z.level].func(z,H);if(ke!==Y&&ke!==q||(z.status=666),ke===D||ke===Y)return B.avail_out===0&&(z.last_flush=-1),p;if(ke===K&&(H===1?l._tr_align(z):H!==5&&(l._tr_stored_block(z,0,0,!1),H===3&&(ie(z.head),z.lookahead===0&&(z.strstart=0,z.block_start=0,z.insert=0))),U(B),B.avail_out===0))return z.last_flush=-1,p}return H!==m?p:z.wrap<=0?1:(z.wrap===2?(ee(z,255&B.adler),ee(z,B.adler>>8&255),ee(z,B.adler>>16&255),ee(z,B.adler>>24&255),ee(z,255&B.total_in),ee(z,B.total_in>>8&255),ee(z,B.total_in>>16&255),ee(z,B.total_in>>24&255)):(ne(z,B.adler>>>16),ne(z,65535&B.adler)),U(B),0<z.wrap&&(z.wrap=-z.wrap),z.pending!==0?p:1)},i.deflateEnd=function(B){var H;return B&&B.state?(H=B.state.status)!==I&&H!==69&&H!==73&&H!==91&&H!==103&&H!==X&&H!==666?Z(B,x):(B.state=null,H===X?Z(B,-3):p):x},i.deflateSetDictionary=function(B,H){var W,z,V,Q,Te,ke,Ae,$,L=H.length;if(!B||!B.state||(Q=(W=B.state).wrap)===2||Q===1&&W.status!==I||W.lookahead)return x;for(Q===1&&(B.adler=c(B.adler,H,L,0)),W.wrap=0,L>=W.w_size&&(Q===0&&(ie(W.head),W.strstart=0,W.block_start=0,W.insert=0),$=new o.Buf8(W.w_size),o.arraySet($,H,L-W.w_size,W.w_size,0),H=$,L=W.w_size),Te=B.avail_in,ke=B.next_in,Ae=B.input,B.avail_in=L,B.next_in=0,B.input=H,de(W);W.lookahead>=T;){for(z=W.strstart,V=W.lookahead-(T-1);W.ins_h=(W.ins_h<<W.hash_shift^W.window[z+T-1])&W.hash_mask,W.prev[z&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=z,z++,--V;);W.strstart=z,W.lookahead=T-1,de(W)}return W.strstart+=W.lookahead,W.block_start=W.strstart,W.insert=W.lookahead,W.lookahead=0,W.match_length=W.prev_length=T-1,W.match_available=0,B.next_in=ke,B.input=Ae,B.avail_in=Te,W.wrap=Q,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,o){var l,c,u,d,f,m,p,x,v,b,y,M,S,A,E,k,C,R,T,P,F,I,X,D,K;l=a.state,c=a.next_in,D=a.input,u=c+(a.avail_in-5),d=a.next_out,K=a.output,f=d-(o-a.avail_out),m=d+(a.avail_out-257),p=l.dmax,x=l.wsize,v=l.whave,b=l.wnext,y=l.window,M=l.hold,S=l.bits,A=l.lencode,E=l.distcode,k=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{S<15&&(M+=D[c++]<<S,S+=8,M+=D[c++]<<S,S+=8),R=A[M&k];t:for(;;){if(M>>>=T=R>>>24,S-=T,(T=R>>>16&255)===0)K[d++]=65535&R;else{if(!(16&T)){if((64&T)==0){R=A[(65535&R)+(M&(1<<T)-1)];continue t}if(32&T){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}P=65535&R,(T&=15)&&(S<T&&(M+=D[c++]<<S,S+=8),P+=M&(1<<T)-1,M>>>=T,S-=T),S<15&&(M+=D[c++]<<S,S+=8,M+=D[c++]<<S,S+=8),R=E[M&C];n:for(;;){if(M>>>=T=R>>>24,S-=T,!(16&(T=R>>>16&255))){if((64&T)==0){R=E[(65535&R)+(M&(1<<T)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(F=65535&R,S<(T&=15)&&(M+=D[c++]<<S,(S+=8)<T&&(M+=D[c++]<<S,S+=8)),p<(F+=M&(1<<T)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(M>>>=T,S-=T,(T=d-f)<F){if(v<(T=F-T)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(X=y,(I=0)===b){if(I+=x-T,T<P){for(P-=T;K[d++]=y[I++],--T;);I=d-F,X=K}}else if(b<T){if(I+=x+b-T,(T-=b)<P){for(P-=T;K[d++]=y[I++],--T;);if(I=0,b<P){for(P-=T=b;K[d++]=y[I++],--T;);I=d-F,X=K}}}else if(I+=b-T,T<P){for(P-=T;K[d++]=y[I++],--T;);I=d-F,X=K}for(;2<P;)K[d++]=X[I++],K[d++]=X[I++],K[d++]=X[I++],P-=3;P&&(K[d++]=X[I++],1<P&&(K[d++]=X[I++]))}else{for(I=d-F;K[d++]=K[I++],K[d++]=K[I++],K[d++]=K[I++],2<(P-=3););P&&(K[d++]=K[I++],1<P&&(K[d++]=K[I++]))}break}}break}}while(c<u&&d<m);c-=P=S>>3,M&=(1<<(S-=P<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<m?m-d+257:257-(d-m),l.hold=M,l.bits=S}},{}],49:[function(n,r,i){var a=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,m=0,p=-2,x=1,v=852,b=592;function y(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function M(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(I){var X;return I&&I.state?(X=I.state,I.total_in=I.total_out=X.total=0,I.msg="",X.wrap&&(I.adler=1&X.wrap),X.mode=x,X.last=0,X.havedict=0,X.dmax=32768,X.head=null,X.hold=0,X.bits=0,X.lencode=X.lendyn=new a.Buf32(v),X.distcode=X.distdyn=new a.Buf32(b),X.sane=1,X.back=-1,m):p}function A(I){var X;return I&&I.state?((X=I.state).wsize=0,X.whave=0,X.wnext=0,S(I)):p}function E(I,X){var D,K;return I&&I.state?(K=I.state,X<0?(D=0,X=-X):(D=1+(X>>4),X<48&&(X&=15)),X&&(X<8||15<X)?p:(K.window!==null&&K.wbits!==X&&(K.window=null),K.wrap=D,K.wbits=X,A(I))):p}function k(I,X){var D,K;return I?(K=new M,(I.state=K).window=null,(D=E(I,X))!==m&&(I.state=null),D):p}var C,R,T=!0;function P(I){if(T){var X;for(C=new a.Buf32(512),R=new a.Buf32(32),X=0;X<144;)I.lens[X++]=8;for(;X<256;)I.lens[X++]=9;for(;X<280;)I.lens[X++]=7;for(;X<288;)I.lens[X++]=8;for(u(d,I.lens,0,288,C,0,I.work,{bits:9}),X=0;X<32;)I.lens[X++]=5;u(f,I.lens,0,32,R,0,I.work,{bits:5}),T=!1}I.lencode=C,I.lenbits=9,I.distcode=R,I.distbits=5}function F(I,X,D,K){var Y,q=I.state;return q.window===null&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new a.Buf8(q.wsize)),K>=q.wsize?(a.arraySet(q.window,X,D-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(K<(Y=q.wsize-q.wnext)&&(Y=K),a.arraySet(q.window,X,D-K,Y,q.wnext),(K-=Y)?(a.arraySet(q.window,X,D-K,K,0),q.wnext=K,q.whave=q.wsize):(q.wnext+=Y,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=Y))),0}i.inflateReset=A,i.inflateReset2=E,i.inflateResetKeep=S,i.inflateInit=function(I){return k(I,15)},i.inflateInit2=k,i.inflate=function(I,X){var D,K,Y,q,Z,re,ie,U,G,ee,ne,se,de,he,Ee,ge,Ne,Re,te,Je,B,H,W,z,V=0,Q=new a.Buf8(4),Te=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return p;(D=I.state).mode===12&&(D.mode=13),Z=I.next_out,Y=I.output,ie=I.avail_out,q=I.next_in,K=I.input,re=I.avail_in,U=D.hold,G=D.bits,ee=re,ne=ie,H=m;e:for(;;)switch(D.mode){case x:if(D.wrap===0){D.mode=13;break}for(;G<16;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if(2&D.wrap&&U===35615){Q[D.check=0]=255&U,Q[1]=U>>>8&255,D.check=l(D.check,Q,2,0),G=U=0,D.mode=2;break}if(D.flags=0,D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&U)<<8)+(U>>8))%31){I.msg="incorrect header check",D.mode=30;break}if((15&U)!=8){I.msg="unknown compression method",D.mode=30;break}if(G-=4,B=8+(15&(U>>>=4)),D.wbits===0)D.wbits=B;else if(B>D.wbits){I.msg="invalid window size",D.mode=30;break}D.dmax=1<<B,I.adler=D.check=1,D.mode=512&U?10:12,G=U=0;break;case 2:for(;G<16;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if(D.flags=U,(255&D.flags)!=8){I.msg="unknown compression method",D.mode=30;break}if(57344&D.flags){I.msg="unknown header flags set",D.mode=30;break}D.head&&(D.head.text=U>>8&1),512&D.flags&&(Q[0]=255&U,Q[1]=U>>>8&255,D.check=l(D.check,Q,2,0)),G=U=0,D.mode=3;case 3:for(;G<32;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}D.head&&(D.head.time=U),512&D.flags&&(Q[0]=255&U,Q[1]=U>>>8&255,Q[2]=U>>>16&255,Q[3]=U>>>24&255,D.check=l(D.check,Q,4,0)),G=U=0,D.mode=4;case 4:for(;G<16;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}D.head&&(D.head.xflags=255&U,D.head.os=U>>8),512&D.flags&&(Q[0]=255&U,Q[1]=U>>>8&255,D.check=l(D.check,Q,2,0)),G=U=0,D.mode=5;case 5:if(1024&D.flags){for(;G<16;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}D.length=U,D.head&&(D.head.extra_len=U),512&D.flags&&(Q[0]=255&U,Q[1]=U>>>8&255,D.check=l(D.check,Q,2,0)),G=U=0}else D.head&&(D.head.extra=null);D.mode=6;case 6:if(1024&D.flags&&(re<(se=D.length)&&(se=re),se&&(D.head&&(B=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Array(D.head.extra_len)),a.arraySet(D.head.extra,K,q,se,B)),512&D.flags&&(D.check=l(D.check,K,se,q)),re-=se,q+=se,D.length-=se),D.length))break e;D.length=0,D.mode=7;case 7:if(2048&D.flags){if(re===0)break e;for(se=0;B=K[q+se++],D.head&&B&&D.length<65536&&(D.head.name+=String.fromCharCode(B)),B&&se<re;);if(512&D.flags&&(D.check=l(D.check,K,se,q)),re-=se,q+=se,B)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=8;case 8:if(4096&D.flags){if(re===0)break e;for(se=0;B=K[q+se++],D.head&&B&&D.length<65536&&(D.head.comment+=String.fromCharCode(B)),B&&se<re;);if(512&D.flags&&(D.check=l(D.check,K,se,q)),re-=se,q+=se,B)break e}else D.head&&(D.head.comment=null);D.mode=9;case 9:if(512&D.flags){for(;G<16;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if(U!==(65535&D.check)){I.msg="header crc mismatch",D.mode=30;break}G=U=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),I.adler=D.check=0,D.mode=12;break;case 10:for(;G<32;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}I.adler=D.check=y(U),G=U=0,D.mode=11;case 11:if(D.havedict===0)return I.next_out=Z,I.avail_out=ie,I.next_in=q,I.avail_in=re,D.hold=U,D.bits=G,2;I.adler=D.check=1,D.mode=12;case 12:if(X===5||X===6)break e;case 13:if(D.last){U>>>=7&G,G-=7&G,D.mode=27;break}for(;G<3;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}switch(D.last=1&U,G-=1,3&(U>>>=1)){case 0:D.mode=14;break;case 1:if(P(D),D.mode=20,X!==6)break;U>>>=2,G-=2;break e;case 2:D.mode=17;break;case 3:I.msg="invalid block type",D.mode=30}U>>>=2,G-=2;break;case 14:for(U>>>=7&G,G-=7&G;G<32;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if((65535&U)!=(U>>>16^65535)){I.msg="invalid stored block lengths",D.mode=30;break}if(D.length=65535&U,G=U=0,D.mode=15,X===6)break e;case 15:D.mode=16;case 16:if(se=D.length){if(re<se&&(se=re),ie<se&&(se=ie),se===0)break e;a.arraySet(Y,K,q,se,Z),re-=se,q+=se,ie-=se,Z+=se,D.length-=se;break}D.mode=12;break;case 17:for(;G<14;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if(D.nlen=257+(31&U),U>>>=5,G-=5,D.ndist=1+(31&U),U>>>=5,G-=5,D.ncode=4+(15&U),U>>>=4,G-=4,286<D.nlen||30<D.ndist){I.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(;G<3;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}D.lens[Te[D.have++]]=7&U,U>>>=3,G-=3}for(;D.have<19;)D.lens[Te[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,W={bits:D.lenbits},H=u(0,D.lens,0,19,D.lencode,0,D.work,W),D.lenbits=W.bits,H){I.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(;ge=(V=D.lencode[U&(1<<D.lenbits)-1])>>>16&255,Ne=65535&V,!((Ee=V>>>24)<=G);){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if(Ne<16)U>>>=Ee,G-=Ee,D.lens[D.have++]=Ne;else{if(Ne===16){for(z=Ee+2;G<z;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if(U>>>=Ee,G-=Ee,D.have===0){I.msg="invalid bit length repeat",D.mode=30;break}B=D.lens[D.have-1],se=3+(3&U),U>>>=2,G-=2}else if(Ne===17){for(z=Ee+3;G<z;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}G-=Ee,B=0,se=3+(7&(U>>>=Ee)),U>>>=3,G-=3}else{for(z=Ee+7;G<z;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}G-=Ee,B=0,se=11+(127&(U>>>=Ee)),U>>>=7,G-=7}if(D.have+se>D.nlen+D.ndist){I.msg="invalid bit length repeat",D.mode=30;break}for(;se--;)D.lens[D.have++]=B}}if(D.mode===30)break;if(D.lens[256]===0){I.msg="invalid code -- missing end-of-block",D.mode=30;break}if(D.lenbits=9,W={bits:D.lenbits},H=u(d,D.lens,0,D.nlen,D.lencode,0,D.work,W),D.lenbits=W.bits,H){I.msg="invalid literal/lengths set",D.mode=30;break}if(D.distbits=6,D.distcode=D.distdyn,W={bits:D.distbits},H=u(f,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,W),D.distbits=W.bits,H){I.msg="invalid distances set",D.mode=30;break}if(D.mode=20,X===6)break e;case 20:D.mode=21;case 21:if(6<=re&&258<=ie){I.next_out=Z,I.avail_out=ie,I.next_in=q,I.avail_in=re,D.hold=U,D.bits=G,c(I,ne),Z=I.next_out,Y=I.output,ie=I.avail_out,q=I.next_in,K=I.input,re=I.avail_in,U=D.hold,G=D.bits,D.mode===12&&(D.back=-1);break}for(D.back=0;ge=(V=D.lencode[U&(1<<D.lenbits)-1])>>>16&255,Ne=65535&V,!((Ee=V>>>24)<=G);){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if(ge&&(240&ge)==0){for(Re=Ee,te=ge,Je=Ne;ge=(V=D.lencode[Je+((U&(1<<Re+te)-1)>>Re)])>>>16&255,Ne=65535&V,!(Re+(Ee=V>>>24)<=G);){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}U>>>=Re,G-=Re,D.back+=Re}if(U>>>=Ee,G-=Ee,D.back+=Ee,D.length=Ne,ge===0){D.mode=26;break}if(32&ge){D.back=-1,D.mode=12;break}if(64&ge){I.msg="invalid literal/length code",D.mode=30;break}D.extra=15&ge,D.mode=22;case 22:if(D.extra){for(z=D.extra;G<z;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}D.length+=U&(1<<D.extra)-1,U>>>=D.extra,G-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=23;case 23:for(;ge=(V=D.distcode[U&(1<<D.distbits)-1])>>>16&255,Ne=65535&V,!((Ee=V>>>24)<=G);){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if((240&ge)==0){for(Re=Ee,te=ge,Je=Ne;ge=(V=D.distcode[Je+((U&(1<<Re+te)-1)>>Re)])>>>16&255,Ne=65535&V,!(Re+(Ee=V>>>24)<=G);){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}U>>>=Re,G-=Re,D.back+=Re}if(U>>>=Ee,G-=Ee,D.back+=Ee,64&ge){I.msg="invalid distance code",D.mode=30;break}D.offset=Ne,D.extra=15&ge,D.mode=24;case 24:if(D.extra){for(z=D.extra;G<z;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}D.offset+=U&(1<<D.extra)-1,U>>>=D.extra,G-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){I.msg="invalid distance too far back",D.mode=30;break}D.mode=25;case 25:if(ie===0)break e;if(se=ne-ie,D.offset>se){if((se=D.offset-se)>D.whave&&D.sane){I.msg="invalid distance too far back",D.mode=30;break}de=se>D.wnext?(se-=D.wnext,D.wsize-se):D.wnext-se,se>D.length&&(se=D.length),he=D.window}else he=Y,de=Z-D.offset,se=D.length;for(ie<se&&(se=ie),ie-=se,D.length-=se;Y[Z++]=he[de++],--se;);D.length===0&&(D.mode=21);break;case 26:if(ie===0)break e;Y[Z++]=D.length,ie--,D.mode=21;break;case 27:if(D.wrap){for(;G<32;){if(re===0)break e;re--,U|=K[q++]<<G,G+=8}if(ne-=ie,I.total_out+=ne,D.total+=ne,ne&&(I.adler=D.check=D.flags?l(D.check,Y,ne,Z-ne):o(D.check,Y,ne,Z-ne)),ne=ie,(D.flags?U:y(U))!==D.check){I.msg="incorrect data check",D.mode=30;break}G=U=0}D.mode=28;case 28:if(D.wrap&&D.flags){for(;G<32;){if(re===0)break e;re--,U+=K[q++]<<G,G+=8}if(U!==(4294967295&D.total)){I.msg="incorrect length check",D.mode=30;break}G=U=0}D.mode=29;case 29:H=1;break e;case 30:H=-3;break e;case 31:return-4;case 32:default:return p}return I.next_out=Z,I.avail_out=ie,I.next_in=q,I.avail_in=re,D.hold=U,D.bits=G,(D.wsize||ne!==I.avail_out&&D.mode<30&&(D.mode<27||X!==4))&&F(I,I.output,I.next_out,ne-I.avail_out)?(D.mode=31,-4):(ee-=I.avail_in,ne-=I.avail_out,I.total_in+=ee,I.total_out+=ne,D.total+=ne,D.wrap&&ne&&(I.adler=D.check=D.flags?l(D.check,Y,ne,I.next_out-ne):o(D.check,Y,ne,I.next_out-ne)),I.data_type=D.bits+(D.last?64:0)+(D.mode===12?128:0)+(D.mode===20||D.mode===15?256:0),(ee==0&&ne===0||X===4)&&H===m&&(H=-5),H)},i.inflateEnd=function(I){if(!I||!I.state)return p;var X=I.state;return X.window&&(X.window=null),I.state=null,m},i.inflateGetHeader=function(I,X){var D;return I&&I.state?(2&(D=I.state).wrap)==0?p:((D.head=X).done=!1,m):p},i.inflateSetDictionary=function(I,X){var D,K=X.length;return I&&I.state?(D=I.state).wrap!==0&&D.mode!==11?p:D.mode===11&&o(1,X,K,0)!==D.check?-3:F(I,X,K,K)?(D.mode=31,-4):(D.havedict=1,m):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,m,p,x,v,b,y){var M,S,A,E,k,C,R,T,P,F=y.bits,I=0,X=0,D=0,K=0,Y=0,q=0,Z=0,re=0,ie=0,U=0,G=null,ee=0,ne=new a.Buf16(16),se=new a.Buf16(16),de=null,he=0;for(I=0;I<=15;I++)ne[I]=0;for(X=0;X<p;X++)ne[f[m+X]]++;for(Y=F,K=15;1<=K&&ne[K]===0;K--);if(K<Y&&(Y=K),K===0)return x[v++]=20971520,x[v++]=20971520,y.bits=1,0;for(D=1;D<K&&ne[D]===0;D++);for(Y<D&&(Y=D),I=re=1;I<=15;I++)if(re<<=1,(re-=ne[I])<0)return-1;if(0<re&&(d===0||K!==1))return-1;for(se[1]=0,I=1;I<15;I++)se[I+1]=se[I]+ne[I];for(X=0;X<p;X++)f[m+X]!==0&&(b[se[f[m+X]]++]=X);if(C=d===0?(G=de=b,19):d===1?(G=o,ee-=257,de=l,he-=257,256):(G=c,de=u,-1),I=D,k=v,Z=X=U=0,A=-1,E=(ie=1<<(q=Y))-1,d===1&&852<ie||d===2&&592<ie)return 1;for(;;){for(R=I-Z,P=b[X]<C?(T=0,b[X]):b[X]>C?(T=de[he+b[X]],G[ee+b[X]]):(T=96,0),M=1<<I-Z,D=S=1<<q;x[k+(U>>Z)+(S-=M)]=R<<24|T<<16|P|0,S!==0;);for(M=1<<I-1;U&M;)M>>=1;if(M!==0?(U&=M-1,U+=M):U=0,X++,--ne[I]==0){if(I===K)break;I=f[m+b[X]]}if(Y<I&&(U&E)!==A){for(Z===0&&(Z=Y),k+=D,re=1<<(q=I-Z);q+Z<K&&!((re-=ne[q+Z])<=0);)q++,re<<=1;if(ie+=1<<q,d===1&&852<ie||d===2&&592<ie)return 1;x[A=U&E]=Y<<24|q<<16|k-v|0}}return U!==0&&(x[k+U]=I-Z<<24|64<<16|0),y.bits=Y,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),o=0,l=1;function c(V){for(var Q=V.length;0<=--Q;)V[Q]=0}var u=0,d=29,f=256,m=f+1+d,p=30,x=19,v=2*m+1,b=15,y=16,M=7,S=256,A=16,E=17,k=18,C=[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],R=[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],P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(m+2));c(F);var I=new Array(2*p);c(I);var X=new Array(512);c(X);var D=new Array(256);c(D);var K=new Array(d);c(K);var Y,q,Z,re=new Array(p);function ie(V,Q,Te,ke,Ae){this.static_tree=V,this.extra_bits=Q,this.extra_base=Te,this.elems=ke,this.max_length=Ae,this.has_stree=V&&V.length}function U(V,Q){this.dyn_tree=V,this.max_code=0,this.stat_desc=Q}function G(V){return V<256?X[V]:X[256+(V>>>7)]}function ee(V,Q){V.pending_buf[V.pending++]=255&Q,V.pending_buf[V.pending++]=Q>>>8&255}function ne(V,Q,Te){V.bi_valid>y-Te?(V.bi_buf|=Q<<V.bi_valid&65535,ee(V,V.bi_buf),V.bi_buf=Q>>y-V.bi_valid,V.bi_valid+=Te-y):(V.bi_buf|=Q<<V.bi_valid&65535,V.bi_valid+=Te)}function se(V,Q,Te){ne(V,Te[2*Q],Te[2*Q+1])}function de(V,Q){for(var Te=0;Te|=1&V,V>>>=1,Te<<=1,0<--Q;);return Te>>>1}function he(V,Q,Te){var ke,Ae,$=new Array(b+1),L=0;for(ke=1;ke<=b;ke++)$[ke]=L=L+Te[ke-1]<<1;for(Ae=0;Ae<=Q;Ae++){var oe=V[2*Ae+1];oe!==0&&(V[2*Ae]=de($[oe]++,oe))}}function Ee(V){var Q;for(Q=0;Q<m;Q++)V.dyn_ltree[2*Q]=0;for(Q=0;Q<p;Q++)V.dyn_dtree[2*Q]=0;for(Q=0;Q<x;Q++)V.bl_tree[2*Q]=0;V.dyn_ltree[2*S]=1,V.opt_len=V.static_len=0,V.last_lit=V.matches=0}function ge(V){8<V.bi_valid?ee(V,V.bi_buf):0<V.bi_valid&&(V.pending_buf[V.pending++]=V.bi_buf),V.bi_buf=0,V.bi_valid=0}function Ne(V,Q,Te,ke){var Ae=2*Q,$=2*Te;return V[Ae]<V[$]||V[Ae]===V[$]&&ke[Q]<=ke[Te]}function Re(V,Q,Te){for(var ke=V.heap[Te],Ae=Te<<1;Ae<=V.heap_len&&(Ae<V.heap_len&&Ne(Q,V.heap[Ae+1],V.heap[Ae],V.depth)&&Ae++,!Ne(Q,ke,V.heap[Ae],V.depth));)V.heap[Te]=V.heap[Ae],Te=Ae,Ae<<=1;V.heap[Te]=ke}function te(V,Q,Te){var ke,Ae,$,L,oe=0;if(V.last_lit!==0)for(;ke=V.pending_buf[V.d_buf+2*oe]<<8|V.pending_buf[V.d_buf+2*oe+1],Ae=V.pending_buf[V.l_buf+oe],oe++,ke===0?se(V,Ae,Q):(se(V,($=D[Ae])+f+1,Q),(L=C[$])!==0&&ne(V,Ae-=K[$],L),se(V,$=G(--ke),Te),(L=R[$])!==0&&ne(V,ke-=re[$],L)),oe<V.last_lit;);se(V,S,Q)}function Je(V,Q){var Te,ke,Ae,$=Q.dyn_tree,L=Q.stat_desc.static_tree,oe=Q.stat_desc.has_stree,ce=Q.stat_desc.elems,xe=-1;for(V.heap_len=0,V.heap_max=v,Te=0;Te<ce;Te++)$[2*Te]!==0?(V.heap[++V.heap_len]=xe=Te,V.depth[Te]=0):$[2*Te+1]=0;for(;V.heap_len<2;)$[2*(Ae=V.heap[++V.heap_len]=xe<2?++xe:0)]=1,V.depth[Ae]=0,V.opt_len--,oe&&(V.static_len-=L[2*Ae+1]);for(Q.max_code=xe,Te=V.heap_len>>1;1<=Te;Te--)Re(V,$,Te);for(Ae=ce;Te=V.heap[1],V.heap[1]=V.heap[V.heap_len--],Re(V,$,1),ke=V.heap[1],V.heap[--V.heap_max]=Te,V.heap[--V.heap_max]=ke,$[2*Ae]=$[2*Te]+$[2*ke],V.depth[Ae]=(V.depth[Te]>=V.depth[ke]?V.depth[Te]:V.depth[ke])+1,$[2*Te+1]=$[2*ke+1]=Ae,V.heap[1]=Ae++,Re(V,$,1),2<=V.heap_len;);V.heap[--V.heap_max]=V.heap[1],(function(ve,_e){var Ie,We,ht,qe,me,rt,Xe=_e.dyn_tree,nt=_e.max_code,ut=_e.stat_desc.static_tree,ae=_e.stat_desc.has_stree,$e=_e.stat_desc.extra_bits,ye=_e.stat_desc.extra_base,Be=_e.stat_desc.max_length,De=0;for(qe=0;qe<=b;qe++)ve.bl_count[qe]=0;for(Xe[2*ve.heap[ve.heap_max]+1]=0,Ie=ve.heap_max+1;Ie<v;Ie++)Be<(qe=Xe[2*Xe[2*(We=ve.heap[Ie])+1]+1]+1)&&(qe=Be,De++),Xe[2*We+1]=qe,nt<We||(ve.bl_count[qe]++,me=0,ye<=We&&(me=$e[We-ye]),rt=Xe[2*We],ve.opt_len+=rt*(qe+me),ae&&(ve.static_len+=rt*(ut[2*We+1]+me)));if(De!==0){do{for(qe=Be-1;ve.bl_count[qe]===0;)qe--;ve.bl_count[qe]--,ve.bl_count[qe+1]+=2,ve.bl_count[Be]--,De-=2}while(0<De);for(qe=Be;qe!==0;qe--)for(We=ve.bl_count[qe];We!==0;)nt<(ht=ve.heap[--Ie])||(Xe[2*ht+1]!==qe&&(ve.opt_len+=(qe-Xe[2*ht+1])*Xe[2*ht],Xe[2*ht+1]=qe),We--)}})(V,Q),he($,xe,V.bl_count)}function B(V,Q,Te){var ke,Ae,$=-1,L=Q[1],oe=0,ce=7,xe=4;for(L===0&&(ce=138,xe=3),Q[2*(Te+1)+1]=65535,ke=0;ke<=Te;ke++)Ae=L,L=Q[2*(ke+1)+1],++oe<ce&&Ae===L||(oe<xe?V.bl_tree[2*Ae]+=oe:Ae!==0?(Ae!==$&&V.bl_tree[2*Ae]++,V.bl_tree[2*A]++):oe<=10?V.bl_tree[2*E]++:V.bl_tree[2*k]++,$=Ae,xe=(oe=0)===L?(ce=138,3):Ae===L?(ce=6,3):(ce=7,4))}function H(V,Q,Te){var ke,Ae,$=-1,L=Q[1],oe=0,ce=7,xe=4;for(L===0&&(ce=138,xe=3),ke=0;ke<=Te;ke++)if(Ae=L,L=Q[2*(ke+1)+1],!(++oe<ce&&Ae===L)){if(oe<xe)for(;se(V,Ae,V.bl_tree),--oe!=0;);else Ae!==0?(Ae!==$&&(se(V,Ae,V.bl_tree),oe--),se(V,A,V.bl_tree),ne(V,oe-3,2)):oe<=10?(se(V,E,V.bl_tree),ne(V,oe-3,3)):(se(V,k,V.bl_tree),ne(V,oe-11,7));$=Ae,xe=(oe=0)===L?(ce=138,3):Ae===L?(ce=6,3):(ce=7,4)}}c(re);var W=!1;function z(V,Q,Te,ke){ne(V,(u<<1)+(ke?1:0),3),(function(Ae,$,L,oe){ge(Ae),ee(Ae,L),ee(Ae,~L),a.arraySet(Ae.pending_buf,Ae.window,$,L,Ae.pending),Ae.pending+=L})(V,Q,Te)}i._tr_init=function(V){W||((function(){var Q,Te,ke,Ae,$,L=new Array(b+1);for(Ae=ke=0;Ae<d-1;Ae++)for(K[Ae]=ke,Q=0;Q<1<<C[Ae];Q++)D[ke++]=Ae;for(D[ke-1]=Ae,Ae=$=0;Ae<16;Ae++)for(re[Ae]=$,Q=0;Q<1<<R[Ae];Q++)X[$++]=Ae;for($>>=7;Ae<p;Ae++)for(re[Ae]=$<<7,Q=0;Q<1<<R[Ae]-7;Q++)X[256+$++]=Ae;for(Te=0;Te<=b;Te++)L[Te]=0;for(Q=0;Q<=143;)F[2*Q+1]=8,Q++,L[8]++;for(;Q<=255;)F[2*Q+1]=9,Q++,L[9]++;for(;Q<=279;)F[2*Q+1]=7,Q++,L[7]++;for(;Q<=287;)F[2*Q+1]=8,Q++,L[8]++;for(he(F,m+1,L),Q=0;Q<p;Q++)I[2*Q+1]=5,I[2*Q]=de(Q,5);Y=new ie(F,C,f+1,m,b),q=new ie(I,R,0,p,b),Z=new ie(new Array(0),T,0,x,M)})(),W=!0),V.l_desc=new U(V.dyn_ltree,Y),V.d_desc=new U(V.dyn_dtree,q),V.bl_desc=new U(V.bl_tree,Z),V.bi_buf=0,V.bi_valid=0,Ee(V)},i._tr_stored_block=z,i._tr_flush_block=function(V,Q,Te,ke){var Ae,$,L=0;0<V.level?(V.strm.data_type===2&&(V.strm.data_type=(function(oe){var ce,xe=4093624447;for(ce=0;ce<=31;ce++,xe>>>=1)if(1&xe&&oe.dyn_ltree[2*ce]!==0)return o;if(oe.dyn_ltree[18]!==0||oe.dyn_ltree[20]!==0||oe.dyn_ltree[26]!==0)return l;for(ce=32;ce<f;ce++)if(oe.dyn_ltree[2*ce]!==0)return l;return o})(V)),Je(V,V.l_desc),Je(V,V.d_desc),L=(function(oe){var ce;for(B(oe,oe.dyn_ltree,oe.l_desc.max_code),B(oe,oe.dyn_dtree,oe.d_desc.max_code),Je(oe,oe.bl_desc),ce=x-1;3<=ce&&oe.bl_tree[2*P[ce]+1]===0;ce--);return oe.opt_len+=3*(ce+1)+5+5+4,ce})(V),Ae=V.opt_len+3+7>>>3,($=V.static_len+3+7>>>3)<=Ae&&(Ae=$)):Ae=$=Te+5,Te+4<=Ae&&Q!==-1?z(V,Q,Te,ke):V.strategy===4||$===Ae?(ne(V,2+(ke?1:0),3),te(V,F,I)):(ne(V,4+(ke?1:0),3),(function(oe,ce,xe,ve){var _e;for(ne(oe,ce-257,5),ne(oe,xe-1,5),ne(oe,ve-4,4),_e=0;_e<ve;_e++)ne(oe,oe.bl_tree[2*P[_e]+1],3);H(oe,oe.dyn_ltree,ce-1),H(oe,oe.dyn_dtree,xe-1)})(V,V.l_desc.max_code+1,V.d_desc.max_code+1,L+1),te(V,V.dyn_ltree,V.dyn_dtree)),Ee(V),ke&&ge(V)},i._tr_tally=function(V,Q,Te){return V.pending_buf[V.d_buf+2*V.last_lit]=Q>>>8&255,V.pending_buf[V.d_buf+2*V.last_lit+1]=255&Q,V.pending_buf[V.l_buf+V.last_lit]=255&Te,V.last_lit++,Q===0?V.dyn_ltree[2*Te]++:(V.matches++,Q--,V.dyn_ltree[2*(D[Te]+f+1)]++,V.dyn_dtree[2*G(Q)]++),V.last_lit===V.lit_bufsize-1},i._tr_align=function(V){ne(V,2,3),se(V,S,F),(function(Q){Q.bi_valid===16?(ee(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)})(V)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(a){(function(o,l){if(!o.setImmediate){var c,u,d,f,m=1,p={},x=!1,v=o.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(o);b=b&&b.setTimeout?b:o,c={}.toString.call(o.process)==="[object process]"?function(A){process.nextTick(function(){M(A)})}:(function(){if(o.postMessage&&!o.importScripts){var A=!0,E=o.onmessage;return o.onmessage=function(){A=!1},o.postMessage("","*"),o.onmessage=E,A}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",S,!1):o.attachEvent("onmessage",S),function(A){o.postMessage(f+A,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){M(A.data)},function(A){d.port2.postMessage(A)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(A){var E=v.createElement("script");E.onreadystatechange=function(){M(A),E.onreadystatechange=null,u.removeChild(E),E=null},u.appendChild(E)}):function(A){setTimeout(M,0,A)},b.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var E=new Array(arguments.length-1),k=0;k<E.length;k++)E[k]=arguments[k+1];var C={callback:A,args:E};return p[m]=C,c(m),m++},b.clearImmediate=y}function y(A){delete p[A]}function M(A){if(x)setTimeout(M,0,A);else{var E=p[A];if(E){x=!0;try{(function(k){var C=k.callback,R=k.args;switch(R.length){case 0:C();break;case 1:C(R[0]);break;case 2:C(R[0],R[1]);break;case 3:C(R[0],R[1],R[2]);break;default:C.apply(l,R)}})(E)}finally{y(A),x=!1}}}}function S(A){A.source===o&&typeof A.data=="string"&&A.data.indexOf(f)===0&&M(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Gv<"u"?Gv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(YC)),YC.exports}var AOe=EOe();const TOe=ko(AOe);function COe(t){const e=new vi;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 uV=COe;async function dV(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],o=[],l=[],c=a.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=a.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}async function kOe(t){const e=await TOe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(p){const x=p.startsWith("/")?p.slice(1):p,v=e.files[x];if(!v)return null;const b=await v.async("string");return i.parseFromString(b,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const p=await c.async("string"),v=i.parseFromString(p,"application/xml").getElementsByTagName("object");for(let b=0;b<v.length;b++){const y=v[b],M=y.getAttribute("id");if(!M)continue;const S=Array.from(y.children).filter(E=>E.tagName==="metadata"&&E.getAttribute("key")==="extruder");if(S.length>0){const E=S[0].getAttribute("value");E&&o.set(M,Math.max(0,parseInt(E,10)-1))}const A=y.getElementsByTagName("part");for(let E=0;E<A.length;E++){const k=A[E],C=k.getAttribute("id");if(!C)continue;const R=Array.from(k.children).filter(T=>T.tagName==="metadata"&&T.getAttribute("key")==="extruder");if(R.length>0){const T=R[0].getAttribute("value");T&&l.set(`${M}:${C}`,Math.max(0,parseInt(T,10)-1))}}}}catch{}const u=Object.keys(e.files).find(p=>p==="3D/3dmodel.model"||p.endsWith("/3dmodel.model"));if(!u){const p=Object.keys(e.files).find(x=>x.endsWith(".model"));if(p){const x=await a(p);if(x){const v=await dV(x,0);v.length>0&&n.set("1",{id:"1",meshes:v,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let p=0;p<f.length;p++){const x=f[p],v=x.getAttribute("id");if(!v)continue;let b=o.get(v)??-1;if(b<0){const A=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";b=Math.max(0,parseInt(A,10)-1)}const y=[],M=x.getElementsByTagName("mesh");for(let A=0;A<M.length;A++){const E=M[A],k=[],C=[],R=E.getElementsByTagName("vertex");for(let P=0;P<R.length;P++){const F=R[P];k.push(parseFloat(F.getAttribute("x")||"0"),parseFloat(F.getAttribute("y")||"0"),parseFloat(F.getAttribute("z")||"0"))}const T=E.getElementsByTagName("triangle");for(let P=0;P<T.length;P++){const F=T[P];C.push(parseInt(F.getAttribute("v1")||"0"),parseInt(F.getAttribute("v2")||"0"),parseInt(F.getAttribute("v3")||"0"))}k.length>0&&C.length>0&&y.push({vertices:k,triangles:C,extruder:b})}const S=x.getElementsByTagName("component");for(let A=0;A<S.length;A++){const E=S[A],k=E.getAttribute("p:path")||E.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),C=E.getAttribute("objectid");if(k){const R=await a(k);if(R){const T=C?`${v}:${C}`:null,P=T?l.get(T)??b:b,F=await dV(R,P),I=E.getAttribute("transform"),X=uV(I);for(const D of F)if(I){const K=[];for(let Y=0;Y<D.vertices.length;Y+=3){const q=new at(D.vertices[Y],D.vertices[Y+1],D.vertices[Y+2]);q.applyMatrix4(X),K.push(q.x,q.y,q.z)}y.push({vertices:K,triangles:D.triangles,extruder:D.extruder})}else y.push(D)}}}y.length>0&&n.set(v,{id:v,meshes:y,defaultExtruder:b})}const m=d.getElementsByTagName("build");if(m.length>0){const p=m[0].getElementsByTagName("item");for(let x=0;x<p.length;x++){const v=p[x],b=v.getAttribute("objectid");if(!b)continue;const y=uV(v.getAttribute("transform"));r.push({objectId:b,transform:y})}}return{objects:n,buildItems:r}}function hV(t){const e=new Xl,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 So(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function jOe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),a=w.useRef(null),o=w.useRef(null),l=w.useRef(null),c=w.useRef(null),[u,d]=w.useState(!0),[f,m]=w.useState(null);w.useEffect(()=>{if(!i.current)return;const v=i.current,b=v.clientWidth,y=v.clientHeight,M=new l3e;M.background=new Nn(1710618),o.current=M;const S=new go(45,b/y,.1,1e4);S.position.set(150,150,150),l.current=S;const A=new uOe({antialias:!0});A.setSize(b,y),A.setPixelRatio(window.devicePixelRatio),v.appendChild(A.domElement),a.current=A;const E=new hOe(S,A.domElement);E.enableDamping=!0,E.dampingFactor=.05,c.current=E;const k=new v3e(16777215,.6);M.add(k);const C=new DH(16777215,.8);C.position.set(100,100,100),M.add(C);const R=new DH(16777215,.4);R.position.set(-100,50,-100),M.add(R);const T=Math.max(e.x,e.y),P=Math.ceil(T/16),F=new w3e(T,P,4473924,3355443);M.add(F);const I=new SO(e.x,e.y),X=new vO({color:44610,transparent:!0,opacity:.15,side:Sl}),D=new Bl(I,X);D.rotation.x=-Math.PI/2,D.position.y=-.5,M.add(D);let K;const Y=()=>{K=requestAnimationFrame(Y),E.update(),A.render(M,S)};Y(),fetch(t).then(Z=>{if(!Z.ok)throw new Error("Failed to load file");return Z.arrayBuffer()}).then(kOe).then(({objects:Z,buildItems:re})=>{if(Z.size===0)throw new Error("No meshes found in 3MF file");const ie=Ne=>{const te=n?.[Ne]||"#00ae42",Je=new Nn(te);return new p3e({color:Je,shininess:30,flatShading:!1})},U=new vb,G=new Map;if(re.length>0)for(const Ne of re){const Re=Z.get(Ne.objectId);if(Re)for(const te of Re.meshes){const Je=Ne.extruder??te.extruder,B=[];for(let W=0;W<te.vertices.length;W+=3){const z=new at(te.vertices[W],te.vertices[W+1],te.vertices[W+2]);z.applyMatrix4(Ne.transform),B.push(z.x,z.y,z.z)}const H=hV({vertices:B,triangles:te.triangles});G.has(Je)||G.set(Je,[]),G.get(Je).push(H)}}else for(const Ne of Z.values())for(const Re of Ne.meshes){const te=Re.extruder,Je=hV(Re);G.has(te)||G.set(te,[]),G.get(te).push(Je)}for(const[Ne,Re]of G){if(Re.length===0)continue;const te=Re.length===1?Re[0]:NOe(Re,!1);if(te){const Je=ie(Ne),B=new Bl(te,Je);U.add(B)}if(Re.length>1)for(const Je of Re)Je.dispose()}const ee=new Df().setFromObject(U),ne=ee.getCenter(new at);U.position.y=-ee.min.y,re.length===0&&(U.position.x=-ne.x,U.position.z=-ne.z),M.add(U);const se=new Df().setFromObject(U),de=se.getCenter(new at),he=se.getSize(new at),ge=Math.max(he.x,he.y,he.z)*1.8;S.position.set(de.x+ge*.7,de.y+ge*.5,de.z+ge*.7),E.target.copy(de),E.update(),d(!1)}).catch(Z=>{m(Z.message),d(!1)});const q=()=>{if(!v)return;const Z=v.clientWidth,re=v.clientHeight;S.aspect=Z/re,S.updateProjectionMatrix(),A.setSize(Z,re)};return window.addEventListener("resize",q),()=>{window.removeEventListener("resize",q),cancelAnimationFrame(K),E.dispose(),A.dispose(),v.removeChild(A.domElement)}},[t,e,n]);const p=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},x=v=>{l.current&&l.current.position.multiplyScalar(v)};return s.jsxs("div",{className:`relative ${r}`,children:[s.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),f&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("p",{className:"text-red-400",children:f})}),!u&&!f&&s.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:s.jsx(Whe,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:s.jsx(Xhe,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(Hf,{className:"w-4 h-4"})})]})]})}const FM="159",Km={ROTATE:0,DOLLY:1,PAN:2},Xm={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},POe=0,fV=1,ROe=2,lJ=1,DOe=2,Cc=3,Hd=0,hs=1,Lc=2,Ad=0,$p=1,mV=2,pV=3,gV=4,OOe=5,Fh=100,LOe=101,IOe=102,xV=103,bV=104,FOe=200,UOe=201,zOe=202,BOe=203,UP=204,zP=205,$Oe=206,HOe=207,VOe=208,GOe=209,WOe=210,qOe=211,KOe=212,XOe=213,YOe=214,QOe=0,ZOe=1,JOe=2,yS=3,eLe=4,tLe=5,nLe=6,rLe=7,NO=0,iLe=1,aLe=2,Td=0,sLe=1,oLe=2,lLe=3,cLe=4,uLe=5,cJ=300,mg=301,pg=302,BP=303,$P=304,UM=306,HP=1e3,qo=1001,VP=1002,ha=1003,yV=1004,QC=1005,xo=1006,dLe=1007,T0=1008,Cd=1009,hLe=1010,fLe=1011,EO=1012,uJ=1013,gd=1014,$c=1015,C0=1016,dJ=1017,hJ=1018,lf=1020,mLe=1021,bo=1023,pLe=1024,gLe=1025,cf=1026,gg=1027,xLe=1028,fJ=1029,bLe=1030,mJ=1031,pJ=1033,ZC=33776,JC=33777,ek=33778,tk=33779,vV=35840,_V=35841,wV=35842,SV=35843,gJ=36196,MV=37492,NV=37496,EV=37808,AV=37809,TV=37810,CV=37811,kV=37812,jV=37813,PV=37814,RV=37815,DV=37816,OV=37817,LV=37818,IV=37819,FV=37820,UV=37821,nk=36492,zV=36494,BV=36495,yLe=36283,$V=36284,HV=36285,VV=36286,xJ=3e3,uf=3001,vLe=3200,_Le=3201,bJ=0,wLe=1,yo="",fa="srgb",cu="srgb-linear",AO="display-p3",zM="display-p3-linear",vS="linear",Mr="srgb",_S="rec709",wS="p3",Ym=7680,GV=519,SLe=512,MLe=513,NLe=514,yJ=515,ELe=516,ALe=517,TLe=518,CLe=519,GP=35044,WV="300 es",WP=1035,Tl=2e3,k0=2001;class Xf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}}const wa=["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 qV=1234567;const Db=Math.PI/180,j0=180/Math.PI;function Xc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(wa[t&255]+wa[t>>8&255]+wa[t>>16&255]+wa[t>>24&255]+"-"+wa[e&255]+wa[e>>8&255]+"-"+wa[e>>16&15|64]+wa[e>>24&255]+"-"+wa[n&63|128]+wa[n>>8&255]+"-"+wa[n>>16&255]+wa[n>>24&255]+wa[r&255]+wa[r>>8&255]+wa[r>>16&255]+wa[r>>24&255]).toLowerCase()}function ma(t,e,n){return Math.max(e,Math.min(n,t))}function TO(t,e){return(t%e+e)%e}function kLe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function jLe(t,e,n){return t!==e?(n-t)/(e-t):0}function Ob(t,e,n){return(1-n)*t+n*e}function PLe(t,e,n,r){return Ob(t,e,1-Math.exp(-n*r))}function RLe(t,e=1){return e-Math.abs(TO(t,e*2)-e)}function DLe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function OLe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function LLe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function ILe(t,e){return t+Math.random()*(e-t)}function FLe(t){return t*(.5-Math.random())}function ULe(t){t!==void 0&&(qV=t);let e=qV+=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 zLe(t){return t*Db}function BLe(t){return t*j0}function qP(t){return(t&t-1)===0&&t!==0}function $Le(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function SS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function HLe(t,e,n,r,i){const a=Math.cos,o=Math.sin,l=a(n/2),c=o(n/2),u=a((e+r)/2),d=o((e+r)/2),f=a((e-r)/2),m=o((e-r)/2),p=a((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*m,l*u);break;case"YZY":t.set(c*m,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*m,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ml(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 or(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 vJ={DEG2RAD:Db,RAD2DEG:j0,generateUUID:Xc,clamp:ma,euclideanModulo:TO,mapLinear:kLe,inverseLerp:jLe,lerp:Ob,damp:PLe,pingpong:RLe,smoothstep:DLe,smootherstep:OLe,randInt:LLe,randFloat:ILe,randFloatSpread:FLe,seededRandom:ULe,degToRad:zLe,radToDeg:BLe,isPowerOfTwo:qP,ceilPowerOfTwo:$Le,floorPowerOfTwo:SS,setQuaternionFromProperEuler:HLe,normalize:or,denormalize:Ml};class rn{constructor(e=0,n=0){rn.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(ma(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class _n{constructor(e,n,r,i,a,o,l,c,u){_n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],m=r[2],p=r[5],x=r[8],v=i[0],b=i[3],y=i[6],M=i[1],S=i[4],A=i[7],E=i[2],k=i[5],C=i[8];return a[0]=o*v+l*M+c*E,a[3]=o*b+l*S+c*k,a[6]=o*y+l*A+c*C,a[1]=u*v+d*M+f*E,a[4]=u*b+d*S+f*k,a[7]=u*y+d*A+f*C,a[2]=m*v+p*M+x*E,a[5]=m*b+p*S+x*k,a[8]=m*y+p*A+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,m=l*c-d*a,p=u*a-o*c,x=n*f+r*m+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*o)*v,e[3]=m*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(o*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(rk.makeScale(e,n)),this}rotate(e){return this.premultiply(rk.makeRotation(-e)),this}translate(e,n){return this.premultiply(rk.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 rk=new _n;function _J(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function MS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function VLe(){const t=MS("canvas");return t.style.display="block",t}const KV={};function Lb(t){t in KV||(KV[t]=!0,console.warn(t))}const XV=new _n().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),YV=new _n().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),F_={[cu]:{transfer:vS,primaries:_S,toReference:t=>t,fromReference:t=>t},[fa]:{transfer:Mr,primaries:_S,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[zM]:{transfer:vS,primaries:wS,toReference:t=>t.applyMatrix3(YV),fromReference:t=>t.applyMatrix3(XV)},[AO]:{transfer:Mr,primaries:wS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(YV),fromReference:t=>t.applyMatrix3(XV).convertLinearToSRGB()}},GLe=new Set([cu,zM]),lr={enabled:!0,_workingColorSpace:cu,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(!GLe.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=F_[e].toReference,i=F_[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 F_[t].primaries},getTransfer:function(t){return t===yo?vS:F_[t].transfer}};function Hp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function ik(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Qm;class wJ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Qm===void 0&&(Qm=MS("canvas")),Qm.width=e.width,Qm.height=e.height;const r=Qm.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Qm}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=MS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Hp(a[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Hp(n[r]/255)*255):n[r]=Hp(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 WLe=0;class SJ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:WLe++}),this.uuid=Xc(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(ak(i[o].image)):a.push(ak(i[o]))}else a=ak(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function ak(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?wJ.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 qLe=0;class fs extends Xf{constructor(e=fs.DEFAULT_IMAGE,n=fs.DEFAULT_MAPPING,r=qo,i=qo,a=xo,o=T0,l=bo,c=Cd,u=fs.DEFAULT_ANISOTROPY,d=yo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:qLe++}),this.uuid=Xc(),this.name="",this.source=new SJ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new rn(0,0),this.repeat=new rn(1,1),this.center=new rn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new _n,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Lb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===uf?fa:yo),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!==cJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case HP:e.x=e.x-Math.floor(e.x);break;case qo:e.x=e.x<0?0:1;break;case VP: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 HP:e.y=e.y-Math.floor(e.y);break;case qo:e.y=e.y<0?0:1;break;case VP: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 Lb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===fa?uf:xJ}set encoding(e){Lb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===uf?fa:yo}}fs.DEFAULT_IMAGE=null;fs.DEFAULT_MAPPING=cJ;fs.DEFAULT_ANISOTROPY=1;class ur{constructor(e=0,n=0,r=0,i=1){ur.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],m=c[1],p=c[5],x=c[9],v=c[2],b=c[6],y=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-v)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+v)<.1&&Math.abs(x+b)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(p+1)/2,E=(y+1)/2,k=(d+m)/4,C=(f+v)/4,R=(x+b)/4;return S>A&&S>E?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=k/r,a=C/r):A>E?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=R/i):E<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(E),r=C/a,i=R/a),this.set(r,i,a,n),this}let M=Math.sqrt((b-x)*(b-x)+(f-v)*(f-v)+(m-d)*(m-d));return Math.abs(M)<.001&&(M=1),this.x=(b-x)/M,this.y=(f-v)/M,this.z=(m-d)/M,this.w=Math.acos((u+p+y-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 KLe extends Xf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new ur(0,0,e,n),this.scissorTest=!1,this.viewport=new ur(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Lb("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===uf?fa:yo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:xo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new fs(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 SJ(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 Of extends KLe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class MJ extends fs{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=ha,this.minFilter=ha,this.wrapR=qo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class XLe extends fs{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=ha,this.minFilter=ha,this.wrapR=qo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Lf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const m=a[o+0],p=a[o+1],x=a[o+2],v=a[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=m,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==m||u!==p||d!==x){let b=1-l;const y=c*m+u*p+d*x+f*v,M=y>=0?1:-1,S=1-y*y;if(S>Number.EPSILON){const E=Math.sqrt(S),k=Math.atan2(E,y*M);b=Math.sin(b*k)/E,l=Math.sin(l*k)/E}const A=l*M;if(c=c*b+m*A,u=u*b+p*A,d=d*b+x*A,f=f*b+v*A,b===1-l){const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],m=a[o+1],p=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*p-u*m,e[n+1]=c*x+d*m+u*f-l*p,e[n+2]=u*x+d*p+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),m=c(r/2),p=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"YXZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"ZXY":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"ZYX":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"YZX":this._x=m*d*f+u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f-m*p*x;break;case"XZY":this._x=m*d*f-u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f+m*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ma(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=a,this;const c=1-l*l;if(c<=Number.EPSILON){const p=1-n;return this._w=p*o+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,m=Math.sin(n*d)/u;return this._w=o*f+this._w*m,this._x=r*f+this._x*m,this._y=i*f+this._y*m,this._z=a*f+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ue{constructor(e=0,n=0,r=0){Ue.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(QV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(QV.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return sk.copy(this).projectOnVector(e),this.sub(sk)}reflect(e){return this.sub(sk.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(ma(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 sk=new Ue,QV=new Lf;class Mo{constructor(e=new Ue(1/0,1/0,1/0),n=new Ue(-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(zo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(zo.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=zo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,zo):zo.fromBufferAttribute(a,o),zo.applyMatrix4(e.matrixWorld),this.expandByPoint(zo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),U_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),U_.copy(r.boundingBox)),U_.applyMatrix4(e.matrixWorld),this.union(U_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,zo),zo.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(sb),z_.subVectors(this.max,sb),Zm.subVectors(e.a,sb),Jm.subVectors(e.b,sb),ep.subVectors(e.c,sb),Wu.subVectors(Jm,Zm),qu.subVectors(ep,Jm),Nh.subVectors(Zm,ep);let n=[0,-Wu.z,Wu.y,0,-qu.z,qu.y,0,-Nh.z,Nh.y,Wu.z,0,-Wu.x,qu.z,0,-qu.x,Nh.z,0,-Nh.x,-Wu.y,Wu.x,0,-qu.y,qu.x,0,-Nh.y,Nh.x,0];return!ok(n,Zm,Jm,ep,z_)||(n=[1,0,0,0,1,0,0,0,1],!ok(n,Zm,Jm,ep,z_))?!1:(B_.crossVectors(Wu,qu),n=[B_.x,B_.y,B_.z],ok(n,Zm,Jm,ep,z_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,zo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(zo).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:(vc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),vc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),vc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),vc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),vc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),vc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),vc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),vc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(vc),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 vc=[new Ue,new Ue,new Ue,new Ue,new Ue,new Ue,new Ue,new Ue],zo=new Ue,U_=new Mo,Zm=new Ue,Jm=new Ue,ep=new Ue,Wu=new Ue,qu=new Ue,Nh=new Ue,sb=new Ue,z_=new Ue,B_=new Ue,Eh=new Ue;function ok(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Eh.fromArray(t,a);const l=i.x*Math.abs(Eh.x)+i.y*Math.abs(Eh.y)+i.z*Math.abs(Eh.z),c=e.dot(Eh),u=n.dot(Eh),d=r.dot(Eh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const YLe=new Mo,ob=new Ue,lk=new Ue;class jl{constructor(e=new Ue,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):YLe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ob.subVectors(e,this.center);const n=ob.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(ob,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):(lk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ob.copy(e.center).add(lk)),this.expandByPoint(ob.copy(e.center).sub(lk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const _c=new Ue,ck=new Ue,$_=new Ue,Ku=new Ue,uk=new Ue,H_=new Ue,dk=new Ue;class CO{constructor(e=new Ue,n=new Ue(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,_c)),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=_c.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(_c.copy(this.origin).addScaledVector(this.direction,n),_c.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){ck.copy(e).add(n).multiplyScalar(.5),$_.copy(n).sub(e).normalize(),Ku.copy(this.origin).sub(ck);const a=e.distanceTo(n)*.5,o=-this.direction.dot($_),l=Ku.dot(this.direction),c=-Ku.dot($_),u=Ku.lengthSq(),d=Math.abs(1-o*o);let f,m,p,x;if(d>0)if(f=o*c-l,m=o*l-c,x=a*d,f>=0)if(m>=-x)if(m<=x){const v=1/d;f*=v,m*=v,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-x?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(ck).addScaledVector($_,m),p}intersectSphere(e,n){_c.subVectors(e.center,this.origin);const r=_c.dot(this.direction),i=_c.dot(_c)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,_c)!==null}intersectTriangle(e,n,r,i,a){uk.subVectors(n,e),H_.subVectors(r,e),dk.crossVectors(uk,H_);let o=this.direction.dot(dk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Ku.subVectors(this.origin,e);const c=l*this.direction.dot(H_.crossVectors(Ku,H_));if(c<0)return null;const u=l*this.direction.dot(uk.cross(Ku));if(u<0||c+u>o)return null;const d=-l*Ku.dot(dk);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class vr{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,x,v,b){vr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,m,p,x,v,b)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,x,v,b){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=m,y[3]=p,y[7]=x,y[11]=v,y[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 vr().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/tp.setFromMatrixColumn(e,0).length(),a=1/tp.setFromMatrixColumn(e,1).length(),o=1/tp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const m=o*d,p=o*f,x=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=m-v*u,n[9]=-l*c,n[2]=v-m*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,x=u*d,v=u*f;n[0]=m+v*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=v+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,x=u*d,v=u*f;n[0]=m-v*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=v-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,x=l*d,v=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=m*u+v,n[1]=c*f,n[5]=v*u+m,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,x=l*c,v=l*u;n[0]=c*d,n[4]=v-m*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=m-v*f}else if(e.order==="XZY"){const m=o*c,p=o*u,x=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+v,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=v*f+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(QLe,e,ZLe)}lookAt(e,n,r){const i=this.elements;return Cs.subVectors(e,n),Cs.lengthSq()===0&&(Cs.z=1),Cs.normalize(),Xu.crossVectors(r,Cs),Xu.lengthSq()===0&&(Math.abs(r.z)===1?Cs.x+=1e-4:Cs.z+=1e-4,Cs.normalize(),Xu.crossVectors(r,Cs)),Xu.normalize(),V_.crossVectors(Cs,Xu),i[0]=Xu.x,i[4]=V_.x,i[8]=Cs.x,i[1]=Xu.y,i[5]=V_.y,i[9]=Cs.y,i[2]=Xu.z,i[6]=V_.z,i[10]=Cs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],m=r[9],p=r[13],x=r[2],v=r[6],b=r[10],y=r[14],M=r[3],S=r[7],A=r[11],E=r[15],k=i[0],C=i[4],R=i[8],T=i[12],P=i[1],F=i[5],I=i[9],X=i[13],D=i[2],K=i[6],Y=i[10],q=i[14],Z=i[3],re=i[7],ie=i[11],U=i[15];return a[0]=o*k+l*P+c*D+u*Z,a[4]=o*C+l*F+c*K+u*re,a[8]=o*R+l*I+c*Y+u*ie,a[12]=o*T+l*X+c*q+u*U,a[1]=d*k+f*P+m*D+p*Z,a[5]=d*C+f*F+m*K+p*re,a[9]=d*R+f*I+m*Y+p*ie,a[13]=d*T+f*X+m*q+p*U,a[2]=x*k+v*P+b*D+y*Z,a[6]=x*C+v*F+b*K+y*re,a[10]=x*R+v*I+b*Y+y*ie,a[14]=x*T+v*X+b*q+y*U,a[3]=M*k+S*P+A*D+E*Z,a[7]=M*C+S*F+A*K+E*re,a[11]=M*R+S*I+A*Y+E*ie,a[15]=M*T+S*X+A*q+E*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],p=e[14],x=e[3],v=e[7],b=e[11],y=e[15];return x*(+a*c*f-i*u*f-a*l*m+r*u*m+i*l*p-r*c*p)+v*(+n*c*p-n*u*m+a*o*m-i*o*p+i*u*d-a*c*d)+b*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+y*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],m=e[10],p=e[11],x=e[12],v=e[13],b=e[14],y=e[15],M=f*b*u-v*m*u+v*c*p-l*b*p-f*c*y+l*m*y,S=x*m*u-d*b*u-x*c*p+o*b*p+d*c*y-o*m*y,A=d*v*u-x*f*u+x*l*p-o*v*p-d*l*y+o*f*y,E=x*f*c-d*v*c-x*l*m+o*v*m+d*l*b-o*f*b,k=n*M+r*S+i*A+a*E;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=M*C,e[1]=(v*m*a-f*b*a-v*i*p+r*b*p+f*i*y-r*m*y)*C,e[2]=(l*b*a-v*c*a+v*i*u-r*b*u-l*i*y+r*c*y)*C,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*C,e[4]=S*C,e[5]=(d*b*a-x*m*a+x*i*p-n*b*p-d*i*y+n*m*y)*C,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*y-n*c*y)*C,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*C,e[8]=A*C,e[9]=(x*f*a-d*v*a-x*r*p+n*v*p+d*r*y-n*f*y)*C,e[10]=(o*v*a-x*l*a+x*r*u-n*v*u-o*r*y+n*l*y)*C,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*C,e[12]=E*C,e[13]=(d*v*i-x*f*i+x*r*m-n*v*m-d*r*b+n*f*b)*C,e[14]=(x*l*i-o*v*i-x*r*c+n*v*c+o*r*b-n*l*b)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,m=a*u,p=a*d,x=a*f,v=o*d,b=o*f,y=l*f,M=c*u,S=c*d,A=c*f,E=r.x,k=r.y,C=r.z;return i[0]=(1-(v+y))*E,i[1]=(p+A)*E,i[2]=(x-S)*E,i[3]=0,i[4]=(p-A)*k,i[5]=(1-(m+y))*k,i[6]=(b+M)*k,i[7]=0,i[8]=(x+S)*C,i[9]=(b-M)*C,i[10]=(1-(m+v))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=tp.set(i[0],i[1],i[2]).length();const o=tp.set(i[4],i[5],i[6]).length(),l=tp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Bo.copy(this);const u=1/a,d=1/o,f=1/l;return Bo.elements[0]*=u,Bo.elements[1]*=u,Bo.elements[2]*=u,Bo.elements[4]*=d,Bo.elements[5]*=d,Bo.elements[6]*=d,Bo.elements[8]*=f,Bo.elements[9]*=f,Bo.elements[10]*=f,n.setFromRotationMatrix(Bo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Tl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),m=(r+i)/(r-i);let p,x;if(l===Tl)p=-(o+a)/(o-a),x=-2*o*a/(o-a);else if(l===k0)p=-o/(o-a),x=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Tl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),m=(n+e)*u,p=(r+i)*d;let x,v;if(l===Tl)x=(o+a)*f,v=-2*f;else if(l===k0)x=a*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-m,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=v,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 tp=new Ue,Bo=new vr,QLe=new Ue(0,0,0),ZLe=new Ue(1,1,1),Xu=new Ue,V_=new Ue,Cs=new Ue,ZV=new vr,JV=new Lf;class Ey{constructor(e=0,n=0,r=0,i=Ey.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(ma(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-ma(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(ma(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-ma(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(ma(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-ma(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return ZV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ZV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return JV.setFromEuler(this),this.setFromQuaternion(JV,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ey.DEFAULT_ORDER="XYZ";class NJ{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 JLe=0;const e7=new Ue,np=new Lf,wc=new vr,G_=new Ue,lb=new Ue,eIe=new Ue,tIe=new Lf,t7=new Ue(1,0,0),n7=new Ue(0,1,0),r7=new Ue(0,0,1),nIe={type:"added"},rIe={type:"removed"};class $a extends Xf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:JLe++}),this.uuid=Xc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=$a.DEFAULT_UP.clone();const e=new Ue,n=new Ey,r=new Lf,i=new Ue(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new vr},normalMatrix:{value:new _n}}),this.matrix=new vr,this.matrixWorld=new vr,this.matrixAutoUpdate=$a.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=$a.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new NJ,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 np.setFromAxisAngle(e,n),this.quaternion.multiply(np),this}rotateOnWorldAxis(e,n){return np.setFromAxisAngle(e,n),this.quaternion.premultiply(np),this}rotateX(e){return this.rotateOnAxis(t7,e)}rotateY(e){return this.rotateOnAxis(n7,e)}rotateZ(e){return this.rotateOnAxis(r7,e)}translateOnAxis(e,n){return e7.copy(e).applyQuaternion(this.quaternion),this.position.add(e7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(t7,e)}translateY(e){return this.translateOnAxis(n7,e)}translateZ(e){return this.translateOnAxis(r7,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(wc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?G_.copy(e):G_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),lb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?wc.lookAt(lb,G_,this.up):wc.lookAt(G_,lb,this.up),this.quaternion.setFromRotationMatrix(wc),i&&(wc.extractRotation(i.matrixWorld),np.setFromRotationMatrix(wc),this.quaternion.premultiply(np.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(nIe)):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(rIe)),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),wc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),wc.multiply(e.parent.matrixWorld)),e.applyMatrix4(wc),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(lb,e,eIe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(lb,tIe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++){const l=i[a];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),m=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}$a.DEFAULT_UP=new Ue(0,1,0);$a.DEFAULT_MATRIX_AUTO_UPDATE=!0;$a.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const $o=new Ue,Sc=new Ue,hk=new Ue,Mc=new Ue,rp=new Ue,ip=new Ue,i7=new Ue,fk=new Ue,mk=new Ue,pk=new Ue;let W_=!1;class Ho{constructor(e=new Ue,n=new Ue,r=new Ue){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),$o.subVectors(e,n),i.cross($o);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){$o.subVectors(i,n),Sc.subVectors(r,n),hk.subVectors(e,n);const o=$o.dot($o),l=$o.dot(Sc),c=$o.dot(hk),u=Sc.dot(Sc),d=Sc.dot(hk),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const m=1/f,p=(u*c-l*d)*m,x=(o*d-l*c)*m;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Mc),Mc.x>=0&&Mc.y>=0&&Mc.x+Mc.y<=1}static getUV(e,n,r,i,a,o,l,c){return W_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),W_=!0),this.getInterpolation(e,n,r,i,a,o,l,c)}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Mc),c.setScalar(0),c.addScaledVector(a,Mc.x),c.addScaledVector(o,Mc.y),c.addScaledVector(l,Mc.z),c}static isFrontFacing(e,n,r,i){return $o.subVectors(r,n),Sc.subVectors(e,n),$o.cross(Sc).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 $o.subVectors(this.c,this.b),Sc.subVectors(this.a,this.b),$o.cross(Sc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ho.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ho.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return W_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),W_=!0),Ho.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Ho.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Ho.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ho.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;rp.subVectors(i,r),ip.subVectors(a,r),fk.subVectors(e,r);const c=rp.dot(fk),u=ip.dot(fk);if(c<=0&&u<=0)return n.copy(r);mk.subVectors(e,i);const d=rp.dot(mk),f=ip.dot(mk);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(rp,o);pk.subVectors(e,a);const p=rp.dot(pk),x=ip.dot(pk);if(x>=0&&p<=x)return n.copy(a);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(ip,l);const b=d*x-p*f;if(b<=0&&f-d>=0&&p-x>=0)return i7.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(i7,l);const y=1/(b+v+m);return o=v*y,l=m*y,n.copy(r).addScaledVector(rp,o).addScaledVector(ip,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const EJ={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},Yu={h:0,s:0,l:0},q_={h:0,s:0,l:0};function gk(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 qt=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=fa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,lr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=lr.workingColorSpace){return this.r=e,this.g=n,this.b=r,lr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=lr.workingColorSpace){if(e=TO(e,1),n=ma(n,0,1),r=ma(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=gk(o,a,e+1/3),this.g=gk(o,a,e),this.b=gk(o,a,e-1/3)}return lr.toWorkingColorSpace(this,i),this}setStyle(e,n=fa){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=fa){const r=EJ[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=Hp(e.r),this.g=Hp(e.g),this.b=Hp(e.b),this}copyLinearToSRGB(e){return this.r=ik(e.r),this.g=ik(e.g),this.b=ik(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=fa){return lr.fromWorkingColorSpace(Sa.copy(this),e),Math.round(ma(Sa.r*255,0,255))*65536+Math.round(ma(Sa.g*255,0,255))*256+Math.round(ma(Sa.b*255,0,255))}getHexString(e=fa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=lr.workingColorSpace){lr.fromWorkingColorSpace(Sa.copy(this),n);const r=Sa.r,i=Sa.g,a=Sa.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=lr.workingColorSpace){return lr.fromWorkingColorSpace(Sa.copy(this),n),e.r=Sa.r,e.g=Sa.g,e.b=Sa.b,e}getStyle(e=fa){lr.fromWorkingColorSpace(Sa.copy(this),e);const n=Sa.r,r=Sa.g,i=Sa.b;return e!==fa?`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(Yu),this.setHSL(Yu.h+e,Yu.s+n,Yu.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(Yu),e.getHSL(q_);const r=Ob(Yu.h,q_.h,n),i=Ob(Yu.s,q_.s,n),a=Ob(Yu.l,q_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Sa=new qt;qt.NAMES=EJ;let iIe=0;class qg extends Xf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:iIe++}),this.uuid=Xc(),this.name="",this.type="Material",this.blending=$p,this.side=Hd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=UP,this.blendDst=zP,this.blendEquation=Fh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qt(0,0,0),this.blendAlpha=0,this.depthFunc=yS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=GV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ym,this.stencilZFail=Ym,this.stencilZPass=Ym,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!==$p&&(r.blending=this.blending),this.side!==Hd&&(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!==UP&&(r.blendSrc=this.blendSrc),this.blendDst!==zP&&(r.blendDst=this.blendDst),this.blendEquation!==Fh&&(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!==yS&&(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!==GV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ym&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Ym&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Ym&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class AJ extends qg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qt(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=NO,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 hi=new Ue,K_=new rn;class Bs{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=GP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=$c,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)K_.fromBufferAttribute(this,n),K_.applyMatrix3(e),this.setXY(n,K_.x,K_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)hi.fromBufferAttribute(this,n),hi.applyMatrix3(e),this.setXYZ(n,hi.x,hi.y,hi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)hi.fromBufferAttribute(this,n),hi.applyMatrix4(e),this.setXYZ(n,hi.x,hi.y,hi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)hi.fromBufferAttribute(this,n),hi.applyNormalMatrix(e),this.setXYZ(n,hi.x,hi.y,hi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)hi.fromBufferAttribute(this,n),hi.transformDirection(e),this.setXYZ(n,hi.x,hi.y,hi.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=Ml(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=or(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Ml(n,this.array)),n}setX(e,n){return this.normalized&&(n=or(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Ml(n,this.array)),n}setY(e,n){return this.normalized&&(n=or(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=Ml(n,this.array)),n}setZ(e,n){return this.normalized&&(n=or(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=Ml(n,this.array)),n}setW(e,n){return this.normalized&&(n=or(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=or(n,this.array),r=or(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=or(n,this.array),r=or(r,this.array),i=or(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=or(n,this.array),r=or(r,this.array),i=or(i,this.array),a=or(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==GP&&(e.usage=this.usage),e}}class TJ extends Bs{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class CJ extends Bs{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class si extends Bs{constructor(e,n,r){super(new Float32Array(e),n,r)}}let aIe=0;const so=new vr,xk=new $a,ap=new Ue,ks=new Mo,cb=new Mo,Bi=new Ue;class Pa extends Xf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:aIe++}),this.uuid=Xc(),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(_J(e)?CJ:TJ)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new _n().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return so.makeRotationFromQuaternion(e),this.applyMatrix4(so),this}rotateX(e){return so.makeRotationX(e),this.applyMatrix4(so),this}rotateY(e){return so.makeRotationY(e),this.applyMatrix4(so),this}rotateZ(e){return so.makeRotationZ(e),this.applyMatrix4(so),this}translate(e,n,r){return so.makeTranslation(e,n,r),this.applyMatrix4(so),this}scale(e,n,r){return so.makeScale(e,n,r),this.applyMatrix4(so),this}lookAt(e){return xk.lookAt(e),xk.updateMatrix(),this.applyMatrix4(xk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ap).negate(),this.translate(ap.x,ap.y,ap.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new si(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Mo);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 Ue(-1/0,-1/0,-1/0),new Ue(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ks.setFromBufferAttribute(a),this.morphTargetsRelative?(Bi.addVectors(this.boundingBox.min,ks.min),this.boundingBox.expandByPoint(Bi),Bi.addVectors(this.boundingBox.max,ks.max),this.boundingBox.expandByPoint(Bi)):(this.boundingBox.expandByPoint(ks.min),this.boundingBox.expandByPoint(ks.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 jl);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 Ue,1/0);return}if(e){const r=this.boundingSphere.center;if(ks.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];cb.setFromBufferAttribute(l),this.morphTargetsRelative?(Bi.addVectors(ks.min,cb.min),ks.expandByPoint(Bi),Bi.addVectors(ks.max,cb.max),ks.expandByPoint(Bi)):(ks.expandByPoint(cb.min),ks.expandByPoint(cb.max))}ks.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Bi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Bi));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Bi.fromBufferAttribute(l,u),c&&(ap.fromBufferAttribute(e,u),Bi.add(ap)),i=Math.max(i,r.distanceToSquared(Bi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Bs(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let P=0;P<l;P++)u[P]=new Ue,d[P]=new Ue;const f=new Ue,m=new Ue,p=new Ue,x=new rn,v=new rn,b=new rn,y=new Ue,M=new Ue;function S(P,F,I){f.fromArray(i,P*3),m.fromArray(i,F*3),p.fromArray(i,I*3),x.fromArray(o,P*2),v.fromArray(o,F*2),b.fromArray(o,I*2),m.sub(f),p.sub(f),v.sub(x),b.sub(x);const X=1/(v.x*b.y-b.x*v.y);isFinite(X)&&(y.copy(m).multiplyScalar(b.y).addScaledVector(p,-v.y).multiplyScalar(X),M.copy(p).multiplyScalar(v.x).addScaledVector(m,-b.x).multiplyScalar(X),u[P].add(y),u[F].add(y),u[I].add(y),d[P].add(M),d[F].add(M),d[I].add(M))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let P=0,F=A.length;P<F;++P){const I=A[P],X=I.start,D=I.count;for(let K=X,Y=X+D;K<Y;K+=3)S(r[K+0],r[K+1],r[K+2])}const E=new Ue,k=new Ue,C=new Ue,R=new Ue;function T(P){C.fromArray(a,P*3),R.copy(C);const F=u[P];E.copy(F),E.sub(C.multiplyScalar(C.dot(F))).normalize(),k.crossVectors(R,F);const X=k.dot(d[P])<0?-1:1;c[P*4]=E.x,c[P*4+1]=E.y,c[P*4+2]=E.z,c[P*4+3]=X}for(let P=0,F=A.length;P<F;++P){const I=A[P],X=I.start,D=I.count;for(let K=X,Y=X+D;K<Y;K+=3)T(r[K+0]),T(r[K+1]),T(r[K+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Bs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new Ue,a=new Ue,o=new Ue,l=new Ue,c=new Ue,u=new Ue,d=new Ue,f=new Ue;if(e)for(let m=0,p=e.count;m<p;m+=3){const x=e.getX(m+0),v=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),o.fromBufferAttribute(n,b),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Bi.fromBufferAttribute(e,n),Bi.normalize(),e.setXYZ(n,Bi.x,Bi.y,Bi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,b=c.length;v<b;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let y=0;y<d;y++)m[x++]=u[p++]}return new Bs(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Pa,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const m=u[d],p=e(m,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let m=0,p=f.length;m<p;m++)d.push(f[m].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const a7=new vr,Ah=new CO,X_=new jl,s7=new Ue,sp=new Ue,op=new Ue,lp=new Ue,bk=new Ue,Y_=new Ue,Q_=new rn,Z_=new rn,J_=new rn,o7=new Ue,l7=new Ue,c7=new Ue,e1=new Ue,t1=new Ue;class Yo extends $a{constructor(e=new Pa,n=new AJ){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){Y_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(bk.fromBufferAttribute(f,e),o?Y_.addScaledVector(bk,d):Y_.addScaledVector(bk.sub(n),d))}n.add(Y_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),X_.copy(r.boundingSphere),X_.applyMatrix4(a),Ah.copy(e.ray).recast(e.near),!(X_.containsPoint(Ah.origin)===!1&&(Ah.intersectSphere(X_,s7)===null||Ah.origin.distanceToSquared(s7)>(e.far-e.near)**2))&&(a7.copy(a).invert(),Ah.copy(e.ray).applyMatrix4(a7),!(r.boundingBox!==null&&Ah.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Ah)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,v=m.length;x<v;x++){const b=m[x],y=o[b.materialIndex],M=Math.max(b.start,p.start),S=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let A=M,E=S;A<E;A+=3){const k=l.getX(A),C=l.getX(A+1),R=l.getX(A+2);i=n1(this,y,e,r,u,d,f,k,C,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let b=x,y=v;b<y;b+=3){const M=l.getX(b),S=l.getX(b+1),A=l.getX(b+2);i=n1(this,o,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,v=m.length;x<v;x++){const b=m[x],y=o[b.materialIndex],M=Math.max(b.start,p.start),S=Math.min(c.count,Math.min(b.start+b.count,p.start+p.count));for(let A=M,E=S;A<E;A+=3){const k=A,C=A+1,R=A+2;i=n1(this,y,e,r,u,d,f,k,C,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let b=x,y=v;b<y;b+=3){const M=b,S=b+1,A=b+2;i=n1(this,o,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function sIe(t,e,n,r,i,a,o,l){let c;if(e.side===hs?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Hd,l),c===null)return null;t1.copy(l),t1.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(t1);return u<n.near||u>n.far?null:{distance:u,point:t1.clone(),object:t}}function n1(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,sp),t.getVertexPosition(c,op),t.getVertexPosition(u,lp);const d=sIe(t,e,n,r,sp,op,lp,e1);if(d){i&&(Q_.fromBufferAttribute(i,l),Z_.fromBufferAttribute(i,c),J_.fromBufferAttribute(i,u),d.uv=Ho.getInterpolation(e1,sp,op,lp,Q_,Z_,J_,new rn)),a&&(Q_.fromBufferAttribute(a,l),Z_.fromBufferAttribute(a,c),J_.fromBufferAttribute(a,u),d.uv1=Ho.getInterpolation(e1,sp,op,lp,Q_,Z_,J_,new rn),d.uv2=d.uv1),o&&(o7.fromBufferAttribute(o,l),l7.fromBufferAttribute(o,c),c7.fromBufferAttribute(o,u),d.normal=Ho.getInterpolation(e1,sp,op,lp,o7,l7,c7,new Ue),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new Ue,materialIndex:0};Ho.getNormal(sp,op,lp,f.normal),d.face=f}return d}class Ay extends Pa{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let m=0,p=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new si(u,3)),this.setAttribute("normal",new si(d,3)),this.setAttribute("uv",new si(f,2));function x(v,b,y,M,S,A,E,k,C,R,T){const P=A/C,F=E/R,I=A/2,X=E/2,D=k/2,K=C+1,Y=R+1;let q=0,Z=0;const re=new Ue;for(let ie=0;ie<Y;ie++){const U=ie*F-X;for(let G=0;G<K;G++){const ee=G*P-I;re[v]=ee*M,re[b]=U*S,re[y]=D,u.push(re.x,re.y,re.z),re[v]=0,re[b]=0,re[y]=k>0?1:-1,d.push(re.x,re.y,re.z),f.push(G/C),f.push(1-ie/R),q+=1}}for(let ie=0;ie<R;ie++)for(let U=0;U<C;U++){const G=m+U+K*ie,ee=m+U+K*(ie+1),ne=m+(U+1)+K*(ie+1),se=m+(U+1)+K*ie;c.push(G,ee,se),c.push(ee,ne,se),Z+=6}l.addGroup(p,Z,T),p+=Z,m+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ay(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function xg(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 Ia(t){const e={};for(let n=0;n<t.length;n++){const r=xg(t[n]);for(const i in r)e[i]=r[i]}return e}function oIe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function kJ(t){return t.getRenderTarget()===null?t.outputColorSpace:lr.workingColorSpace}const kO={clone:xg,merge:Ia};var lIe=`void main() {
  3920. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3921. }`,cIe=`void main() {
  3922. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3923. }`;class Vd extends qg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=lIe,this.fragmentShader=cIe,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=xg(e.uniforms),this.uniformsGroups=oIe(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 jJ extends $a{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vr,this.projectionMatrix=new vr,this.projectionMatrixInverse=new vr,this.coordinateSystem=Tl}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 Ps extends jJ{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=j0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Db*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return j0*2*Math.atan(Math.tan(Db*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,a,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Db*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const cp=-90,up=1;class uIe extends $a{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ps(cp,up,e,n);i.layers=this.layers,this.add(i);const a=new Ps(cp,up,e,n);a.layers=this.layers,this.add(a);const o=new Ps(cp,up,e,n);o.layers=this.layers,this.add(o);const l=new Ps(cp,up,e,n);l.layers=this.layers,this.add(l);const c=new Ps(cp,up,e,n);c.layers=this.layers,this.add(c);const u=new Ps(cp,up,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===Tl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===k0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class PJ extends fs{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:mg,super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class dIe extends Of{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&&(Lb("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===uf?fa:yo),this.texture=new PJ(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:xo}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:`
  3924. varying vec3 vWorldDirection;
  3925. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3926. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3927. }
  3928. void main() {
  3929. vWorldDirection = transformDirection( position, modelMatrix );
  3930. #include <begin_vertex>
  3931. #include <project_vertex>
  3932. }
  3933. `,fragmentShader:`
  3934. uniform sampler2D tEquirect;
  3935. varying vec3 vWorldDirection;
  3936. #include <common>
  3937. void main() {
  3938. vec3 direction = normalize( vWorldDirection );
  3939. vec2 sampleUV = equirectUv( direction );
  3940. gl_FragColor = texture2D( tEquirect, sampleUV );
  3941. }
  3942. `},i=new Ay(5,5,5),a=new Vd({name:"CubemapFromEquirect",uniforms:xg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:hs,blending:Ad});a.uniforms.tEquirect.value=n;const o=new Yo(i,a),l=n.minFilter;return n.minFilter===T0&&(n.minFilter=xo),new uIe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}}const yk=new Ue,hIe=new Ue,fIe=new _n;class ad{constructor(e=new Ue(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=yk.subVectors(r,n).cross(hIe.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(yk),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||fIe.getNormalMatrix(e),i=this.coplanarPoint(yk).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Th=new jl,r1=new Ue;class BM{constructor(e=new ad,n=new ad,r=new ad,i=new ad,a=new ad,o=new ad){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Tl){const r=this.planes,i=e.elements,a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],m=i[7],p=i[8],x=i[9],v=i[10],b=i[11],y=i[12],M=i[13],S=i[14],A=i[15];if(r[0].setComponents(c-a,m-u,b-p,A-y).normalize(),r[1].setComponents(c+a,m+u,b+p,A+y).normalize(),r[2].setComponents(c+o,m+d,b+x,A+M).normalize(),r[3].setComponents(c-o,m-d,b-x,A-M).normalize(),r[4].setComponents(c-l,m-f,b-v,A-S).normalize(),n===Tl)r[5].setComponents(c+l,m+f,b+v,A+S).normalize();else if(n===k0)r[5].setComponents(l,f,v,S).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(),Th.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Th.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Th)}intersectsSprite(e){return Th.center.set(0,0,0),Th.radius=.7071067811865476,Th.applyMatrix4(e.matrixWorld),this.intersectsSphere(Th)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(r1.x=i.normal.x>0?e.max.x:e.min.x,r1.y=i.normal.y>0?e.max.y:e.min.y,r1.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(r1)<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 RJ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function mIe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,m=u.usage,p=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,m),u.onUploadCallback();let v;if(f instanceof Float32Array)v=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)v=t.SHORT;else if(f instanceof Uint32Array)v=t.UNSIGNED_INT;else if(f instanceof Int32Array)v=t.INT;else if(f instanceof Int8Array)v=t.BYTE;else if(f instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const m=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&x.length===0&&t.bufferSubData(f,0,m),x.length!==0){for(let v=0,b=x.length;v<b;v++){const y=x[v];n?t.bufferSubData(f,y.start*m.BYTES_PER_ELEMENT,m,y.start,y.count):t.bufferSubData(f,y.start*m.BYTES_PER_ELEMENT,m.subarray(y.start,y.start+y.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m,p.offset,p.count):t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m.subarray(p.offset,p.offset+p.count)),p.count=-1),d.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const m=r.get(u);(!m||m.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:o,remove:l,update:c}}class jO extends Pa{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,m=n/c,p=[],x=[],v=[],b=[];for(let y=0;y<d;y++){const M=y*m-o;for(let S=0;S<u;S++){const A=S*f-a;x.push(A,-M,0),v.push(0,0,1),b.push(S/l),b.push(1-y/c)}}for(let y=0;y<c;y++)for(let M=0;M<l;M++){const S=M+u*y,A=M+u*(y+1),E=M+1+u*(y+1),k=M+1+u*y;p.push(S,A,k),p.push(A,E,k)}this.setIndex(p),this.setAttribute("position",new si(x,3)),this.setAttribute("normal",new si(v,3)),this.setAttribute("uv",new si(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jO(e.width,e.height,e.widthSegments,e.heightSegments)}}var pIe=`#ifdef USE_ALPHAHASH
  3943. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3944. #endif`,gIe=`#ifdef USE_ALPHAHASH
  3945. const float ALPHA_HASH_SCALE = 0.05;
  3946. float hash2D( vec2 value ) {
  3947. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3948. }
  3949. float hash3D( vec3 value ) {
  3950. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3951. }
  3952. float getAlphaHashThreshold( vec3 position ) {
  3953. float maxDeriv = max(
  3954. length( dFdx( position.xyz ) ),
  3955. length( dFdy( position.xyz ) )
  3956. );
  3957. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3958. vec2 pixScales = vec2(
  3959. exp2( floor( log2( pixScale ) ) ),
  3960. exp2( ceil( log2( pixScale ) ) )
  3961. );
  3962. vec2 alpha = vec2(
  3963. hash3D( floor( pixScales.x * position.xyz ) ),
  3964. hash3D( floor( pixScales.y * position.xyz ) )
  3965. );
  3966. float lerpFactor = fract( log2( pixScale ) );
  3967. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3968. float a = min( lerpFactor, 1.0 - lerpFactor );
  3969. vec3 cases = vec3(
  3970. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3971. ( x - 0.5 * a ) / ( 1.0 - a ),
  3972. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3973. );
  3974. float threshold = ( x < ( 1.0 - a ) )
  3975. ? ( ( x < a ) ? cases.x : cases.y )
  3976. : cases.z;
  3977. return clamp( threshold , 1.0e-6, 1.0 );
  3978. }
  3979. #endif`,xIe=`#ifdef USE_ALPHAMAP
  3980. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3981. #endif`,bIe=`#ifdef USE_ALPHAMAP
  3982. uniform sampler2D alphaMap;
  3983. #endif`,yIe=`#ifdef USE_ALPHATEST
  3984. if ( diffuseColor.a < alphaTest ) discard;
  3985. #endif`,vIe=`#ifdef USE_ALPHATEST
  3986. uniform float alphaTest;
  3987. #endif`,_Ie=`#ifdef USE_AOMAP
  3988. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3989. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3990. #if defined( USE_CLEARCOAT )
  3991. clearcoatSpecularIndirect *= ambientOcclusion;
  3992. #endif
  3993. #if defined( USE_SHEEN )
  3994. sheenSpecularIndirect *= ambientOcclusion;
  3995. #endif
  3996. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3997. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3998. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3999. #endif
  4000. #endif`,wIe=`#ifdef USE_AOMAP
  4001. uniform sampler2D aoMap;
  4002. uniform float aoMapIntensity;
  4003. #endif`,SIe=`#ifdef USE_BATCHING
  4004. attribute float batchId;
  4005. uniform highp sampler2D batchingTexture;
  4006. mat4 getBatchingMatrix( const in float i ) {
  4007. int size = textureSize( batchingTexture, 0 ).x;
  4008. int j = int( i ) * 4;
  4009. int x = j % size;
  4010. int y = j / size;
  4011. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  4012. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  4013. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  4014. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  4015. return mat4( v1, v2, v3, v4 );
  4016. }
  4017. #endif`,MIe=`#ifdef USE_BATCHING
  4018. mat4 batchingMatrix = getBatchingMatrix( batchId );
  4019. #endif`,NIe=`vec3 transformed = vec3( position );
  4020. #ifdef USE_ALPHAHASH
  4021. vPosition = vec3( position );
  4022. #endif`,EIe=`vec3 objectNormal = vec3( normal );
  4023. #ifdef USE_TANGENT
  4024. vec3 objectTangent = vec3( tangent.xyz );
  4025. #endif`,AIe=`float G_BlinnPhong_Implicit( ) {
  4026. return 0.25;
  4027. }
  4028. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  4029. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  4030. }
  4031. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  4032. vec3 halfDir = normalize( lightDir + viewDir );
  4033. float dotNH = saturate( dot( normal, halfDir ) );
  4034. float dotVH = saturate( dot( viewDir, halfDir ) );
  4035. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  4036. float G = G_BlinnPhong_Implicit( );
  4037. float D = D_BlinnPhong( shininess, dotNH );
  4038. return F * ( G * D );
  4039. } // validated`,TIe=`#ifdef USE_IRIDESCENCE
  4040. const mat3 XYZ_TO_REC709 = mat3(
  4041. 3.2404542, -0.9692660, 0.0556434,
  4042. -1.5371385, 1.8760108, -0.2040259,
  4043. -0.4985314, 0.0415560, 1.0572252
  4044. );
  4045. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  4046. vec3 sqrtF0 = sqrt( fresnel0 );
  4047. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  4048. }
  4049. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  4050. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  4051. }
  4052. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  4053. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  4054. }
  4055. vec3 evalSensitivity( float OPD, vec3 shift ) {
  4056. float phase = 2.0 * PI * OPD * 1.0e-9;
  4057. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  4058. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  4059. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  4060. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  4061. 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 ) );
  4062. xyz /= 1.0685e-7;
  4063. vec3 rgb = XYZ_TO_REC709 * xyz;
  4064. return rgb;
  4065. }
  4066. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  4067. vec3 I;
  4068. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  4069. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  4070. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  4071. if ( cosTheta2Sq < 0.0 ) {
  4072. return vec3( 1.0 );
  4073. }
  4074. float cosTheta2 = sqrt( cosTheta2Sq );
  4075. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  4076. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  4077. float T121 = 1.0 - R12;
  4078. float phi12 = 0.0;
  4079. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4080. float phi21 = PI - phi12;
  4081. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4082. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4083. vec3 phi23 = vec3( 0.0 );
  4084. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4085. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4086. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4087. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4088. vec3 phi = vec3( phi21 ) + phi23;
  4089. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4090. vec3 r123 = sqrt( R123 );
  4091. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4092. vec3 C0 = R12 + Rs;
  4093. I = C0;
  4094. vec3 Cm = Rs - T121;
  4095. for ( int m = 1; m <= 2; ++ m ) {
  4096. Cm *= r123;
  4097. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4098. I += Cm * Sm;
  4099. }
  4100. return max( I, vec3( 0.0 ) );
  4101. }
  4102. #endif`,CIe=`#ifdef USE_BUMPMAP
  4103. uniform sampler2D bumpMap;
  4104. uniform float bumpScale;
  4105. vec2 dHdxy_fwd() {
  4106. vec2 dSTdx = dFdx( vBumpMapUv );
  4107. vec2 dSTdy = dFdy( vBumpMapUv );
  4108. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4109. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4110. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4111. return vec2( dBx, dBy );
  4112. }
  4113. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4114. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4115. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4116. vec3 vN = surf_norm;
  4117. vec3 R1 = cross( vSigmaY, vN );
  4118. vec3 R2 = cross( vN, vSigmaX );
  4119. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4120. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4121. return normalize( abs( fDet ) * surf_norm - vGrad );
  4122. }
  4123. #endif`,kIe=`#if NUM_CLIPPING_PLANES > 0
  4124. vec4 plane;
  4125. #pragma unroll_loop_start
  4126. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4127. plane = clippingPlanes[ i ];
  4128. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4129. }
  4130. #pragma unroll_loop_end
  4131. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4132. bool clipped = true;
  4133. #pragma unroll_loop_start
  4134. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4135. plane = clippingPlanes[ i ];
  4136. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4137. }
  4138. #pragma unroll_loop_end
  4139. if ( clipped ) discard;
  4140. #endif
  4141. #endif`,jIe=`#if NUM_CLIPPING_PLANES > 0
  4142. varying vec3 vClipPosition;
  4143. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4144. #endif`,PIe=`#if NUM_CLIPPING_PLANES > 0
  4145. varying vec3 vClipPosition;
  4146. #endif`,RIe=`#if NUM_CLIPPING_PLANES > 0
  4147. vClipPosition = - mvPosition.xyz;
  4148. #endif`,DIe=`#if defined( USE_COLOR_ALPHA )
  4149. diffuseColor *= vColor;
  4150. #elif defined( USE_COLOR )
  4151. diffuseColor.rgb *= vColor;
  4152. #endif`,OIe=`#if defined( USE_COLOR_ALPHA )
  4153. varying vec4 vColor;
  4154. #elif defined( USE_COLOR )
  4155. varying vec3 vColor;
  4156. #endif`,LIe=`#if defined( USE_COLOR_ALPHA )
  4157. varying vec4 vColor;
  4158. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4159. varying vec3 vColor;
  4160. #endif`,IIe=`#if defined( USE_COLOR_ALPHA )
  4161. vColor = vec4( 1.0 );
  4162. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4163. vColor = vec3( 1.0 );
  4164. #endif
  4165. #ifdef USE_COLOR
  4166. vColor *= color;
  4167. #endif
  4168. #ifdef USE_INSTANCING_COLOR
  4169. vColor.xyz *= instanceColor.xyz;
  4170. #endif`,FIe=`#define PI 3.141592653589793
  4171. #define PI2 6.283185307179586
  4172. #define PI_HALF 1.5707963267948966
  4173. #define RECIPROCAL_PI 0.3183098861837907
  4174. #define RECIPROCAL_PI2 0.15915494309189535
  4175. #define EPSILON 1e-6
  4176. #ifndef saturate
  4177. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4178. #endif
  4179. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4180. float pow2( const in float x ) { return x*x; }
  4181. vec3 pow2( const in vec3 x ) { return x*x; }
  4182. float pow3( const in float x ) { return x*x*x; }
  4183. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4184. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4185. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4186. highp float rand( const in vec2 uv ) {
  4187. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4188. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4189. return fract( sin( sn ) * c );
  4190. }
  4191. #ifdef HIGH_PRECISION
  4192. float precisionSafeLength( vec3 v ) { return length( v ); }
  4193. #else
  4194. float precisionSafeLength( vec3 v ) {
  4195. float maxComponent = max3( abs( v ) );
  4196. return length( v / maxComponent ) * maxComponent;
  4197. }
  4198. #endif
  4199. struct IncidentLight {
  4200. vec3 color;
  4201. vec3 direction;
  4202. bool visible;
  4203. };
  4204. struct ReflectedLight {
  4205. vec3 directDiffuse;
  4206. vec3 directSpecular;
  4207. vec3 indirectDiffuse;
  4208. vec3 indirectSpecular;
  4209. };
  4210. #ifdef USE_ALPHAHASH
  4211. varying vec3 vPosition;
  4212. #endif
  4213. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4214. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4215. }
  4216. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4217. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4218. }
  4219. mat3 transposeMat3( const in mat3 m ) {
  4220. mat3 tmp;
  4221. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4222. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4223. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4224. return tmp;
  4225. }
  4226. float luminance( const in vec3 rgb ) {
  4227. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4228. return dot( weights, rgb );
  4229. }
  4230. bool isPerspectiveMatrix( mat4 m ) {
  4231. return m[ 2 ][ 3 ] == - 1.0;
  4232. }
  4233. vec2 equirectUv( in vec3 dir ) {
  4234. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4235. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4236. return vec2( u, v );
  4237. }
  4238. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4239. return RECIPROCAL_PI * diffuseColor;
  4240. }
  4241. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4242. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4243. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4244. }
  4245. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4246. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4247. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4248. } // validated`,UIe=`#ifdef ENVMAP_TYPE_CUBE_UV
  4249. #define cubeUV_minMipLevel 4.0
  4250. #define cubeUV_minTileSize 16.0
  4251. float getFace( vec3 direction ) {
  4252. vec3 absDirection = abs( direction );
  4253. float face = - 1.0;
  4254. if ( absDirection.x > absDirection.z ) {
  4255. if ( absDirection.x > absDirection.y )
  4256. face = direction.x > 0.0 ? 0.0 : 3.0;
  4257. else
  4258. face = direction.y > 0.0 ? 1.0 : 4.0;
  4259. } else {
  4260. if ( absDirection.z > absDirection.y )
  4261. face = direction.z > 0.0 ? 2.0 : 5.0;
  4262. else
  4263. face = direction.y > 0.0 ? 1.0 : 4.0;
  4264. }
  4265. return face;
  4266. }
  4267. vec2 getUV( vec3 direction, float face ) {
  4268. vec2 uv;
  4269. if ( face == 0.0 ) {
  4270. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4271. } else if ( face == 1.0 ) {
  4272. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4273. } else if ( face == 2.0 ) {
  4274. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4275. } else if ( face == 3.0 ) {
  4276. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4277. } else if ( face == 4.0 ) {
  4278. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4279. } else {
  4280. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4281. }
  4282. return 0.5 * ( uv + 1.0 );
  4283. }
  4284. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4285. float face = getFace( direction );
  4286. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4287. mipInt = max( mipInt, cubeUV_minMipLevel );
  4288. float faceSize = exp2( mipInt );
  4289. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4290. if ( face > 2.0 ) {
  4291. uv.y += faceSize;
  4292. face -= 3.0;
  4293. }
  4294. uv.x += face * faceSize;
  4295. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4296. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4297. uv.x *= CUBEUV_TEXEL_WIDTH;
  4298. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4299. #ifdef texture2DGradEXT
  4300. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4301. #else
  4302. return texture2D( envMap, uv ).rgb;
  4303. #endif
  4304. }
  4305. #define cubeUV_r0 1.0
  4306. #define cubeUV_v0 0.339
  4307. #define cubeUV_m0 - 2.0
  4308. #define cubeUV_r1 0.8
  4309. #define cubeUV_v1 0.276
  4310. #define cubeUV_m1 - 1.0
  4311. #define cubeUV_r4 0.4
  4312. #define cubeUV_v4 0.046
  4313. #define cubeUV_m4 2.0
  4314. #define cubeUV_r5 0.305
  4315. #define cubeUV_v5 0.016
  4316. #define cubeUV_m5 3.0
  4317. #define cubeUV_r6 0.21
  4318. #define cubeUV_v6 0.0038
  4319. #define cubeUV_m6 4.0
  4320. float roughnessToMip( float roughness ) {
  4321. float mip = 0.0;
  4322. if ( roughness >= cubeUV_r1 ) {
  4323. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4324. } else if ( roughness >= cubeUV_r4 ) {
  4325. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4326. } else if ( roughness >= cubeUV_r5 ) {
  4327. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4328. } else if ( roughness >= cubeUV_r6 ) {
  4329. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4330. } else {
  4331. mip = - 2.0 * log2( 1.16 * roughness ); }
  4332. return mip;
  4333. }
  4334. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4335. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4336. float mipF = fract( mip );
  4337. float mipInt = floor( mip );
  4338. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4339. if ( mipF == 0.0 ) {
  4340. return vec4( color0, 1.0 );
  4341. } else {
  4342. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4343. return vec4( mix( color0, color1, mipF ), 1.0 );
  4344. }
  4345. }
  4346. #endif`,zIe=`vec3 transformedNormal = objectNormal;
  4347. #ifdef USE_TANGENT
  4348. vec3 transformedTangent = objectTangent;
  4349. #endif
  4350. #ifdef USE_BATCHING
  4351. mat3 bm = mat3( batchingMatrix );
  4352. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4353. transformedNormal = bm * transformedNormal;
  4354. #ifdef USE_TANGENT
  4355. transformedTangent = bm * transformedTangent;
  4356. #endif
  4357. #endif
  4358. #ifdef USE_INSTANCING
  4359. mat3 im = mat3( instanceMatrix );
  4360. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4361. transformedNormal = im * transformedNormal;
  4362. #ifdef USE_TANGENT
  4363. transformedTangent = im * transformedTangent;
  4364. #endif
  4365. #endif
  4366. transformedNormal = normalMatrix * transformedNormal;
  4367. #ifdef FLIP_SIDED
  4368. transformedNormal = - transformedNormal;
  4369. #endif
  4370. #ifdef USE_TANGENT
  4371. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4372. #ifdef FLIP_SIDED
  4373. transformedTangent = - transformedTangent;
  4374. #endif
  4375. #endif`,BIe=`#ifdef USE_DISPLACEMENTMAP
  4376. uniform sampler2D displacementMap;
  4377. uniform float displacementScale;
  4378. uniform float displacementBias;
  4379. #endif`,$Ie=`#ifdef USE_DISPLACEMENTMAP
  4380. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4381. #endif`,HIe=`#ifdef USE_EMISSIVEMAP
  4382. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4383. totalEmissiveRadiance *= emissiveColor.rgb;
  4384. #endif`,VIe=`#ifdef USE_EMISSIVEMAP
  4385. uniform sampler2D emissiveMap;
  4386. #endif`,GIe="gl_FragColor = linearToOutputTexel( gl_FragColor );",WIe=`
  4387. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4388. vec3( 0.8224621, 0.177538, 0.0 ),
  4389. vec3( 0.0331941, 0.9668058, 0.0 ),
  4390. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4391. );
  4392. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4393. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4394. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4395. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4396. );
  4397. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4398. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4399. }
  4400. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4401. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4402. }
  4403. vec4 LinearTransferOETF( in vec4 value ) {
  4404. return value;
  4405. }
  4406. vec4 sRGBTransferOETF( in vec4 value ) {
  4407. 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 );
  4408. }
  4409. vec4 LinearToLinear( in vec4 value ) {
  4410. return value;
  4411. }
  4412. vec4 LinearTosRGB( in vec4 value ) {
  4413. return sRGBTransferOETF( value );
  4414. }`,qIe=`#ifdef USE_ENVMAP
  4415. #ifdef ENV_WORLDPOS
  4416. vec3 cameraToFrag;
  4417. if ( isOrthographic ) {
  4418. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4419. } else {
  4420. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4421. }
  4422. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4423. #ifdef ENVMAP_MODE_REFLECTION
  4424. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4425. #else
  4426. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4427. #endif
  4428. #else
  4429. vec3 reflectVec = vReflect;
  4430. #endif
  4431. #ifdef ENVMAP_TYPE_CUBE
  4432. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4433. #else
  4434. vec4 envColor = vec4( 0.0 );
  4435. #endif
  4436. #ifdef ENVMAP_BLENDING_MULTIPLY
  4437. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4438. #elif defined( ENVMAP_BLENDING_MIX )
  4439. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4440. #elif defined( ENVMAP_BLENDING_ADD )
  4441. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4442. #endif
  4443. #endif`,KIe=`#ifdef USE_ENVMAP
  4444. uniform float envMapIntensity;
  4445. uniform float flipEnvMap;
  4446. #ifdef ENVMAP_TYPE_CUBE
  4447. uniform samplerCube envMap;
  4448. #else
  4449. uniform sampler2D envMap;
  4450. #endif
  4451. #endif`,XIe=`#ifdef USE_ENVMAP
  4452. uniform float reflectivity;
  4453. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4454. #define ENV_WORLDPOS
  4455. #endif
  4456. #ifdef ENV_WORLDPOS
  4457. varying vec3 vWorldPosition;
  4458. uniform float refractionRatio;
  4459. #else
  4460. varying vec3 vReflect;
  4461. #endif
  4462. #endif`,YIe=`#ifdef USE_ENVMAP
  4463. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4464. #define ENV_WORLDPOS
  4465. #endif
  4466. #ifdef ENV_WORLDPOS
  4467. varying vec3 vWorldPosition;
  4468. #else
  4469. varying vec3 vReflect;
  4470. uniform float refractionRatio;
  4471. #endif
  4472. #endif`,QIe=`#ifdef USE_ENVMAP
  4473. #ifdef ENV_WORLDPOS
  4474. vWorldPosition = worldPosition.xyz;
  4475. #else
  4476. vec3 cameraToVertex;
  4477. if ( isOrthographic ) {
  4478. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4479. } else {
  4480. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4481. }
  4482. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4483. #ifdef ENVMAP_MODE_REFLECTION
  4484. vReflect = reflect( cameraToVertex, worldNormal );
  4485. #else
  4486. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4487. #endif
  4488. #endif
  4489. #endif`,ZIe=`#ifdef USE_FOG
  4490. vFogDepth = - mvPosition.z;
  4491. #endif`,JIe=`#ifdef USE_FOG
  4492. varying float vFogDepth;
  4493. #endif`,e5e=`#ifdef USE_FOG
  4494. #ifdef FOG_EXP2
  4495. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4496. #else
  4497. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4498. #endif
  4499. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4500. #endif`,t5e=`#ifdef USE_FOG
  4501. uniform vec3 fogColor;
  4502. varying float vFogDepth;
  4503. #ifdef FOG_EXP2
  4504. uniform float fogDensity;
  4505. #else
  4506. uniform float fogNear;
  4507. uniform float fogFar;
  4508. #endif
  4509. #endif`,n5e=`#ifdef USE_GRADIENTMAP
  4510. uniform sampler2D gradientMap;
  4511. #endif
  4512. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4513. float dotNL = dot( normal, lightDirection );
  4514. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4515. #ifdef USE_GRADIENTMAP
  4516. return vec3( texture2D( gradientMap, coord ).r );
  4517. #else
  4518. vec2 fw = fwidth( coord ) * 0.5;
  4519. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4520. #endif
  4521. }`,r5e=`#ifdef USE_LIGHTMAP
  4522. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4523. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4524. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4525. #endif`,i5e=`#ifdef USE_LIGHTMAP
  4526. uniform sampler2D lightMap;
  4527. uniform float lightMapIntensity;
  4528. #endif`,a5e=`LambertMaterial material;
  4529. material.diffuseColor = diffuseColor.rgb;
  4530. material.specularStrength = specularStrength;`,s5e=`varying vec3 vViewPosition;
  4531. struct LambertMaterial {
  4532. vec3 diffuseColor;
  4533. float specularStrength;
  4534. };
  4535. 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 ) {
  4536. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4537. vec3 irradiance = dotNL * directLight.color;
  4538. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4539. }
  4540. 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 ) {
  4541. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4542. }
  4543. #define RE_Direct RE_Direct_Lambert
  4544. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,o5e=`uniform bool receiveShadow;
  4545. uniform vec3 ambientLightColor;
  4546. #if defined( USE_LIGHT_PROBES )
  4547. uniform vec3 lightProbe[ 9 ];
  4548. #endif
  4549. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4550. float x = normal.x, y = normal.y, z = normal.z;
  4551. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4552. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4553. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4554. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4555. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4556. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4557. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4558. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4559. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4560. return result;
  4561. }
  4562. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4563. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4564. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4565. return irradiance;
  4566. }
  4567. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4568. vec3 irradiance = ambientLightColor;
  4569. return irradiance;
  4570. }
  4571. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4572. #if defined ( LEGACY_LIGHTS )
  4573. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4574. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4575. }
  4576. return 1.0;
  4577. #else
  4578. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4579. if ( cutoffDistance > 0.0 ) {
  4580. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4581. }
  4582. return distanceFalloff;
  4583. #endif
  4584. }
  4585. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4586. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4587. }
  4588. #if NUM_DIR_LIGHTS > 0
  4589. struct DirectionalLight {
  4590. vec3 direction;
  4591. vec3 color;
  4592. };
  4593. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4594. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4595. light.color = directionalLight.color;
  4596. light.direction = directionalLight.direction;
  4597. light.visible = true;
  4598. }
  4599. #endif
  4600. #if NUM_POINT_LIGHTS > 0
  4601. struct PointLight {
  4602. vec3 position;
  4603. vec3 color;
  4604. float distance;
  4605. float decay;
  4606. };
  4607. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4608. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4609. vec3 lVector = pointLight.position - geometryPosition;
  4610. light.direction = normalize( lVector );
  4611. float lightDistance = length( lVector );
  4612. light.color = pointLight.color;
  4613. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4614. light.visible = ( light.color != vec3( 0.0 ) );
  4615. }
  4616. #endif
  4617. #if NUM_SPOT_LIGHTS > 0
  4618. struct SpotLight {
  4619. vec3 position;
  4620. vec3 direction;
  4621. vec3 color;
  4622. float distance;
  4623. float decay;
  4624. float coneCos;
  4625. float penumbraCos;
  4626. };
  4627. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4628. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4629. vec3 lVector = spotLight.position - geometryPosition;
  4630. light.direction = normalize( lVector );
  4631. float angleCos = dot( light.direction, spotLight.direction );
  4632. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4633. if ( spotAttenuation > 0.0 ) {
  4634. float lightDistance = length( lVector );
  4635. light.color = spotLight.color * spotAttenuation;
  4636. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4637. light.visible = ( light.color != vec3( 0.0 ) );
  4638. } else {
  4639. light.color = vec3( 0.0 );
  4640. light.visible = false;
  4641. }
  4642. }
  4643. #endif
  4644. #if NUM_RECT_AREA_LIGHTS > 0
  4645. struct RectAreaLight {
  4646. vec3 color;
  4647. vec3 position;
  4648. vec3 halfWidth;
  4649. vec3 halfHeight;
  4650. };
  4651. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4652. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4653. #endif
  4654. #if NUM_HEMI_LIGHTS > 0
  4655. struct HemisphereLight {
  4656. vec3 direction;
  4657. vec3 skyColor;
  4658. vec3 groundColor;
  4659. };
  4660. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4661. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4662. float dotNL = dot( normal, hemiLight.direction );
  4663. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4664. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4665. return irradiance;
  4666. }
  4667. #endif`,l5e=`#ifdef USE_ENVMAP
  4668. vec3 getIBLIrradiance( const in vec3 normal ) {
  4669. #ifdef ENVMAP_TYPE_CUBE_UV
  4670. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4671. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4672. return PI * envMapColor.rgb * envMapIntensity;
  4673. #else
  4674. return vec3( 0.0 );
  4675. #endif
  4676. }
  4677. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4678. #ifdef ENVMAP_TYPE_CUBE_UV
  4679. vec3 reflectVec = reflect( - viewDir, normal );
  4680. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4681. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4682. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4683. return envMapColor.rgb * envMapIntensity;
  4684. #else
  4685. return vec3( 0.0 );
  4686. #endif
  4687. }
  4688. #ifdef USE_ANISOTROPY
  4689. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4690. #ifdef ENVMAP_TYPE_CUBE_UV
  4691. vec3 bentNormal = cross( bitangent, viewDir );
  4692. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4693. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4694. return getIBLRadiance( viewDir, bentNormal, roughness );
  4695. #else
  4696. return vec3( 0.0 );
  4697. #endif
  4698. }
  4699. #endif
  4700. #endif`,c5e=`ToonMaterial material;
  4701. material.diffuseColor = diffuseColor.rgb;`,u5e=`varying vec3 vViewPosition;
  4702. struct ToonMaterial {
  4703. vec3 diffuseColor;
  4704. };
  4705. 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 ) {
  4706. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4707. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4708. }
  4709. 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 ) {
  4710. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4711. }
  4712. #define RE_Direct RE_Direct_Toon
  4713. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,d5e=`BlinnPhongMaterial material;
  4714. material.diffuseColor = diffuseColor.rgb;
  4715. material.specularColor = specular;
  4716. material.specularShininess = shininess;
  4717. material.specularStrength = specularStrength;`,h5e=`varying vec3 vViewPosition;
  4718. struct BlinnPhongMaterial {
  4719. vec3 diffuseColor;
  4720. vec3 specularColor;
  4721. float specularShininess;
  4722. float specularStrength;
  4723. };
  4724. 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 ) {
  4725. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4726. vec3 irradiance = dotNL * directLight.color;
  4727. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4728. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4729. }
  4730. 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 ) {
  4731. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4732. }
  4733. #define RE_Direct RE_Direct_BlinnPhong
  4734. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,f5e=`PhysicalMaterial material;
  4735. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4736. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4737. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4738. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4739. material.roughness = min( material.roughness, 1.0 );
  4740. #ifdef IOR
  4741. material.ior = ior;
  4742. #ifdef USE_SPECULAR
  4743. float specularIntensityFactor = specularIntensity;
  4744. vec3 specularColorFactor = specularColor;
  4745. #ifdef USE_SPECULAR_COLORMAP
  4746. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4747. #endif
  4748. #ifdef USE_SPECULAR_INTENSITYMAP
  4749. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4750. #endif
  4751. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4752. #else
  4753. float specularIntensityFactor = 1.0;
  4754. vec3 specularColorFactor = vec3( 1.0 );
  4755. material.specularF90 = 1.0;
  4756. #endif
  4757. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4758. #else
  4759. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4760. material.specularF90 = 1.0;
  4761. #endif
  4762. #ifdef USE_CLEARCOAT
  4763. material.clearcoat = clearcoat;
  4764. material.clearcoatRoughness = clearcoatRoughness;
  4765. material.clearcoatF0 = vec3( 0.04 );
  4766. material.clearcoatF90 = 1.0;
  4767. #ifdef USE_CLEARCOATMAP
  4768. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4769. #endif
  4770. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4771. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4772. #endif
  4773. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4774. material.clearcoatRoughness += geometryRoughness;
  4775. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4776. #endif
  4777. #ifdef USE_IRIDESCENCE
  4778. material.iridescence = iridescence;
  4779. material.iridescenceIOR = iridescenceIOR;
  4780. #ifdef USE_IRIDESCENCEMAP
  4781. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4782. #endif
  4783. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4784. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4785. #else
  4786. material.iridescenceThickness = iridescenceThicknessMaximum;
  4787. #endif
  4788. #endif
  4789. #ifdef USE_SHEEN
  4790. material.sheenColor = sheenColor;
  4791. #ifdef USE_SHEEN_COLORMAP
  4792. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4793. #endif
  4794. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4795. #ifdef USE_SHEEN_ROUGHNESSMAP
  4796. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4797. #endif
  4798. #endif
  4799. #ifdef USE_ANISOTROPY
  4800. #ifdef USE_ANISOTROPYMAP
  4801. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4802. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4803. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4804. #else
  4805. vec2 anisotropyV = anisotropyVector;
  4806. #endif
  4807. material.anisotropy = length( anisotropyV );
  4808. if( material.anisotropy == 0.0 ) {
  4809. anisotropyV = vec2( 1.0, 0.0 );
  4810. } else {
  4811. anisotropyV /= material.anisotropy;
  4812. material.anisotropy = saturate( material.anisotropy );
  4813. }
  4814. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4815. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4816. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4817. #endif`,m5e=`struct PhysicalMaterial {
  4818. vec3 diffuseColor;
  4819. float roughness;
  4820. vec3 specularColor;
  4821. float specularF90;
  4822. #ifdef USE_CLEARCOAT
  4823. float clearcoat;
  4824. float clearcoatRoughness;
  4825. vec3 clearcoatF0;
  4826. float clearcoatF90;
  4827. #endif
  4828. #ifdef USE_IRIDESCENCE
  4829. float iridescence;
  4830. float iridescenceIOR;
  4831. float iridescenceThickness;
  4832. vec3 iridescenceFresnel;
  4833. vec3 iridescenceF0;
  4834. #endif
  4835. #ifdef USE_SHEEN
  4836. vec3 sheenColor;
  4837. float sheenRoughness;
  4838. #endif
  4839. #ifdef IOR
  4840. float ior;
  4841. #endif
  4842. #ifdef USE_TRANSMISSION
  4843. float transmission;
  4844. float transmissionAlpha;
  4845. float thickness;
  4846. float attenuationDistance;
  4847. vec3 attenuationColor;
  4848. #endif
  4849. #ifdef USE_ANISOTROPY
  4850. float anisotropy;
  4851. float alphaT;
  4852. vec3 anisotropyT;
  4853. vec3 anisotropyB;
  4854. #endif
  4855. };
  4856. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4857. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4858. vec3 sheenSpecularDirect = vec3( 0.0 );
  4859. vec3 sheenSpecularIndirect = vec3(0.0 );
  4860. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4861. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4862. float x2 = x * x;
  4863. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4864. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4865. }
  4866. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4867. float a2 = pow2( alpha );
  4868. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4869. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4870. return 0.5 / max( gv + gl, EPSILON );
  4871. }
  4872. float D_GGX( const in float alpha, const in float dotNH ) {
  4873. float a2 = pow2( alpha );
  4874. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4875. return RECIPROCAL_PI * a2 / pow2( denom );
  4876. }
  4877. #ifdef USE_ANISOTROPY
  4878. 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 ) {
  4879. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4880. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4881. float v = 0.5 / ( gv + gl );
  4882. return saturate(v);
  4883. }
  4884. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4885. float a2 = alphaT * alphaB;
  4886. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4887. highp float v2 = dot( v, v );
  4888. float w2 = a2 / v2;
  4889. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4890. }
  4891. #endif
  4892. #ifdef USE_CLEARCOAT
  4893. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4894. vec3 f0 = material.clearcoatF0;
  4895. float f90 = material.clearcoatF90;
  4896. float roughness = material.clearcoatRoughness;
  4897. float alpha = pow2( roughness );
  4898. vec3 halfDir = normalize( lightDir + viewDir );
  4899. float dotNL = saturate( dot( normal, lightDir ) );
  4900. float dotNV = saturate( dot( normal, viewDir ) );
  4901. float dotNH = saturate( dot( normal, halfDir ) );
  4902. float dotVH = saturate( dot( viewDir, halfDir ) );
  4903. vec3 F = F_Schlick( f0, f90, dotVH );
  4904. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4905. float D = D_GGX( alpha, dotNH );
  4906. return F * ( V * D );
  4907. }
  4908. #endif
  4909. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4910. vec3 f0 = material.specularColor;
  4911. float f90 = material.specularF90;
  4912. float roughness = material.roughness;
  4913. float alpha = pow2( roughness );
  4914. vec3 halfDir = normalize( lightDir + viewDir );
  4915. float dotNL = saturate( dot( normal, lightDir ) );
  4916. float dotNV = saturate( dot( normal, viewDir ) );
  4917. float dotNH = saturate( dot( normal, halfDir ) );
  4918. float dotVH = saturate( dot( viewDir, halfDir ) );
  4919. vec3 F = F_Schlick( f0, f90, dotVH );
  4920. #ifdef USE_IRIDESCENCE
  4921. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4922. #endif
  4923. #ifdef USE_ANISOTROPY
  4924. float dotTL = dot( material.anisotropyT, lightDir );
  4925. float dotTV = dot( material.anisotropyT, viewDir );
  4926. float dotTH = dot( material.anisotropyT, halfDir );
  4927. float dotBL = dot( material.anisotropyB, lightDir );
  4928. float dotBV = dot( material.anisotropyB, viewDir );
  4929. float dotBH = dot( material.anisotropyB, halfDir );
  4930. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4931. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4932. #else
  4933. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4934. float D = D_GGX( alpha, dotNH );
  4935. #endif
  4936. return F * ( V * D );
  4937. }
  4938. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4939. const float LUT_SIZE = 64.0;
  4940. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4941. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4942. float dotNV = saturate( dot( N, V ) );
  4943. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4944. uv = uv * LUT_SCALE + LUT_BIAS;
  4945. return uv;
  4946. }
  4947. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4948. float l = length( f );
  4949. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4950. }
  4951. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4952. float x = dot( v1, v2 );
  4953. float y = abs( x );
  4954. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4955. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4956. float v = a / b;
  4957. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4958. return cross( v1, v2 ) * theta_sintheta;
  4959. }
  4960. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4961. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4962. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4963. vec3 lightNormal = cross( v1, v2 );
  4964. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4965. vec3 T1, T2;
  4966. T1 = normalize( V - N * dot( V, N ) );
  4967. T2 = - cross( N, T1 );
  4968. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4969. vec3 coords[ 4 ];
  4970. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4971. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4972. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4973. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4974. coords[ 0 ] = normalize( coords[ 0 ] );
  4975. coords[ 1 ] = normalize( coords[ 1 ] );
  4976. coords[ 2 ] = normalize( coords[ 2 ] );
  4977. coords[ 3 ] = normalize( coords[ 3 ] );
  4978. vec3 vectorFormFactor = vec3( 0.0 );
  4979. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4980. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4981. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4982. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4983. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4984. return vec3( result );
  4985. }
  4986. #if defined( USE_SHEEN )
  4987. float D_Charlie( float roughness, float dotNH ) {
  4988. float alpha = pow2( roughness );
  4989. float invAlpha = 1.0 / alpha;
  4990. float cos2h = dotNH * dotNH;
  4991. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4992. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4993. }
  4994. float V_Neubelt( float dotNV, float dotNL ) {
  4995. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4996. }
  4997. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4998. vec3 halfDir = normalize( lightDir + viewDir );
  4999. float dotNL = saturate( dot( normal, lightDir ) );
  5000. float dotNV = saturate( dot( normal, viewDir ) );
  5001. float dotNH = saturate( dot( normal, halfDir ) );
  5002. float D = D_Charlie( sheenRoughness, dotNH );
  5003. float V = V_Neubelt( dotNV, dotNL );
  5004. return sheenColor * ( D * V );
  5005. }
  5006. #endif
  5007. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5008. float dotNV = saturate( dot( normal, viewDir ) );
  5009. float r2 = roughness * roughness;
  5010. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  5011. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  5012. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  5013. return saturate( DG * RECIPROCAL_PI );
  5014. }
  5015. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5016. float dotNV = saturate( dot( normal, viewDir ) );
  5017. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  5018. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  5019. vec4 r = roughness * c0 + c1;
  5020. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  5021. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  5022. return fab;
  5023. }
  5024. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  5025. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5026. return specularColor * fab.x + specularF90 * fab.y;
  5027. }
  5028. #ifdef USE_IRIDESCENCE
  5029. 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 ) {
  5030. #else
  5031. 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 ) {
  5032. #endif
  5033. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5034. #ifdef USE_IRIDESCENCE
  5035. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  5036. #else
  5037. vec3 Fr = specularColor;
  5038. #endif
  5039. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  5040. float Ess = fab.x + fab.y;
  5041. float Ems = 1.0 - Ess;
  5042. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  5043. singleScatter += FssEss;
  5044. multiScatter += Fms * Ems;
  5045. }
  5046. #if NUM_RECT_AREA_LIGHTS > 0
  5047. 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 ) {
  5048. vec3 normal = geometryNormal;
  5049. vec3 viewDir = geometryViewDir;
  5050. vec3 position = geometryPosition;
  5051. vec3 lightPos = rectAreaLight.position;
  5052. vec3 halfWidth = rectAreaLight.halfWidth;
  5053. vec3 halfHeight = rectAreaLight.halfHeight;
  5054. vec3 lightColor = rectAreaLight.color;
  5055. float roughness = material.roughness;
  5056. vec3 rectCoords[ 4 ];
  5057. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  5058. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  5059. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  5060. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  5061. vec4 t1 = texture2D( ltc_1, uv );
  5062. vec4 t2 = texture2D( ltc_2, uv );
  5063. mat3 mInv = mat3(
  5064. vec3( t1.x, 0, t1.y ),
  5065. vec3( 0, 1, 0 ),
  5066. vec3( t1.z, 0, t1.w )
  5067. );
  5068. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  5069. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  5070. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  5071. }
  5072. #endif
  5073. 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 ) {
  5074. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  5075. vec3 irradiance = dotNL * directLight.color;
  5076. #ifdef USE_CLEARCOAT
  5077. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  5078. vec3 ccIrradiance = dotNLcc * directLight.color;
  5079. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5080. #endif
  5081. #ifdef USE_SHEEN
  5082. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5083. #endif
  5084. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5085. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5086. }
  5087. 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 ) {
  5088. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5089. }
  5090. 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) {
  5091. #ifdef USE_CLEARCOAT
  5092. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5093. #endif
  5094. #ifdef USE_SHEEN
  5095. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5096. #endif
  5097. vec3 singleScattering = vec3( 0.0 );
  5098. vec3 multiScattering = vec3( 0.0 );
  5099. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5100. #ifdef USE_IRIDESCENCE
  5101. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5102. #else
  5103. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5104. #endif
  5105. vec3 totalScattering = singleScattering + multiScattering;
  5106. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5107. reflectedLight.indirectSpecular += radiance * singleScattering;
  5108. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5109. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5110. }
  5111. #define RE_Direct RE_Direct_Physical
  5112. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5113. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5114. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5115. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5116. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5117. }`,p5e=`
  5118. vec3 geometryPosition = - vViewPosition;
  5119. vec3 geometryNormal = normal;
  5120. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5121. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5122. #ifdef USE_CLEARCOAT
  5123. geometryClearcoatNormal = clearcoatNormal;
  5124. #endif
  5125. #ifdef USE_IRIDESCENCE
  5126. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5127. if ( material.iridescenceThickness == 0.0 ) {
  5128. material.iridescence = 0.0;
  5129. } else {
  5130. material.iridescence = saturate( material.iridescence );
  5131. }
  5132. if ( material.iridescence > 0.0 ) {
  5133. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5134. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5135. }
  5136. #endif
  5137. IncidentLight directLight;
  5138. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5139. PointLight pointLight;
  5140. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5141. PointLightShadow pointLightShadow;
  5142. #endif
  5143. #pragma unroll_loop_start
  5144. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5145. pointLight = pointLights[ i ];
  5146. getPointLightInfo( pointLight, geometryPosition, directLight );
  5147. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5148. pointLightShadow = pointLightShadows[ i ];
  5149. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5150. #endif
  5151. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5152. }
  5153. #pragma unroll_loop_end
  5154. #endif
  5155. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5156. SpotLight spotLight;
  5157. vec4 spotColor;
  5158. vec3 spotLightCoord;
  5159. bool inSpotLightMap;
  5160. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5161. SpotLightShadow spotLightShadow;
  5162. #endif
  5163. #pragma unroll_loop_start
  5164. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5165. spotLight = spotLights[ i ];
  5166. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5167. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5168. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5169. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5170. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5171. #else
  5172. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5173. #endif
  5174. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5175. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5176. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5177. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5178. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5179. #endif
  5180. #undef SPOT_LIGHT_MAP_INDEX
  5181. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5182. spotLightShadow = spotLightShadows[ i ];
  5183. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5184. #endif
  5185. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5186. }
  5187. #pragma unroll_loop_end
  5188. #endif
  5189. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5190. DirectionalLight directionalLight;
  5191. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5192. DirectionalLightShadow directionalLightShadow;
  5193. #endif
  5194. #pragma unroll_loop_start
  5195. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5196. directionalLight = directionalLights[ i ];
  5197. getDirectionalLightInfo( directionalLight, directLight );
  5198. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5199. directionalLightShadow = directionalLightShadows[ i ];
  5200. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5201. #endif
  5202. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5203. }
  5204. #pragma unroll_loop_end
  5205. #endif
  5206. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5207. RectAreaLight rectAreaLight;
  5208. #pragma unroll_loop_start
  5209. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5210. rectAreaLight = rectAreaLights[ i ];
  5211. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5212. }
  5213. #pragma unroll_loop_end
  5214. #endif
  5215. #if defined( RE_IndirectDiffuse )
  5216. vec3 iblIrradiance = vec3( 0.0 );
  5217. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5218. #if defined( USE_LIGHT_PROBES )
  5219. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5220. #endif
  5221. #if ( NUM_HEMI_LIGHTS > 0 )
  5222. #pragma unroll_loop_start
  5223. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5224. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5225. }
  5226. #pragma unroll_loop_end
  5227. #endif
  5228. #endif
  5229. #if defined( RE_IndirectSpecular )
  5230. vec3 radiance = vec3( 0.0 );
  5231. vec3 clearcoatRadiance = vec3( 0.0 );
  5232. #endif`,g5e=`#if defined( RE_IndirectDiffuse )
  5233. #ifdef USE_LIGHTMAP
  5234. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5235. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5236. irradiance += lightMapIrradiance;
  5237. #endif
  5238. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5239. iblIrradiance += getIBLIrradiance( geometryNormal );
  5240. #endif
  5241. #endif
  5242. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5243. #ifdef USE_ANISOTROPY
  5244. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5245. #else
  5246. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5247. #endif
  5248. #ifdef USE_CLEARCOAT
  5249. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5250. #endif
  5251. #endif`,x5e=`#if defined( RE_IndirectDiffuse )
  5252. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5253. #endif
  5254. #if defined( RE_IndirectSpecular )
  5255. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5256. #endif`,b5e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5257. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5258. #endif`,y5e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5259. uniform float logDepthBufFC;
  5260. varying float vFragDepth;
  5261. varying float vIsPerspective;
  5262. #endif`,v5e=`#ifdef USE_LOGDEPTHBUF
  5263. #ifdef USE_LOGDEPTHBUF_EXT
  5264. varying float vFragDepth;
  5265. varying float vIsPerspective;
  5266. #else
  5267. uniform float logDepthBufFC;
  5268. #endif
  5269. #endif`,_5e=`#ifdef USE_LOGDEPTHBUF
  5270. #ifdef USE_LOGDEPTHBUF_EXT
  5271. vFragDepth = 1.0 + gl_Position.w;
  5272. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5273. #else
  5274. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5275. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5276. gl_Position.z *= gl_Position.w;
  5277. }
  5278. #endif
  5279. #endif`,w5e=`#ifdef USE_MAP
  5280. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5281. #ifdef DECODE_VIDEO_TEXTURE
  5282. 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 );
  5283. #endif
  5284. diffuseColor *= sampledDiffuseColor;
  5285. #endif`,S5e=`#ifdef USE_MAP
  5286. uniform sampler2D map;
  5287. #endif`,M5e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5288. #if defined( USE_POINTS_UV )
  5289. vec2 uv = vUv;
  5290. #else
  5291. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5292. #endif
  5293. #endif
  5294. #ifdef USE_MAP
  5295. diffuseColor *= texture2D( map, uv );
  5296. #endif
  5297. #ifdef USE_ALPHAMAP
  5298. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5299. #endif`,N5e=`#if defined( USE_POINTS_UV )
  5300. varying vec2 vUv;
  5301. #else
  5302. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5303. uniform mat3 uvTransform;
  5304. #endif
  5305. #endif
  5306. #ifdef USE_MAP
  5307. uniform sampler2D map;
  5308. #endif
  5309. #ifdef USE_ALPHAMAP
  5310. uniform sampler2D alphaMap;
  5311. #endif`,E5e=`float metalnessFactor = metalness;
  5312. #ifdef USE_METALNESSMAP
  5313. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5314. metalnessFactor *= texelMetalness.b;
  5315. #endif`,A5e=`#ifdef USE_METALNESSMAP
  5316. uniform sampler2D metalnessMap;
  5317. #endif`,T5e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5318. vColor *= morphTargetBaseInfluence;
  5319. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5320. #if defined( USE_COLOR_ALPHA )
  5321. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5322. #elif defined( USE_COLOR )
  5323. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5324. #endif
  5325. }
  5326. #endif`,C5e=`#ifdef USE_MORPHNORMALS
  5327. objectNormal *= morphTargetBaseInfluence;
  5328. #ifdef MORPHTARGETS_TEXTURE
  5329. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5330. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5331. }
  5332. #else
  5333. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5334. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5335. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5336. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5337. #endif
  5338. #endif`,k5e=`#ifdef USE_MORPHTARGETS
  5339. uniform float morphTargetBaseInfluence;
  5340. #ifdef MORPHTARGETS_TEXTURE
  5341. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5342. uniform sampler2DArray morphTargetsTexture;
  5343. uniform ivec2 morphTargetsTextureSize;
  5344. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5345. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5346. int y = texelIndex / morphTargetsTextureSize.x;
  5347. int x = texelIndex - y * morphTargetsTextureSize.x;
  5348. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5349. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5350. }
  5351. #else
  5352. #ifndef USE_MORPHNORMALS
  5353. uniform float morphTargetInfluences[ 8 ];
  5354. #else
  5355. uniform float morphTargetInfluences[ 4 ];
  5356. #endif
  5357. #endif
  5358. #endif`,j5e=`#ifdef USE_MORPHTARGETS
  5359. transformed *= morphTargetBaseInfluence;
  5360. #ifdef MORPHTARGETS_TEXTURE
  5361. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5362. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5363. }
  5364. #else
  5365. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5366. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5367. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5368. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5369. #ifndef USE_MORPHNORMALS
  5370. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5371. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5372. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5373. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5374. #endif
  5375. #endif
  5376. #endif`,P5e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5377. #ifdef FLAT_SHADED
  5378. vec3 fdx = dFdx( vViewPosition );
  5379. vec3 fdy = dFdy( vViewPosition );
  5380. vec3 normal = normalize( cross( fdx, fdy ) );
  5381. #else
  5382. vec3 normal = normalize( vNormal );
  5383. #ifdef DOUBLE_SIDED
  5384. normal *= faceDirection;
  5385. #endif
  5386. #endif
  5387. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5388. #ifdef USE_TANGENT
  5389. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5390. #else
  5391. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5392. #if defined( USE_NORMALMAP )
  5393. vNormalMapUv
  5394. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5395. vClearcoatNormalMapUv
  5396. #else
  5397. vUv
  5398. #endif
  5399. );
  5400. #endif
  5401. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5402. tbn[0] *= faceDirection;
  5403. tbn[1] *= faceDirection;
  5404. #endif
  5405. #endif
  5406. #ifdef USE_CLEARCOAT_NORMALMAP
  5407. #ifdef USE_TANGENT
  5408. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5409. #else
  5410. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5411. #endif
  5412. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5413. tbn2[0] *= faceDirection;
  5414. tbn2[1] *= faceDirection;
  5415. #endif
  5416. #endif
  5417. vec3 nonPerturbedNormal = normal;`,R5e=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5418. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5419. #ifdef FLIP_SIDED
  5420. normal = - normal;
  5421. #endif
  5422. #ifdef DOUBLE_SIDED
  5423. normal = normal * faceDirection;
  5424. #endif
  5425. normal = normalize( normalMatrix * normal );
  5426. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5427. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5428. mapN.xy *= normalScale;
  5429. normal = normalize( tbn * mapN );
  5430. #elif defined( USE_BUMPMAP )
  5431. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5432. #endif`,D5e=`#ifndef FLAT_SHADED
  5433. varying vec3 vNormal;
  5434. #ifdef USE_TANGENT
  5435. varying vec3 vTangent;
  5436. varying vec3 vBitangent;
  5437. #endif
  5438. #endif`,O5e=`#ifndef FLAT_SHADED
  5439. varying vec3 vNormal;
  5440. #ifdef USE_TANGENT
  5441. varying vec3 vTangent;
  5442. varying vec3 vBitangent;
  5443. #endif
  5444. #endif`,L5e=`#ifndef FLAT_SHADED
  5445. vNormal = normalize( transformedNormal );
  5446. #ifdef USE_TANGENT
  5447. vTangent = normalize( transformedTangent );
  5448. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5449. #endif
  5450. #endif`,I5e=`#ifdef USE_NORMALMAP
  5451. uniform sampler2D normalMap;
  5452. uniform vec2 normalScale;
  5453. #endif
  5454. #ifdef USE_NORMALMAP_OBJECTSPACE
  5455. uniform mat3 normalMatrix;
  5456. #endif
  5457. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5458. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5459. vec3 q0 = dFdx( eye_pos.xyz );
  5460. vec3 q1 = dFdy( eye_pos.xyz );
  5461. vec2 st0 = dFdx( uv.st );
  5462. vec2 st1 = dFdy( uv.st );
  5463. vec3 N = surf_norm;
  5464. vec3 q1perp = cross( q1, N );
  5465. vec3 q0perp = cross( N, q0 );
  5466. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5467. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5468. float det = max( dot( T, T ), dot( B, B ) );
  5469. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5470. return mat3( T * scale, B * scale, N );
  5471. }
  5472. #endif`,F5e=`#ifdef USE_CLEARCOAT
  5473. vec3 clearcoatNormal = nonPerturbedNormal;
  5474. #endif`,U5e=`#ifdef USE_CLEARCOAT_NORMALMAP
  5475. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5476. clearcoatMapN.xy *= clearcoatNormalScale;
  5477. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5478. #endif`,z5e=`#ifdef USE_CLEARCOATMAP
  5479. uniform sampler2D clearcoatMap;
  5480. #endif
  5481. #ifdef USE_CLEARCOAT_NORMALMAP
  5482. uniform sampler2D clearcoatNormalMap;
  5483. uniform vec2 clearcoatNormalScale;
  5484. #endif
  5485. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5486. uniform sampler2D clearcoatRoughnessMap;
  5487. #endif`,B5e=`#ifdef USE_IRIDESCENCEMAP
  5488. uniform sampler2D iridescenceMap;
  5489. #endif
  5490. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5491. uniform sampler2D iridescenceThicknessMap;
  5492. #endif`,$5e=`#ifdef OPAQUE
  5493. diffuseColor.a = 1.0;
  5494. #endif
  5495. #ifdef USE_TRANSMISSION
  5496. diffuseColor.a *= material.transmissionAlpha;
  5497. #endif
  5498. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,H5e=`vec3 packNormalToRGB( const in vec3 normal ) {
  5499. return normalize( normal ) * 0.5 + 0.5;
  5500. }
  5501. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5502. return 2.0 * rgb.xyz - 1.0;
  5503. }
  5504. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5505. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5506. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5507. const float ShiftRight8 = 1. / 256.;
  5508. vec4 packDepthToRGBA( const in float v ) {
  5509. vec4 r = vec4( fract( v * PackFactors ), v );
  5510. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5511. }
  5512. float unpackRGBAToDepth( const in vec4 v ) {
  5513. return dot( v, UnpackFactors );
  5514. }
  5515. vec2 packDepthToRG( in highp float v ) {
  5516. return packDepthToRGBA( v ).yx;
  5517. }
  5518. float unpackRGToDepth( const in highp vec2 v ) {
  5519. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5520. }
  5521. vec4 pack2HalfToRGBA( vec2 v ) {
  5522. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5523. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5524. }
  5525. vec2 unpackRGBATo2Half( vec4 v ) {
  5526. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5527. }
  5528. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5529. return ( viewZ + near ) / ( near - far );
  5530. }
  5531. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5532. return depth * ( near - far ) - near;
  5533. }
  5534. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5535. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5536. }
  5537. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5538. return ( near * far ) / ( ( far - near ) * depth - far );
  5539. }`,V5e=`#ifdef PREMULTIPLIED_ALPHA
  5540. gl_FragColor.rgb *= gl_FragColor.a;
  5541. #endif`,G5e=`vec4 mvPosition = vec4( transformed, 1.0 );
  5542. #ifdef USE_BATCHING
  5543. mvPosition = batchingMatrix * mvPosition;
  5544. #endif
  5545. #ifdef USE_INSTANCING
  5546. mvPosition = instanceMatrix * mvPosition;
  5547. #endif
  5548. mvPosition = modelViewMatrix * mvPosition;
  5549. gl_Position = projectionMatrix * mvPosition;`,W5e=`#ifdef DITHERING
  5550. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5551. #endif`,q5e=`#ifdef DITHERING
  5552. vec3 dithering( vec3 color ) {
  5553. float grid_position = rand( gl_FragCoord.xy );
  5554. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5555. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5556. return color + dither_shift_RGB;
  5557. }
  5558. #endif`,K5e=`float roughnessFactor = roughness;
  5559. #ifdef USE_ROUGHNESSMAP
  5560. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5561. roughnessFactor *= texelRoughness.g;
  5562. #endif`,X5e=`#ifdef USE_ROUGHNESSMAP
  5563. uniform sampler2D roughnessMap;
  5564. #endif`,Y5e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5565. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5566. #endif
  5567. #if NUM_SPOT_LIGHT_MAPS > 0
  5568. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5569. #endif
  5570. #ifdef USE_SHADOWMAP
  5571. #if NUM_DIR_LIGHT_SHADOWS > 0
  5572. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5573. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5574. struct DirectionalLightShadow {
  5575. float shadowBias;
  5576. float shadowNormalBias;
  5577. float shadowRadius;
  5578. vec2 shadowMapSize;
  5579. };
  5580. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5581. #endif
  5582. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5583. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5584. struct SpotLightShadow {
  5585. float shadowBias;
  5586. float shadowNormalBias;
  5587. float shadowRadius;
  5588. vec2 shadowMapSize;
  5589. };
  5590. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5591. #endif
  5592. #if NUM_POINT_LIGHT_SHADOWS > 0
  5593. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5594. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5595. struct PointLightShadow {
  5596. float shadowBias;
  5597. float shadowNormalBias;
  5598. float shadowRadius;
  5599. vec2 shadowMapSize;
  5600. float shadowCameraNear;
  5601. float shadowCameraFar;
  5602. };
  5603. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5604. #endif
  5605. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5606. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5607. }
  5608. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5609. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5610. }
  5611. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5612. float occlusion = 1.0;
  5613. vec2 distribution = texture2DDistribution( shadow, uv );
  5614. float hard_shadow = step( compare , distribution.x );
  5615. if (hard_shadow != 1.0 ) {
  5616. float distance = compare - distribution.x ;
  5617. float variance = max( 0.00000, distribution.y * distribution.y );
  5618. 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 );
  5619. }
  5620. return occlusion;
  5621. }
  5622. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5623. float shadow = 1.0;
  5624. shadowCoord.xyz /= shadowCoord.w;
  5625. shadowCoord.z += shadowBias;
  5626. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5627. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5628. if ( frustumTest ) {
  5629. #if defined( SHADOWMAP_TYPE_PCF )
  5630. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5631. float dx0 = - texelSize.x * shadowRadius;
  5632. float dy0 = - texelSize.y * shadowRadius;
  5633. float dx1 = + texelSize.x * shadowRadius;
  5634. float dy1 = + texelSize.y * shadowRadius;
  5635. float dx2 = dx0 / 2.0;
  5636. float dy2 = dy0 / 2.0;
  5637. float dx3 = dx1 / 2.0;
  5638. float dy3 = dy1 / 2.0;
  5639. shadow = (
  5640. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5641. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5642. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5643. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5644. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5645. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5646. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5647. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5648. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5649. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5650. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5651. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5652. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5653. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5654. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5655. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5656. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5657. ) * ( 1.0 / 17.0 );
  5658. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5659. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5660. float dx = texelSize.x;
  5661. float dy = texelSize.y;
  5662. vec2 uv = shadowCoord.xy;
  5663. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5664. uv -= f * texelSize;
  5665. shadow = (
  5666. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5667. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5668. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5669. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5670. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5671. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5672. f.x ) +
  5673. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5674. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5675. f.x ) +
  5676. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5677. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5678. f.y ) +
  5679. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5680. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5681. f.y ) +
  5682. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5683. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5684. f.x ),
  5685. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5686. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5687. f.x ),
  5688. f.y )
  5689. ) * ( 1.0 / 9.0 );
  5690. #elif defined( SHADOWMAP_TYPE_VSM )
  5691. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5692. #else
  5693. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5694. #endif
  5695. }
  5696. return shadow;
  5697. }
  5698. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5699. vec3 absV = abs( v );
  5700. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5701. absV *= scaleToCube;
  5702. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5703. vec2 planar = v.xy;
  5704. float almostATexel = 1.5 * texelSizeY;
  5705. float almostOne = 1.0 - almostATexel;
  5706. if ( absV.z >= almostOne ) {
  5707. if ( v.z > 0.0 )
  5708. planar.x = 4.0 - v.x;
  5709. } else if ( absV.x >= almostOne ) {
  5710. float signX = sign( v.x );
  5711. planar.x = v.z * signX + 2.0 * signX;
  5712. } else if ( absV.y >= almostOne ) {
  5713. float signY = sign( v.y );
  5714. planar.x = v.x + 2.0 * signY + 2.0;
  5715. planar.y = v.z * signY - 2.0;
  5716. }
  5717. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5718. }
  5719. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5720. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5721. vec3 lightToPosition = shadowCoord.xyz;
  5722. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5723. vec3 bd3D = normalize( lightToPosition );
  5724. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5725. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5726. return (
  5727. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5728. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5729. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5730. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5731. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5732. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5733. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5734. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5735. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5736. ) * ( 1.0 / 9.0 );
  5737. #else
  5738. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5739. #endif
  5740. }
  5741. #endif`,Q5e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5742. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5743. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5744. #endif
  5745. #ifdef USE_SHADOWMAP
  5746. #if NUM_DIR_LIGHT_SHADOWS > 0
  5747. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5748. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5749. struct DirectionalLightShadow {
  5750. float shadowBias;
  5751. float shadowNormalBias;
  5752. float shadowRadius;
  5753. vec2 shadowMapSize;
  5754. };
  5755. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5756. #endif
  5757. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5758. struct SpotLightShadow {
  5759. float shadowBias;
  5760. float shadowNormalBias;
  5761. float shadowRadius;
  5762. vec2 shadowMapSize;
  5763. };
  5764. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5765. #endif
  5766. #if NUM_POINT_LIGHT_SHADOWS > 0
  5767. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5768. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5769. struct PointLightShadow {
  5770. float shadowBias;
  5771. float shadowNormalBias;
  5772. float shadowRadius;
  5773. vec2 shadowMapSize;
  5774. float shadowCameraNear;
  5775. float shadowCameraFar;
  5776. };
  5777. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5778. #endif
  5779. #endif`,Z5e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5780. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5781. vec4 shadowWorldPosition;
  5782. #endif
  5783. #if defined( USE_SHADOWMAP )
  5784. #if NUM_DIR_LIGHT_SHADOWS > 0
  5785. #pragma unroll_loop_start
  5786. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5787. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5788. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5789. }
  5790. #pragma unroll_loop_end
  5791. #endif
  5792. #if NUM_POINT_LIGHT_SHADOWS > 0
  5793. #pragma unroll_loop_start
  5794. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5795. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5796. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5797. }
  5798. #pragma unroll_loop_end
  5799. #endif
  5800. #endif
  5801. #if NUM_SPOT_LIGHT_COORDS > 0
  5802. #pragma unroll_loop_start
  5803. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5804. shadowWorldPosition = worldPosition;
  5805. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5806. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5807. #endif
  5808. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5809. }
  5810. #pragma unroll_loop_end
  5811. #endif`,J5e=`float getShadowMask() {
  5812. float shadow = 1.0;
  5813. #ifdef USE_SHADOWMAP
  5814. #if NUM_DIR_LIGHT_SHADOWS > 0
  5815. DirectionalLightShadow directionalLight;
  5816. #pragma unroll_loop_start
  5817. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5818. directionalLight = directionalLightShadows[ i ];
  5819. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5820. }
  5821. #pragma unroll_loop_end
  5822. #endif
  5823. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5824. SpotLightShadow spotLight;
  5825. #pragma unroll_loop_start
  5826. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5827. spotLight = spotLightShadows[ i ];
  5828. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5829. }
  5830. #pragma unroll_loop_end
  5831. #endif
  5832. #if NUM_POINT_LIGHT_SHADOWS > 0
  5833. PointLightShadow pointLight;
  5834. #pragma unroll_loop_start
  5835. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5836. pointLight = pointLightShadows[ i ];
  5837. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5838. }
  5839. #pragma unroll_loop_end
  5840. #endif
  5841. #endif
  5842. return shadow;
  5843. }`,eFe=`#ifdef USE_SKINNING
  5844. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5845. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5846. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5847. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5848. #endif`,tFe=`#ifdef USE_SKINNING
  5849. uniform mat4 bindMatrix;
  5850. uniform mat4 bindMatrixInverse;
  5851. uniform highp sampler2D boneTexture;
  5852. mat4 getBoneMatrix( const in float i ) {
  5853. int size = textureSize( boneTexture, 0 ).x;
  5854. int j = int( i ) * 4;
  5855. int x = j % size;
  5856. int y = j / size;
  5857. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5858. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5859. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5860. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5861. return mat4( v1, v2, v3, v4 );
  5862. }
  5863. #endif`,nFe=`#ifdef USE_SKINNING
  5864. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5865. vec4 skinned = vec4( 0.0 );
  5866. skinned += boneMatX * skinVertex * skinWeight.x;
  5867. skinned += boneMatY * skinVertex * skinWeight.y;
  5868. skinned += boneMatZ * skinVertex * skinWeight.z;
  5869. skinned += boneMatW * skinVertex * skinWeight.w;
  5870. transformed = ( bindMatrixInverse * skinned ).xyz;
  5871. #endif`,rFe=`#ifdef USE_SKINNING
  5872. mat4 skinMatrix = mat4( 0.0 );
  5873. skinMatrix += skinWeight.x * boneMatX;
  5874. skinMatrix += skinWeight.y * boneMatY;
  5875. skinMatrix += skinWeight.z * boneMatZ;
  5876. skinMatrix += skinWeight.w * boneMatW;
  5877. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5878. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5879. #ifdef USE_TANGENT
  5880. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5881. #endif
  5882. #endif`,iFe=`float specularStrength;
  5883. #ifdef USE_SPECULARMAP
  5884. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5885. specularStrength = texelSpecular.r;
  5886. #else
  5887. specularStrength = 1.0;
  5888. #endif`,aFe=`#ifdef USE_SPECULARMAP
  5889. uniform sampler2D specularMap;
  5890. #endif`,sFe=`#if defined( TONE_MAPPING )
  5891. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5892. #endif`,oFe=`#ifndef saturate
  5893. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5894. #endif
  5895. uniform float toneMappingExposure;
  5896. vec3 LinearToneMapping( vec3 color ) {
  5897. return saturate( toneMappingExposure * color );
  5898. }
  5899. vec3 ReinhardToneMapping( vec3 color ) {
  5900. color *= toneMappingExposure;
  5901. return saturate( color / ( vec3( 1.0 ) + color ) );
  5902. }
  5903. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5904. color *= toneMappingExposure;
  5905. color = max( vec3( 0.0 ), color - 0.004 );
  5906. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5907. }
  5908. vec3 RRTAndODTFit( vec3 v ) {
  5909. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5910. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5911. return a / b;
  5912. }
  5913. vec3 ACESFilmicToneMapping( vec3 color ) {
  5914. const mat3 ACESInputMat = mat3(
  5915. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5916. vec3( 0.04823, 0.01566, 0.83777 )
  5917. );
  5918. const mat3 ACESOutputMat = mat3(
  5919. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5920. vec3( -0.07367, -0.00605, 1.07602 )
  5921. );
  5922. color *= toneMappingExposure / 0.6;
  5923. color = ACESInputMat * color;
  5924. color = RRTAndODTFit( color );
  5925. color = ACESOutputMat * color;
  5926. return saturate( color );
  5927. }
  5928. vec3 CustomToneMapping( vec3 color ) { return color; }`,lFe=`#ifdef USE_TRANSMISSION
  5929. material.transmission = transmission;
  5930. material.transmissionAlpha = 1.0;
  5931. material.thickness = thickness;
  5932. material.attenuationDistance = attenuationDistance;
  5933. material.attenuationColor = attenuationColor;
  5934. #ifdef USE_TRANSMISSIONMAP
  5935. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5936. #endif
  5937. #ifdef USE_THICKNESSMAP
  5938. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5939. #endif
  5940. vec3 pos = vWorldPosition;
  5941. vec3 v = normalize( cameraPosition - pos );
  5942. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5943. vec4 transmitted = getIBLVolumeRefraction(
  5944. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5945. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5946. material.attenuationColor, material.attenuationDistance );
  5947. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5948. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5949. #endif`,cFe=`#ifdef USE_TRANSMISSION
  5950. uniform float transmission;
  5951. uniform float thickness;
  5952. uniform float attenuationDistance;
  5953. uniform vec3 attenuationColor;
  5954. #ifdef USE_TRANSMISSIONMAP
  5955. uniform sampler2D transmissionMap;
  5956. #endif
  5957. #ifdef USE_THICKNESSMAP
  5958. uniform sampler2D thicknessMap;
  5959. #endif
  5960. uniform vec2 transmissionSamplerSize;
  5961. uniform sampler2D transmissionSamplerMap;
  5962. uniform mat4 modelMatrix;
  5963. uniform mat4 projectionMatrix;
  5964. varying vec3 vWorldPosition;
  5965. float w0( float a ) {
  5966. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5967. }
  5968. float w1( float a ) {
  5969. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5970. }
  5971. float w2( float a ){
  5972. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5973. }
  5974. float w3( float a ) {
  5975. return ( 1.0 / 6.0 ) * ( a * a * a );
  5976. }
  5977. float g0( float a ) {
  5978. return w0( a ) + w1( a );
  5979. }
  5980. float g1( float a ) {
  5981. return w2( a ) + w3( a );
  5982. }
  5983. float h0( float a ) {
  5984. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5985. }
  5986. float h1( float a ) {
  5987. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5988. }
  5989. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5990. uv = uv * texelSize.zw + 0.5;
  5991. vec2 iuv = floor( uv );
  5992. vec2 fuv = fract( uv );
  5993. float g0x = g0( fuv.x );
  5994. float g1x = g1( fuv.x );
  5995. float h0x = h0( fuv.x );
  5996. float h1x = h1( fuv.x );
  5997. float h0y = h0( fuv.y );
  5998. float h1y = h1( fuv.y );
  5999. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6000. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6001. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6002. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6003. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  6004. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  6005. }
  6006. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  6007. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  6008. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  6009. vec2 fLodSizeInv = 1.0 / fLodSize;
  6010. vec2 cLodSizeInv = 1.0 / cLodSize;
  6011. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  6012. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  6013. return mix( fSample, cSample, fract( lod ) );
  6014. }
  6015. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  6016. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  6017. vec3 modelScale;
  6018. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  6019. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  6020. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  6021. return normalize( refractionVector ) * thickness * modelScale;
  6022. }
  6023. float applyIorToRoughness( const in float roughness, const in float ior ) {
  6024. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  6025. }
  6026. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  6027. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  6028. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  6029. }
  6030. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  6031. if ( isinf( attenuationDistance ) ) {
  6032. return vec3( 1.0 );
  6033. } else {
  6034. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  6035. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  6036. }
  6037. }
  6038. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  6039. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  6040. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  6041. const in vec3 attenuationColor, const in float attenuationDistance ) {
  6042. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  6043. vec3 refractedRayExit = position + transmissionRay;
  6044. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  6045. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  6046. refractionCoords += 1.0;
  6047. refractionCoords /= 2.0;
  6048. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  6049. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  6050. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  6051. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  6052. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  6053. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  6054. }
  6055. #endif`,uFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6056. varying vec2 vUv;
  6057. #endif
  6058. #ifdef USE_MAP
  6059. varying vec2 vMapUv;
  6060. #endif
  6061. #ifdef USE_ALPHAMAP
  6062. varying vec2 vAlphaMapUv;
  6063. #endif
  6064. #ifdef USE_LIGHTMAP
  6065. varying vec2 vLightMapUv;
  6066. #endif
  6067. #ifdef USE_AOMAP
  6068. varying vec2 vAoMapUv;
  6069. #endif
  6070. #ifdef USE_BUMPMAP
  6071. varying vec2 vBumpMapUv;
  6072. #endif
  6073. #ifdef USE_NORMALMAP
  6074. varying vec2 vNormalMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. varying vec2 vEmissiveMapUv;
  6078. #endif
  6079. #ifdef USE_METALNESSMAP
  6080. varying vec2 vMetalnessMapUv;
  6081. #endif
  6082. #ifdef USE_ROUGHNESSMAP
  6083. varying vec2 vRoughnessMapUv;
  6084. #endif
  6085. #ifdef USE_ANISOTROPYMAP
  6086. varying vec2 vAnisotropyMapUv;
  6087. #endif
  6088. #ifdef USE_CLEARCOATMAP
  6089. varying vec2 vClearcoatMapUv;
  6090. #endif
  6091. #ifdef USE_CLEARCOAT_NORMALMAP
  6092. varying vec2 vClearcoatNormalMapUv;
  6093. #endif
  6094. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6095. varying vec2 vClearcoatRoughnessMapUv;
  6096. #endif
  6097. #ifdef USE_IRIDESCENCEMAP
  6098. varying vec2 vIridescenceMapUv;
  6099. #endif
  6100. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6101. varying vec2 vIridescenceThicknessMapUv;
  6102. #endif
  6103. #ifdef USE_SHEEN_COLORMAP
  6104. varying vec2 vSheenColorMapUv;
  6105. #endif
  6106. #ifdef USE_SHEEN_ROUGHNESSMAP
  6107. varying vec2 vSheenRoughnessMapUv;
  6108. #endif
  6109. #ifdef USE_SPECULARMAP
  6110. varying vec2 vSpecularMapUv;
  6111. #endif
  6112. #ifdef USE_SPECULAR_COLORMAP
  6113. varying vec2 vSpecularColorMapUv;
  6114. #endif
  6115. #ifdef USE_SPECULAR_INTENSITYMAP
  6116. varying vec2 vSpecularIntensityMapUv;
  6117. #endif
  6118. #ifdef USE_TRANSMISSIONMAP
  6119. uniform mat3 transmissionMapTransform;
  6120. varying vec2 vTransmissionMapUv;
  6121. #endif
  6122. #ifdef USE_THICKNESSMAP
  6123. uniform mat3 thicknessMapTransform;
  6124. varying vec2 vThicknessMapUv;
  6125. #endif`,dFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6126. varying vec2 vUv;
  6127. #endif
  6128. #ifdef USE_MAP
  6129. uniform mat3 mapTransform;
  6130. varying vec2 vMapUv;
  6131. #endif
  6132. #ifdef USE_ALPHAMAP
  6133. uniform mat3 alphaMapTransform;
  6134. varying vec2 vAlphaMapUv;
  6135. #endif
  6136. #ifdef USE_LIGHTMAP
  6137. uniform mat3 lightMapTransform;
  6138. varying vec2 vLightMapUv;
  6139. #endif
  6140. #ifdef USE_AOMAP
  6141. uniform mat3 aoMapTransform;
  6142. varying vec2 vAoMapUv;
  6143. #endif
  6144. #ifdef USE_BUMPMAP
  6145. uniform mat3 bumpMapTransform;
  6146. varying vec2 vBumpMapUv;
  6147. #endif
  6148. #ifdef USE_NORMALMAP
  6149. uniform mat3 normalMapTransform;
  6150. varying vec2 vNormalMapUv;
  6151. #endif
  6152. #ifdef USE_DISPLACEMENTMAP
  6153. uniform mat3 displacementMapTransform;
  6154. varying vec2 vDisplacementMapUv;
  6155. #endif
  6156. #ifdef USE_EMISSIVEMAP
  6157. uniform mat3 emissiveMapTransform;
  6158. varying vec2 vEmissiveMapUv;
  6159. #endif
  6160. #ifdef USE_METALNESSMAP
  6161. uniform mat3 metalnessMapTransform;
  6162. varying vec2 vMetalnessMapUv;
  6163. #endif
  6164. #ifdef USE_ROUGHNESSMAP
  6165. uniform mat3 roughnessMapTransform;
  6166. varying vec2 vRoughnessMapUv;
  6167. #endif
  6168. #ifdef USE_ANISOTROPYMAP
  6169. uniform mat3 anisotropyMapTransform;
  6170. varying vec2 vAnisotropyMapUv;
  6171. #endif
  6172. #ifdef USE_CLEARCOATMAP
  6173. uniform mat3 clearcoatMapTransform;
  6174. varying vec2 vClearcoatMapUv;
  6175. #endif
  6176. #ifdef USE_CLEARCOAT_NORMALMAP
  6177. uniform mat3 clearcoatNormalMapTransform;
  6178. varying vec2 vClearcoatNormalMapUv;
  6179. #endif
  6180. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6181. uniform mat3 clearcoatRoughnessMapTransform;
  6182. varying vec2 vClearcoatRoughnessMapUv;
  6183. #endif
  6184. #ifdef USE_SHEEN_COLORMAP
  6185. uniform mat3 sheenColorMapTransform;
  6186. varying vec2 vSheenColorMapUv;
  6187. #endif
  6188. #ifdef USE_SHEEN_ROUGHNESSMAP
  6189. uniform mat3 sheenRoughnessMapTransform;
  6190. varying vec2 vSheenRoughnessMapUv;
  6191. #endif
  6192. #ifdef USE_IRIDESCENCEMAP
  6193. uniform mat3 iridescenceMapTransform;
  6194. varying vec2 vIridescenceMapUv;
  6195. #endif
  6196. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6197. uniform mat3 iridescenceThicknessMapTransform;
  6198. varying vec2 vIridescenceThicknessMapUv;
  6199. #endif
  6200. #ifdef USE_SPECULARMAP
  6201. uniform mat3 specularMapTransform;
  6202. varying vec2 vSpecularMapUv;
  6203. #endif
  6204. #ifdef USE_SPECULAR_COLORMAP
  6205. uniform mat3 specularColorMapTransform;
  6206. varying vec2 vSpecularColorMapUv;
  6207. #endif
  6208. #ifdef USE_SPECULAR_INTENSITYMAP
  6209. uniform mat3 specularIntensityMapTransform;
  6210. varying vec2 vSpecularIntensityMapUv;
  6211. #endif
  6212. #ifdef USE_TRANSMISSIONMAP
  6213. uniform mat3 transmissionMapTransform;
  6214. varying vec2 vTransmissionMapUv;
  6215. #endif
  6216. #ifdef USE_THICKNESSMAP
  6217. uniform mat3 thicknessMapTransform;
  6218. varying vec2 vThicknessMapUv;
  6219. #endif`,hFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6220. vUv = vec3( uv, 1 ).xy;
  6221. #endif
  6222. #ifdef USE_MAP
  6223. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6224. #endif
  6225. #ifdef USE_ALPHAMAP
  6226. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6227. #endif
  6228. #ifdef USE_LIGHTMAP
  6229. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6230. #endif
  6231. #ifdef USE_AOMAP
  6232. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6233. #endif
  6234. #ifdef USE_BUMPMAP
  6235. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6236. #endif
  6237. #ifdef USE_NORMALMAP
  6238. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6239. #endif
  6240. #ifdef USE_DISPLACEMENTMAP
  6241. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6242. #endif
  6243. #ifdef USE_EMISSIVEMAP
  6244. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6245. #endif
  6246. #ifdef USE_METALNESSMAP
  6247. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6248. #endif
  6249. #ifdef USE_ROUGHNESSMAP
  6250. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6251. #endif
  6252. #ifdef USE_ANISOTROPYMAP
  6253. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6254. #endif
  6255. #ifdef USE_CLEARCOATMAP
  6256. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6257. #endif
  6258. #ifdef USE_CLEARCOAT_NORMALMAP
  6259. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6260. #endif
  6261. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6262. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6263. #endif
  6264. #ifdef USE_IRIDESCENCEMAP
  6265. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6266. #endif
  6267. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6268. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6269. #endif
  6270. #ifdef USE_SHEEN_COLORMAP
  6271. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6272. #endif
  6273. #ifdef USE_SHEEN_ROUGHNESSMAP
  6274. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6275. #endif
  6276. #ifdef USE_SPECULARMAP
  6277. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6278. #endif
  6279. #ifdef USE_SPECULAR_COLORMAP
  6280. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6281. #endif
  6282. #ifdef USE_SPECULAR_INTENSITYMAP
  6283. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6284. #endif
  6285. #ifdef USE_TRANSMISSIONMAP
  6286. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6287. #endif
  6288. #ifdef USE_THICKNESSMAP
  6289. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6290. #endif`,fFe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6291. vec4 worldPosition = vec4( transformed, 1.0 );
  6292. #ifdef USE_BATCHING
  6293. worldPosition = batchingMatrix * worldPosition;
  6294. #endif
  6295. #ifdef USE_INSTANCING
  6296. worldPosition = instanceMatrix * worldPosition;
  6297. #endif
  6298. worldPosition = modelMatrix * worldPosition;
  6299. #endif`;const mFe=`varying vec2 vUv;
  6300. uniform mat3 uvTransform;
  6301. void main() {
  6302. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6303. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6304. }`,pFe=`uniform sampler2D t2D;
  6305. uniform float backgroundIntensity;
  6306. varying vec2 vUv;
  6307. void main() {
  6308. vec4 texColor = texture2D( t2D, vUv );
  6309. #ifdef DECODE_VIDEO_TEXTURE
  6310. 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 );
  6311. #endif
  6312. texColor.rgb *= backgroundIntensity;
  6313. gl_FragColor = texColor;
  6314. #include <tonemapping_fragment>
  6315. #include <colorspace_fragment>
  6316. }`,gFe=`varying vec3 vWorldDirection;
  6317. #include <common>
  6318. void main() {
  6319. vWorldDirection = transformDirection( position, modelMatrix );
  6320. #include <begin_vertex>
  6321. #include <project_vertex>
  6322. gl_Position.z = gl_Position.w;
  6323. }`,xFe=`#ifdef ENVMAP_TYPE_CUBE
  6324. uniform samplerCube envMap;
  6325. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6326. uniform sampler2D envMap;
  6327. #endif
  6328. uniform float flipEnvMap;
  6329. uniform float backgroundBlurriness;
  6330. uniform float backgroundIntensity;
  6331. varying vec3 vWorldDirection;
  6332. #include <cube_uv_reflection_fragment>
  6333. void main() {
  6334. #ifdef ENVMAP_TYPE_CUBE
  6335. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6336. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6337. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6338. #else
  6339. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6340. #endif
  6341. texColor.rgb *= backgroundIntensity;
  6342. gl_FragColor = texColor;
  6343. #include <tonemapping_fragment>
  6344. #include <colorspace_fragment>
  6345. }`,bFe=`varying vec3 vWorldDirection;
  6346. #include <common>
  6347. void main() {
  6348. vWorldDirection = transformDirection( position, modelMatrix );
  6349. #include <begin_vertex>
  6350. #include <project_vertex>
  6351. gl_Position.z = gl_Position.w;
  6352. }`,yFe=`uniform samplerCube tCube;
  6353. uniform float tFlip;
  6354. uniform float opacity;
  6355. varying vec3 vWorldDirection;
  6356. void main() {
  6357. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6358. gl_FragColor = texColor;
  6359. gl_FragColor.a *= opacity;
  6360. #include <tonemapping_fragment>
  6361. #include <colorspace_fragment>
  6362. }`,vFe=`#include <common>
  6363. #include <batching_pars_vertex>
  6364. #include <uv_pars_vertex>
  6365. #include <displacementmap_pars_vertex>
  6366. #include <morphtarget_pars_vertex>
  6367. #include <skinning_pars_vertex>
  6368. #include <logdepthbuf_pars_vertex>
  6369. #include <clipping_planes_pars_vertex>
  6370. varying vec2 vHighPrecisionZW;
  6371. void main() {
  6372. #include <uv_vertex>
  6373. #include <batching_vertex>
  6374. #include <skinbase_vertex>
  6375. #ifdef USE_DISPLACEMENTMAP
  6376. #include <beginnormal_vertex>
  6377. #include <morphnormal_vertex>
  6378. #include <skinnormal_vertex>
  6379. #endif
  6380. #include <begin_vertex>
  6381. #include <morphtarget_vertex>
  6382. #include <skinning_vertex>
  6383. #include <displacementmap_vertex>
  6384. #include <project_vertex>
  6385. #include <logdepthbuf_vertex>
  6386. #include <clipping_planes_vertex>
  6387. vHighPrecisionZW = gl_Position.zw;
  6388. }`,_Fe=`#if DEPTH_PACKING == 3200
  6389. uniform float opacity;
  6390. #endif
  6391. #include <common>
  6392. #include <packing>
  6393. #include <uv_pars_fragment>
  6394. #include <map_pars_fragment>
  6395. #include <alphamap_pars_fragment>
  6396. #include <alphatest_pars_fragment>
  6397. #include <alphahash_pars_fragment>
  6398. #include <logdepthbuf_pars_fragment>
  6399. #include <clipping_planes_pars_fragment>
  6400. varying vec2 vHighPrecisionZW;
  6401. void main() {
  6402. #include <clipping_planes_fragment>
  6403. vec4 diffuseColor = vec4( 1.0 );
  6404. #if DEPTH_PACKING == 3200
  6405. diffuseColor.a = opacity;
  6406. #endif
  6407. #include <map_fragment>
  6408. #include <alphamap_fragment>
  6409. #include <alphatest_fragment>
  6410. #include <alphahash_fragment>
  6411. #include <logdepthbuf_fragment>
  6412. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6413. #if DEPTH_PACKING == 3200
  6414. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6415. #elif DEPTH_PACKING == 3201
  6416. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6417. #endif
  6418. }`,wFe=`#define DISTANCE
  6419. varying vec3 vWorldPosition;
  6420. #include <common>
  6421. #include <batching_pars_vertex>
  6422. #include <uv_pars_vertex>
  6423. #include <displacementmap_pars_vertex>
  6424. #include <morphtarget_pars_vertex>
  6425. #include <skinning_pars_vertex>
  6426. #include <clipping_planes_pars_vertex>
  6427. void main() {
  6428. #include <uv_vertex>
  6429. #include <batching_vertex>
  6430. #include <skinbase_vertex>
  6431. #ifdef USE_DISPLACEMENTMAP
  6432. #include <beginnormal_vertex>
  6433. #include <morphnormal_vertex>
  6434. #include <skinnormal_vertex>
  6435. #endif
  6436. #include <begin_vertex>
  6437. #include <morphtarget_vertex>
  6438. #include <skinning_vertex>
  6439. #include <displacementmap_vertex>
  6440. #include <project_vertex>
  6441. #include <worldpos_vertex>
  6442. #include <clipping_planes_vertex>
  6443. vWorldPosition = worldPosition.xyz;
  6444. }`,SFe=`#define DISTANCE
  6445. uniform vec3 referencePosition;
  6446. uniform float nearDistance;
  6447. uniform float farDistance;
  6448. varying vec3 vWorldPosition;
  6449. #include <common>
  6450. #include <packing>
  6451. #include <uv_pars_fragment>
  6452. #include <map_pars_fragment>
  6453. #include <alphamap_pars_fragment>
  6454. #include <alphatest_pars_fragment>
  6455. #include <alphahash_pars_fragment>
  6456. #include <clipping_planes_pars_fragment>
  6457. void main () {
  6458. #include <clipping_planes_fragment>
  6459. vec4 diffuseColor = vec4( 1.0 );
  6460. #include <map_fragment>
  6461. #include <alphamap_fragment>
  6462. #include <alphatest_fragment>
  6463. #include <alphahash_fragment>
  6464. float dist = length( vWorldPosition - referencePosition );
  6465. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6466. dist = saturate( dist );
  6467. gl_FragColor = packDepthToRGBA( dist );
  6468. }`,MFe=`varying vec3 vWorldDirection;
  6469. #include <common>
  6470. void main() {
  6471. vWorldDirection = transformDirection( position, modelMatrix );
  6472. #include <begin_vertex>
  6473. #include <project_vertex>
  6474. }`,NFe=`uniform sampler2D tEquirect;
  6475. varying vec3 vWorldDirection;
  6476. #include <common>
  6477. void main() {
  6478. vec3 direction = normalize( vWorldDirection );
  6479. vec2 sampleUV = equirectUv( direction );
  6480. gl_FragColor = texture2D( tEquirect, sampleUV );
  6481. #include <tonemapping_fragment>
  6482. #include <colorspace_fragment>
  6483. }`,EFe=`uniform float scale;
  6484. attribute float lineDistance;
  6485. varying float vLineDistance;
  6486. #include <common>
  6487. #include <uv_pars_vertex>
  6488. #include <color_pars_vertex>
  6489. #include <fog_pars_vertex>
  6490. #include <morphtarget_pars_vertex>
  6491. #include <logdepthbuf_pars_vertex>
  6492. #include <clipping_planes_pars_vertex>
  6493. void main() {
  6494. vLineDistance = scale * lineDistance;
  6495. #include <uv_vertex>
  6496. #include <color_vertex>
  6497. #include <morphcolor_vertex>
  6498. #include <begin_vertex>
  6499. #include <morphtarget_vertex>
  6500. #include <project_vertex>
  6501. #include <logdepthbuf_vertex>
  6502. #include <clipping_planes_vertex>
  6503. #include <fog_vertex>
  6504. }`,AFe=`uniform vec3 diffuse;
  6505. uniform float opacity;
  6506. uniform float dashSize;
  6507. uniform float totalSize;
  6508. varying float vLineDistance;
  6509. #include <common>
  6510. #include <color_pars_fragment>
  6511. #include <uv_pars_fragment>
  6512. #include <map_pars_fragment>
  6513. #include <fog_pars_fragment>
  6514. #include <logdepthbuf_pars_fragment>
  6515. #include <clipping_planes_pars_fragment>
  6516. void main() {
  6517. #include <clipping_planes_fragment>
  6518. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6519. discard;
  6520. }
  6521. vec3 outgoingLight = vec3( 0.0 );
  6522. vec4 diffuseColor = vec4( diffuse, opacity );
  6523. #include <logdepthbuf_fragment>
  6524. #include <map_fragment>
  6525. #include <color_fragment>
  6526. outgoingLight = diffuseColor.rgb;
  6527. #include <opaque_fragment>
  6528. #include <tonemapping_fragment>
  6529. #include <colorspace_fragment>
  6530. #include <fog_fragment>
  6531. #include <premultiplied_alpha_fragment>
  6532. }`,TFe=`#include <common>
  6533. #include <batching_pars_vertex>
  6534. #include <uv_pars_vertex>
  6535. #include <envmap_pars_vertex>
  6536. #include <color_pars_vertex>
  6537. #include <fog_pars_vertex>
  6538. #include <morphtarget_pars_vertex>
  6539. #include <skinning_pars_vertex>
  6540. #include <logdepthbuf_pars_vertex>
  6541. #include <clipping_planes_pars_vertex>
  6542. void main() {
  6543. #include <uv_vertex>
  6544. #include <color_vertex>
  6545. #include <morphcolor_vertex>
  6546. #include <batching_vertex>
  6547. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6548. #include <beginnormal_vertex>
  6549. #include <morphnormal_vertex>
  6550. #include <skinbase_vertex>
  6551. #include <skinnormal_vertex>
  6552. #include <defaultnormal_vertex>
  6553. #endif
  6554. #include <begin_vertex>
  6555. #include <morphtarget_vertex>
  6556. #include <skinning_vertex>
  6557. #include <project_vertex>
  6558. #include <logdepthbuf_vertex>
  6559. #include <clipping_planes_vertex>
  6560. #include <worldpos_vertex>
  6561. #include <envmap_vertex>
  6562. #include <fog_vertex>
  6563. }`,CFe=`uniform vec3 diffuse;
  6564. uniform float opacity;
  6565. #ifndef FLAT_SHADED
  6566. varying vec3 vNormal;
  6567. #endif
  6568. #include <common>
  6569. #include <dithering_pars_fragment>
  6570. #include <color_pars_fragment>
  6571. #include <uv_pars_fragment>
  6572. #include <map_pars_fragment>
  6573. #include <alphamap_pars_fragment>
  6574. #include <alphatest_pars_fragment>
  6575. #include <alphahash_pars_fragment>
  6576. #include <aomap_pars_fragment>
  6577. #include <lightmap_pars_fragment>
  6578. #include <envmap_common_pars_fragment>
  6579. #include <envmap_pars_fragment>
  6580. #include <fog_pars_fragment>
  6581. #include <specularmap_pars_fragment>
  6582. #include <logdepthbuf_pars_fragment>
  6583. #include <clipping_planes_pars_fragment>
  6584. void main() {
  6585. #include <clipping_planes_fragment>
  6586. vec4 diffuseColor = vec4( diffuse, opacity );
  6587. #include <logdepthbuf_fragment>
  6588. #include <map_fragment>
  6589. #include <color_fragment>
  6590. #include <alphamap_fragment>
  6591. #include <alphatest_fragment>
  6592. #include <alphahash_fragment>
  6593. #include <specularmap_fragment>
  6594. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6595. #ifdef USE_LIGHTMAP
  6596. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6597. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6598. #else
  6599. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6600. #endif
  6601. #include <aomap_fragment>
  6602. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6603. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6604. #include <envmap_fragment>
  6605. #include <opaque_fragment>
  6606. #include <tonemapping_fragment>
  6607. #include <colorspace_fragment>
  6608. #include <fog_fragment>
  6609. #include <premultiplied_alpha_fragment>
  6610. #include <dithering_fragment>
  6611. }`,kFe=`#define LAMBERT
  6612. varying vec3 vViewPosition;
  6613. #include <common>
  6614. #include <batching_pars_vertex>
  6615. #include <uv_pars_vertex>
  6616. #include <displacementmap_pars_vertex>
  6617. #include <envmap_pars_vertex>
  6618. #include <color_pars_vertex>
  6619. #include <fog_pars_vertex>
  6620. #include <normal_pars_vertex>
  6621. #include <morphtarget_pars_vertex>
  6622. #include <skinning_pars_vertex>
  6623. #include <shadowmap_pars_vertex>
  6624. #include <logdepthbuf_pars_vertex>
  6625. #include <clipping_planes_pars_vertex>
  6626. void main() {
  6627. #include <uv_vertex>
  6628. #include <color_vertex>
  6629. #include <morphcolor_vertex>
  6630. #include <batching_vertex>
  6631. #include <beginnormal_vertex>
  6632. #include <morphnormal_vertex>
  6633. #include <skinbase_vertex>
  6634. #include <skinnormal_vertex>
  6635. #include <defaultnormal_vertex>
  6636. #include <normal_vertex>
  6637. #include <begin_vertex>
  6638. #include <morphtarget_vertex>
  6639. #include <skinning_vertex>
  6640. #include <displacementmap_vertex>
  6641. #include <project_vertex>
  6642. #include <logdepthbuf_vertex>
  6643. #include <clipping_planes_vertex>
  6644. vViewPosition = - mvPosition.xyz;
  6645. #include <worldpos_vertex>
  6646. #include <envmap_vertex>
  6647. #include <shadowmap_vertex>
  6648. #include <fog_vertex>
  6649. }`,jFe=`#define LAMBERT
  6650. uniform vec3 diffuse;
  6651. uniform vec3 emissive;
  6652. uniform float opacity;
  6653. #include <common>
  6654. #include <packing>
  6655. #include <dithering_pars_fragment>
  6656. #include <color_pars_fragment>
  6657. #include <uv_pars_fragment>
  6658. #include <map_pars_fragment>
  6659. #include <alphamap_pars_fragment>
  6660. #include <alphatest_pars_fragment>
  6661. #include <alphahash_pars_fragment>
  6662. #include <aomap_pars_fragment>
  6663. #include <lightmap_pars_fragment>
  6664. #include <emissivemap_pars_fragment>
  6665. #include <envmap_common_pars_fragment>
  6666. #include <envmap_pars_fragment>
  6667. #include <fog_pars_fragment>
  6668. #include <bsdfs>
  6669. #include <lights_pars_begin>
  6670. #include <normal_pars_fragment>
  6671. #include <lights_lambert_pars_fragment>
  6672. #include <shadowmap_pars_fragment>
  6673. #include <bumpmap_pars_fragment>
  6674. #include <normalmap_pars_fragment>
  6675. #include <specularmap_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. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6682. vec3 totalEmissiveRadiance = emissive;
  6683. #include <logdepthbuf_fragment>
  6684. #include <map_fragment>
  6685. #include <color_fragment>
  6686. #include <alphamap_fragment>
  6687. #include <alphatest_fragment>
  6688. #include <alphahash_fragment>
  6689. #include <specularmap_fragment>
  6690. #include <normal_fragment_begin>
  6691. #include <normal_fragment_maps>
  6692. #include <emissivemap_fragment>
  6693. #include <lights_lambert_fragment>
  6694. #include <lights_fragment_begin>
  6695. #include <lights_fragment_maps>
  6696. #include <lights_fragment_end>
  6697. #include <aomap_fragment>
  6698. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6699. #include <envmap_fragment>
  6700. #include <opaque_fragment>
  6701. #include <tonemapping_fragment>
  6702. #include <colorspace_fragment>
  6703. #include <fog_fragment>
  6704. #include <premultiplied_alpha_fragment>
  6705. #include <dithering_fragment>
  6706. }`,PFe=`#define MATCAP
  6707. varying vec3 vViewPosition;
  6708. #include <common>
  6709. #include <batching_pars_vertex>
  6710. #include <uv_pars_vertex>
  6711. #include <color_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <fog_pars_vertex>
  6714. #include <normal_pars_vertex>
  6715. #include <morphtarget_pars_vertex>
  6716. #include <skinning_pars_vertex>
  6717. #include <logdepthbuf_pars_vertex>
  6718. #include <clipping_planes_pars_vertex>
  6719. void main() {
  6720. #include <uv_vertex>
  6721. #include <color_vertex>
  6722. #include <morphcolor_vertex>
  6723. #include <batching_vertex>
  6724. #include <beginnormal_vertex>
  6725. #include <morphnormal_vertex>
  6726. #include <skinbase_vertex>
  6727. #include <skinnormal_vertex>
  6728. #include <defaultnormal_vertex>
  6729. #include <normal_vertex>
  6730. #include <begin_vertex>
  6731. #include <morphtarget_vertex>
  6732. #include <skinning_vertex>
  6733. #include <displacementmap_vertex>
  6734. #include <project_vertex>
  6735. #include <logdepthbuf_vertex>
  6736. #include <clipping_planes_vertex>
  6737. #include <fog_vertex>
  6738. vViewPosition = - mvPosition.xyz;
  6739. }`,RFe=`#define MATCAP
  6740. uniform vec3 diffuse;
  6741. uniform float opacity;
  6742. uniform sampler2D matcap;
  6743. varying vec3 vViewPosition;
  6744. #include <common>
  6745. #include <dithering_pars_fragment>
  6746. #include <color_pars_fragment>
  6747. #include <uv_pars_fragment>
  6748. #include <map_pars_fragment>
  6749. #include <alphamap_pars_fragment>
  6750. #include <alphatest_pars_fragment>
  6751. #include <alphahash_pars_fragment>
  6752. #include <fog_pars_fragment>
  6753. #include <normal_pars_fragment>
  6754. #include <bumpmap_pars_fragment>
  6755. #include <normalmap_pars_fragment>
  6756. #include <logdepthbuf_pars_fragment>
  6757. #include <clipping_planes_pars_fragment>
  6758. void main() {
  6759. #include <clipping_planes_fragment>
  6760. vec4 diffuseColor = vec4( diffuse, opacity );
  6761. #include <logdepthbuf_fragment>
  6762. #include <map_fragment>
  6763. #include <color_fragment>
  6764. #include <alphamap_fragment>
  6765. #include <alphatest_fragment>
  6766. #include <alphahash_fragment>
  6767. #include <normal_fragment_begin>
  6768. #include <normal_fragment_maps>
  6769. vec3 viewDir = normalize( vViewPosition );
  6770. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6771. vec3 y = cross( viewDir, x );
  6772. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6773. #ifdef USE_MATCAP
  6774. vec4 matcapColor = texture2D( matcap, uv );
  6775. #else
  6776. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6777. #endif
  6778. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6779. #include <opaque_fragment>
  6780. #include <tonemapping_fragment>
  6781. #include <colorspace_fragment>
  6782. #include <fog_fragment>
  6783. #include <premultiplied_alpha_fragment>
  6784. #include <dithering_fragment>
  6785. }`,DFe=`#define NORMAL
  6786. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6787. varying vec3 vViewPosition;
  6788. #endif
  6789. #include <common>
  6790. #include <batching_pars_vertex>
  6791. #include <uv_pars_vertex>
  6792. #include <displacementmap_pars_vertex>
  6793. #include <normal_pars_vertex>
  6794. #include <morphtarget_pars_vertex>
  6795. #include <skinning_pars_vertex>
  6796. #include <logdepthbuf_pars_vertex>
  6797. #include <clipping_planes_pars_vertex>
  6798. void main() {
  6799. #include <uv_vertex>
  6800. #include <batching_vertex>
  6801. #include <beginnormal_vertex>
  6802. #include <morphnormal_vertex>
  6803. #include <skinbase_vertex>
  6804. #include <skinnormal_vertex>
  6805. #include <defaultnormal_vertex>
  6806. #include <normal_vertex>
  6807. #include <begin_vertex>
  6808. #include <morphtarget_vertex>
  6809. #include <skinning_vertex>
  6810. #include <displacementmap_vertex>
  6811. #include <project_vertex>
  6812. #include <logdepthbuf_vertex>
  6813. #include <clipping_planes_vertex>
  6814. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6815. vViewPosition = - mvPosition.xyz;
  6816. #endif
  6817. }`,OFe=`#define NORMAL
  6818. uniform float opacity;
  6819. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6820. varying vec3 vViewPosition;
  6821. #endif
  6822. #include <packing>
  6823. #include <uv_pars_fragment>
  6824. #include <normal_pars_fragment>
  6825. #include <bumpmap_pars_fragment>
  6826. #include <normalmap_pars_fragment>
  6827. #include <logdepthbuf_pars_fragment>
  6828. #include <clipping_planes_pars_fragment>
  6829. void main() {
  6830. #include <clipping_planes_fragment>
  6831. #include <logdepthbuf_fragment>
  6832. #include <normal_fragment_begin>
  6833. #include <normal_fragment_maps>
  6834. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6835. #ifdef OPAQUE
  6836. gl_FragColor.a = 1.0;
  6837. #endif
  6838. }`,LFe=`#define PHONG
  6839. varying vec3 vViewPosition;
  6840. #include <common>
  6841. #include <batching_pars_vertex>
  6842. #include <uv_pars_vertex>
  6843. #include <displacementmap_pars_vertex>
  6844. #include <envmap_pars_vertex>
  6845. #include <color_pars_vertex>
  6846. #include <fog_pars_vertex>
  6847. #include <normal_pars_vertex>
  6848. #include <morphtarget_pars_vertex>
  6849. #include <skinning_pars_vertex>
  6850. #include <shadowmap_pars_vertex>
  6851. #include <logdepthbuf_pars_vertex>
  6852. #include <clipping_planes_pars_vertex>
  6853. void main() {
  6854. #include <uv_vertex>
  6855. #include <color_vertex>
  6856. #include <morphcolor_vertex>
  6857. #include <batching_vertex>
  6858. #include <beginnormal_vertex>
  6859. #include <morphnormal_vertex>
  6860. #include <skinbase_vertex>
  6861. #include <skinnormal_vertex>
  6862. #include <defaultnormal_vertex>
  6863. #include <normal_vertex>
  6864. #include <begin_vertex>
  6865. #include <morphtarget_vertex>
  6866. #include <skinning_vertex>
  6867. #include <displacementmap_vertex>
  6868. #include <project_vertex>
  6869. #include <logdepthbuf_vertex>
  6870. #include <clipping_planes_vertex>
  6871. vViewPosition = - mvPosition.xyz;
  6872. #include <worldpos_vertex>
  6873. #include <envmap_vertex>
  6874. #include <shadowmap_vertex>
  6875. #include <fog_vertex>
  6876. }`,IFe=`#define PHONG
  6877. uniform vec3 diffuse;
  6878. uniform vec3 emissive;
  6879. uniform vec3 specular;
  6880. uniform float shininess;
  6881. uniform float opacity;
  6882. #include <common>
  6883. #include <packing>
  6884. #include <dithering_pars_fragment>
  6885. #include <color_pars_fragment>
  6886. #include <uv_pars_fragment>
  6887. #include <map_pars_fragment>
  6888. #include <alphamap_pars_fragment>
  6889. #include <alphatest_pars_fragment>
  6890. #include <alphahash_pars_fragment>
  6891. #include <aomap_pars_fragment>
  6892. #include <lightmap_pars_fragment>
  6893. #include <emissivemap_pars_fragment>
  6894. #include <envmap_common_pars_fragment>
  6895. #include <envmap_pars_fragment>
  6896. #include <fog_pars_fragment>
  6897. #include <bsdfs>
  6898. #include <lights_pars_begin>
  6899. #include <normal_pars_fragment>
  6900. #include <lights_phong_pars_fragment>
  6901. #include <shadowmap_pars_fragment>
  6902. #include <bumpmap_pars_fragment>
  6903. #include <normalmap_pars_fragment>
  6904. #include <specularmap_pars_fragment>
  6905. #include <logdepthbuf_pars_fragment>
  6906. #include <clipping_planes_pars_fragment>
  6907. void main() {
  6908. #include <clipping_planes_fragment>
  6909. vec4 diffuseColor = vec4( diffuse, opacity );
  6910. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6911. vec3 totalEmissiveRadiance = emissive;
  6912. #include <logdepthbuf_fragment>
  6913. #include <map_fragment>
  6914. #include <color_fragment>
  6915. #include <alphamap_fragment>
  6916. #include <alphatest_fragment>
  6917. #include <alphahash_fragment>
  6918. #include <specularmap_fragment>
  6919. #include <normal_fragment_begin>
  6920. #include <normal_fragment_maps>
  6921. #include <emissivemap_fragment>
  6922. #include <lights_phong_fragment>
  6923. #include <lights_fragment_begin>
  6924. #include <lights_fragment_maps>
  6925. #include <lights_fragment_end>
  6926. #include <aomap_fragment>
  6927. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6928. #include <envmap_fragment>
  6929. #include <opaque_fragment>
  6930. #include <tonemapping_fragment>
  6931. #include <colorspace_fragment>
  6932. #include <fog_fragment>
  6933. #include <premultiplied_alpha_fragment>
  6934. #include <dithering_fragment>
  6935. }`,FFe=`#define STANDARD
  6936. varying vec3 vViewPosition;
  6937. #ifdef USE_TRANSMISSION
  6938. varying vec3 vWorldPosition;
  6939. #endif
  6940. #include <common>
  6941. #include <batching_pars_vertex>
  6942. #include <uv_pars_vertex>
  6943. #include <displacementmap_pars_vertex>
  6944. #include <color_pars_vertex>
  6945. #include <fog_pars_vertex>
  6946. #include <normal_pars_vertex>
  6947. #include <morphtarget_pars_vertex>
  6948. #include <skinning_pars_vertex>
  6949. #include <shadowmap_pars_vertex>
  6950. #include <logdepthbuf_pars_vertex>
  6951. #include <clipping_planes_pars_vertex>
  6952. void main() {
  6953. #include <uv_vertex>
  6954. #include <color_vertex>
  6955. #include <morphcolor_vertex>
  6956. #include <batching_vertex>
  6957. #include <beginnormal_vertex>
  6958. #include <morphnormal_vertex>
  6959. #include <skinbase_vertex>
  6960. #include <skinnormal_vertex>
  6961. #include <defaultnormal_vertex>
  6962. #include <normal_vertex>
  6963. #include <begin_vertex>
  6964. #include <morphtarget_vertex>
  6965. #include <skinning_vertex>
  6966. #include <displacementmap_vertex>
  6967. #include <project_vertex>
  6968. #include <logdepthbuf_vertex>
  6969. #include <clipping_planes_vertex>
  6970. vViewPosition = - mvPosition.xyz;
  6971. #include <worldpos_vertex>
  6972. #include <shadowmap_vertex>
  6973. #include <fog_vertex>
  6974. #ifdef USE_TRANSMISSION
  6975. vWorldPosition = worldPosition.xyz;
  6976. #endif
  6977. }`,UFe=`#define STANDARD
  6978. #ifdef PHYSICAL
  6979. #define IOR
  6980. #define USE_SPECULAR
  6981. #endif
  6982. uniform vec3 diffuse;
  6983. uniform vec3 emissive;
  6984. uniform float roughness;
  6985. uniform float metalness;
  6986. uniform float opacity;
  6987. #ifdef IOR
  6988. uniform float ior;
  6989. #endif
  6990. #ifdef USE_SPECULAR
  6991. uniform float specularIntensity;
  6992. uniform vec3 specularColor;
  6993. #ifdef USE_SPECULAR_COLORMAP
  6994. uniform sampler2D specularColorMap;
  6995. #endif
  6996. #ifdef USE_SPECULAR_INTENSITYMAP
  6997. uniform sampler2D specularIntensityMap;
  6998. #endif
  6999. #endif
  7000. #ifdef USE_CLEARCOAT
  7001. uniform float clearcoat;
  7002. uniform float clearcoatRoughness;
  7003. #endif
  7004. #ifdef USE_IRIDESCENCE
  7005. uniform float iridescence;
  7006. uniform float iridescenceIOR;
  7007. uniform float iridescenceThicknessMinimum;
  7008. uniform float iridescenceThicknessMaximum;
  7009. #endif
  7010. #ifdef USE_SHEEN
  7011. uniform vec3 sheenColor;
  7012. uniform float sheenRoughness;
  7013. #ifdef USE_SHEEN_COLORMAP
  7014. uniform sampler2D sheenColorMap;
  7015. #endif
  7016. #ifdef USE_SHEEN_ROUGHNESSMAP
  7017. uniform sampler2D sheenRoughnessMap;
  7018. #endif
  7019. #endif
  7020. #ifdef USE_ANISOTROPY
  7021. uniform vec2 anisotropyVector;
  7022. #ifdef USE_ANISOTROPYMAP
  7023. uniform sampler2D anisotropyMap;
  7024. #endif
  7025. #endif
  7026. varying vec3 vViewPosition;
  7027. #include <common>
  7028. #include <packing>
  7029. #include <dithering_pars_fragment>
  7030. #include <color_pars_fragment>
  7031. #include <uv_pars_fragment>
  7032. #include <map_pars_fragment>
  7033. #include <alphamap_pars_fragment>
  7034. #include <alphatest_pars_fragment>
  7035. #include <alphahash_pars_fragment>
  7036. #include <aomap_pars_fragment>
  7037. #include <lightmap_pars_fragment>
  7038. #include <emissivemap_pars_fragment>
  7039. #include <iridescence_fragment>
  7040. #include <cube_uv_reflection_fragment>
  7041. #include <envmap_common_pars_fragment>
  7042. #include <envmap_physical_pars_fragment>
  7043. #include <fog_pars_fragment>
  7044. #include <lights_pars_begin>
  7045. #include <normal_pars_fragment>
  7046. #include <lights_physical_pars_fragment>
  7047. #include <transmission_pars_fragment>
  7048. #include <shadowmap_pars_fragment>
  7049. #include <bumpmap_pars_fragment>
  7050. #include <normalmap_pars_fragment>
  7051. #include <clearcoat_pars_fragment>
  7052. #include <iridescence_pars_fragment>
  7053. #include <roughnessmap_pars_fragment>
  7054. #include <metalnessmap_pars_fragment>
  7055. #include <logdepthbuf_pars_fragment>
  7056. #include <clipping_planes_pars_fragment>
  7057. void main() {
  7058. #include <clipping_planes_fragment>
  7059. vec4 diffuseColor = vec4( diffuse, opacity );
  7060. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7061. vec3 totalEmissiveRadiance = emissive;
  7062. #include <logdepthbuf_fragment>
  7063. #include <map_fragment>
  7064. #include <color_fragment>
  7065. #include <alphamap_fragment>
  7066. #include <alphatest_fragment>
  7067. #include <alphahash_fragment>
  7068. #include <roughnessmap_fragment>
  7069. #include <metalnessmap_fragment>
  7070. #include <normal_fragment_begin>
  7071. #include <normal_fragment_maps>
  7072. #include <clearcoat_normal_fragment_begin>
  7073. #include <clearcoat_normal_fragment_maps>
  7074. #include <emissivemap_fragment>
  7075. #include <lights_physical_fragment>
  7076. #include <lights_fragment_begin>
  7077. #include <lights_fragment_maps>
  7078. #include <lights_fragment_end>
  7079. #include <aomap_fragment>
  7080. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7081. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7082. #include <transmission_fragment>
  7083. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7084. #ifdef USE_SHEEN
  7085. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7086. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7087. #endif
  7088. #ifdef USE_CLEARCOAT
  7089. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7090. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7091. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7092. #endif
  7093. #include <opaque_fragment>
  7094. #include <tonemapping_fragment>
  7095. #include <colorspace_fragment>
  7096. #include <fog_fragment>
  7097. #include <premultiplied_alpha_fragment>
  7098. #include <dithering_fragment>
  7099. }`,zFe=`#define TOON
  7100. varying vec3 vViewPosition;
  7101. #include <common>
  7102. #include <batching_pars_vertex>
  7103. #include <uv_pars_vertex>
  7104. #include <displacementmap_pars_vertex>
  7105. #include <color_pars_vertex>
  7106. #include <fog_pars_vertex>
  7107. #include <normal_pars_vertex>
  7108. #include <morphtarget_pars_vertex>
  7109. #include <skinning_pars_vertex>
  7110. #include <shadowmap_pars_vertex>
  7111. #include <logdepthbuf_pars_vertex>
  7112. #include <clipping_planes_pars_vertex>
  7113. void main() {
  7114. #include <uv_vertex>
  7115. #include <color_vertex>
  7116. #include <morphcolor_vertex>
  7117. #include <batching_vertex>
  7118. #include <beginnormal_vertex>
  7119. #include <morphnormal_vertex>
  7120. #include <skinbase_vertex>
  7121. #include <skinnormal_vertex>
  7122. #include <defaultnormal_vertex>
  7123. #include <normal_vertex>
  7124. #include <begin_vertex>
  7125. #include <morphtarget_vertex>
  7126. #include <skinning_vertex>
  7127. #include <displacementmap_vertex>
  7128. #include <project_vertex>
  7129. #include <logdepthbuf_vertex>
  7130. #include <clipping_planes_vertex>
  7131. vViewPosition = - mvPosition.xyz;
  7132. #include <worldpos_vertex>
  7133. #include <shadowmap_vertex>
  7134. #include <fog_vertex>
  7135. }`,BFe=`#define TOON
  7136. uniform vec3 diffuse;
  7137. uniform vec3 emissive;
  7138. uniform float opacity;
  7139. #include <common>
  7140. #include <packing>
  7141. #include <dithering_pars_fragment>
  7142. #include <color_pars_fragment>
  7143. #include <uv_pars_fragment>
  7144. #include <map_pars_fragment>
  7145. #include <alphamap_pars_fragment>
  7146. #include <alphatest_pars_fragment>
  7147. #include <alphahash_pars_fragment>
  7148. #include <aomap_pars_fragment>
  7149. #include <lightmap_pars_fragment>
  7150. #include <emissivemap_pars_fragment>
  7151. #include <gradientmap_pars_fragment>
  7152. #include <fog_pars_fragment>
  7153. #include <bsdfs>
  7154. #include <lights_pars_begin>
  7155. #include <normal_pars_fragment>
  7156. #include <lights_toon_pars_fragment>
  7157. #include <shadowmap_pars_fragment>
  7158. #include <bumpmap_pars_fragment>
  7159. #include <normalmap_pars_fragment>
  7160. #include <logdepthbuf_pars_fragment>
  7161. #include <clipping_planes_pars_fragment>
  7162. void main() {
  7163. #include <clipping_planes_fragment>
  7164. vec4 diffuseColor = vec4( diffuse, opacity );
  7165. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7166. vec3 totalEmissiveRadiance = emissive;
  7167. #include <logdepthbuf_fragment>
  7168. #include <map_fragment>
  7169. #include <color_fragment>
  7170. #include <alphamap_fragment>
  7171. #include <alphatest_fragment>
  7172. #include <alphahash_fragment>
  7173. #include <normal_fragment_begin>
  7174. #include <normal_fragment_maps>
  7175. #include <emissivemap_fragment>
  7176. #include <lights_toon_fragment>
  7177. #include <lights_fragment_begin>
  7178. #include <lights_fragment_maps>
  7179. #include <lights_fragment_end>
  7180. #include <aomap_fragment>
  7181. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7182. #include <opaque_fragment>
  7183. #include <tonemapping_fragment>
  7184. #include <colorspace_fragment>
  7185. #include <fog_fragment>
  7186. #include <premultiplied_alpha_fragment>
  7187. #include <dithering_fragment>
  7188. }`,$Fe=`uniform float size;
  7189. uniform float scale;
  7190. #include <common>
  7191. #include <color_pars_vertex>
  7192. #include <fog_pars_vertex>
  7193. #include <morphtarget_pars_vertex>
  7194. #include <logdepthbuf_pars_vertex>
  7195. #include <clipping_planes_pars_vertex>
  7196. #ifdef USE_POINTS_UV
  7197. varying vec2 vUv;
  7198. uniform mat3 uvTransform;
  7199. #endif
  7200. void main() {
  7201. #ifdef USE_POINTS_UV
  7202. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7203. #endif
  7204. #include <color_vertex>
  7205. #include <morphcolor_vertex>
  7206. #include <begin_vertex>
  7207. #include <morphtarget_vertex>
  7208. #include <project_vertex>
  7209. gl_PointSize = size;
  7210. #ifdef USE_SIZEATTENUATION
  7211. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7212. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7213. #endif
  7214. #include <logdepthbuf_vertex>
  7215. #include <clipping_planes_vertex>
  7216. #include <worldpos_vertex>
  7217. #include <fog_vertex>
  7218. }`,HFe=`uniform vec3 diffuse;
  7219. uniform float opacity;
  7220. #include <common>
  7221. #include <color_pars_fragment>
  7222. #include <map_particle_pars_fragment>
  7223. #include <alphatest_pars_fragment>
  7224. #include <alphahash_pars_fragment>
  7225. #include <fog_pars_fragment>
  7226. #include <logdepthbuf_pars_fragment>
  7227. #include <clipping_planes_pars_fragment>
  7228. void main() {
  7229. #include <clipping_planes_fragment>
  7230. vec3 outgoingLight = vec3( 0.0 );
  7231. vec4 diffuseColor = vec4( diffuse, opacity );
  7232. #include <logdepthbuf_fragment>
  7233. #include <map_particle_fragment>
  7234. #include <color_fragment>
  7235. #include <alphatest_fragment>
  7236. #include <alphahash_fragment>
  7237. outgoingLight = diffuseColor.rgb;
  7238. #include <opaque_fragment>
  7239. #include <tonemapping_fragment>
  7240. #include <colorspace_fragment>
  7241. #include <fog_fragment>
  7242. #include <premultiplied_alpha_fragment>
  7243. }`,VFe=`#include <common>
  7244. #include <batching_pars_vertex>
  7245. #include <fog_pars_vertex>
  7246. #include <morphtarget_pars_vertex>
  7247. #include <skinning_pars_vertex>
  7248. #include <logdepthbuf_pars_vertex>
  7249. #include <shadowmap_pars_vertex>
  7250. void main() {
  7251. #include <batching_vertex>
  7252. #include <beginnormal_vertex>
  7253. #include <morphnormal_vertex>
  7254. #include <skinbase_vertex>
  7255. #include <skinnormal_vertex>
  7256. #include <defaultnormal_vertex>
  7257. #include <begin_vertex>
  7258. #include <morphtarget_vertex>
  7259. #include <skinning_vertex>
  7260. #include <project_vertex>
  7261. #include <logdepthbuf_vertex>
  7262. #include <worldpos_vertex>
  7263. #include <shadowmap_vertex>
  7264. #include <fog_vertex>
  7265. }`,GFe=`uniform vec3 color;
  7266. uniform float opacity;
  7267. #include <common>
  7268. #include <packing>
  7269. #include <fog_pars_fragment>
  7270. #include <bsdfs>
  7271. #include <lights_pars_begin>
  7272. #include <logdepthbuf_pars_fragment>
  7273. #include <shadowmap_pars_fragment>
  7274. #include <shadowmask_pars_fragment>
  7275. void main() {
  7276. #include <logdepthbuf_fragment>
  7277. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7278. #include <tonemapping_fragment>
  7279. #include <colorspace_fragment>
  7280. #include <fog_fragment>
  7281. }`,WFe=`uniform float rotation;
  7282. uniform vec2 center;
  7283. #include <common>
  7284. #include <uv_pars_vertex>
  7285. #include <fog_pars_vertex>
  7286. #include <logdepthbuf_pars_vertex>
  7287. #include <clipping_planes_pars_vertex>
  7288. void main() {
  7289. #include <uv_vertex>
  7290. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7291. vec2 scale;
  7292. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7293. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7294. #ifndef USE_SIZEATTENUATION
  7295. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7296. if ( isPerspective ) scale *= - mvPosition.z;
  7297. #endif
  7298. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7299. vec2 rotatedPosition;
  7300. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7301. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7302. mvPosition.xy += rotatedPosition;
  7303. gl_Position = projectionMatrix * mvPosition;
  7304. #include <logdepthbuf_vertex>
  7305. #include <clipping_planes_vertex>
  7306. #include <fog_vertex>
  7307. }`,qFe=`uniform vec3 diffuse;
  7308. uniform float opacity;
  7309. #include <common>
  7310. #include <uv_pars_fragment>
  7311. #include <map_pars_fragment>
  7312. #include <alphamap_pars_fragment>
  7313. #include <alphatest_pars_fragment>
  7314. #include <alphahash_pars_fragment>
  7315. #include <fog_pars_fragment>
  7316. #include <logdepthbuf_pars_fragment>
  7317. #include <clipping_planes_pars_fragment>
  7318. void main() {
  7319. #include <clipping_planes_fragment>
  7320. vec3 outgoingLight = vec3( 0.0 );
  7321. vec4 diffuseColor = vec4( diffuse, opacity );
  7322. #include <logdepthbuf_fragment>
  7323. #include <map_fragment>
  7324. #include <alphamap_fragment>
  7325. #include <alphatest_fragment>
  7326. #include <alphahash_fragment>
  7327. outgoingLight = diffuseColor.rgb;
  7328. #include <opaque_fragment>
  7329. #include <tonemapping_fragment>
  7330. #include <colorspace_fragment>
  7331. #include <fog_fragment>
  7332. }`,pn={alphahash_fragment:pIe,alphahash_pars_fragment:gIe,alphamap_fragment:xIe,alphamap_pars_fragment:bIe,alphatest_fragment:yIe,alphatest_pars_fragment:vIe,aomap_fragment:_Ie,aomap_pars_fragment:wIe,batching_pars_vertex:SIe,batching_vertex:MIe,begin_vertex:NIe,beginnormal_vertex:EIe,bsdfs:AIe,iridescence_fragment:TIe,bumpmap_pars_fragment:CIe,clipping_planes_fragment:kIe,clipping_planes_pars_fragment:jIe,clipping_planes_pars_vertex:PIe,clipping_planes_vertex:RIe,color_fragment:DIe,color_pars_fragment:OIe,color_pars_vertex:LIe,color_vertex:IIe,common:FIe,cube_uv_reflection_fragment:UIe,defaultnormal_vertex:zIe,displacementmap_pars_vertex:BIe,displacementmap_vertex:$Ie,emissivemap_fragment:HIe,emissivemap_pars_fragment:VIe,colorspace_fragment:GIe,colorspace_pars_fragment:WIe,envmap_fragment:qIe,envmap_common_pars_fragment:KIe,envmap_pars_fragment:XIe,envmap_pars_vertex:YIe,envmap_physical_pars_fragment:l5e,envmap_vertex:QIe,fog_vertex:ZIe,fog_pars_vertex:JIe,fog_fragment:e5e,fog_pars_fragment:t5e,gradientmap_pars_fragment:n5e,lightmap_fragment:r5e,lightmap_pars_fragment:i5e,lights_lambert_fragment:a5e,lights_lambert_pars_fragment:s5e,lights_pars_begin:o5e,lights_toon_fragment:c5e,lights_toon_pars_fragment:u5e,lights_phong_fragment:d5e,lights_phong_pars_fragment:h5e,lights_physical_fragment:f5e,lights_physical_pars_fragment:m5e,lights_fragment_begin:p5e,lights_fragment_maps:g5e,lights_fragment_end:x5e,logdepthbuf_fragment:b5e,logdepthbuf_pars_fragment:y5e,logdepthbuf_pars_vertex:v5e,logdepthbuf_vertex:_5e,map_fragment:w5e,map_pars_fragment:S5e,map_particle_fragment:M5e,map_particle_pars_fragment:N5e,metalnessmap_fragment:E5e,metalnessmap_pars_fragment:A5e,morphcolor_vertex:T5e,morphnormal_vertex:C5e,morphtarget_pars_vertex:k5e,morphtarget_vertex:j5e,normal_fragment_begin:P5e,normal_fragment_maps:R5e,normal_pars_fragment:D5e,normal_pars_vertex:O5e,normal_vertex:L5e,normalmap_pars_fragment:I5e,clearcoat_normal_fragment_begin:F5e,clearcoat_normal_fragment_maps:U5e,clearcoat_pars_fragment:z5e,iridescence_pars_fragment:B5e,opaque_fragment:$5e,packing:H5e,premultiplied_alpha_fragment:V5e,project_vertex:G5e,dithering_fragment:W5e,dithering_pars_fragment:q5e,roughnessmap_fragment:K5e,roughnessmap_pars_fragment:X5e,shadowmap_pars_fragment:Y5e,shadowmap_pars_vertex:Q5e,shadowmap_vertex:Z5e,shadowmask_pars_fragment:J5e,skinbase_vertex:eFe,skinning_pars_vertex:tFe,skinning_vertex:nFe,skinnormal_vertex:rFe,specularmap_fragment:iFe,specularmap_pars_fragment:aFe,tonemapping_fragment:sFe,tonemapping_pars_fragment:oFe,transmission_fragment:lFe,transmission_pars_fragment:cFe,uv_pars_fragment:uFe,uv_pars_vertex:dFe,uv_vertex:hFe,worldpos_vertex:fFe,background_vert:mFe,background_frag:pFe,backgroundCube_vert:gFe,backgroundCube_frag:xFe,cube_vert:bFe,cube_frag:yFe,depth_vert:vFe,depth_frag:_Fe,distanceRGBA_vert:wFe,distanceRGBA_frag:SFe,equirect_vert:MFe,equirect_frag:NFe,linedashed_vert:EFe,linedashed_frag:AFe,meshbasic_vert:TFe,meshbasic_frag:CFe,meshlambert_vert:kFe,meshlambert_frag:jFe,meshmatcap_vert:PFe,meshmatcap_frag:RFe,meshnormal_vert:DFe,meshnormal_frag:OFe,meshphong_vert:LFe,meshphong_frag:IFe,meshphysical_vert:FFe,meshphysical_frag:UFe,meshtoon_vert:zFe,meshtoon_frag:BFe,points_vert:$Fe,points_frag:HFe,shadow_vert:VFe,shadow_frag:GFe,sprite_vert:WFe,sprite_frag:qFe},kt={common:{diffuse:{value:new qt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new _n},alphaMap:{value:null},alphaMapTransform:{value:new _n},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new _n}},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 _n}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new _n}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new _n},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new _n},normalScale:{value:new rn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new _n},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new _n}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new _n}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new _n}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new qt(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 qt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new _n},alphaTest:{value:0},uvTransform:{value:new _n}},sprite:{diffuse:{value:new qt(16777215)},opacity:{value:1},center:{value:new rn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new _n},alphaMap:{value:null},alphaMapTransform:{value:new _n},alphaTest:{value:0}}},ss={basic:{uniforms:Ia([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.fog]),vertexShader:pn.meshbasic_vert,fragmentShader:pn.meshbasic_frag},lambert:{uniforms:Ia([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,kt.lights,{emissive:{value:new qt(0)}}]),vertexShader:pn.meshlambert_vert,fragmentShader:pn.meshlambert_frag},phong:{uniforms:Ia([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,kt.lights,{emissive:{value:new qt(0)},specular:{value:new qt(1118481)},shininess:{value:30}}]),vertexShader:pn.meshphong_vert,fragmentShader:pn.meshphong_frag},standard:{uniforms:Ia([kt.common,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.roughnessmap,kt.metalnessmap,kt.fog,kt.lights,{emissive:{value:new qt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:pn.meshphysical_vert,fragmentShader:pn.meshphysical_frag},toon:{uniforms:Ia([kt.common,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.gradientmap,kt.fog,kt.lights,{emissive:{value:new qt(0)}}]),vertexShader:pn.meshtoon_vert,fragmentShader:pn.meshtoon_frag},matcap:{uniforms:Ia([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,{matcap:{value:null}}]),vertexShader:pn.meshmatcap_vert,fragmentShader:pn.meshmatcap_frag},points:{uniforms:Ia([kt.points,kt.fog]),vertexShader:pn.points_vert,fragmentShader:pn.points_frag},dashed:{uniforms:Ia([kt.common,kt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:pn.linedashed_vert,fragmentShader:pn.linedashed_frag},depth:{uniforms:Ia([kt.common,kt.displacementmap]),vertexShader:pn.depth_vert,fragmentShader:pn.depth_frag},normal:{uniforms:Ia([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,{opacity:{value:1}}]),vertexShader:pn.meshnormal_vert,fragmentShader:pn.meshnormal_frag},sprite:{uniforms:Ia([kt.sprite,kt.fog]),vertexShader:pn.sprite_vert,fragmentShader:pn.sprite_frag},background:{uniforms:{uvTransform:{value:new _n},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}},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:Ia([kt.common,kt.displacementmap,{referencePosition:{value:new Ue},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:pn.distanceRGBA_vert,fragmentShader:pn.distanceRGBA_frag},shadow:{uniforms:Ia([kt.lights,kt.fog,{color:{value:new qt(0)},opacity:{value:1}}]),vertexShader:pn.shadow_vert,fragmentShader:pn.shadow_frag}};ss.physical={uniforms:Ia([ss.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new _n},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new _n},clearcoatNormalScale:{value:new rn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new _n},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new _n},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new _n},sheen:{value:0},sheenColor:{value:new qt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new _n},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new _n},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new _n},transmissionSamplerSize:{value:new rn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new _n},attenuationDistance:{value:0},attenuationColor:{value:new qt(0)},specularColor:{value:new qt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new _n},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new _n},anisotropyVector:{value:new rn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new _n}}]),vertexShader:pn.meshphysical_vert,fragmentShader:pn.meshphysical_frag};const i1={r:0,b:0,g:0};function KFe(t,e,n,r,i,a,o){const l=new qt(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function x(b,y){let M=!1,S=y.isScene===!0?y.background:null;S&&S.isTexture&&(S=(y.backgroundBlurriness>0?n:e).get(S)),S===null?v(l,c):S&&S.isColor&&(v(S,1),M=!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||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),S&&(S.isCubeTexture||S.mapping===UM)?(d===void 0&&(d=new Yo(new Ay(1,1,1),new Vd({name:"BackgroundCubeMaterial",uniforms:xg(ss.backgroundCube.uniforms),vertexShader:ss.backgroundCube.vertexShader,fragmentShader:ss.backgroundCube.fragmentShader,side:hs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(E,k,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=S,d.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,d.material.toneMapped=lr.getTransfer(S.colorSpace)!==Mr,(f!==S||m!==S.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=S,m=S.version,p=t.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new Yo(new jO(2,2),new Vd({name:"BackgroundMaterial",uniforms:xg(ss.background.uniforms),vertexShader:ss.background.vertexShader,fragmentShader:ss.background.fragmentShader,side:Hd,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=S,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=lr.getTransfer(S.colorSpace)!==Mr,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(f!==S||m!==S.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=S,m=S.version,p=t.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null))}function v(b,y){b.getRGB(i1,kJ(t)),r.buffers.color.setClear(i1.r,i1.g,i1.b,y,o)}return{getClearColor:function(){return l},setClearColor:function(b,y=1){l.set(b),c=y,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,v(l,c)},render:x}}function XFe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||a!==null,l={},c=b(null);let u=c,d=!1;function f(D,K,Y,q,Z){let re=!1;if(o){const ie=v(q,Y,K);u!==ie&&(u=ie,p(u.object)),re=y(D,q,Y,Z),re&&M(D,q,Y,Z)}else{const ie=K.wireframe===!0;(u.geometry!==q.id||u.program!==Y.id||u.wireframe!==ie)&&(u.geometry=q.id,u.program=Y.id,u.wireframe=ie,re=!0)}Z!==null&&n.update(Z,t.ELEMENT_ARRAY_BUFFER),(re||d)&&(d=!1,R(D,K,Y,q),Z!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Z).buffer))}function m(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(D){return r.isWebGL2?t.bindVertexArray(D):a.bindVertexArrayOES(D)}function x(D){return r.isWebGL2?t.deleteVertexArray(D):a.deleteVertexArrayOES(D)}function v(D,K,Y){const q=Y.wireframe===!0;let Z=l[D.id];Z===void 0&&(Z={},l[D.id]=Z);let re=Z[K.id];re===void 0&&(re={},Z[K.id]=re);let ie=re[q];return ie===void 0&&(ie=b(m()),re[q]=ie),ie}function b(D){const K=[],Y=[],q=[];for(let Z=0;Z<i;Z++)K[Z]=0,Y[Z]=0,q[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:K,enabledAttributes:Y,attributeDivisors:q,object:D,attributes:{},index:null}}function y(D,K,Y,q){const Z=u.attributes,re=K.attributes;let ie=0;const U=Y.getAttributes();for(const G in U)if(U[G].location>=0){const ne=Z[G];let se=re[G];if(se===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&(se=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&(se=D.instanceColor)),ne===void 0||ne.attribute!==se||se&&ne.data!==se.data)return!0;ie++}return u.attributesNum!==ie||u.index!==q}function M(D,K,Y,q){const Z={},re=K.attributes;let ie=0;const U=Y.getAttributes();for(const G in U)if(U[G].location>=0){let ne=re[G];ne===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&(ne=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&(ne=D.instanceColor));const se={};se.attribute=ne,ne&&ne.data&&(se.data=ne.data),Z[G]=se,ie++}u.attributes=Z,u.attributesNum=ie,u.index=q}function S(){const D=u.newAttributes;for(let K=0,Y=D.length;K<Y;K++)D[K]=0}function A(D){E(D,0)}function E(D,K){const Y=u.newAttributes,q=u.enabledAttributes,Z=u.attributeDivisors;Y[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),Z[D]!==K&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,K),Z[D]=K)}function k(){const D=u.newAttributes,K=u.enabledAttributes;for(let Y=0,q=K.length;Y<q;Y++)K[Y]!==D[Y]&&(t.disableVertexAttribArray(Y),K[Y]=0)}function C(D,K,Y,q,Z,re,ie){ie===!0?t.vertexAttribIPointer(D,K,Y,Z,re):t.vertexAttribPointer(D,K,Y,q,Z,re)}function R(D,K,Y,q){if(r.isWebGL2===!1&&(D.isInstancedMesh||q.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const Z=q.attributes,re=Y.getAttributes(),ie=K.defaultAttributeValues;for(const U in re){const G=re[U];if(G.location>=0){let ee=Z[U];if(ee===void 0&&(U==="instanceMatrix"&&D.instanceMatrix&&(ee=D.instanceMatrix),U==="instanceColor"&&D.instanceColor&&(ee=D.instanceColor)),ee!==void 0){const ne=ee.normalized,se=ee.itemSize,de=n.get(ee);if(de===void 0)continue;const he=de.buffer,Ee=de.type,ge=de.bytesPerElement,Ne=r.isWebGL2===!0&&(Ee===t.INT||Ee===t.UNSIGNED_INT||ee.gpuType===uJ);if(ee.isInterleavedBufferAttribute){const Re=ee.data,te=Re.stride,Je=ee.offset;if(Re.isInstancedInterleavedBuffer){for(let B=0;B<G.locationSize;B++)E(G.location+B,Re.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let B=0;B<G.locationSize;B++)A(G.location+B);t.bindBuffer(t.ARRAY_BUFFER,he);for(let B=0;B<G.locationSize;B++)C(G.location+B,se/G.locationSize,Ee,ne,te*ge,(Je+se/G.locationSize*B)*ge,Ne)}else{if(ee.isInstancedBufferAttribute){for(let Re=0;Re<G.locationSize;Re++)E(G.location+Re,ee.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let Re=0;Re<G.locationSize;Re++)A(G.location+Re);t.bindBuffer(t.ARRAY_BUFFER,he);for(let Re=0;Re<G.locationSize;Re++)C(G.location+Re,se/G.locationSize,Ee,ne,se*ge,se/G.locationSize*Re*ge,Ne)}}else if(ie!==void 0){const ne=ie[U];if(ne!==void 0)switch(ne.length){case 2:t.vertexAttrib2fv(G.location,ne);break;case 3:t.vertexAttrib3fv(G.location,ne);break;case 4:t.vertexAttrib4fv(G.location,ne);break;default:t.vertexAttrib1fv(G.location,ne)}}}}k()}function T(){I();for(const D in l){const K=l[D];for(const Y in K){const q=K[Y];for(const Z in q)x(q[Z].object),delete q[Z];delete K[Y]}delete l[D]}}function P(D){if(l[D.id]===void 0)return;const K=l[D.id];for(const Y in K){const q=K[Y];for(const Z in q)x(q[Z].object),delete q[Z];delete K[Y]}delete l[D.id]}function F(D){for(const K in l){const Y=l[K];if(Y[D.id]===void 0)continue;const q=Y[D.id];for(const Z in q)x(q[Z].object),delete q[Z];delete Y[D.id]}}function I(){X(),d=!0,u!==c&&(u=c,p(u.object))}function X(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:I,resetDefaultState:X,dispose:T,releaseStatesOfGeometry:P,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:A,disableUnusedAttributes:k}}function YFe(t,e,n,r){const i=r.isWebGL2;let a;function o(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,m){if(m===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](a,d,f,m),n.update(f,a,m)}function u(d,f,m){if(m===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<m;x++)this.render(d[x],f[x]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,m);let x=0;for(let v=0;v<m;v++)x+=f[v];n.update(x,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function QFe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=a(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),b=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),y=t.getParameter(t.MAX_VARYING_VECTORS),M=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),S=m>0,A=o||e.has("OES_texture_float"),E=S&&A,k=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:p,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:b,maxVaryings:y,maxFragmentUniforms:M,vertexTextures:S,floatFragmentTextures:A,floatVertexTextures:E,maxSamples:k}}function ZFe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new ad,l=new _n,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const x=f.clippingPlanes,v=f.clipIntersection,b=f.clipShadows,y=t.get(f);if(!i||x===null||x.length===0||a&&!b)a?d(null):u();else{const M=a?0:r,S=M*4;let A=y.clippingState||null;c.value=A,A=d(x,m,S,p);for(let E=0;E!==S;++E)A[E]=n[E];y.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=M}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,x){const v=f!==null?f.length:0;let b=null;if(v!==0){if(b=c.value,x!==!0||b===null){const y=p+v*4,M=m.matrixWorldInverse;l.getNormalMatrix(M),(b===null||b.length<y)&&(b=new Float32Array(y));for(let S=0,A=p;S!==v;++S,A+=4)o.copy(f[S]).applyMatrix4(M,l),o.normal.toArray(b,A),b[A+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,b}}function JFe(t){let e=new WeakMap;function n(o,l){return l===BP?o.mapping=mg:l===$P&&(o.mapping=pg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===BP||l===$P)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 dIe(c.height/2);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class eUe extends jJ{constructor(e=-1,n=1,r=1,i=-1,a=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=o,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,o,l,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const jp=4,u7=[.125,.215,.35,.446,.526,.582],Uh=20,vk=new eUe,d7=new qt;let _k=null,wk=0,Sk=0;const Oh=(1+Math.sqrt(5))/2,dp=1/Oh,h7=[new Ue(1,1,1),new Ue(-1,1,1),new Ue(1,1,-1),new Ue(-1,1,-1),new Ue(0,Oh,dp),new Ue(0,Oh,-dp),new Ue(dp,0,Oh),new Ue(-dp,0,Oh),new Ue(Oh,dp,0),new Ue(-Oh,dp,0)];class f7{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){_k=this._renderer.getRenderTarget(),wk=this._renderer.getActiveCubeFace(),Sk=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=g7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=p7(),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(_k,wk,Sk),e.scissorTest=!1,a1(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===mg||e.mapping===pg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_k=this._renderer.getRenderTarget(),wk=this._renderer.getActiveCubeFace(),Sk=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:xo,minFilter:xo,generateMipmaps:!1,type:C0,format:bo,colorSpace:cu,depthBuffer:!1},i=m7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=m7(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=tUe(a)),this._blurMaterial=nUe(a,e,n)}return i}_compileMaterial(e){const n=new Yo(this._lodPlanes[0],e);this._renderer.compile(n,vk)}_sceneToCubeUV(e,n,r,i){const l=new Ps(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(d7),d.toneMapping=Td,d.autoClear=!1;const p=new AJ({name:"PMREM.Background",side:hs,depthWrite:!1,depthTest:!1}),x=new Yo(new Ay,p);let v=!1;const b=e.background;b?b.isColor&&(p.color.copy(b),e.background=null,v=!0):(p.color.copy(d7),v=!0);for(let y=0;y<6;y++){const M=y%3;M===0?(l.up.set(0,c[y],0),l.lookAt(u[y],0,0)):M===1?(l.up.set(0,0,c[y]),l.lookAt(0,u[y],0)):(l.up.set(0,c[y],0),l.lookAt(0,0,u[y]));const S=this._cubeSize;a1(i,M*S,y>2?S:0,S,S),d.setRenderTarget(i),v&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=m,d.autoClear=f,e.background=b}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===mg||e.mapping===pg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=g7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=p7());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new Yo(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;a1(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,vk)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=h7[(i-1)%h7.length];this._blur(e,i-1,i,a,o)}n.autoClear=r}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Yo(this._lodPlanes[i],u),m=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Uh-1),v=a/x,b=isFinite(a)?1+Math.floor(d*v):Uh;b>Uh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Uh}`);const y=[];let M=0;for(let C=0;C<Uh;++C){const R=C/v,T=Math.exp(-R*R/2);y.push(T),C===0?M+=T:C<b&&(M+=2*T)}for(let C=0;C<y.length;C++)y[C]=y[C]/M;m.envMap.value=e.texture,m.samples.value=b,m.weights.value=y,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:S}=this;m.dTheta.value=x,m.mipInt.value=S-r;const A=this._sizeLods[i],E=3*A*(i>S-jp?i-S+jp:0),k=4*(this._cubeSize-A);a1(n,E,k,3*A,2*A),c.setRenderTarget(n),c.render(f,vk)}}function tUe(t){const e=[],n=[],r=[];let i=t;const a=t-jp+1+u7.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-jp?c=u7[o-t+jp-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,v=3,b=2,y=1,M=new Float32Array(v*x*p),S=new Float32Array(b*x*p),A=new Float32Array(y*x*p);for(let k=0;k<p;k++){const C=k%3*2/3-1,R=k>2?0:-1,T=[C,R,0,C+2/3,R,0,C+2/3,R+1,0,C,R,0,C+2/3,R+1,0,C,R+1,0];M.set(T,v*x*k),S.set(m,b*x*k);const P=[k,k,k,k,k,k];A.set(P,y*x*k)}const E=new Pa;E.setAttribute("position",new Bs(M,v)),E.setAttribute("uv",new Bs(S,b)),E.setAttribute("faceIndex",new Bs(A,y)),e.push(E),i>jp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function m7(t,e,n){const r=new Of(t,e,n);return r.texture.mapping=UM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function a1(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function nUe(t,e,n){const r=new Float32Array(Uh),i=new Ue(0,1,0);return new Vd({name:"SphericalGaussianBlur",defines:{n:Uh,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:PO(),fragmentShader:`
  7333. precision mediump float;
  7334. precision mediump int;
  7335. varying vec3 vOutputDirection;
  7336. uniform sampler2D envMap;
  7337. uniform int samples;
  7338. uniform float weights[ n ];
  7339. uniform bool latitudinal;
  7340. uniform float dTheta;
  7341. uniform float mipInt;
  7342. uniform vec3 poleAxis;
  7343. #define ENVMAP_TYPE_CUBE_UV
  7344. #include <cube_uv_reflection_fragment>
  7345. vec3 getSample( float theta, vec3 axis ) {
  7346. float cosTheta = cos( theta );
  7347. // Rodrigues' axis-angle rotation
  7348. vec3 sampleDirection = vOutputDirection * cosTheta
  7349. + cross( axis, vOutputDirection ) * sin( theta )
  7350. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7351. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7352. }
  7353. void main() {
  7354. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7355. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7356. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7357. }
  7358. axis = normalize( axis );
  7359. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7360. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7361. for ( int i = 1; i < n; i++ ) {
  7362. if ( i >= samples ) {
  7363. break;
  7364. }
  7365. float theta = dTheta * float( i );
  7366. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7367. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7368. }
  7369. }
  7370. `,blending:Ad,depthTest:!1,depthWrite:!1})}function p7(){return new Vd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:PO(),fragmentShader:`
  7371. precision mediump float;
  7372. precision mediump int;
  7373. varying vec3 vOutputDirection;
  7374. uniform sampler2D envMap;
  7375. #include <common>
  7376. void main() {
  7377. vec3 outputDirection = normalize( vOutputDirection );
  7378. vec2 uv = equirectUv( outputDirection );
  7379. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7380. }
  7381. `,blending:Ad,depthTest:!1,depthWrite:!1})}function g7(){return new Vd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:PO(),fragmentShader:`
  7382. precision mediump float;
  7383. precision mediump int;
  7384. uniform float flipEnvMap;
  7385. varying vec3 vOutputDirection;
  7386. uniform samplerCube envMap;
  7387. void main() {
  7388. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7389. }
  7390. `,blending:Ad,depthTest:!1,depthWrite:!1})}function PO(){return`
  7391. precision mediump float;
  7392. precision mediump int;
  7393. attribute float faceIndex;
  7394. varying vec3 vOutputDirection;
  7395. // RH coordinate system; PMREM face-indexing convention
  7396. vec3 getDirection( vec2 uv, float face ) {
  7397. uv = 2.0 * uv - 1.0;
  7398. vec3 direction = vec3( uv, 1.0 );
  7399. if ( face == 0.0 ) {
  7400. direction = direction.zyx; // ( 1, v, u ) pos x
  7401. } else if ( face == 1.0 ) {
  7402. direction = direction.xzy;
  7403. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7404. } else if ( face == 2.0 ) {
  7405. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7406. } else if ( face == 3.0 ) {
  7407. direction = direction.zyx;
  7408. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7409. } else if ( face == 4.0 ) {
  7410. direction = direction.xzy;
  7411. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7412. } else if ( face == 5.0 ) {
  7413. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7414. }
  7415. return direction;
  7416. }
  7417. void main() {
  7418. vOutputDirection = getDirection( uv, faceIndex );
  7419. gl_Position = vec4( position, 1.0 );
  7420. }
  7421. `}function rUe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===BP||c===$P,d=c===mg||c===pg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new f7(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new f7(t));const m=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,m),l.addEventListener("dispose",a),m.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function iUe(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 aUe(t,e,n,r){const i={},a=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);for(const x in m.morphAttributes){const v=m.morphAttributes[x];for(let b=0,y=v.length;b<y;b++)e.remove(v[b])}m.removeEventListener("dispose",o),delete i[m.id];const p=a.get(m);p&&(e.remove(p),a.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const x in m)e.update(m[x],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const x in p){const v=p[x];for(let b=0,y=v.length;b<y;b++)e.update(v[b],t.ARRAY_BUFFER)}}function u(f){const m=[],p=f.index,x=f.attributes.position;let v=0;if(p!==null){const M=p.array;v=p.version;for(let S=0,A=M.length;S<A;S+=3){const E=M[S+0],k=M[S+1],C=M[S+2];m.push(E,k,k,C,C,E)}}else if(x!==void 0){const M=x.array;v=x.version;for(let S=0,A=M.length/3-1;S<A;S+=3){const E=S+0,k=S+1,C=S+2;m.push(E,k,k,C,C,E)}}else return;const b=new(_J(m)?CJ:TJ)(m,1);b.version=v;const y=a.get(f);y&&e.remove(y),a.set(f,b)}function d(f){const m=a.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function sUe(t,e,n,r){const i=r.isWebGL2;let a;function o(p){a=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(a,x,l,p*c),n.update(x,a,1)}function f(p,x,v){if(v===0)return;let b,y;if(i)b=t,y="drawElementsInstanced";else if(b=e.get("ANGLE_instanced_arrays"),y="drawElementsInstancedANGLE",b===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}b[y](a,x,l,p*c,v),n.update(x,a,v)}function m(p,x,v){if(v===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let y=0;y<v;y++)this.render(p[y]/c,x[y]);else{b.multiDrawElementsWEBGL(a,x,0,l,p,0,v);let y=0;for(let M=0;M<v;M++)y+=x[M];n.update(y,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=m}function oUe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function lUe(t,e){return t[0]-e[0]}function cUe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function uUe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new ur,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const m=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=x!==void 0?x.length:0;let b=a.get(d);if(b===void 0||b.count!==v){let K=function(){X.dispose(),a.delete(d),d.removeEventListener("dispose",K)};var p=K;b!==void 0&&b.texture.dispose();const S=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,E=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],C=d.morphAttributes.normal||[],R=d.morphAttributes.color||[];let T=0;S===!0&&(T=1),A===!0&&(T=2),E===!0&&(T=3);let P=d.attributes.position.count*T,F=1;P>e.maxTextureSize&&(F=Math.ceil(P/e.maxTextureSize),P=e.maxTextureSize);const I=new Float32Array(P*F*4*v),X=new MJ(I,P,F,v);X.type=$c,X.needsUpdate=!0;const D=T*4;for(let Y=0;Y<v;Y++){const q=k[Y],Z=C[Y],re=R[Y],ie=P*F*4*Y;for(let U=0;U<q.count;U++){const G=U*D;S===!0&&(o.fromBufferAttribute(q,U),I[ie+G+0]=o.x,I[ie+G+1]=o.y,I[ie+G+2]=o.z,I[ie+G+3]=0),A===!0&&(o.fromBufferAttribute(Z,U),I[ie+G+4]=o.x,I[ie+G+5]=o.y,I[ie+G+6]=o.z,I[ie+G+7]=0),E===!0&&(o.fromBufferAttribute(re,U),I[ie+G+8]=o.x,I[ie+G+9]=o.y,I[ie+G+10]=o.z,I[ie+G+11]=re.itemSize===4?o.w:1)}}b={count:v,texture:X,size:new rn(P,F)},a.set(d,b),d.addEventListener("dispose",K)}let y=0;for(let S=0;S<m.length;S++)y+=m[S];const M=d.morphTargetsRelative?1:1-y;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",m),f.getUniforms().setValue(t,"morphTargetsTexture",b.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",b.size)}else{const x=m===void 0?0:m.length;let v=r[d.id];if(v===void 0||v.length!==x){v=[];for(let A=0;A<x;A++)v[A]=[A,0];r[d.id]=v}for(let A=0;A<x;A++){const E=v[A];E[0]=A,E[1]=m[A]}v.sort(cUe);for(let A=0;A<8;A++)A<x&&v[A][1]?(l[A][0]=v[A][0],l[A][1]=v[A][1]):(l[A][0]=Number.MAX_SAFE_INTEGER,l[A][1]=0);l.sort(lUe);const b=d.morphAttributes.position,y=d.morphAttributes.normal;let M=0;for(let A=0;A<8;A++){const E=l[A],k=E[0],C=E[1];k!==Number.MAX_SAFE_INTEGER&&C?(b&&d.getAttribute("morphTarget"+A)!==b[k]&&d.setAttribute("morphTarget"+A,b[k]),y&&d.getAttribute("morphNormal"+A)!==y[k]&&d.setAttribute("morphNormal"+A,y[k]),i[A]=C,M+=C):(b&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),y&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const S=d.morphTargetsRelative?1:1-M;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function dUe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}class DJ extends fs{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:cf,d!==cf&&d!==gg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===cf&&(r=gd),r===void 0&&d===gg&&(r=lf),super(null,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:ha,this.minFilter=c!==void 0?c:ha,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 OJ=new fs,LJ=new DJ(1,1);LJ.compareFunction=yJ;const IJ=new MJ,FJ=new XLe,UJ=new PJ,x7=[],b7=[],y7=new Float32Array(16),v7=new Float32Array(9),_7=new Float32Array(4);function Kg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=x7[i];if(a===void 0&&(a=new Float32Array(i),x7[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ci(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 ki(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function $M(t,e){let n=b7[e];n===void 0&&(n=new Int32Array(e),b7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function hUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function fUe(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(Ci(n,e))return;t.uniform2fv(this.addr,e),ki(n,e)}}function mUe(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(Ci(n,e))return;t.uniform3fv(this.addr,e),ki(n,e)}}function pUe(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(Ci(n,e))return;t.uniform4fv(this.addr,e),ki(n,e)}}function gUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;_7.set(r),t.uniformMatrix2fv(this.addr,!1,_7),ki(n,r)}}function xUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;v7.set(r),t.uniformMatrix3fv(this.addr,!1,v7),ki(n,r)}}function bUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;y7.set(r),t.uniformMatrix4fv(this.addr,!1,y7),ki(n,r)}}function yUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function vUe(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(Ci(n,e))return;t.uniform2iv(this.addr,e),ki(n,e)}}function _Ue(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(Ci(n,e))return;t.uniform3iv(this.addr,e),ki(n,e)}}function wUe(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(Ci(n,e))return;t.uniform4iv(this.addr,e),ki(n,e)}}function SUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function MUe(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(Ci(n,e))return;t.uniform2uiv(this.addr,e),ki(n,e)}}function NUe(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(Ci(n,e))return;t.uniform3uiv(this.addr,e),ki(n,e)}}function EUe(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(Ci(n,e))return;t.uniform4uiv(this.addr,e),ki(n,e)}}function AUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const a=this.type===t.SAMPLER_2D_SHADOW?LJ:OJ;n.setTexture2D(e||a,i)}function TUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||FJ,i)}function CUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||UJ,i)}function kUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||IJ,i)}function jUe(t){switch(t){case 5126:return hUe;case 35664:return fUe;case 35665:return mUe;case 35666:return pUe;case 35674:return gUe;case 35675:return xUe;case 35676:return bUe;case 5124:case 35670:return yUe;case 35667:case 35671:return vUe;case 35668:case 35672:return _Ue;case 35669:case 35673:return wUe;case 5125:return SUe;case 36294:return MUe;case 36295:return NUe;case 36296:return EUe;case 35678:case 36198:case 36298:case 36306:case 35682:return AUe;case 35679:case 36299:case 36307:return TUe;case 35680:case 36300:case 36308:case 36293:return CUe;case 36289:case 36303:case 36311:case 36292:return kUe}}function PUe(t,e){t.uniform1fv(this.addr,e)}function RUe(t,e){const n=Kg(e,this.size,2);t.uniform2fv(this.addr,n)}function DUe(t,e){const n=Kg(e,this.size,3);t.uniform3fv(this.addr,n)}function OUe(t,e){const n=Kg(e,this.size,4);t.uniform4fv(this.addr,n)}function LUe(t,e){const n=Kg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function IUe(t,e){const n=Kg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function FUe(t,e){const n=Kg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function UUe(t,e){t.uniform1iv(this.addr,e)}function zUe(t,e){t.uniform2iv(this.addr,e)}function BUe(t,e){t.uniform3iv(this.addr,e)}function $Ue(t,e){t.uniform4iv(this.addr,e)}function HUe(t,e){t.uniform1uiv(this.addr,e)}function VUe(t,e){t.uniform2uiv(this.addr,e)}function GUe(t,e){t.uniform3uiv(this.addr,e)}function WUe(t,e){t.uniform4uiv(this.addr,e)}function qUe(t,e,n){const r=this.cache,i=e.length,a=$M(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||OJ,a[o])}function KUe(t,e,n){const r=this.cache,i=e.length,a=$M(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||FJ,a[o])}function XUe(t,e,n){const r=this.cache,i=e.length,a=$M(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||UJ,a[o])}function YUe(t,e,n){const r=this.cache,i=e.length,a=$M(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||IJ,a[o])}function QUe(t){switch(t){case 5126:return PUe;case 35664:return RUe;case 35665:return DUe;case 35666:return OUe;case 35674:return LUe;case 35675:return IUe;case 35676:return FUe;case 5124:case 35670:return UUe;case 35667:case 35671:return zUe;case 35668:case 35672:return BUe;case 35669:case 35673:return $Ue;case 5125:return HUe;case 36294:return VUe;case 36295:return GUe;case 36296:return WUe;case 35678:case 36198:case 36298:case 36306:case 35682:return qUe;case 35679:case 36299:case 36307:return KUe;case 35680:case 36300:case 36308:case 36293:return XUe;case 36289:case 36303:case 36311:case 36292:return YUe}}class ZUe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=jUe(n.type)}}class JUe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=QUe(n.type)}}class eze{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}}const Mk=/(\w+)(\])?(\[|\.)?/g;function w7(t,e){t.seq.push(e),t.map[e.id]=e}function tze(t,e,n){const r=t.name,i=r.length;for(Mk.lastIndex=0;;){const a=Mk.exec(r),o=Mk.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){w7(n,u===void 0?new ZUe(l,t,e):new JUe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new eze(l),w7(n,f)),n=f}}}class Y1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);tze(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function S7(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const nze=37297;let rze=0;function ize(t,e){const n=t.split(`
  7422. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  7423. `)}function aze(t){const e=lr.getPrimaries(lr.workingColorSpace),n=lr.getPrimaries(t);let r;switch(e===n?r="":e===wS&&n===_S?r="LinearDisplayP3ToLinearSRGB":e===_S&&n===wS&&(r="LinearSRGBToLinearDisplayP3"),t){case cu:case zM:return[r,"LinearTransferOETF"];case fa:case AO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function M7(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
  7424. `+i+`
  7425. `+ize(t.getShaderSource(e),o)}else return i}function sze(t,e){const n=aze(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function oze(t,e){let n;switch(e){case sLe:n="Linear";break;case oLe:n="Reinhard";break;case lLe:n="OptimizedCineon";break;case cLe:n="ACESFilmic";break;case uLe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function lze(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(wb).join(`
  7426. `)}function cze(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7427. `)}function uze(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function wb(t){return t!==""}function N7(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 E7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const dze=/^[ \t]*#include +<([\w\d./]+)>/gm;function KP(t){return t.replace(dze,fze)}const hze=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function fze(t,e){let n=pn[e];if(n===void 0){const r=hze.get(e);if(r!==void 0)n=pn[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 KP(n)}const mze=/#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 A7(t){return t.replace(mze,pze)}function pze(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function T7(t){let e="precision "+t.precision+` float;
  7428. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7429. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7430. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7431. #define LOW_PRECISION`),e}function gze(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===lJ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===DOe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Cc&&(e="SHADOWMAP_TYPE_VSM"),e}function xze(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case mg:case pg:e="ENVMAP_TYPE_CUBE";break;case UM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function bze(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case pg:e="ENVMAP_MODE_REFRACTION";break}return e}function yze(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case NO:e="ENVMAP_BLENDING_MULTIPLY";break;case iLe:e="ENVMAP_BLENDING_MIX";break;case aLe:e="ENVMAP_BLENDING_ADD";break}return e}function vze(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 _ze(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=gze(n),u=xze(n),d=bze(n),f=yze(n),m=vze(n),p=n.isWebGL2?"":lze(n),x=cze(a),v=i.createProgram();let b,y,M=n.glslVersion?"#version "+n.glslVersion+`
  7432. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(wb).join(`
  7433. `),b.length>0&&(b+=`
  7434. `),y=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(wb).join(`
  7435. `),y.length>0&&(y+=`
  7436. `)):(b=[T7(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",`
  7437. `].filter(wb).join(`
  7438. `),y=[p,T7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Td?"#define TONE_MAPPING":"",n.toneMapping!==Td?pn.tonemapping_pars_fragment:"",n.toneMapping!==Td?oze("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",pn.colorspace_pars_fragment,sze("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7439. `].filter(wb).join(`
  7440. `)),o=KP(o),o=N7(o,n),o=E7(o,n),l=KP(l),l=N7(l,n),l=E7(l,n),o=A7(o),l=A7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(M=`#version 300 es
  7441. `,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7442. `)+`
  7443. `+b,y=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===WV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===WV?"":"#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(`
  7444. `)+`
  7445. `+y);const S=M+b+o,A=M+y+l,E=S7(i,i.VERTEX_SHADER,S),k=S7(i,i.FRAGMENT_SHADER,A);i.attachShader(v,E),i.attachShader(v,k),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function C(F){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(v).trim(),X=i.getShaderInfoLog(E).trim(),D=i.getShaderInfoLog(k).trim();let K=!0,Y=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(K=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,E,k);else{const q=M7(i,E,"vertex"),Z=M7(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  7446. Program Info Log: `+I+`
  7447. `+q+`
  7448. `+Z)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(X===""||D==="")&&(Y=!1);Y&&(F.diagnostics={runnable:K,programLog:I,vertexShader:{log:X,prefix:b},fragmentShader:{log:D,prefix:y}})}i.deleteShader(E),i.deleteShader(k),R=new Y1(i,v),T=uze(i,v)}let R;this.getUniforms=function(){return R===void 0&&C(this),R};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(v,nze)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=rze++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=E,this.fragmentShader=k,this}let wze=0;class Sze{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new Mze(e),n.set(e,r)),r}}class Mze{constructor(e){this.id=wze++,this.code=e,this.usedTimes=0}}function Nze(t,e,n,r,i,a,o){const l=new NJ,c=new Sze,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,m=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(T){return T===0?"uv":`uv${T}`}function b(T,P,F,I,X){const D=I.fog,K=X.geometry,Y=T.isMeshStandardMaterial?I.environment:null,q=(T.isMeshStandardMaterial?n:e).get(T.envMap||Y),Z=q&&q.mapping===UM?q.image.height:null,re=x[T.type];T.precision!==null&&(p=i.getMaxPrecision(T.precision),p!==T.precision&&console.warn("THREE.WebGLProgram.getParameters:",T.precision,"not supported, using",p,"instead."));const ie=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,U=ie!==void 0?ie.length:0;let G=0;K.morphAttributes.position!==void 0&&(G=1),K.morphAttributes.normal!==void 0&&(G=2),K.morphAttributes.color!==void 0&&(G=3);let ee,ne,se,de;if(re){const Xt=ss[re];ee=Xt.vertexShader,ne=Xt.fragmentShader}else ee=T.vertexShader,ne=T.fragmentShader,c.update(T),se=c.getVertexShaderID(T),de=c.getFragmentShaderID(T);const he=t.getRenderTarget(),Ee=X.isInstancedMesh===!0,ge=X.isBatchedMesh===!0,Ne=!!T.map,Re=!!T.matcap,te=!!q,Je=!!T.aoMap,B=!!T.lightMap,H=!!T.bumpMap,W=!!T.normalMap,z=!!T.displacementMap,V=!!T.emissiveMap,Q=!!T.metalnessMap,Te=!!T.roughnessMap,ke=T.anisotropy>0,Ae=T.clearcoat>0,$=T.iridescence>0,L=T.sheen>0,oe=T.transmission>0,ce=ke&&!!T.anisotropyMap,xe=Ae&&!!T.clearcoatMap,ve=Ae&&!!T.clearcoatNormalMap,_e=Ae&&!!T.clearcoatRoughnessMap,Ie=$&&!!T.iridescenceMap,We=$&&!!T.iridescenceThicknessMap,ht=L&&!!T.sheenColorMap,qe=L&&!!T.sheenRoughnessMap,me=!!T.specularMap,rt=!!T.specularColorMap,Xe=!!T.specularIntensityMap,nt=oe&&!!T.transmissionMap,ut=oe&&!!T.thicknessMap,ae=!!T.gradientMap,$e=!!T.alphaMap,ye=T.alphaTest>0,Be=!!T.alphaHash,De=!!T.extensions,we=!!K.attributes.uv1,Ve=!!K.attributes.uv2,dt=!!K.attributes.uv3;let Tt=Td;return T.toneMapped&&(he===null||he.isXRRenderTarget===!0)&&(Tt=t.toneMapping),{isWebGL2:d,shaderID:re,shaderType:T.type,shaderName:T.name,vertexShader:ee,fragmentShader:ne,defines:T.defines,customVertexShaderID:se,customFragmentShaderID:de,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:p,batching:ge,instancing:Ee,instancingColor:Ee&&X.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:he===null?t.outputColorSpace:he.isXRRenderTarget===!0?he.texture.colorSpace:cu,map:Ne,matcap:Re,envMap:te,envMapMode:te&&q.mapping,envMapCubeUVHeight:Z,aoMap:Je,lightMap:B,bumpMap:H,normalMap:W,displacementMap:m&&z,emissiveMap:V,normalMapObjectSpace:W&&T.normalMapType===wLe,normalMapTangentSpace:W&&T.normalMapType===bJ,metalnessMap:Q,roughnessMap:Te,anisotropy:ke,anisotropyMap:ce,clearcoat:Ae,clearcoatMap:xe,clearcoatNormalMap:ve,clearcoatRoughnessMap:_e,iridescence:$,iridescenceMap:Ie,iridescenceThicknessMap:We,sheen:L,sheenColorMap:ht,sheenRoughnessMap:qe,specularMap:me,specularColorMap:rt,specularIntensityMap:Xe,transmission:oe,transmissionMap:nt,thicknessMap:ut,gradientMap:ae,opaque:T.transparent===!1&&T.blending===$p,alphaMap:$e,alphaTest:ye,alphaHash:Be,combine:T.combine,mapUv:Ne&&v(T.map.channel),aoMapUv:Je&&v(T.aoMap.channel),lightMapUv:B&&v(T.lightMap.channel),bumpMapUv:H&&v(T.bumpMap.channel),normalMapUv:W&&v(T.normalMap.channel),displacementMapUv:z&&v(T.displacementMap.channel),emissiveMapUv:V&&v(T.emissiveMap.channel),metalnessMapUv:Q&&v(T.metalnessMap.channel),roughnessMapUv:Te&&v(T.roughnessMap.channel),anisotropyMapUv:ce&&v(T.anisotropyMap.channel),clearcoatMapUv:xe&&v(T.clearcoatMap.channel),clearcoatNormalMapUv:ve&&v(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&v(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Ie&&v(T.iridescenceMap.channel),iridescenceThicknessMapUv:We&&v(T.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&v(T.sheenColorMap.channel),sheenRoughnessMapUv:qe&&v(T.sheenRoughnessMap.channel),specularMapUv:me&&v(T.specularMap.channel),specularColorMapUv:rt&&v(T.specularColorMap.channel),specularIntensityMapUv:Xe&&v(T.specularIntensityMap.channel),transmissionMapUv:nt&&v(T.transmissionMap.channel),thicknessMapUv:ut&&v(T.thicknessMap.channel),alphaMapUv:$e&&v(T.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(W||ke),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,vertexUv1s:we,vertexUv2s:Ve,vertexUv3s:dt,pointsUvs:X.isPoints===!0&&!!K.attributes.uv&&(Ne||$e),fog:!!D,useFog:T.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:T.flatShading===!0,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:X.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:G,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:Tt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ne&&T.map.isVideoTexture===!0&&lr.getTransfer(T.map.colorSpace)===Mr,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Lc,flipSided:T.side===hs,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionDerivatives:De&&T.extensions.derivatives===!0,extensionFragDepth:De&&T.extensions.fragDepth===!0,extensionDrawBuffers:De&&T.extensions.drawBuffers===!0,extensionShaderTextureLOD:De&&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 y(T){const P=[];if(T.shaderID?P.push(T.shaderID):(P.push(T.customVertexShaderID),P.push(T.customFragmentShaderID)),T.defines!==void 0)for(const F in T.defines)P.push(F),P.push(T.defines[F]);return T.isRawShaderMaterial===!1&&(M(P,T),S(P,T),P.push(t.outputColorSpace)),P.push(T.customProgramCacheKey),P.join()}function M(T,P){T.push(P.precision),T.push(P.outputColorSpace),T.push(P.envMapMode),T.push(P.envMapCubeUVHeight),T.push(P.mapUv),T.push(P.alphaMapUv),T.push(P.lightMapUv),T.push(P.aoMapUv),T.push(P.bumpMapUv),T.push(P.normalMapUv),T.push(P.displacementMapUv),T.push(P.emissiveMapUv),T.push(P.metalnessMapUv),T.push(P.roughnessMapUv),T.push(P.anisotropyMapUv),T.push(P.clearcoatMapUv),T.push(P.clearcoatNormalMapUv),T.push(P.clearcoatRoughnessMapUv),T.push(P.iridescenceMapUv),T.push(P.iridescenceThicknessMapUv),T.push(P.sheenColorMapUv),T.push(P.sheenRoughnessMapUv),T.push(P.specularMapUv),T.push(P.specularColorMapUv),T.push(P.specularIntensityMapUv),T.push(P.transmissionMapUv),T.push(P.thicknessMapUv),T.push(P.combine),T.push(P.fogExp2),T.push(P.sizeAttenuation),T.push(P.morphTargetsCount),T.push(P.morphAttributeCount),T.push(P.numDirLights),T.push(P.numPointLights),T.push(P.numSpotLights),T.push(P.numSpotLightMaps),T.push(P.numHemiLights),T.push(P.numRectAreaLights),T.push(P.numDirLightShadows),T.push(P.numPointLightShadows),T.push(P.numSpotLightShadows),T.push(P.numSpotLightShadowsWithMaps),T.push(P.numLightProbes),T.push(P.shadowMapType),T.push(P.toneMapping),T.push(P.numClippingPlanes),T.push(P.numClipIntersection),T.push(P.depthPacking)}function S(T,P){l.disableAll(),P.isWebGL2&&l.enable(0),P.supportsVertexTextures&&l.enable(1),P.instancing&&l.enable(2),P.instancingColor&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),T.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.skinning&&l.enable(4),P.morphTargets&&l.enable(5),P.morphNormals&&l.enable(6),P.morphColors&&l.enable(7),P.premultipliedAlpha&&l.enable(8),P.shadowMapEnabled&&l.enable(9),P.useLegacyLights&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),T.push(l.mask)}function A(T){const P=x[T.type];let F;if(P){const I=ss[P];F=kO.clone(I.uniforms)}else F=T.uniforms;return F}function E(T,P){let F;for(let I=0,X=u.length;I<X;I++){const D=u[I];if(D.cacheKey===P){F=D,++F.usedTimes;break}}return F===void 0&&(F=new _ze(t,P,T,a),u.push(F)),F}function k(T){if(--T.usedTimes===0){const P=u.indexOf(T);u[P]=u[u.length-1],u.pop(),T.destroy()}}function C(T){c.remove(T)}function R(){c.dispose()}return{getParameters:b,getProgramCacheKey:y,getUniforms:A,acquireProgram:E,releaseProgram:k,releaseShaderCache:C,programs:u,dispose:R}}function Eze(){let t=new WeakMap;function e(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function n(a){t.delete(a)}function r(a,o,l){t.get(a)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function Aze(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 C7(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function k7(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,m,p,x,v,b){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:m,material:p,groupOrder:x,renderOrder:f.renderOrder,z:v,group:b},t[e]=y):(y.id=f.id,y.object=f,y.geometry=m,y.material=p,y.groupOrder=x,y.renderOrder=f.renderOrder,y.z=v,y.group=b),e++,y}function l(f,m,p,x,v,b){const y=o(f,m,p,x,v,b);p.transmission>0?r.push(y):p.transparent===!0?i.push(y):n.push(y)}function c(f,m,p,x,v,b){const y=o(f,m,p,x,v,b);p.transmission>0?r.unshift(y):p.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,m){n.length>1&&n.sort(f||Aze),r.length>1&&r.sort(m||C7),i.length>1&&i.sort(m||C7)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function Tze(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new k7,t.set(r,[o])):i>=a.length?(o=new k7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function Cze(){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 Ue,color:new qt};break;case"SpotLight":n={position:new Ue,direction:new Ue,color:new qt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ue,color:new qt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ue,skyColor:new qt,groundColor:new qt};break;case"RectAreaLight":n={color:new qt,position:new Ue,halfWidth:new Ue,halfHeight:new Ue};break}return t[e.id]=n,n}}}function kze(){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 rn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let jze=0;function Pze(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Rze(t,e){const n=new Cze,r=kze(),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 Ue);const a=new Ue,o=new vr,l=new vr;function c(d,f){let m=0,p=0,x=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let v=0,b=0,y=0,M=0,S=0,A=0,E=0,k=0,C=0,R=0,T=0;d.sort(Pze);const P=f===!0?Math.PI:1;for(let I=0,X=d.length;I<X;I++){const D=d[I],K=D.color,Y=D.intensity,q=D.distance,Z=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)m+=K.r*Y*P,p+=K.g*Y*P,x+=K.b*Y*P;else if(D.isLightProbe){for(let re=0;re<9;re++)i.probe[re].addScaledVector(D.sh.coefficients[re],Y);T++}else if(D.isDirectionalLight){const re=n.get(D);if(re.color.copy(D.color).multiplyScalar(D.intensity*P),D.castShadow){const ie=D.shadow,U=r.get(D);U.shadowBias=ie.bias,U.shadowNormalBias=ie.normalBias,U.shadowRadius=ie.radius,U.shadowMapSize=ie.mapSize,i.directionalShadow[v]=U,i.directionalShadowMap[v]=Z,i.directionalShadowMatrix[v]=D.shadow.matrix,A++}i.directional[v]=re,v++}else if(D.isSpotLight){const re=n.get(D);re.position.setFromMatrixPosition(D.matrixWorld),re.color.copy(K).multiplyScalar(Y*P),re.distance=q,re.coneCos=Math.cos(D.angle),re.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),re.decay=D.decay,i.spot[y]=re;const ie=D.shadow;if(D.map&&(i.spotLightMap[C]=D.map,C++,ie.updateMatrices(D),D.castShadow&&R++),i.spotLightMatrix[y]=ie.matrix,D.castShadow){const U=r.get(D);U.shadowBias=ie.bias,U.shadowNormalBias=ie.normalBias,U.shadowRadius=ie.radius,U.shadowMapSize=ie.mapSize,i.spotShadow[y]=U,i.spotShadowMap[y]=Z,k++}y++}else if(D.isRectAreaLight){const re=n.get(D);re.color.copy(K).multiplyScalar(Y),re.halfWidth.set(D.width*.5,0,0),re.halfHeight.set(0,D.height*.5,0),i.rectArea[M]=re,M++}else if(D.isPointLight){const re=n.get(D);if(re.color.copy(D.color).multiplyScalar(D.intensity*P),re.distance=D.distance,re.decay=D.decay,D.castShadow){const ie=D.shadow,U=r.get(D);U.shadowBias=ie.bias,U.shadowNormalBias=ie.normalBias,U.shadowRadius=ie.radius,U.shadowMapSize=ie.mapSize,U.shadowCameraNear=ie.camera.near,U.shadowCameraFar=ie.camera.far,i.pointShadow[b]=U,i.pointShadowMap[b]=Z,i.pointShadowMatrix[b]=D.shadow.matrix,E++}i.point[b]=re,b++}else if(D.isHemisphereLight){const re=n.get(D);re.skyColor.copy(D.color).multiplyScalar(Y*P),re.groundColor.copy(D.groundColor).multiplyScalar(Y*P),i.hemi[S]=re,S++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=kt.LTC_FLOAT_1,i.rectAreaLTC2=kt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=kt.LTC_HALF_1,i.rectAreaLTC2=kt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=m,i.ambient[1]=p,i.ambient[2]=x;const F=i.hash;(F.directionalLength!==v||F.pointLength!==b||F.spotLength!==y||F.rectAreaLength!==M||F.hemiLength!==S||F.numDirectionalShadows!==A||F.numPointShadows!==E||F.numSpotShadows!==k||F.numSpotMaps!==C||F.numLightProbes!==T)&&(i.directional.length=v,i.spot.length=y,i.rectArea.length=M,i.point.length=b,i.hemi.length=S,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=k+C-R,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=T,F.directionalLength=v,F.pointLength=b,F.spotLength=y,F.rectAreaLength=M,F.hemiLength=S,F.numDirectionalShadows=A,F.numPointShadows=E,F.numSpotShadows=k,F.numSpotMaps=C,F.numLightProbes=T,i.version=jze++)}function u(d,f){let m=0,p=0,x=0,v=0,b=0;const y=f.matrixWorldInverse;for(let M=0,S=d.length;M<S;M++){const A=d[M];if(A.isDirectionalLight){const E=i.directional[m];E.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),E.direction.sub(a),E.direction.transformDirection(y),m++}else if(A.isSpotLight){const E=i.spot[x];E.position.setFromMatrixPosition(A.matrixWorld),E.position.applyMatrix4(y),E.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),E.direction.sub(a),E.direction.transformDirection(y),x++}else if(A.isRectAreaLight){const E=i.rectArea[v];E.position.setFromMatrixPosition(A.matrixWorld),E.position.applyMatrix4(y),l.identity(),o.copy(A.matrixWorld),o.premultiply(y),l.extractRotation(o),E.halfWidth.set(A.width*.5,0,0),E.halfHeight.set(0,A.height*.5,0),E.halfWidth.applyMatrix4(l),E.halfHeight.applyMatrix4(l),v++}else if(A.isPointLight){const E=i.point[p];E.position.setFromMatrixPosition(A.matrixWorld),E.position.applyMatrix4(y),p++}else if(A.isHemisphereLight){const E=i.hemi[b];E.direction.setFromMatrixPosition(A.matrixWorld),E.direction.transformDirection(y),b++}}}return{setup:c,setupView:u,state:i}}function j7(t,e){const n=new Rze(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function o(f){r.push(f)}function l(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function Dze(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new j7(t,e),n.set(a,[c])):o>=l.length?(c=new j7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class Oze extends qg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=vLe,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 Lze extends qg{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 Ize=`void main() {
  7449. gl_Position = vec4( position, 1.0 );
  7450. }`,Fze=`uniform sampler2D shadow_pass;
  7451. uniform vec2 resolution;
  7452. uniform float radius;
  7453. #include <packing>
  7454. void main() {
  7455. const float samples = float( VSM_SAMPLES );
  7456. float mean = 0.0;
  7457. float squared_mean = 0.0;
  7458. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7459. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7460. for ( float i = 0.0; i < samples; i ++ ) {
  7461. float uvOffset = uvStart + i * uvStride;
  7462. #ifdef HORIZONTAL_PASS
  7463. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7464. mean += distribution.x;
  7465. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7466. #else
  7467. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7468. mean += depth;
  7469. squared_mean += depth * depth;
  7470. #endif
  7471. }
  7472. mean = mean / samples;
  7473. squared_mean = squared_mean / samples;
  7474. float std_dev = sqrt( squared_mean - mean * mean );
  7475. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7476. }`;function Uze(t,e,n){let r=new BM;const i=new rn,a=new rn,o=new ur,l=new Oze({depthPacking:_Le}),c=new Lze,u={},d=n.maxTextureSize,f={[Hd]:hs,[hs]:Hd,[Lc]:Lc},m=new Vd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new rn},radius:{value:4}},vertexShader:Ize,fragmentShader:Fze}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const x=new Pa;x.setAttribute("position",new Bs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Yo(x,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=lJ;let y=this.type;this.render=function(E,k,C){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||E.length===0)return;const R=t.getRenderTarget(),T=t.getActiveCubeFace(),P=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Ad),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const I=y!==Cc&&this.type===Cc,X=y===Cc&&this.type!==Cc;for(let D=0,K=E.length;D<K;D++){const Y=E[D],q=Y.shadow;if(q===void 0){console.warn("THREE.WebGLShadowMap:",Y,"has no shadow.");continue}if(q.autoUpdate===!1&&q.needsUpdate===!1)continue;i.copy(q.mapSize);const Z=q.getFrameExtents();if(i.multiply(Z),a.copy(q.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,q.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,q.mapSize.y=a.y)),q.map===null||I===!0||X===!0){const ie=this.type!==Cc?{minFilter:ha,magFilter:ha}:{};q.map!==null&&q.map.dispose(),q.map=new Of(i.x,i.y,ie),q.map.texture.name=Y.name+".shadowMap",q.camera.updateProjectionMatrix()}t.setRenderTarget(q.map),t.clear();const re=q.getViewportCount();for(let ie=0;ie<re;ie++){const U=q.getViewport(ie);o.set(a.x*U.x,a.y*U.y,a.x*U.z,a.y*U.w),F.viewport(o),q.updateMatrices(Y,ie),r=q.getFrustum(),A(k,C,q.camera,Y,this.type)}q.isPointLightShadow!==!0&&this.type===Cc&&M(q,C),q.needsUpdate=!1}y=this.type,b.needsUpdate=!1,t.setRenderTarget(R,T,P)};function M(E,k){const C=e.update(v);m.defines.VSM_SAMPLES!==E.blurSamples&&(m.defines.VSM_SAMPLES=E.blurSamples,p.defines.VSM_SAMPLES=E.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Of(i.x,i.y)),m.uniforms.shadow_pass.value=E.map.texture,m.uniforms.resolution.value=E.mapSize,m.uniforms.radius.value=E.radius,t.setRenderTarget(E.mapPass),t.clear(),t.renderBufferDirect(k,null,C,m,v,null),p.uniforms.shadow_pass.value=E.mapPass.texture,p.uniforms.resolution.value=E.mapSize,p.uniforms.radius.value=E.radius,t.setRenderTarget(E.map),t.clear(),t.renderBufferDirect(k,null,C,p,v,null)}function S(E,k,C,R){let T=null;const P=C.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(P!==void 0)T=P;else if(T=C.isPointLight===!0?c:l,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const F=T.uuid,I=k.uuid;let X=u[F];X===void 0&&(X={},u[F]=X);let D=X[I];D===void 0&&(D=T.clone(),X[I]=D),T=D}if(T.visible=k.visible,T.wireframe=k.wireframe,R===Cc?T.side=k.shadowSide!==null?k.shadowSide:k.side:T.side=k.shadowSide!==null?k.shadowSide:f[k.side],T.alphaMap=k.alphaMap,T.alphaTest=k.alphaTest,T.map=k.map,T.clipShadows=k.clipShadows,T.clippingPlanes=k.clippingPlanes,T.clipIntersection=k.clipIntersection,T.displacementMap=k.displacementMap,T.displacementScale=k.displacementScale,T.displacementBias=k.displacementBias,T.wireframeLinewidth=k.wireframeLinewidth,T.linewidth=k.linewidth,C.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const F=t.properties.get(T);F.light=C}return T}function A(E,k,C,R,T){if(E.visible===!1)return;if(E.layers.test(k.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&T===Cc)&&(!E.frustumCulled||r.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,E.matrixWorld);const I=e.update(E),X=E.material;if(Array.isArray(X)){const D=I.groups;for(let K=0,Y=D.length;K<Y;K++){const q=D[K],Z=X[q.materialIndex];if(Z&&Z.visible){const re=S(E,Z,R,T);E.onBeforeShadow(t,E,k,C,I,re,q),t.renderBufferDirect(C,null,I,re,E,q),E.onAfterShadow(t,E,k,C,I,re,q)}}}else if(X.visible){const D=S(E,X,R,T);E.onBeforeShadow(t,E,k,C,I,D,null),t.renderBufferDirect(C,null,I,D,E,null),E.onAfterShadow(t,E,k,C,I,D,null)}}const F=E.children;for(let I=0,X=F.length;I<X;I++)A(F[I],k,C,R,T)}}function zze(t,e,n){const r=n.isWebGL2;function i(){let ye=!1;const Be=new ur;let De=null;const we=new ur(0,0,0,0);return{setMask:function(Ve){De!==Ve&&!ye&&(t.colorMask(Ve,Ve,Ve,Ve),De=Ve)},setLocked:function(Ve){ye=Ve},setClear:function(Ve,dt,Tt,Ct,Xt){Xt===!0&&(Ve*=Ct,dt*=Ct,Tt*=Ct),Be.set(Ve,dt,Tt,Ct),we.equals(Be)===!1&&(t.clearColor(Ve,dt,Tt,Ct),we.copy(Be))},reset:function(){ye=!1,De=null,we.set(-1,0,0,0)}}}function a(){let ye=!1,Be=null,De=null,we=null;return{setTest:function(Ve){Ve?ge(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(Ve){Be!==Ve&&!ye&&(t.depthMask(Ve),Be=Ve)},setFunc:function(Ve){if(De!==Ve){switch(Ve){case QOe:t.depthFunc(t.NEVER);break;case ZOe:t.depthFunc(t.ALWAYS);break;case JOe:t.depthFunc(t.LESS);break;case yS:t.depthFunc(t.LEQUAL);break;case eLe:t.depthFunc(t.EQUAL);break;case tLe:t.depthFunc(t.GEQUAL);break;case nLe:t.depthFunc(t.GREATER);break;case rLe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}De=Ve}},setLocked:function(Ve){ye=Ve},setClear:function(Ve){we!==Ve&&(t.clearDepth(Ve),we=Ve)},reset:function(){ye=!1,Be=null,De=null,we=null}}}function o(){let ye=!1,Be=null,De=null,we=null,Ve=null,dt=null,Tt=null,Ct=null,Xt=null;return{setTest:function(Pt){ye||(Pt?ge(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(Pt){Be!==Pt&&!ye&&(t.stencilMask(Pt),Be=Pt)},setFunc:function(Pt,an,bn){(De!==Pt||we!==an||Ve!==bn)&&(t.stencilFunc(Pt,an,bn),De=Pt,we=an,Ve=bn)},setOp:function(Pt,an,bn){(dt!==Pt||Tt!==an||Ct!==bn)&&(t.stencilOp(Pt,an,bn),dt=Pt,Tt=an,Ct=bn)},setLocked:function(Pt){ye=Pt},setClear:function(Pt){Xt!==Pt&&(t.clearStencil(Pt),Xt=Pt)},reset:function(){ye=!1,Be=null,De=null,we=null,Ve=null,dt=null,Tt=null,Ct=null,Xt=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let m={},p={},x=new WeakMap,v=[],b=null,y=!1,M=null,S=null,A=null,E=null,k=null,C=null,R=null,T=new qt(0,0,0),P=0,F=!1,I=null,X=null,D=null,K=null,Y=null;const q=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Z=!1,re=0;const ie=t.getParameter(t.VERSION);ie.indexOf("WebGL")!==-1?(re=parseFloat(/^WebGL (\d)/.exec(ie)[1]),Z=re>=1):ie.indexOf("OpenGL ES")!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),Z=re>=2);let U=null,G={};const ee=t.getParameter(t.SCISSOR_BOX),ne=t.getParameter(t.VIEWPORT),se=new ur().fromArray(ee),de=new ur().fromArray(ne);function he(ye,Be,De,we){const Ve=new Uint8Array(4),dt=t.createTexture();t.bindTexture(ye,dt),t.texParameteri(ye,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ye,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Tt=0;Tt<De;Tt++)r&&(ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY)?t.texImage3D(Be,0,t.RGBA,1,1,we,0,t.RGBA,t.UNSIGNED_BYTE,Ve):t.texImage2D(Be+Tt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ve);return dt}const Ee={};Ee[t.TEXTURE_2D]=he(t.TEXTURE_2D,t.TEXTURE_2D,1),Ee[t.TEXTURE_CUBE_MAP]=he(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ee[t.TEXTURE_2D_ARRAY]=he(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ee[t.TEXTURE_3D]=he(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),ge(t.DEPTH_TEST),c.setFunc(yS),V(!1),Q(fV),ge(t.CULL_FACE),W(Ad);function ge(ye){m[ye]!==!0&&(t.enable(ye),m[ye]=!0)}function Ne(ye){m[ye]!==!1&&(t.disable(ye),m[ye]=!1)}function Re(ye,Be){return p[ye]!==Be?(t.bindFramebuffer(ye,Be),p[ye]=Be,r&&(ye===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=Be),ye===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=Be)),!0):!1}function te(ye,Be){let De=v,we=!1;if(ye)if(De=x.get(Be),De===void 0&&(De=[],x.set(Be,De)),ye.isWebGLMultipleRenderTargets){const Ve=ye.texture;if(De.length!==Ve.length||De[0]!==t.COLOR_ATTACHMENT0){for(let dt=0,Tt=Ve.length;dt<Tt;dt++)De[dt]=t.COLOR_ATTACHMENT0+dt;De.length=Ve.length,we=!0}}else De[0]!==t.COLOR_ATTACHMENT0&&(De[0]=t.COLOR_ATTACHMENT0,we=!0);else De[0]!==t.BACK&&(De[0]=t.BACK,we=!0);we&&(n.isWebGL2?t.drawBuffers(De):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(De))}function Je(ye){return b!==ye?(t.useProgram(ye),b=ye,!0):!1}const B={[Fh]:t.FUNC_ADD,[LOe]:t.FUNC_SUBTRACT,[IOe]:t.FUNC_REVERSE_SUBTRACT};if(r)B[xV]=t.MIN,B[bV]=t.MAX;else{const ye=e.get("EXT_blend_minmax");ye!==null&&(B[xV]=ye.MIN_EXT,B[bV]=ye.MAX_EXT)}const H={[FOe]:t.ZERO,[UOe]:t.ONE,[zOe]:t.SRC_COLOR,[UP]:t.SRC_ALPHA,[WOe]:t.SRC_ALPHA_SATURATE,[VOe]:t.DST_COLOR,[$Oe]:t.DST_ALPHA,[BOe]:t.ONE_MINUS_SRC_COLOR,[zP]:t.ONE_MINUS_SRC_ALPHA,[GOe]:t.ONE_MINUS_DST_COLOR,[HOe]:t.ONE_MINUS_DST_ALPHA,[qOe]:t.CONSTANT_COLOR,[KOe]:t.ONE_MINUS_CONSTANT_COLOR,[XOe]:t.CONSTANT_ALPHA,[YOe]:t.ONE_MINUS_CONSTANT_ALPHA};function W(ye,Be,De,we,Ve,dt,Tt,Ct,Xt,Pt){if(ye===Ad){y===!0&&(Ne(t.BLEND),y=!1);return}if(y===!1&&(ge(t.BLEND),y=!0),ye!==OOe){if(ye!==M||Pt!==F){if((S!==Fh||k!==Fh)&&(t.blendEquation(t.FUNC_ADD),S=Fh,k=Fh),Pt)switch(ye){case $p:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case mV:t.blendFunc(t.ONE,t.ONE);break;case pV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case gV:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ye);break}else switch(ye){case $p:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case mV:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case pV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case gV:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ye);break}A=null,E=null,C=null,R=null,T.set(0,0,0),P=0,M=ye,F=Pt}return}Ve=Ve||Be,dt=dt||De,Tt=Tt||we,(Be!==S||Ve!==k)&&(t.blendEquationSeparate(B[Be],B[Ve]),S=Be,k=Ve),(De!==A||we!==E||dt!==C||Tt!==R)&&(t.blendFuncSeparate(H[De],H[we],H[dt],H[Tt]),A=De,E=we,C=dt,R=Tt),(Ct.equals(T)===!1||Xt!==P)&&(t.blendColor(Ct.r,Ct.g,Ct.b,Xt),T.copy(Ct),P=Xt),M=ye,F=!1}function z(ye,Be){ye.side===Lc?Ne(t.CULL_FACE):ge(t.CULL_FACE);let De=ye.side===hs;Be&&(De=!De),V(De),ye.blending===$p&&ye.transparent===!1?W(Ad):W(ye.blending,ye.blendEquation,ye.blendSrc,ye.blendDst,ye.blendEquationAlpha,ye.blendSrcAlpha,ye.blendDstAlpha,ye.blendColor,ye.blendAlpha,ye.premultipliedAlpha),c.setFunc(ye.depthFunc),c.setTest(ye.depthTest),c.setMask(ye.depthWrite),l.setMask(ye.colorWrite);const we=ye.stencilWrite;u.setTest(we),we&&(u.setMask(ye.stencilWriteMask),u.setFunc(ye.stencilFunc,ye.stencilRef,ye.stencilFuncMask),u.setOp(ye.stencilFail,ye.stencilZFail,ye.stencilZPass)),ke(ye.polygonOffset,ye.polygonOffsetFactor,ye.polygonOffsetUnits),ye.alphaToCoverage===!0?ge(t.SAMPLE_ALPHA_TO_COVERAGE):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function V(ye){I!==ye&&(ye?t.frontFace(t.CW):t.frontFace(t.CCW),I=ye)}function Q(ye){ye!==POe?(ge(t.CULL_FACE),ye!==X&&(ye===fV?t.cullFace(t.BACK):ye===ROe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),X=ye}function Te(ye){ye!==D&&(Z&&t.lineWidth(ye),D=ye)}function ke(ye,Be,De){ye?(ge(t.POLYGON_OFFSET_FILL),(K!==Be||Y!==De)&&(t.polygonOffset(Be,De),K=Be,Y=De)):Ne(t.POLYGON_OFFSET_FILL)}function Ae(ye){ye?ge(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function $(ye){ye===void 0&&(ye=t.TEXTURE0+q-1),U!==ye&&(t.activeTexture(ye),U=ye)}function L(ye,Be,De){De===void 0&&(U===null?De=t.TEXTURE0+q-1:De=U);let we=G[De];we===void 0&&(we={type:void 0,texture:void 0},G[De]=we),(we.type!==ye||we.texture!==Be)&&(U!==De&&(t.activeTexture(De),U=De),t.bindTexture(ye,Be||Ee[ye]),we.type=ye,we.texture=Be)}function oe(){const ye=G[U];ye!==void 0&&ye.type!==void 0&&(t.bindTexture(ye.type,null),ye.type=void 0,ye.texture=void 0)}function ce(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function xe(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function ve(){try{t.texSubImage2D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function _e(){try{t.texSubImage3D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function Ie(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function We(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function ht(){try{t.texStorage2D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function qe(){try{t.texStorage3D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function me(){try{t.texImage2D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function rt(){try{t.texImage3D.apply(t,arguments)}catch(ye){console.error("THREE.WebGLState:",ye)}}function Xe(ye){se.equals(ye)===!1&&(t.scissor(ye.x,ye.y,ye.z,ye.w),se.copy(ye))}function nt(ye){de.equals(ye)===!1&&(t.viewport(ye.x,ye.y,ye.z,ye.w),de.copy(ye))}function ut(ye,Be){let De=f.get(Be);De===void 0&&(De=new WeakMap,f.set(Be,De));let we=De.get(ye);we===void 0&&(we=t.getUniformBlockIndex(Be,ye.name),De.set(ye,we))}function ae(ye,Be){const we=f.get(Be).get(ye);d.get(Be)!==we&&(t.uniformBlockBinding(Be,we,ye.__bindingPointIndex),d.set(Be,we))}function $e(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),m={},U=null,G={},p={},x=new WeakMap,v=[],b=null,y=!1,M=null,S=null,A=null,E=null,k=null,C=null,R=null,T=new qt(0,0,0),P=0,F=!1,I=null,X=null,D=null,K=null,Y=null,se.set(0,0,t.canvas.width,t.canvas.height),de.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:ge,disable:Ne,bindFramebuffer:Re,drawBuffers:te,useProgram:Je,setBlending:W,setMaterial:z,setFlipSided:V,setCullFace:Q,setLineWidth:Te,setPolygonOffset:ke,setScissorTest:Ae,activeTexture:$,bindTexture:L,unbindTexture:oe,compressedTexImage2D:ce,compressedTexImage3D:xe,texImage2D:me,texImage3D:rt,updateUBOMapping:ut,uniformBlockBinding:ae,texStorage2D:ht,texStorage3D:qe,texSubImage2D:ve,texSubImage3D:_e,compressedTexSubImage2D:Ie,compressedTexSubImage3D:We,scissor:Xe,viewport:nt,reset:$e}}function Bze(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,m=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let v;const b=new WeakMap;let y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M($,L){return y?new OffscreenCanvas($,L):MS("canvas")}function S($,L,oe,ce){let xe=1;if(($.width>ce||$.height>ce)&&(xe=ce/Math.max($.width,$.height)),xe<1||L===!0)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap){const ve=L?SS:Math.floor,_e=ve(xe*$.width),Ie=ve(xe*$.height);v===void 0&&(v=M(_e,Ie));const We=oe?M(_e,Ie):v;return We.width=_e,We.height=Ie,We.getContext("2d").drawImage($,0,0,_e,Ie),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+_e+"x"+Ie+")."),We}else return"data"in $&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),$;return $}function A($){return qP($.width)&&qP($.height)}function E($){return l?!1:$.wrapS!==qo||$.wrapT!==qo||$.minFilter!==ha&&$.minFilter!==xo}function k($,L){return $.generateMipmaps&&L&&$.minFilter!==ha&&$.minFilter!==xo}function C($){t.generateMipmap($)}function R($,L,oe,ce,xe=!1){if(l===!1)return L;if($!==null){if(t[$]!==void 0)return t[$];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ve=L;if(L===t.RED&&(oe===t.FLOAT&&(ve=t.R32F),oe===t.HALF_FLOAT&&(ve=t.R16F),oe===t.UNSIGNED_BYTE&&(ve=t.R8)),L===t.RED_INTEGER&&(oe===t.UNSIGNED_BYTE&&(ve=t.R8UI),oe===t.UNSIGNED_SHORT&&(ve=t.R16UI),oe===t.UNSIGNED_INT&&(ve=t.R32UI),oe===t.BYTE&&(ve=t.R8I),oe===t.SHORT&&(ve=t.R16I),oe===t.INT&&(ve=t.R32I)),L===t.RG&&(oe===t.FLOAT&&(ve=t.RG32F),oe===t.HALF_FLOAT&&(ve=t.RG16F),oe===t.UNSIGNED_BYTE&&(ve=t.RG8)),L===t.RGBA){const _e=xe?vS:lr.getTransfer(ce);oe===t.FLOAT&&(ve=t.RGBA32F),oe===t.HALF_FLOAT&&(ve=t.RGBA16F),oe===t.UNSIGNED_BYTE&&(ve=_e===Mr?t.SRGB8_ALPHA8:t.RGBA8),oe===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),oe===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function T($,L,oe){return k($,oe)===!0||$.isFramebufferTexture&&$.minFilter!==ha&&$.minFilter!==xo?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function P($){return $===ha||$===yV||$===QC?t.NEAREST:t.LINEAR}function F($){const L=$.target;L.removeEventListener("dispose",F),X(L),L.isVideoTexture&&x.delete(L)}function I($){const L=$.target;L.removeEventListener("dispose",I),K(L)}function X($){const L=r.get($);if(L.__webglInit===void 0)return;const oe=$.source,ce=b.get(oe);if(ce){const xe=ce[L.__cacheKey];xe.usedTimes--,xe.usedTimes===0&&D($),Object.keys(ce).length===0&&b.delete(oe)}r.remove($)}function D($){const L=r.get($);t.deleteTexture(L.__webglTexture);const oe=$.source,ce=b.get(oe);delete ce[L.__cacheKey],o.memory.textures--}function K($){const L=$.texture,oe=r.get($),ce=r.get(L);if(ce.__webglTexture!==void 0&&(t.deleteTexture(ce.__webglTexture),o.memory.textures--),$.depthTexture&&$.depthTexture.dispose(),$.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++){if(Array.isArray(oe.__webglFramebuffer[xe]))for(let ve=0;ve<oe.__webglFramebuffer[xe].length;ve++)t.deleteFramebuffer(oe.__webglFramebuffer[xe][ve]);else t.deleteFramebuffer(oe.__webglFramebuffer[xe]);oe.__webglDepthbuffer&&t.deleteRenderbuffer(oe.__webglDepthbuffer[xe])}else{if(Array.isArray(oe.__webglFramebuffer))for(let xe=0;xe<oe.__webglFramebuffer.length;xe++)t.deleteFramebuffer(oe.__webglFramebuffer[xe]);else t.deleteFramebuffer(oe.__webglFramebuffer);if(oe.__webglDepthbuffer&&t.deleteRenderbuffer(oe.__webglDepthbuffer),oe.__webglMultisampledFramebuffer&&t.deleteFramebuffer(oe.__webglMultisampledFramebuffer),oe.__webglColorRenderbuffer)for(let xe=0;xe<oe.__webglColorRenderbuffer.length;xe++)oe.__webglColorRenderbuffer[xe]&&t.deleteRenderbuffer(oe.__webglColorRenderbuffer[xe]);oe.__webglDepthRenderbuffer&&t.deleteRenderbuffer(oe.__webglDepthRenderbuffer)}if($.isWebGLMultipleRenderTargets)for(let xe=0,ve=L.length;xe<ve;xe++){const _e=r.get(L[xe]);_e.__webglTexture&&(t.deleteTexture(_e.__webglTexture),o.memory.textures--),r.remove(L[xe])}r.remove(L),r.remove($)}let Y=0;function q(){Y=0}function Z(){const $=Y;return $>=c&&console.warn("THREE.WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+c),Y+=1,$}function re($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function ie($,L){const oe=r.get($);if($.isVideoTexture&&ke($),$.isRenderTargetTexture===!1&&$.version>0&&oe.__version!==$.version){const ce=$.image;if(ce===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ce.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ge(oe,$,L);return}}n.bindTexture(t.TEXTURE_2D,oe.__webglTexture,t.TEXTURE0+L)}function U($,L){const oe=r.get($);if($.version>0&&oe.__version!==$.version){ge(oe,$,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,oe.__webglTexture,t.TEXTURE0+L)}function G($,L){const oe=r.get($);if($.version>0&&oe.__version!==$.version){ge(oe,$,L);return}n.bindTexture(t.TEXTURE_3D,oe.__webglTexture,t.TEXTURE0+L)}function ee($,L){const oe=r.get($);if($.version>0&&oe.__version!==$.version){Ne(oe,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,oe.__webglTexture,t.TEXTURE0+L)}const ne={[HP]:t.REPEAT,[qo]:t.CLAMP_TO_EDGE,[VP]:t.MIRRORED_REPEAT},se={[ha]:t.NEAREST,[yV]:t.NEAREST_MIPMAP_NEAREST,[QC]:t.NEAREST_MIPMAP_LINEAR,[xo]:t.LINEAR,[dLe]:t.LINEAR_MIPMAP_NEAREST,[T0]:t.LINEAR_MIPMAP_LINEAR},de={[SLe]:t.NEVER,[CLe]:t.ALWAYS,[MLe]:t.LESS,[yJ]:t.LEQUAL,[NLe]:t.EQUAL,[TLe]:t.GEQUAL,[ELe]:t.GREATER,[ALe]:t.NOTEQUAL};function he($,L,oe){if(oe?(t.texParameteri($,t.TEXTURE_WRAP_S,ne[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ne[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ne[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,se[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,se[L.minFilter])):(t.texParameteri($,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri($,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==qo||L.wrapT!==qo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri($,t.TEXTURE_MAG_FILTER,P(L.magFilter)),t.texParameteri($,t.TEXTURE_MIN_FILTER,P(L.minFilter)),L.minFilter!==ha&&L.minFilter!==xo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,de[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ce=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===ha||L.minFilter!==QC&&L.minFilter!==T0||L.type===$c&&e.has("OES_texture_float_linear")===!1||l===!1&&L.type===C0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf($,ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ee($,L){let oe=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",F));const ce=L.source;let xe=b.get(ce);xe===void 0&&(xe={},b.set(ce,xe));const ve=re(L);if(ve!==$.__cacheKey){xe[ve]===void 0&&(xe[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,oe=!0),xe[ve].usedTimes++;const _e=xe[$.__cacheKey];_e!==void 0&&(xe[$.__cacheKey].usedTimes--,_e.usedTimes===0&&D(L)),$.__cacheKey=ve,$.__webglTexture=xe[ve].texture}return oe}function ge($,L,oe){let ce=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ce=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ce=t.TEXTURE_3D);const xe=Ee($,L),ve=L.source;n.bindTexture(ce,$.__webglTexture,t.TEXTURE0+oe);const _e=r.get(ve);if(ve.version!==_e.__version||xe===!0){n.activeTexture(t.TEXTURE0+oe);const Ie=lr.getPrimaries(lr.workingColorSpace),We=L.colorSpace===yo?null:lr.getPrimaries(L.colorSpace),ht=L.colorSpace===yo||Ie===We?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,ht);const qe=E(L)&&A(L.image)===!1;let me=S(L.image,qe,!1,d);me=Ae(L,me);const rt=A(me)||l,Xe=a.convert(L.format,L.colorSpace);let nt=a.convert(L.type),ut=R(L.internalFormat,Xe,nt,L.colorSpace,L.isVideoTexture);he(ce,L,rt);let ae;const $e=L.mipmaps,ye=l&&L.isVideoTexture!==!0&&ut!==gJ,Be=_e.__version===void 0||xe===!0,De=T(L,me,rt);if(L.isDepthTexture)ut=t.DEPTH_COMPONENT,l?L.type===$c?ut=t.DEPTH_COMPONENT32F:L.type===gd?ut=t.DEPTH_COMPONENT24:L.type===lf?ut=t.DEPTH24_STENCIL8:ut=t.DEPTH_COMPONENT16:L.type===$c&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===cf&&ut===t.DEPTH_COMPONENT&&L.type!==EO&&L.type!==gd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=gd,nt=a.convert(L.type)),L.format===gg&&ut===t.DEPTH_COMPONENT&&(ut=t.DEPTH_STENCIL,L.type!==lf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=lf,nt=a.convert(L.type))),Be&&(ye?n.texStorage2D(t.TEXTURE_2D,1,ut,me.width,me.height):n.texImage2D(t.TEXTURE_2D,0,ut,me.width,me.height,0,Xe,nt,null));else if(L.isDataTexture)if($e.length>0&&rt){ye&&Be&&n.texStorage2D(t.TEXTURE_2D,De,ut,$e[0].width,$e[0].height);for(let we=0,Ve=$e.length;we<Ve;we++)ae=$e[we],ye?n.texSubImage2D(t.TEXTURE_2D,we,0,0,ae.width,ae.height,Xe,nt,ae.data):n.texImage2D(t.TEXTURE_2D,we,ut,ae.width,ae.height,0,Xe,nt,ae.data);L.generateMipmaps=!1}else ye?(Be&&n.texStorage2D(t.TEXTURE_2D,De,ut,me.width,me.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,me.width,me.height,Xe,nt,me.data)):n.texImage2D(t.TEXTURE_2D,0,ut,me.width,me.height,0,Xe,nt,me.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ye&&Be&&n.texStorage3D(t.TEXTURE_2D_ARRAY,De,ut,$e[0].width,$e[0].height,me.depth);for(let we=0,Ve=$e.length;we<Ve;we++)ae=$e[we],L.format!==bo?Xe!==null?ye?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,we,0,0,0,ae.width,ae.height,me.depth,Xe,ae.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,we,ut,ae.width,ae.height,me.depth,0,ae.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ye?n.texSubImage3D(t.TEXTURE_2D_ARRAY,we,0,0,0,ae.width,ae.height,me.depth,Xe,nt,ae.data):n.texImage3D(t.TEXTURE_2D_ARRAY,we,ut,ae.width,ae.height,me.depth,0,Xe,nt,ae.data)}else{ye&&Be&&n.texStorage2D(t.TEXTURE_2D,De,ut,$e[0].width,$e[0].height);for(let we=0,Ve=$e.length;we<Ve;we++)ae=$e[we],L.format!==bo?Xe!==null?ye?n.compressedTexSubImage2D(t.TEXTURE_2D,we,0,0,ae.width,ae.height,Xe,ae.data):n.compressedTexImage2D(t.TEXTURE_2D,we,ut,ae.width,ae.height,0,ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ye?n.texSubImage2D(t.TEXTURE_2D,we,0,0,ae.width,ae.height,Xe,nt,ae.data):n.texImage2D(t.TEXTURE_2D,we,ut,ae.width,ae.height,0,Xe,nt,ae.data)}else if(L.isDataArrayTexture)ye?(Be&&n.texStorage3D(t.TEXTURE_2D_ARRAY,De,ut,me.width,me.height,me.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,Xe,nt,me.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ut,me.width,me.height,me.depth,0,Xe,nt,me.data);else if(L.isData3DTexture)ye?(Be&&n.texStorage3D(t.TEXTURE_3D,De,ut,me.width,me.height,me.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,Xe,nt,me.data)):n.texImage3D(t.TEXTURE_3D,0,ut,me.width,me.height,me.depth,0,Xe,nt,me.data);else if(L.isFramebufferTexture){if(Be)if(ye)n.texStorage2D(t.TEXTURE_2D,De,ut,me.width,me.height);else{let we=me.width,Ve=me.height;for(let dt=0;dt<De;dt++)n.texImage2D(t.TEXTURE_2D,dt,ut,we,Ve,0,Xe,nt,null),we>>=1,Ve>>=1}}else if($e.length>0&&rt){ye&&Be&&n.texStorage2D(t.TEXTURE_2D,De,ut,$e[0].width,$e[0].height);for(let we=0,Ve=$e.length;we<Ve;we++)ae=$e[we],ye?n.texSubImage2D(t.TEXTURE_2D,we,0,0,Xe,nt,ae):n.texImage2D(t.TEXTURE_2D,we,ut,Xe,nt,ae);L.generateMipmaps=!1}else ye?(Be&&n.texStorage2D(t.TEXTURE_2D,De,ut,me.width,me.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Xe,nt,me)):n.texImage2D(t.TEXTURE_2D,0,ut,Xe,nt,me);k(L,rt)&&C(ce),_e.__version=ve.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Ne($,L,oe){if(L.image.length!==6)return;const ce=Ee($,L),xe=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+oe);const ve=r.get(xe);if(xe.version!==ve.__version||ce===!0){n.activeTexture(t.TEXTURE0+oe);const _e=lr.getPrimaries(lr.workingColorSpace),Ie=L.colorSpace===yo?null:lr.getPrimaries(L.colorSpace),We=L.colorSpace===yo||_e===Ie?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,We);const ht=L.isCompressedTexture||L.image[0].isCompressedTexture,qe=L.image[0]&&L.image[0].isDataTexture,me=[];for(let we=0;we<6;we++)!ht&&!qe?me[we]=S(L.image[we],!1,!0,u):me[we]=qe?L.image[we].image:L.image[we],me[we]=Ae(L,me[we]);const rt=me[0],Xe=A(rt)||l,nt=a.convert(L.format,L.colorSpace),ut=a.convert(L.type),ae=R(L.internalFormat,nt,ut,L.colorSpace),$e=l&&L.isVideoTexture!==!0,ye=ve.__version===void 0||ce===!0;let Be=T(L,rt,Xe);he(t.TEXTURE_CUBE_MAP,L,Xe);let De;if(ht){$e&&ye&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Be,ae,rt.width,rt.height);for(let we=0;we<6;we++){De=me[we].mipmaps;for(let Ve=0;Ve<De.length;Ve++){const dt=De[Ve];L.format!==bo?nt!==null?$e?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve,0,0,dt.width,dt.height,nt,dt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve,ae,dt.width,dt.height,0,dt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve,0,0,dt.width,dt.height,nt,ut,dt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve,ae,dt.width,dt.height,0,nt,ut,dt.data)}}}else{De=L.mipmaps,$e&&ye&&(De.length>0&&Be++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Be,ae,me[0].width,me[0].height));for(let we=0;we<6;we++)if(qe){$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,me[we].width,me[we].height,nt,ut,me[we].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ae,me[we].width,me[we].height,0,nt,ut,me[we].data);for(let Ve=0;Ve<De.length;Ve++){const Tt=De[Ve].image[we].image;$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve+1,0,0,Tt.width,Tt.height,nt,ut,Tt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve+1,ae,Tt.width,Tt.height,0,nt,ut,Tt.data)}}else{$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,nt,ut,me[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ae,nt,ut,me[we]);for(let Ve=0;Ve<De.length;Ve++){const dt=De[Ve];$e?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve+1,0,0,nt,ut,dt.image[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ve+1,ae,nt,ut,dt.image[we])}}}k(L,Xe)&&C(t.TEXTURE_CUBE_MAP),ve.__version=xe.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Re($,L,oe,ce,xe,ve){const _e=a.convert(oe.format,oe.colorSpace),Ie=a.convert(oe.type),We=R(oe.internalFormat,_e,Ie,oe.colorSpace);if(!r.get(L).__hasExternalTextures){const qe=Math.max(1,L.width>>ve),me=Math.max(1,L.height>>ve);xe===t.TEXTURE_3D||xe===t.TEXTURE_2D_ARRAY?n.texImage3D(xe,ve,We,qe,me,L.depth,0,_e,Ie,null):n.texImage2D(xe,ve,We,qe,me,0,_e,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Te(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ce,xe,r.get(oe).__webglTexture,0,Q(L)):(xe===t.TEXTURE_2D||xe>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&xe<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ce,xe,r.get(oe).__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function te($,L,oe){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer&&!L.stencilBuffer){let ce=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(oe||Te(L)){const xe=L.depthTexture;xe&&xe.isDepthTexture&&(xe.type===$c?ce=t.DEPTH_COMPONENT32F:xe.type===gd&&(ce=t.DEPTH_COMPONENT24));const ve=Q(L);Te(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,ce,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,ce,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ce,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,$)}else if(L.depthBuffer&&L.stencilBuffer){const ce=Q(L);oe&&Te(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ce,t.DEPTH24_STENCIL8,L.width,L.height):Te(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ce,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,$)}else{const ce=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let xe=0;xe<ce.length;xe++){const ve=ce[xe],_e=a.convert(ve.format,ve.colorSpace),Ie=a.convert(ve.type),We=R(ve.internalFormat,_e,Ie,ve.colorSpace),ht=Q(L);oe&&Te(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ht,We,L.width,L.height):Te(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ht,We,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,We,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Je($,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),ie(L.depthTexture,0);const ce=r.get(L.depthTexture).__webglTexture,xe=Q(L);if(L.depthTexture.format===cf)Te(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ce,0,xe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ce,0);else if(L.depthTexture.format===gg)Te(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ce,0,xe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ce,0);else throw new Error("Unknown depthTexture format")}function B($){const L=r.get($),oe=$.isWebGLCubeRenderTarget===!0;if($.depthTexture&&!L.__autoAllocateDepthBuffer){if(oe)throw new Error("target.depthTexture not supported in Cube render targets");Je(L.__webglFramebuffer,$)}else if(oe){L.__webglDepthbuffer=[];for(let ce=0;ce<6;ce++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ce]),L.__webglDepthbuffer[ce]=t.createRenderbuffer(),te(L.__webglDepthbuffer[ce],$,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),te(L.__webglDepthbuffer,$,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function H($,L,oe){const ce=r.get($);L!==void 0&&Re(ce.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),oe!==void 0&&B($)}function W($){const L=$.texture,oe=r.get($),ce=r.get(L);$.addEventListener("dispose",I),$.isWebGLMultipleRenderTargets!==!0&&(ce.__webglTexture===void 0&&(ce.__webglTexture=t.createTexture()),ce.__version=L.version,o.memory.textures++);const xe=$.isWebGLCubeRenderTarget===!0,ve=$.isWebGLMultipleRenderTargets===!0,_e=A($)||l;if(xe){oe.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(l&&L.mipmaps&&L.mipmaps.length>0){oe.__webglFramebuffer[Ie]=[];for(let We=0;We<L.mipmaps.length;We++)oe.__webglFramebuffer[Ie][We]=t.createFramebuffer()}else oe.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(l&&L.mipmaps&&L.mipmaps.length>0){oe.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)oe.__webglFramebuffer[Ie]=t.createFramebuffer()}else oe.__webglFramebuffer=t.createFramebuffer();if(ve)if(i.drawBuffers){const Ie=$.texture;for(let We=0,ht=Ie.length;We<ht;We++){const qe=r.get(Ie[We]);qe.__webglTexture===void 0&&(qe.__webglTexture=t.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&$.samples>0&&Te($)===!1){const Ie=ve?L:[L];oe.__webglMultisampledFramebuffer=t.createFramebuffer(),oe.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,oe.__webglMultisampledFramebuffer);for(let We=0;We<Ie.length;We++){const ht=Ie[We];oe.__webglColorRenderbuffer[We]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,oe.__webglColorRenderbuffer[We]);const qe=a.convert(ht.format,ht.colorSpace),me=a.convert(ht.type),rt=R(ht.internalFormat,qe,me,ht.colorSpace,$.isXRRenderTarget===!0),Xe=Q($);t.renderbufferStorageMultisample(t.RENDERBUFFER,Xe,rt,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.RENDERBUFFER,oe.__webglColorRenderbuffer[We])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(oe.__webglDepthRenderbuffer=t.createRenderbuffer(),te(oe.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(xe){n.bindTexture(t.TEXTURE_CUBE_MAP,ce.__webglTexture),he(t.TEXTURE_CUBE_MAP,L,_e);for(let Ie=0;Ie<6;Ie++)if(l&&L.mipmaps&&L.mipmaps.length>0)for(let We=0;We<L.mipmaps.length;We++)Re(oe.__webglFramebuffer[Ie][We],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,We);else Re(oe.__webglFramebuffer[Ie],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);k(L,_e)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ve){const Ie=$.texture;for(let We=0,ht=Ie.length;We<ht;We++){const qe=Ie[We],me=r.get(qe);n.bindTexture(t.TEXTURE_2D,me.__webglTexture),he(t.TEXTURE_2D,qe,_e),Re(oe.__webglFramebuffer,$,qe,t.COLOR_ATTACHMENT0+We,t.TEXTURE_2D,0),k(qe,_e)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(l?Ie=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ie,ce.__webglTexture),he(Ie,L,_e),l&&L.mipmaps&&L.mipmaps.length>0)for(let We=0;We<L.mipmaps.length;We++)Re(oe.__webglFramebuffer[We],$,L,t.COLOR_ATTACHMENT0,Ie,We);else Re(oe.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,Ie,0);k(L,_e)&&C(Ie),n.unbindTexture()}$.depthBuffer&&B($)}function z($){const L=A($)||l,oe=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let ce=0,xe=oe.length;ce<xe;ce++){const ve=oe[ce];if(k(ve,L)){const _e=$.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ie=r.get(ve).__webglTexture;n.bindTexture(_e,Ie),C(_e),n.unbindTexture()}}}function V($){if(l&&$.samples>0&&Te($)===!1){const L=$.isWebGLMultipleRenderTargets?$.texture:[$.texture],oe=$.width,ce=$.height;let xe=t.COLOR_BUFFER_BIT;const ve=[],_e=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=r.get($),We=$.isWebGLMultipleRenderTargets===!0;if(We)for(let ht=0;ht<L.length;ht++)n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer);for(let ht=0;ht<L.length;ht++){ve.push(t.COLOR_ATTACHMENT0+ht),$.depthBuffer&&ve.push(_e);const qe=Ie.__ignoreDepthValues!==void 0?Ie.__ignoreDepthValues:!1;if(qe===!1&&($.depthBuffer&&(xe|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&(xe|=t.STENCIL_BUFFER_BIT)),We&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[ht]),qe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[_e]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[_e])),We){const me=r.get(L[ht]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,me,0)}t.blitFramebuffer(0,0,oe,ce,0,0,oe,ce,xe,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ve)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),We)for(let ht=0;ht<L.length;ht++){n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[ht]);const qe=r.get(L[ht]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ht,t.TEXTURE_2D,qe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer)}}function Q($){return Math.min(f,$.samples)}function Te($){const L=r.get($);return l&&$.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function ke($){const L=o.render.frame;x.get($)!==L&&(x.set($,L),$.update())}function Ae($,L){const oe=$.colorSpace,ce=$.format,xe=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||$.format===WP||oe!==cu&&oe!==yo&&(lr.getTransfer(oe)===Mr?l===!1?e.has("EXT_sRGB")===!0&&ce===bo?($.format=WP,$.minFilter=xo,$.generateMipmaps=!1):L=wJ.sRGBToLinear(L):(ce!==bo||xe!==Cd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",oe)),L}this.allocateTextureUnit=Z,this.resetTextureUnits=q,this.setTexture2D=ie,this.setTexture2DArray=U,this.setTexture3D=G,this.setTextureCube=ee,this.rebindTextures=H,this.setupRenderTarget=W,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=V,this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=Te}function $ze(t,e,n){const r=n.isWebGL2;function i(a,o=yo){let l;const c=lr.getTransfer(o);if(a===Cd)return t.UNSIGNED_BYTE;if(a===dJ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===hJ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===hLe)return t.BYTE;if(a===fLe)return t.SHORT;if(a===EO)return t.UNSIGNED_SHORT;if(a===uJ)return t.INT;if(a===gd)return t.UNSIGNED_INT;if(a===$c)return t.FLOAT;if(a===C0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===mLe)return t.ALPHA;if(a===bo)return t.RGBA;if(a===pLe)return t.LUMINANCE;if(a===gLe)return t.LUMINANCE_ALPHA;if(a===cf)return t.DEPTH_COMPONENT;if(a===gg)return t.DEPTH_STENCIL;if(a===WP)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===xLe)return t.RED;if(a===fJ)return t.RED_INTEGER;if(a===bLe)return t.RG;if(a===mJ)return t.RG_INTEGER;if(a===pJ)return t.RGBA_INTEGER;if(a===ZC||a===JC||a===ek||a===tk)if(c===Mr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===ZC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===JC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===ek)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===tk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===ZC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===JC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===ek)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===tk)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===vV||a===_V||a===wV||a===SV)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===vV)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===_V)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===wV)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===SV)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===gJ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===MV||a===NV)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===MV)return c===Mr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===NV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===EV||a===AV||a===TV||a===CV||a===kV||a===jV||a===PV||a===RV||a===DV||a===OV||a===LV||a===IV||a===FV||a===UV)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===EV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===AV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===TV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===CV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===kV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===jV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===PV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===RV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===DV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===OV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===LV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===IV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===FV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===UV)return c===Mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===nk||a===zV||a===BV)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===nk)return c===Mr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===zV)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===BV)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===yLe||a===$V||a===HV||a===VV)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===nk)return l.COMPRESSED_RED_RGTC1_EXT;if(a===$V)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===HV)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===VV)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===lf?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class Hze extends Ps{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Sb extends $a{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Vze={type:"move"};class Nk{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Sb,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 Sb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ue,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ue),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Sb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ue,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ue),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const v of e.hand.values()){const b=n.getJointPose(v,r),y=this._getHandJoint(u,v);b!==null&&(y.matrix.fromArray(b.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=b.radius),y.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&m>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(Vze)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Sb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class Gze extends Xf{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,m=null,p=null,x=null;const v=n.getContextAttributes();let b=null,y=null;const M=[],S=[],A=new rn;let E=null;const k=new Ps;k.layers.enable(1),k.viewport=new ur;const C=new Ps;C.layers.enable(2),C.viewport=new ur;const R=[k,C],T=new Hze;T.layers.enable(1),T.layers.enable(2);let P=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ee){let ne=M[ee];return ne===void 0&&(ne=new Nk,M[ee]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(ee){let ne=M[ee];return ne===void 0&&(ne=new Nk,M[ee]=ne),ne.getGripSpace()},this.getHand=function(ee){let ne=M[ee];return ne===void 0&&(ne=new Nk,M[ee]=ne),ne.getHandSpace()};function I(ee){const ne=S.indexOf(ee.inputSource);if(ne===-1)return;const se=M[ne];se!==void 0&&(se.update(ee.inputSource,ee.frame,u||o),se.dispatchEvent({type:ee.type,data:ee.inputSource}))}function X(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",D);for(let ee=0;ee<M.length;ee++){const ne=S[ee];ne!==null&&(S[ee]=null,M[ee].disconnect(ne))}P=null,F=null,e.setRenderTarget(b),p=null,m=null,f=null,i=null,y=null,G.stop(),r.isPresenting=!1,e.setPixelRatio(E),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ee){a=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ee){l=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ee){u=ee},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ee){if(i=ee,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",X),i.addEventListener("inputsourceschange",D),v.xrCompatible!==!0&&await n.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ne={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,ne),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new Of(p.framebufferWidth,p.framebufferHeight,{format:bo,type:Cd,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let ne=null,se=null,de=null;v.depth&&(de=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ne=v.stencil?gg:cf,se=v.stencil?lf:gd);const he={colorFormat:n.RGBA8,depthFormat:de,scaleFactor:a};f=new XRWebGLBinding(i,n),m=f.createProjectionLayer(he),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),y=new Of(m.textureWidth,m.textureHeight,{format:bo,type:Cd,depthTexture:new DJ(m.textureWidth,m.textureHeight,se,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ee=e.properties.get(y);Ee.__ignoreDepthValues=m.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),G.setContext(i),G.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function D(ee){for(let ne=0;ne<ee.removed.length;ne++){const se=ee.removed[ne],de=S.indexOf(se);de>=0&&(S[de]=null,M[de].disconnect(se))}for(let ne=0;ne<ee.added.length;ne++){const se=ee.added[ne];let de=S.indexOf(se);if(de===-1){for(let Ee=0;Ee<M.length;Ee++)if(Ee>=S.length){S.push(se),de=Ee;break}else if(S[Ee]===null){S[Ee]=se,de=Ee;break}if(de===-1)break}const he=M[de];he&&he.connect(se)}}const K=new Ue,Y=new Ue;function q(ee,ne,se){K.setFromMatrixPosition(ne.matrixWorld),Y.setFromMatrixPosition(se.matrixWorld);const de=K.distanceTo(Y),he=ne.projectionMatrix.elements,Ee=se.projectionMatrix.elements,ge=he[14]/(he[10]-1),Ne=he[14]/(he[10]+1),Re=(he[9]+1)/he[5],te=(he[9]-1)/he[5],Je=(he[8]-1)/he[0],B=(Ee[8]+1)/Ee[0],H=ge*Je,W=ge*B,z=de/(-Je+B),V=z*-Je;ne.matrixWorld.decompose(ee.position,ee.quaternion,ee.scale),ee.translateX(V),ee.translateZ(z),ee.matrixWorld.compose(ee.position,ee.quaternion,ee.scale),ee.matrixWorldInverse.copy(ee.matrixWorld).invert();const Q=ge+z,Te=Ne+z,ke=H-V,Ae=W+(de-V),$=Re*Ne/Te*Q,L=te*Ne/Te*Q;ee.projectionMatrix.makePerspective(ke,Ae,$,L,Q,Te),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert()}function Z(ee,ne){ne===null?ee.matrixWorld.copy(ee.matrix):ee.matrixWorld.multiplyMatrices(ne.matrixWorld,ee.matrix),ee.matrixWorldInverse.copy(ee.matrixWorld).invert()}this.updateCamera=function(ee){if(i===null)return;T.near=C.near=k.near=ee.near,T.far=C.far=k.far=ee.far,(P!==T.near||F!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),P=T.near,F=T.far);const ne=ee.parent,se=T.cameras;Z(T,ne);for(let de=0;de<se.length;de++)Z(se[de],ne);se.length===2?q(T,k,C):T.projectionMatrix.copy(k.projectionMatrix),re(ee,T,ne)};function re(ee,ne,se){se===null?ee.matrix.copy(ne.matrixWorld):(ee.matrix.copy(se.matrixWorld),ee.matrix.invert(),ee.matrix.multiply(ne.matrixWorld)),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.updateMatrixWorld(!0),ee.projectionMatrix.copy(ne.projectionMatrix),ee.projectionMatrixInverse.copy(ne.projectionMatrixInverse),ee.isPerspectiveCamera&&(ee.fov=j0*2*Math.atan(1/ee.projectionMatrix.elements[5]),ee.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(ee){c=ee,m!==null&&(m.fixedFoveation=ee),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ee)};let ie=null;function U(ee,ne){if(d=ne.getViewerPose(u||o),x=ne,d!==null){const se=d.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let de=!1;se.length!==T.cameras.length&&(T.cameras.length=0,de=!0);for(let he=0;he<se.length;he++){const Ee=se[he];let ge=null;if(p!==null)ge=p.getViewport(Ee);else{const Re=f.getViewSubImage(m,Ee);ge=Re.viewport,he===0&&(e.setRenderTargetTextures(y,Re.colorTexture,m.ignoreDepthValues?void 0:Re.depthStencilTexture),e.setRenderTarget(y))}let Ne=R[he];Ne===void 0&&(Ne=new Ps,Ne.layers.enable(he),Ne.viewport=new ur,R[he]=Ne),Ne.matrix.fromArray(Ee.transform.matrix),Ne.matrix.decompose(Ne.position,Ne.quaternion,Ne.scale),Ne.projectionMatrix.fromArray(Ee.projectionMatrix),Ne.projectionMatrixInverse.copy(Ne.projectionMatrix).invert(),Ne.viewport.set(ge.x,ge.y,ge.width,ge.height),he===0&&(T.matrix.copy(Ne.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),de===!0&&T.cameras.push(Ne)}}for(let se=0;se<M.length;se++){const de=S[se],he=M[se];de!==null&&he!==void 0&&he.update(de,ne,u||o)}ie&&ie(ee,ne),ne.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ne}),x=null}const G=new RJ;G.setAnimationLoop(U),this.setAnimationLoop=function(ee){ie=ee},this.dispose=function(){}}}function Wze(t,e){function n(b,y){b.matrixAutoUpdate===!0&&b.updateMatrix(),y.value.copy(b.matrix)}function r(b,y){y.color.getRGB(b.fogColor.value,kJ(t)),y.isFog?(b.fogNear.value=y.near,b.fogFar.value=y.far):y.isFogExp2&&(b.fogDensity.value=y.density)}function i(b,y,M,S,A){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(b,y):y.isMeshToonMaterial?(a(b,y),f(b,y)):y.isMeshPhongMaterial?(a(b,y),d(b,y)):y.isMeshStandardMaterial?(a(b,y),m(b,y),y.isMeshPhysicalMaterial&&p(b,y,A)):y.isMeshMatcapMaterial?(a(b,y),x(b,y)):y.isMeshDepthMaterial?a(b,y):y.isMeshDistanceMaterial?(a(b,y),v(b,y)):y.isMeshNormalMaterial?a(b,y):y.isLineBasicMaterial?(o(b,y),y.isLineDashedMaterial&&l(b,y)):y.isPointsMaterial?c(b,y,M,S):y.isSpriteMaterial?u(b,y):y.isShadowMaterial?(b.color.value.copy(y.color),b.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(b,y){b.opacity.value=y.opacity,y.color&&b.diffuse.value.copy(y.color),y.emissive&&b.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(b.map.value=y.map,n(y.map,b.mapTransform)),y.alphaMap&&(b.alphaMap.value=y.alphaMap,n(y.alphaMap,b.alphaMapTransform)),y.bumpMap&&(b.bumpMap.value=y.bumpMap,n(y.bumpMap,b.bumpMapTransform),b.bumpScale.value=y.bumpScale,y.side===hs&&(b.bumpScale.value*=-1)),y.normalMap&&(b.normalMap.value=y.normalMap,n(y.normalMap,b.normalMapTransform),b.normalScale.value.copy(y.normalScale),y.side===hs&&b.normalScale.value.negate()),y.displacementMap&&(b.displacementMap.value=y.displacementMap,n(y.displacementMap,b.displacementMapTransform),b.displacementScale.value=y.displacementScale,b.displacementBias.value=y.displacementBias),y.emissiveMap&&(b.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,b.emissiveMapTransform)),y.specularMap&&(b.specularMap.value=y.specularMap,n(y.specularMap,b.specularMapTransform)),y.alphaTest>0&&(b.alphaTest.value=y.alphaTest);const M=e.get(y).envMap;if(M&&(b.envMap.value=M,b.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=y.reflectivity,b.ior.value=y.ior,b.refractionRatio.value=y.refractionRatio),y.lightMap){b.lightMap.value=y.lightMap;const S=t._useLegacyLights===!0?Math.PI:1;b.lightMapIntensity.value=y.lightMapIntensity*S,n(y.lightMap,b.lightMapTransform)}y.aoMap&&(b.aoMap.value=y.aoMap,b.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,b.aoMapTransform))}function o(b,y){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,y.map&&(b.map.value=y.map,n(y.map,b.mapTransform))}function l(b,y){b.dashSize.value=y.dashSize,b.totalSize.value=y.dashSize+y.gapSize,b.scale.value=y.scale}function c(b,y,M,S){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,b.size.value=y.size*M,b.scale.value=S*.5,y.map&&(b.map.value=y.map,n(y.map,b.uvTransform)),y.alphaMap&&(b.alphaMap.value=y.alphaMap,n(y.alphaMap,b.alphaMapTransform)),y.alphaTest>0&&(b.alphaTest.value=y.alphaTest)}function u(b,y){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,b.rotation.value=y.rotation,y.map&&(b.map.value=y.map,n(y.map,b.mapTransform)),y.alphaMap&&(b.alphaMap.value=y.alphaMap,n(y.alphaMap,b.alphaMapTransform)),y.alphaTest>0&&(b.alphaTest.value=y.alphaTest)}function d(b,y){b.specular.value.copy(y.specular),b.shininess.value=Math.max(y.shininess,1e-4)}function f(b,y){y.gradientMap&&(b.gradientMap.value=y.gradientMap)}function m(b,y){b.metalness.value=y.metalness,y.metalnessMap&&(b.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,b.metalnessMapTransform)),b.roughness.value=y.roughness,y.roughnessMap&&(b.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,b.roughnessMapTransform)),e.get(y).envMap&&(b.envMapIntensity.value=y.envMapIntensity)}function p(b,y,M){b.ior.value=y.ior,y.sheen>0&&(b.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),b.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(b.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,b.sheenColorMapTransform)),y.sheenRoughnessMap&&(b.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,b.sheenRoughnessMapTransform))),y.clearcoat>0&&(b.clearcoat.value=y.clearcoat,b.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(b.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,b.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(b.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===hs&&b.clearcoatNormalScale.value.negate())),y.iridescence>0&&(b.iridescence.value=y.iridescence,b.iridescenceIOR.value=y.iridescenceIOR,b.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(b.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,b.iridescenceMapTransform)),y.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),y.transmission>0&&(b.transmission.value=y.transmission,b.transmissionSamplerMap.value=M.texture,b.transmissionSamplerSize.value.set(M.width,M.height),y.transmissionMap&&(b.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,b.transmissionMapTransform)),b.thickness.value=y.thickness,y.thicknessMap&&(b.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=y.attenuationDistance,b.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(b.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(b.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=y.specularIntensity,b.specularColor.value.copy(y.specularColor),y.specularColorMap&&(b.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,b.specularColorMapTransform)),y.specularIntensityMap&&(b.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,y){y.matcap&&(b.matcap.value=y.matcap)}function v(b,y){const M=e.get(y).light;b.referencePosition.value.setFromMatrixPosition(M.matrixWorld),b.nearDistance.value=M.shadow.camera.near,b.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function qze(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(M,S){const A=S.program;r.uniformBlockBinding(M,A)}function u(M,S){let A=i[M.id];A===void 0&&(x(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",b));const E=S.program;r.updateUBOMapping(M,E);const k=e.render.frame;a[M.id]!==k&&(m(M),a[M.id]=k)}function d(M){const S=f();M.__bindingPointIndex=S;const A=t.createBuffer(),E=M.__size,k=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,E,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let M=0;M<l;M++)if(o.indexOf(M)===-1)return o.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(M){const S=i[M.id],A=M.uniforms,E=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,C=A.length;k<C;k++){const R=A[k];if(p(R,k,E)===!0){const T=R.__offset,P=Array.isArray(R.value)?R.value:[R.value];let F=0;for(let I=0;I<P.length;I++){const X=P[I],D=v(X);typeof X=="number"?(R.__data[0]=X,t.bufferSubData(t.UNIFORM_BUFFER,T+F,R.__data)):X.isMatrix3?(R.__data[0]=X.elements[0],R.__data[1]=X.elements[1],R.__data[2]=X.elements[2],R.__data[3]=X.elements[0],R.__data[4]=X.elements[3],R.__data[5]=X.elements[4],R.__data[6]=X.elements[5],R.__data[7]=X.elements[0],R.__data[8]=X.elements[6],R.__data[9]=X.elements[7],R.__data[10]=X.elements[8],R.__data[11]=X.elements[0]):(X.toArray(R.__data,F),F+=D.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,T,R.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(M,S,A){const E=M.value;if(A[S]===void 0){if(typeof E=="number")A[S]=E;else{const k=Array.isArray(E)?E:[E],C=[];for(let R=0;R<k.length;R++)C.push(k[R].clone());A[S]=C}return!0}else if(typeof E=="number"){if(A[S]!==E)return A[S]=E,!0}else{const k=Array.isArray(A[S])?A[S]:[A[S]],C=Array.isArray(E)?E:[E];for(let R=0;R<k.length;R++){const T=k[R];if(T.equals(C[R])===!1)return T.copy(C[R]),!0}}return!1}function x(M){const S=M.uniforms;let A=0;const E=16;let k=0;for(let C=0,R=S.length;C<R;C++){const T=S[C],P={boundary:0,storage:0},F=Array.isArray(T.value)?T.value:[T.value];for(let I=0,X=F.length;I<X;I++){const D=F[I],K=v(D);P.boundary+=K.boundary,P.storage+=K.storage}if(T.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=A,C>0){k=A%E;const I=E-k;k!==0&&I-P.boundary<0&&(A+=E-k,T.__offset=A)}A+=P.storage}return k=A%E,k>0&&(A+=E-k),M.__size=A,M.__cache={},this}function v(M){const S={boundary:0,storage:0};return typeof M=="number"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),S}function b(M){const S=M.target;S.removeEventListener("dispose",b);const A=o.indexOf(S.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function y(){for(const M in i)t.deleteBuffer(i[M]);o=[],i={},a={}}return{bind:c,update:u,dispose:y}}class XP{constructor(e={}){const{canvas:n=VLe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let m;r!==null?m=r.getContextAttributes().alpha:m=o;const p=new Uint32Array(4),x=new Int32Array(4);let v=null,b=null;const y=[],M=[];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=fa,this._useLegacyLights=!1,this.toneMapping=Td,this.toneMappingExposure=1;const S=this;let A=!1,E=0,k=0,C=null,R=-1,T=null;const P=new ur,F=new ur;let I=null;const X=new qt(0);let D=0,K=n.width,Y=n.height,q=1,Z=null,re=null;const ie=new ur(0,0,K,Y),U=new ur(0,0,K,Y);let G=!1;const ee=new BM;let ne=!1,se=!1,de=null;const he=new vr,Ee=new rn,ge=new Ue,Ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Re(){return C===null?q:1}let te=r;function Je(ue,ze){for(let Ye=0;Ye<ue.length;Ye++){const Ke=ue[Ye],Qe=n.getContext(Ke,ze);if(Qe!==null)return Qe}return null}try{const ue={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${FM}`),n.addEventListener("webglcontextlost",$e,!1),n.addEventListener("webglcontextrestored",ye,!1),n.addEventListener("webglcontextcreationerror",Be,!1),te===null){const ze=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&ze.shift(),te=Je(ze,ue),te===null)throw Je(ze)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&te instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),te.getShaderPrecisionFormat===void 0&&(te.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ue){throw console.error("THREE.WebGLRenderer: "+ue.message),ue}let B,H,W,z,V,Q,Te,ke,Ae,$,L,oe,ce,xe,ve,_e,Ie,We,ht,qe,me,rt,Xe,nt;function ut(){B=new iUe(te),H=new QFe(te,B,e),B.init(H),rt=new $ze(te,B,H),W=new zze(te,B,H),z=new oUe(te),V=new Eze,Q=new Bze(te,B,W,V,H,rt,z),Te=new JFe(S),ke=new rUe(S),Ae=new mIe(te,H),Xe=new XFe(te,B,Ae,H),$=new aUe(te,Ae,z,Xe),L=new dUe(te,$,Ae,z),ht=new uUe(te,H,Q),_e=new ZFe(V),oe=new Nze(S,Te,ke,B,H,Xe,_e),ce=new Wze(S,V),xe=new Tze,ve=new Dze(B,H),We=new KFe(S,Te,ke,W,L,m,c),Ie=new Uze(S,L,H),nt=new qze(te,z,H,W),qe=new YFe(te,B,z,H),me=new sUe(te,B,z,H),z.programs=oe.programs,S.capabilities=H,S.extensions=B,S.properties=V,S.renderLists=xe,S.shadowMap=Ie,S.state=W,S.info=z}ut();const ae=new Gze(S,te);this.xr=ae,this.getContext=function(){return te},this.getContextAttributes=function(){return te.getContextAttributes()},this.forceContextLoss=function(){const ue=B.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=B.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(ue){ue!==void 0&&(q=ue,this.setSize(K,Y,!1))},this.getSize=function(ue){return ue.set(K,Y)},this.setSize=function(ue,ze,Ye=!0){if(ae.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=ue,Y=ze,n.width=Math.floor(ue*q),n.height=Math.floor(ze*q),Ye===!0&&(n.style.width=ue+"px",n.style.height=ze+"px"),this.setViewport(0,0,ue,ze)},this.getDrawingBufferSize=function(ue){return ue.set(K*q,Y*q).floor()},this.setDrawingBufferSize=function(ue,ze,Ye){K=ue,Y=ze,q=Ye,n.width=Math.floor(ue*Ye),n.height=Math.floor(ze*Ye),this.setViewport(0,0,ue,ze)},this.getCurrentViewport=function(ue){return ue.copy(P)},this.getViewport=function(ue){return ue.copy(ie)},this.setViewport=function(ue,ze,Ye,Ke){ue.isVector4?ie.set(ue.x,ue.y,ue.z,ue.w):ie.set(ue,ze,Ye,Ke),W.viewport(P.copy(ie).multiplyScalar(q).floor())},this.getScissor=function(ue){return ue.copy(U)},this.setScissor=function(ue,ze,Ye,Ke){ue.isVector4?U.set(ue.x,ue.y,ue.z,ue.w):U.set(ue,ze,Ye,Ke),W.scissor(F.copy(U).multiplyScalar(q).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(ue){W.setScissorTest(G=ue)},this.setOpaqueSort=function(ue){Z=ue},this.setTransparentSort=function(ue){re=ue},this.getClearColor=function(ue){return ue.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor.apply(We,arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha.apply(We,arguments)},this.clear=function(ue=!0,ze=!0,Ye=!0){let Ke=0;if(ue){let Qe=!1;if(C!==null){const Nt=C.texture.format;Qe=Nt===pJ||Nt===mJ||Nt===fJ}if(Qe){const Nt=C.texture.type,le=Nt===Cd||Nt===gd||Nt===EO||Nt===lf||Nt===dJ||Nt===hJ,Se=We.getClearColor(),Le=We.getClearAlpha(),Oe=Se.r,Pe=Se.g,ct=Se.b;le?(p[0]=Oe,p[1]=Pe,p[2]=ct,p[3]=Le,te.clearBufferuiv(te.COLOR,0,p)):(x[0]=Oe,x[1]=Pe,x[2]=ct,x[3]=Le,te.clearBufferiv(te.COLOR,0,x))}else Ke|=te.COLOR_BUFFER_BIT}ze&&(Ke|=te.DEPTH_BUFFER_BIT),Ye&&(Ke|=te.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),te.clear(Ke)},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",$e,!1),n.removeEventListener("webglcontextrestored",ye,!1),n.removeEventListener("webglcontextcreationerror",Be,!1),xe.dispose(),ve.dispose(),V.dispose(),Te.dispose(),ke.dispose(),L.dispose(),Xe.dispose(),nt.dispose(),oe.dispose(),ae.dispose(),ae.removeEventListener("sessionstart",Xt),ae.removeEventListener("sessionend",Pt),de&&(de.dispose(),de=null),an.stop()};function $e(ue){ue.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ye(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const ue=z.autoReset,ze=Ie.enabled,Ye=Ie.autoUpdate,Ke=Ie.needsUpdate,Qe=Ie.type;ut(),z.autoReset=ue,Ie.enabled=ze,Ie.autoUpdate=Ye,Ie.needsUpdate=Ke,Ie.type=Qe}function Be(ue){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function De(ue){const ze=ue.target;ze.removeEventListener("dispose",De),we(ze)}function we(ue){Ve(ue),V.remove(ue)}function Ve(ue){const ze=V.get(ue).programs;ze!==void 0&&(ze.forEach(function(Ye){oe.releaseProgram(Ye)}),ue.isShaderMaterial&&oe.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,ze,Ye,Ke,Qe,Nt){ze===null&&(ze=Ne);const le=Qe.isMesh&&Qe.matrixWorld.determinant()<0,Se=bt(ue,ze,Ye,Ke,Qe);W.setMaterial(Ke,le);let Le=Ye.index,Oe=1;if(Ke.wireframe===!0){if(Le=$.getWireframeAttribute(Ye),Le===void 0)return;Oe=2}const Pe=Ye.drawRange,ct=Ye.attributes.position;let vt=Pe.start*Oe,Et=(Pe.start+Pe.count)*Oe;Nt!==null&&(vt=Math.max(vt,Nt.start*Oe),Et=Math.min(Et,(Nt.start+Nt.count)*Oe)),Le!==null?(vt=Math.max(vt,0),Et=Math.min(Et,Le.count)):ct!=null&&(vt=Math.max(vt,0),Et=Math.min(Et,ct.count));const _t=Et-vt;if(_t<0||_t===1/0)return;Xe.setup(Qe,Ke,Se,Ye,Le);let yt,be=qe;if(Le!==null&&(yt=Ae.get(Le),be=me,be.setIndex(yt)),Qe.isMesh)Ke.wireframe===!0?(W.setLineWidth(Ke.wireframeLinewidth*Re()),be.setMode(te.LINES)):be.setMode(te.TRIANGLES);else if(Qe.isLine){let st=Ke.linewidth;st===void 0&&(st=1),W.setLineWidth(st*Re()),Qe.isLineSegments?be.setMode(te.LINES):Qe.isLineLoop?be.setMode(te.LINE_LOOP):be.setMode(te.LINE_STRIP)}else Qe.isPoints?be.setMode(te.POINTS):Qe.isSprite&&be.setMode(te.TRIANGLES);if(Qe.isBatchedMesh)be.renderMultiDraw(Qe._multiDrawStarts,Qe._multiDrawCounts,Qe._multiDrawCount);else if(Qe.isInstancedMesh)be.renderInstances(vt,_t,Qe.count);else if(Ye.isInstancedBufferGeometry){const st=Ye._maxInstanceCount!==void 0?Ye._maxInstanceCount:1/0,zt=Math.min(Ye.instanceCount,st);be.renderInstances(vt,_t,zt)}else be.render(vt,_t)};function dt(ue,ze,Ye){ue.transparent===!0&&ue.side===Lc&&ue.forceSinglePass===!1?(ue.side=hs,ue.needsUpdate=!0,$r(ue,ze,Ye),ue.side=Hd,ue.needsUpdate=!0,$r(ue,ze,Ye),ue.side=Lc):$r(ue,ze,Ye)}this.compile=function(ue,ze,Ye=null){Ye===null&&(Ye=ue),b=ve.get(Ye),b.init(),M.push(b),Ye.traverseVisible(function(Qe){Qe.isLight&&Qe.layers.test(ze.layers)&&(b.pushLight(Qe),Qe.castShadow&&b.pushShadow(Qe))}),ue!==Ye&&ue.traverseVisible(function(Qe){Qe.isLight&&Qe.layers.test(ze.layers)&&(b.pushLight(Qe),Qe.castShadow&&b.pushShadow(Qe))}),b.setupLights(S._useLegacyLights);const Ke=new Set;return ue.traverse(function(Qe){const Nt=Qe.material;if(Nt)if(Array.isArray(Nt))for(let le=0;le<Nt.length;le++){const Se=Nt[le];dt(Se,Ye,Qe),Ke.add(Se)}else dt(Nt,Ye,Qe),Ke.add(Nt)}),M.pop(),b=null,Ke},this.compileAsync=function(ue,ze,Ye=null){const Ke=this.compile(ue,ze,Ye);return new Promise(Qe=>{function Nt(){if(Ke.forEach(function(le){V.get(le).currentProgram.isReady()&&Ke.delete(le)}),Ke.size===0){Qe(ue);return}setTimeout(Nt,10)}B.get("KHR_parallel_shader_compile")!==null?Nt():setTimeout(Nt,10)})};let Tt=null;function Ct(ue){Tt&&Tt(ue)}function Xt(){an.stop()}function Pt(){an.start()}const an=new RJ;an.setAnimationLoop(Ct),typeof self<"u"&&an.setContext(self),this.setAnimationLoop=function(ue){Tt=ue,ae.setAnimationLoop(ue),ue===null?an.stop():an.start()},ae.addEventListener("sessionstart",Xt),ae.addEventListener("sessionend",Pt),this.render=function(ue,ze){if(ze!==void 0&&ze.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),ze.parent===null&&ze.matrixWorldAutoUpdate===!0&&ze.updateMatrixWorld(),ae.enabled===!0&&ae.isPresenting===!0&&(ae.cameraAutoUpdate===!0&&ae.updateCamera(ze),ze=ae.getCamera()),ue.isScene===!0&&ue.onBeforeRender(S,ue,ze,C),b=ve.get(ue,M.length),b.init(),M.push(b),he.multiplyMatrices(ze.projectionMatrix,ze.matrixWorldInverse),ee.setFromProjectionMatrix(he),se=this.localClippingEnabled,ne=_e.init(this.clippingPlanes,se),v=xe.get(ue,y.length),v.init(),y.push(v),bn(ue,ze,0,S.sortObjects),v.finish(),S.sortObjects===!0&&v.sort(Z,re),this.info.render.frame++,ne===!0&&_e.beginShadows();const Ye=b.state.shadowsArray;if(Ie.render(Ye,ue,ze),ne===!0&&_e.endShadows(),this.info.autoReset===!0&&this.info.reset(),We.render(v,ue),b.setupLights(S._useLegacyLights),ze.isArrayCamera){const Ke=ze.cameras;for(let Qe=0,Nt=Ke.length;Qe<Nt;Qe++){const le=Ke[Qe];Kn(v,ue,le,le.viewport)}}else Kn(v,ue,ze);C!==null&&(Q.updateMultisampleRenderTarget(C),Q.updateRenderTargetMipmap(C)),ue.isScene===!0&&ue.onAfterRender(S,ue,ze),Xe.resetDefaultState(),R=-1,T=null,M.pop(),M.length>0?b=M[M.length-1]:b=null,y.pop(),y.length>0?v=y[y.length-1]:v=null};function bn(ue,ze,Ye,Ke){if(ue.visible===!1)return;if(ue.layers.test(ze.layers)){if(ue.isGroup)Ye=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(ze);else if(ue.isLight)b.pushLight(ue),ue.castShadow&&b.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||ee.intersectsSprite(ue)){Ke&&ge.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(he);const le=L.update(ue),Se=ue.material;Se.visible&&v.push(ue,le,Se,Ye,ge.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||ee.intersectsObject(ue))){const le=L.update(ue),Se=ue.material;if(Ke&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),ge.copy(ue.boundingSphere.center)):(le.boundingSphere===null&&le.computeBoundingSphere(),ge.copy(le.boundingSphere.center)),ge.applyMatrix4(ue.matrixWorld).applyMatrix4(he)),Array.isArray(Se)){const Le=le.groups;for(let Oe=0,Pe=Le.length;Oe<Pe;Oe++){const ct=Le[Oe],vt=Se[ct.materialIndex];vt&&vt.visible&&v.push(ue,le,vt,Ye,ge.z,ct)}}else Se.visible&&v.push(ue,le,Se,Ye,ge.z,null)}}const Nt=ue.children;for(let le=0,Se=Nt.length;le<Se;le++)bn(Nt[le],ze,Ye,Ke)}function Kn(ue,ze,Ye,Ke){const Qe=ue.opaque,Nt=ue.transmissive,le=ue.transparent;b.setupLightsView(Ye),ne===!0&&_e.setGlobalState(S.clippingPlanes,Ye),Nt.length>0&&zn(Qe,Nt,ze,Ye),Ke&&W.viewport(P.copy(Ke)),Qe.length>0&&Vn(Qe,ze,Ye),Nt.length>0&&Vn(Nt,ze,Ye),le.length>0&&Vn(le,ze,Ye),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function zn(ue,ze,Ye,Ke){if((Ye.isScene===!0?Ye.overrideMaterial:null)!==null)return;const Nt=H.isWebGL2;de===null&&(de=new Of(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")?C0:Cd,minFilter:T0,samples:Nt?4:0})),S.getDrawingBufferSize(Ee),Nt?de.setSize(Ee.x,Ee.y):de.setSize(SS(Ee.x),SS(Ee.y));const le=S.getRenderTarget();S.setRenderTarget(de),S.getClearColor(X),D=S.getClearAlpha(),D<1&&S.setClearColor(16777215,.5),S.clear();const Se=S.toneMapping;S.toneMapping=Td,Vn(ue,Ye,Ke),Q.updateMultisampleRenderTarget(de),Q.updateRenderTargetMipmap(de);let Le=!1;for(let Oe=0,Pe=ze.length;Oe<Pe;Oe++){const ct=ze[Oe],vt=ct.object,Et=ct.geometry,_t=ct.material,yt=ct.group;if(_t.side===Lc&&vt.layers.test(Ke.layers)){const be=_t.side;_t.side=hs,_t.needsUpdate=!0,_r(vt,Ye,Ke,Et,_t,yt),_t.side=be,_t.needsUpdate=!0,Le=!0}}Le===!0&&(Q.updateMultisampleRenderTarget(de),Q.updateRenderTargetMipmap(de)),S.setRenderTarget(le),S.setClearColor(X,D),S.toneMapping=Se}function Vn(ue,ze,Ye){const Ke=ze.isScene===!0?ze.overrideMaterial:null;for(let Qe=0,Nt=ue.length;Qe<Nt;Qe++){const le=ue[Qe],Se=le.object,Le=le.geometry,Oe=Ke===null?le.material:Ke,Pe=le.group;Se.layers.test(Ye.layers)&&_r(Se,ze,Ye,Le,Oe,Pe)}}function _r(ue,ze,Ye,Ke,Qe,Nt){ue.onBeforeRender(S,ze,Ye,Ke,Qe,Nt),ue.modelViewMatrix.multiplyMatrices(Ye.matrixWorldInverse,ue.matrixWorld),ue.normalMatrix.getNormalMatrix(ue.modelViewMatrix),Qe.onBeforeRender(S,ze,Ye,Ke,ue,Nt),Qe.transparent===!0&&Qe.side===Lc&&Qe.forceSinglePass===!1?(Qe.side=hs,Qe.needsUpdate=!0,S.renderBufferDirect(Ye,ze,Ke,Qe,ue,Nt),Qe.side=Hd,Qe.needsUpdate=!0,S.renderBufferDirect(Ye,ze,Ke,Qe,ue,Nt),Qe.side=Lc):S.renderBufferDirect(Ye,ze,Ke,Qe,ue,Nt),ue.onAfterRender(S,ze,Ye,Ke,Qe,Nt)}function $r(ue,ze,Ye){ze.isScene!==!0&&(ze=Ne);const Ke=V.get(ue),Qe=b.state.lights,Nt=b.state.shadowsArray,le=Qe.state.version,Se=oe.getParameters(ue,Qe.state,Nt,ze,Ye),Le=oe.getProgramCacheKey(Se);let Oe=Ke.programs;Ke.environment=ue.isMeshStandardMaterial?ze.environment:null,Ke.fog=ze.fog,Ke.envMap=(ue.isMeshStandardMaterial?ke:Te).get(ue.envMap||Ke.environment),Oe===void 0&&(ue.addEventListener("dispose",De),Oe=new Map,Ke.programs=Oe);let Pe=Oe.get(Le);if(Pe!==void 0){if(Ke.currentProgram===Pe&&Ke.lightsStateVersion===le)return hr(ue,Se),Pe}else Se.uniforms=oe.getUniforms(ue),ue.onBuild(Ye,Se,S),ue.onBeforeCompile(Se,S),Pe=oe.acquireProgram(Se,Le),Oe.set(Le,Pe),Ke.uniforms=Se.uniforms;const ct=Ke.uniforms;return(!ue.isShaderMaterial&&!ue.isRawShaderMaterial||ue.clipping===!0)&&(ct.clippingPlanes=_e.uniform),hr(ue,Se),Ke.needsLights=yn(ue),Ke.lightsStateVersion=le,Ke.needsLights&&(ct.ambientLightColor.value=Qe.state.ambient,ct.lightProbe.value=Qe.state.probe,ct.directionalLights.value=Qe.state.directional,ct.directionalLightShadows.value=Qe.state.directionalShadow,ct.spotLights.value=Qe.state.spot,ct.spotLightShadows.value=Qe.state.spotShadow,ct.rectAreaLights.value=Qe.state.rectArea,ct.ltc_1.value=Qe.state.rectAreaLTC1,ct.ltc_2.value=Qe.state.rectAreaLTC2,ct.pointLights.value=Qe.state.point,ct.pointLightShadows.value=Qe.state.pointShadow,ct.hemisphereLights.value=Qe.state.hemi,ct.directionalShadowMap.value=Qe.state.directionalShadowMap,ct.directionalShadowMatrix.value=Qe.state.directionalShadowMatrix,ct.spotShadowMap.value=Qe.state.spotShadowMap,ct.spotLightMatrix.value=Qe.state.spotLightMatrix,ct.spotLightMap.value=Qe.state.spotLightMap,ct.pointShadowMap.value=Qe.state.pointShadowMap,ct.pointShadowMatrix.value=Qe.state.pointShadowMatrix),Ke.currentProgram=Pe,Ke.uniformsList=null,Pe}function Tr(ue){if(ue.uniformsList===null){const ze=ue.currentProgram.getUniforms();ue.uniformsList=Y1.seqWithValue(ze.seq,ue.uniforms)}return ue.uniformsList}function hr(ue,ze){const Ye=V.get(ue);Ye.outputColorSpace=ze.outputColorSpace,Ye.batching=ze.batching,Ye.instancing=ze.instancing,Ye.instancingColor=ze.instancingColor,Ye.skinning=ze.skinning,Ye.morphTargets=ze.morphTargets,Ye.morphNormals=ze.morphNormals,Ye.morphColors=ze.morphColors,Ye.morphTargetsCount=ze.morphTargetsCount,Ye.numClippingPlanes=ze.numClippingPlanes,Ye.numIntersection=ze.numClipIntersection,Ye.vertexAlphas=ze.vertexAlphas,Ye.vertexTangents=ze.vertexTangents,Ye.toneMapping=ze.toneMapping}function bt(ue,ze,Ye,Ke,Qe){ze.isScene!==!0&&(ze=Ne),Q.resetTextureUnits();const Nt=ze.fog,le=Ke.isMeshStandardMaterial?ze.environment:null,Se=C===null?S.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:cu,Le=(Ke.isMeshStandardMaterial?ke:Te).get(Ke.envMap||le),Oe=Ke.vertexColors===!0&&!!Ye.attributes.color&&Ye.attributes.color.itemSize===4,Pe=!!Ye.attributes.tangent&&(!!Ke.normalMap||Ke.anisotropy>0),ct=!!Ye.morphAttributes.position,vt=!!Ye.morphAttributes.normal,Et=!!Ye.morphAttributes.color;let _t=Td;Ke.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(_t=S.toneMapping);const yt=Ye.morphAttributes.position||Ye.morphAttributes.normal||Ye.morphAttributes.color,be=yt!==void 0?yt.length:0,st=V.get(Ke),zt=b.state.lights;if(ne===!0&&(se===!0||ue!==T)){const ti=ue===T&&Ke.id===R;_e.setState(Ke,ue,ti)}let Ot=!1;Ke.version===st.__version?(st.needsLights&&st.lightsStateVersion!==zt.state.version||st.outputColorSpace!==Se||Qe.isBatchedMesh&&st.batching===!1||!Qe.isBatchedMesh&&st.batching===!0||Qe.isInstancedMesh&&st.instancing===!1||!Qe.isInstancedMesh&&st.instancing===!0||Qe.isSkinnedMesh&&st.skinning===!1||!Qe.isSkinnedMesh&&st.skinning===!0||Qe.isInstancedMesh&&st.instancingColor===!0&&Qe.instanceColor===null||Qe.isInstancedMesh&&st.instancingColor===!1&&Qe.instanceColor!==null||st.envMap!==Le||Ke.fog===!0&&st.fog!==Nt||st.numClippingPlanes!==void 0&&(st.numClippingPlanes!==_e.numPlanes||st.numIntersection!==_e.numIntersection)||st.vertexAlphas!==Oe||st.vertexTangents!==Pe||st.morphTargets!==ct||st.morphNormals!==vt||st.morphColors!==Et||st.toneMapping!==_t||H.isWebGL2===!0&&st.morphTargetsCount!==be)&&(Ot=!0):(Ot=!0,st.__version=Ke.version);let tn=st.currentProgram;Ot===!0&&(tn=$r(Ke,ze,Qe));let sn=!1,$t=!1,Ht=!1;const on=tn.getUniforms(),cn=st.uniforms;if(W.useProgram(tn.program)&&(sn=!0,$t=!0,Ht=!0),Ke.id!==R&&(R=Ke.id,$t=!0),sn||T!==ue){on.setValue(te,"projectionMatrix",ue.projectionMatrix),on.setValue(te,"viewMatrix",ue.matrixWorldInverse);const ti=on.map.cameraPosition;ti!==void 0&&ti.setValue(te,ge.setFromMatrixPosition(ue.matrixWorld)),H.logarithmicDepthBuffer&&on.setValue(te,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(Ke.isMeshPhongMaterial||Ke.isMeshToonMaterial||Ke.isMeshLambertMaterial||Ke.isMeshBasicMaterial||Ke.isMeshStandardMaterial||Ke.isShaderMaterial)&&on.setValue(te,"isOrthographic",ue.isOrthographicCamera===!0),T!==ue&&(T=ue,$t=!0,Ht=!0)}if(Qe.isSkinnedMesh){on.setOptional(te,Qe,"bindMatrix"),on.setOptional(te,Qe,"bindMatrixInverse");const ti=Qe.skeleton;ti&&(H.floatVertexTextures?(ti.boneTexture===null&&ti.computeBoneTexture(),on.setValue(te,"boneTexture",ti.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."))}Qe.isBatchedMesh&&(on.setOptional(te,Qe,"batchingTexture"),on.setValue(te,"batchingTexture",Qe._matricesTexture,Q));const Hr=Ye.morphAttributes;if((Hr.position!==void 0||Hr.normal!==void 0||Hr.color!==void 0&&H.isWebGL2===!0)&&ht.update(Qe,Ye,tn),($t||st.receiveShadow!==Qe.receiveShadow)&&(st.receiveShadow=Qe.receiveShadow,on.setValue(te,"receiveShadow",Qe.receiveShadow)),Ke.isMeshGouraudMaterial&&Ke.envMap!==null&&(cn.envMap.value=Le,cn.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),$t&&(on.setValue(te,"toneMappingExposure",S.toneMappingExposure),st.needsLights&&Yt(cn,Ht),Nt&&Ke.fog===!0&&ce.refreshFogUniforms(cn,Nt),ce.refreshMaterialUniforms(cn,Ke,q,Y,de),Y1.upload(te,Tr(st),cn,Q)),Ke.isShaderMaterial&&Ke.uniformsNeedUpdate===!0&&(Y1.upload(te,Tr(st),cn,Q),Ke.uniformsNeedUpdate=!1),Ke.isSpriteMaterial&&on.setValue(te,"center",Qe.center),on.setValue(te,"modelViewMatrix",Qe.modelViewMatrix),on.setValue(te,"normalMatrix",Qe.normalMatrix),on.setValue(te,"modelMatrix",Qe.matrixWorld),Ke.isShaderMaterial||Ke.isRawShaderMaterial){const ti=Ke.uniformsGroups;for(let Gn=0,Ro=ti.length;Gn<Ro;Gn++)if(H.isWebGL2){const Xn=ti[Gn];nt.update(Xn,tn),nt.bind(Xn,tn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return tn}function Yt(ue,ze){ue.ambientLightColor.needsUpdate=ze,ue.lightProbe.needsUpdate=ze,ue.directionalLights.needsUpdate=ze,ue.directionalLightShadows.needsUpdate=ze,ue.pointLights.needsUpdate=ze,ue.pointLightShadows.needsUpdate=ze,ue.spotLights.needsUpdate=ze,ue.spotLightShadows.needsUpdate=ze,ue.rectAreaLights.needsUpdate=ze,ue.hemisphereLights.needsUpdate=ze}function yn(ue){return ue.isMeshLambertMaterial||ue.isMeshToonMaterial||ue.isMeshPhongMaterial||ue.isMeshStandardMaterial||ue.isShadowMaterial||ue.isShaderMaterial&&ue.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(ue,ze,Ye){V.get(ue.texture).__webglTexture=ze,V.get(ue.depthTexture).__webglTexture=Ye;const Ke=V.get(ue);Ke.__hasExternalTextures=!0,Ke.__hasExternalTextures&&(Ke.__autoAllocateDepthBuffer=Ye===void 0,Ke.__autoAllocateDepthBuffer||B.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Ke.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ue,ze){const Ye=V.get(ue);Ye.__webglFramebuffer=ze,Ye.__useDefaultFramebuffer=ze===void 0},this.setRenderTarget=function(ue,ze=0,Ye=0){C=ue,E=ze,k=Ye;let Ke=!0,Qe=null,Nt=!1,le=!1;if(ue){const Le=V.get(ue);Le.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(te.FRAMEBUFFER,null),Ke=!1):Le.__webglFramebuffer===void 0?Q.setupRenderTarget(ue):Le.__hasExternalTextures&&Q.rebindTextures(ue,V.get(ue.texture).__webglTexture,V.get(ue.depthTexture).__webglTexture);const Oe=ue.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(le=!0);const Pe=V.get(ue).__webglFramebuffer;ue.isWebGLCubeRenderTarget?(Array.isArray(Pe[ze])?Qe=Pe[ze][Ye]:Qe=Pe[ze],Nt=!0):H.isWebGL2&&ue.samples>0&&Q.useMultisampledRTT(ue)===!1?Qe=V.get(ue).__webglMultisampledFramebuffer:Array.isArray(Pe)?Qe=Pe[Ye]:Qe=Pe,P.copy(ue.viewport),F.copy(ue.scissor),I=ue.scissorTest}else P.copy(ie).multiplyScalar(q).floor(),F.copy(U).multiplyScalar(q).floor(),I=G;if(W.bindFramebuffer(te.FRAMEBUFFER,Qe)&&H.drawBuffers&&Ke&&W.drawBuffers(ue,Qe),W.viewport(P),W.scissor(F),W.setScissorTest(I),Nt){const Le=V.get(ue.texture);te.framebufferTexture2D(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,te.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Le.__webglTexture,Ye)}else if(le){const Le=V.get(ue.texture),Oe=ze||0;te.framebufferTextureLayer(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,Le.__webglTexture,Ye||0,Oe)}R=-1},this.readRenderTargetPixels=function(ue,ze,Ye,Ke,Qe,Nt,le){if(!(ue&&ue.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=V.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&le!==void 0&&(Se=Se[le]),Se){W.bindFramebuffer(te.FRAMEBUFFER,Se);try{const Le=ue.texture,Oe=Le.format,Pe=Le.type;if(Oe!==bo&&rt.convert(Oe)!==te.getParameter(te.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ct=Pe===C0&&(B.has("EXT_color_buffer_half_float")||H.isWebGL2&&B.has("EXT_color_buffer_float"));if(Pe!==Cd&&rt.convert(Pe)!==te.getParameter(te.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Pe===$c&&(H.isWebGL2||B.has("OES_texture_float")||B.has("WEBGL_color_buffer_float")))&&!ct){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ze>=0&&ze<=ue.width-Ke&&Ye>=0&&Ye<=ue.height-Qe&&te.readPixels(ze,Ye,Ke,Qe,rt.convert(Oe),rt.convert(Pe),Nt)}finally{const Le=C!==null?V.get(C).__webglFramebuffer:null;W.bindFramebuffer(te.FRAMEBUFFER,Le)}}},this.copyFramebufferToTexture=function(ue,ze,Ye=0){const Ke=Math.pow(2,-Ye),Qe=Math.floor(ze.image.width*Ke),Nt=Math.floor(ze.image.height*Ke);Q.setTexture2D(ze,0),te.copyTexSubImage2D(te.TEXTURE_2D,Ye,0,0,ue.x,ue.y,Qe,Nt),W.unbindTexture()},this.copyTextureToTexture=function(ue,ze,Ye,Ke=0){const Qe=ze.image.width,Nt=ze.image.height,le=rt.convert(Ye.format),Se=rt.convert(Ye.type);Q.setTexture2D(Ye,0),te.pixelStorei(te.UNPACK_FLIP_Y_WEBGL,Ye.flipY),te.pixelStorei(te.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ye.premultiplyAlpha),te.pixelStorei(te.UNPACK_ALIGNMENT,Ye.unpackAlignment),ze.isDataTexture?te.texSubImage2D(te.TEXTURE_2D,Ke,ue.x,ue.y,Qe,Nt,le,Se,ze.image.data):ze.isCompressedTexture?te.compressedTexSubImage2D(te.TEXTURE_2D,Ke,ue.x,ue.y,ze.mipmaps[0].width,ze.mipmaps[0].height,le,ze.mipmaps[0].data):te.texSubImage2D(te.TEXTURE_2D,Ke,ue.x,ue.y,le,Se,ze.image),Ke===0&&Ye.generateMipmaps&&te.generateMipmap(te.TEXTURE_2D),W.unbindTexture()},this.copyTextureToTexture3D=function(ue,ze,Ye,Ke,Qe=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Nt=ue.max.x-ue.min.x+1,le=ue.max.y-ue.min.y+1,Se=ue.max.z-ue.min.z+1,Le=rt.convert(Ke.format),Oe=rt.convert(Ke.type);let Pe;if(Ke.isData3DTexture)Q.setTexture3D(Ke,0),Pe=te.TEXTURE_3D;else if(Ke.isDataArrayTexture)Q.setTexture2DArray(Ke,0),Pe=te.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}te.pixelStorei(te.UNPACK_FLIP_Y_WEBGL,Ke.flipY),te.pixelStorei(te.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ke.premultiplyAlpha),te.pixelStorei(te.UNPACK_ALIGNMENT,Ke.unpackAlignment);const ct=te.getParameter(te.UNPACK_ROW_LENGTH),vt=te.getParameter(te.UNPACK_IMAGE_HEIGHT),Et=te.getParameter(te.UNPACK_SKIP_PIXELS),_t=te.getParameter(te.UNPACK_SKIP_ROWS),yt=te.getParameter(te.UNPACK_SKIP_IMAGES),be=Ye.isCompressedTexture?Ye.mipmaps[0]:Ye.image;te.pixelStorei(te.UNPACK_ROW_LENGTH,be.width),te.pixelStorei(te.UNPACK_IMAGE_HEIGHT,be.height),te.pixelStorei(te.UNPACK_SKIP_PIXELS,ue.min.x),te.pixelStorei(te.UNPACK_SKIP_ROWS,ue.min.y),te.pixelStorei(te.UNPACK_SKIP_IMAGES,ue.min.z),Ye.isDataTexture||Ye.isData3DTexture?te.texSubImage3D(Pe,Qe,ze.x,ze.y,ze.z,Nt,le,Se,Le,Oe,be.data):Ye.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),te.compressedTexSubImage3D(Pe,Qe,ze.x,ze.y,ze.z,Nt,le,Se,Le,be.data)):te.texSubImage3D(Pe,Qe,ze.x,ze.y,ze.z,Nt,le,Se,Le,Oe,be),te.pixelStorei(te.UNPACK_ROW_LENGTH,ct),te.pixelStorei(te.UNPACK_IMAGE_HEIGHT,vt),te.pixelStorei(te.UNPACK_SKIP_PIXELS,Et),te.pixelStorei(te.UNPACK_SKIP_ROWS,_t),te.pixelStorei(te.UNPACK_SKIP_IMAGES,yt),Qe===0&&Ke.generateMipmaps&&te.generateMipmap(Pe),W.unbindTexture()},this.initTexture=function(ue){ue.isCubeTexture?Q.setTextureCube(ue,0):ue.isData3DTexture?Q.setTexture3D(ue,0):ue.isDataArrayTexture||ue.isCompressedArrayTexture?Q.setTexture2DArray(ue,0):Q.setTexture2D(ue,0),W.unbindTexture()},this.resetState=function(){E=0,k=0,C=null,W.reset(),Xe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Tl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===AO?"display-p3":"srgb",n.unpackColorSpace=lr.workingColorSpace===zM?"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===fa?uf:xJ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===uf?fa:cu}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 Kze extends XP{}Kze.prototype.isWebGL1Renderer=!0;class RO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new qt(e),this.near=n,this.far=r}clone(){return new RO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Xze extends $a{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 Yze{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=GP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Xc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Xc()),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=Xc()),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 Oa=new Ue;class xd{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++)Oa.fromBufferAttribute(this,n),Oa.applyMatrix4(e),this.setXYZ(n,Oa.x,Oa.y,Oa.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Oa.fromBufferAttribute(this,n),Oa.applyNormalMatrix(e),this.setXYZ(n,Oa.x,Oa.y,Oa.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Oa.fromBufferAttribute(this,n),Oa.transformDirection(e),this.setXYZ(n,Oa.x,Oa.y,Oa.z);return this}setX(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=or(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=Ml(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Ml(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Ml(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Ml(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=or(n,this.array),r=or(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=or(n,this.array),r=or(r,this.array),i=or(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(n=or(n,this.array),r=or(r,this.array),i=or(i,this.array),a=or(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return new Bs(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 xd(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Qze extends fs{constructor(e=null,n=1,r=1,i,a,o,l,c,u=ha,d=ha,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function Zze(t,e){return t.z-e.z}function Jze(t,e){return e.z-t.z}class eBe{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const a=r[this.index];i.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=n}reset(){this.list.length=0,this.index=0}}const hp="batchId",Qu=new vr,P7=new vr,tBe=new vr,R7=new vr,Ek=new BM,s1=new Mo,Ch=new jl,ub=new Ue,Ak=new eBe,Ma=new Yo,o1=[];function nBe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let a=0;a<i;a++)for(let o=0;o<r;o++)e.setComponent(a+n,o,t.getComponent(a,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class rBe extends Yo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Pa,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 Qze(n,e,e,bo,$c);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,m=new u.constructor(r*d),p=new c.constructor(m,d,f);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new Bs(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(hp,new Bs(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(hp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${hp}"`);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===hp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Mo);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,Qu),this.getBoundingBoxAt(i,s1).applyMatrix4(Qu),n.union(s1))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new jl);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,Qu),this.getBoundingSphereAt(i,Ch).applyMatrix4(Qu),n.union(Ch))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,m=this._active,p=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),m.push(!0);const v=this._geometryCount;this._geometryCount++,tBe.toArray(x,v*16),p.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Mo,sphereInitialized:!1,sphere:new jl});const b=this.geometry.getAttribute(hp);for(let y=0;y<i.vertexCount;y++)b.setX(i.vertexStart+y,v);return b.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const p in r.attributes){if(p===hp)continue;const x=n.getAttribute(p),v=r.getAttribute(p);nBe(x,v,c);const b=x.itemSize;for(let y=x.count,M=u;y<M;y++){const S=c+y;for(let A=0;A<b;A++)v.setComponent(S,A,0)}v.needsUpdate=!0}if(i){const p=l.indexStart;for(let x=0;x<o.count;x++)a.setX(p+x,c+o.getX(x));for(let x=o.count,v=l.indexCount;x<v;x++)a.setX(p+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],m=n.getAttribute("position");return f.count=i?o.count:m.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,o=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let m=d;l&&(m=l.getX(m)),a.expandByPoint(ub.fromBufferAttribute(c,m))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,s1),s1.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,m=u.start+u.count;f<m;f++){let p=f;l&&(p=l.getX(p)),ub.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(ub))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;Ma.material=this.material,Ma.geometry.index=c.index,Ma.geometry.attributes=c.attributes,Ma.geometry.boundingBox===null&&(Ma.geometry.boundingBox=new Mo),Ma.geometry.boundingSphere===null&&(Ma.geometry.boundingSphere=new jl);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];Ma.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Ma.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Ma.geometry.boundingBox),this.getBoundingSphereAt(u,Ma.geometry.boundingSphere),Ma.raycast(e,o1);for(let f=0,m=o1.length;f<m;f++){const p=o1[f];p.object=this,p.batchId=u,n.push(p)}o1.length=0}Ma.material=null,Ma.geometry.index=null,Ma.geometry.attributes={},Ma.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,m=this.perObjectFrustumCulled;m&&(R7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),Ek.setFromProjectionMatrix(R7,e.isWebGPURenderer?k0:Tl));let p=0;if(this.sortObjects){P7.copy(this.matrixWorld).invert(),ub.setFromMatrixPosition(r.matrixWorld).applyMatrix4(P7);for(let b=0,y=c.length;b<y;b++)if(c[b]){this.getMatrixAt(b,Qu),this.getBoundingSphereAt(b,Ch).applyMatrix4(Qu);let M=!1;if(m&&(M=!Ek.intersectsSphere(Ch)),!M){const S=ub.distanceTo(Ch.center);Ak.push(f[b],S)}}const x=Ak.list,v=this.customSort;v===null?x.sort(a.transparent?Jze:Zze):v.call(this,x,r);for(let b=0,y=x.length;b<y;b++){const M=x[b];u[p]=M.start*l,d[p]=M.count,p++}Ak.reset()}else for(let x=0,v=c.length;x<v;x++)if(c[x]){let b=!1;if(m&&(this.getMatrixAt(x,Qu),this.getBoundingSphereAt(x,Ch).applyMatrix4(Qu),b=!Ek.intersectsSphere(Ch)),!b){const y=f[x];u[p]=y.start*l,d[p]=y.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class Ty extends qg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qt(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 D7=new Ue,O7=new Ue,L7=new vr,Tk=new CO,l1=new jl;class iBe extends $a{constructor(e=new Pa,n=new Ty){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)D7.fromBufferAttribute(n,i-1),O7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=D7.distanceTo(O7);e.setAttribute("lineDistance",new si(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),l1.copy(r.boundingSphere),l1.applyMatrix4(i),l1.radius+=a,e.ray.intersectsSphere(l1)===!1)return;L7.copy(i).invert(),Tk.copy(e.ray).applyMatrix4(L7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new Ue,d=new Ue,f=new Ue,m=new Ue,p=this.isLineSegments?2:1,x=r.index,b=r.attributes.position;if(x!==null){const y=Math.max(0,o.start),M=Math.min(x.count,o.start+o.count);for(let S=y,A=M-1;S<A;S+=p){const E=x.getX(S),k=x.getX(S+1);if(u.fromBufferAttribute(b,E),d.fromBufferAttribute(b,k),Tk.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(m);R<e.near||R>e.far||n.push({distance:R,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const y=Math.max(0,o.start),M=Math.min(b.count,o.start+o.count);for(let S=y,A=M-1;S<A;S+=p){if(u.fromBufferAttribute(b,S),d.fromBufferAttribute(b,S+1),Tk.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(m);k<e.near||k>e.far||n.push({distance:k,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const I7=new Ue,F7=new Ue;class HM extends iBe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)I7.fromBufferAttribute(n,i),F7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+I7.distanceTo(F7);e.setAttribute("lineDistance",new si(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class aBe extends Pa{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Ue,a=new Ue;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],m=f.start,p=f.count;for(let x=m,v=m+p;x<v;x+=3)for(let b=0;b<3;b++){const y=l.getX(x+b),M=l.getX(x+(b+1)%3);i.fromBufferAttribute(o,y),a.fromBufferAttribute(o,M),U7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(o,d),a.fromBufferAttribute(o,f),U7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new si(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function U7(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 sBe extends qg{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=bJ,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.combine=NO,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 oBe extends Ty{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 zJ extends $a{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new qt(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 Ck=new vr,z7=new Ue,B7=new Ue;class lBe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new rn(512,512),this.map=null,this.mapPass=null,this.matrix=new vr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new BM,this._frameExtents=new rn(1,1),this._viewportCount=1,this._viewports=[new ur(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;z7.setFromMatrixPosition(e.matrixWorld),n.position.copy(z7),B7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(B7),n.updateMatrixWorld(),Ck.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ck),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Ck)}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 $7=new vr,db=new Ue,kk=new Ue;class cBe extends lBe{constructor(){super(new Ps(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new rn(4,2),this._viewportCount=6,this._viewports=[new ur(2,1,1,1),new ur(0,1,1,1),new ur(3,1,1,1),new ur(1,1,1,1),new ur(3,0,1,1),new ur(1,0,1,1)],this._cubeDirections=[new Ue(1,0,0),new Ue(-1,0,0),new Ue(0,0,1),new Ue(0,0,-1),new Ue(0,1,0),new Ue(0,-1,0)],this._cubeUps=[new Ue(0,1,0),new Ue(0,1,0),new Ue(0,1,0),new Ue(0,1,0),new Ue(0,0,1),new Ue(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),db.setFromMatrixPosition(e.matrixWorld),r.position.copy(db),kk.copy(r.position),kk.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(kk),r.updateMatrixWorld(),i.makeTranslation(-db.x,-db.y,-db.z),$7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix($7)}}class uBe extends zJ{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 cBe}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 dBe extends zJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class hBe extends Pa{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 YP extends Yze{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 H7{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(ma(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const V7=new Ue,c1=new Ue;class fBe{constructor(e=new Ue,n=new Ue){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){V7.subVectors(e,this.start),c1.subVectors(this.end,this.start);const r=c1.dot(c1);let a=c1.dot(V7)/r;return n&&(a=ma(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class mBe extends HM{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 Pa;i.setAttribute("position",new si(n,3)),i.setAttribute("color",new si(r,3));const a=new Ty({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new qt,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:FM}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=FM);class Pl{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Pl.nextNameID=Pl.nextNameID||0,this.$name.id=`lil-gui-name-${++Pl.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 pBe extends Pl{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 QP(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 gBe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:QP,toHexString:QP},P0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},xBe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=P0.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 P0.toHexString(i)}},bBe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=P0.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 P0.toHexString(i)}},yBe=[gBe,P0,xBe,bBe];function vBe(t){return yBe.find(e=>e.match(t))}class _Be extends Pl{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=vBe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=QP(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class jk extends Pl{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 wBe extends Pl{constructor(e,n,r,i,a,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let M=parseFloat(this.$input.value);isNaN(M)||(this._stepExplicit&&(M=this._snap(M)),this.setValue(this._clamp(M)))},r=M=>{const S=parseFloat(this.$input.value);isNaN(S)||(this._snapClampSetValue(S+M),this.$input.value=this.getValue())},i=M=>{M.key==="Enter"&&this.$input.blur(),M.code==="ArrowUp"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M))),M.code==="ArrowDown"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M)*-1))},a=M=>{this._inputFocused&&(M.preventDefault(),r(this._step*this._normalizeMouseWheel(M)))};let o=!1,l,c,u,d,f;const m=5,p=M=>{l=M.clientX,c=u=M.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",v)},x=M=>{if(o){const S=M.clientX-l,A=M.clientY-c;Math.abs(A)>m?(M.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(S)>m&&v()}if(!o){const S=M.clientY-u;f-=S*this._step*this._arrowKeyMultiplier(M),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=M.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",v)},b=()=>{this._inputFocused=!0},y=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",b),this.$input.addEventListener("blur",y)}_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=(y,M,S,A,E)=>(y-M)/(S-M)*(E-A)+A,n=y=>{const M=this.$slider.getBoundingClientRect();let S=e(y,M.left,M.right,this._min,this._max);this._snapClampSetValue(S)},r=y=>{this._setDraggingStyle(!0),n(y.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=y=>{n(y.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=y=>{y.preventDefault(),this._setDraggingStyle(!0),n(y.touches[0].clientX),o=!1},d=y=>{y.touches.length>1||(this._hasScrollBar?(l=y.touches[0].clientX,c=y.touches[0].clientY,o=!0):u(y),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",m))},f=y=>{if(o){const M=y.touches[0].clientX-l,S=y.touches[0].clientY-c;Math.abs(M)>Math.abs(S)?u(y):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m))}else y.preventDefault(),n(y.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m)},p=this._callOnFinishChange.bind(this),x=400;let v;const b=y=>{if(Math.abs(y.deltaX)<Math.abs(y.deltaY)&&this._hasScrollBar)return;y.preventDefault();const S=this._normalizeMouseWheel(y)*this._step;this._snapClampSetValue(this.getValue()+S),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",b,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class SBe extends Pl{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 MBe extends Pl{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 NBe=`.lil-gui {
  7477. font-family: var(--font-family);
  7478. font-size: var(--font-size);
  7479. line-height: 1;
  7480. font-weight: normal;
  7481. font-style: normal;
  7482. text-align: left;
  7483. color: var(--text-color);
  7484. user-select: none;
  7485. -webkit-user-select: none;
  7486. touch-action: manipulation;
  7487. --background-color: #1f1f1f;
  7488. --text-color: #ebebeb;
  7489. --title-background-color: #111111;
  7490. --title-text-color: #ebebeb;
  7491. --widget-color: #424242;
  7492. --hover-color: #4f4f4f;
  7493. --focus-color: #595959;
  7494. --number-color: #2cc9ff;
  7495. --string-color: #a2db3c;
  7496. --font-size: 11px;
  7497. --input-font-size: 11px;
  7498. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7499. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7500. --padding: 4px;
  7501. --spacing: 4px;
  7502. --widget-height: 20px;
  7503. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7504. --name-width: 45%;
  7505. --slider-knob-width: 2px;
  7506. --slider-input-width: 27%;
  7507. --color-input-width: 27%;
  7508. --slider-input-min-width: 45px;
  7509. --color-input-min-width: 45px;
  7510. --folder-indent: 7px;
  7511. --widget-padding: 0 0 0 3px;
  7512. --widget-border-radius: 2px;
  7513. --checkbox-size: calc(0.75 * var(--widget-height));
  7514. --scrollbar-width: 5px;
  7515. }
  7516. .lil-gui, .lil-gui * {
  7517. box-sizing: border-box;
  7518. margin: 0;
  7519. padding: 0;
  7520. }
  7521. .lil-gui.root {
  7522. width: var(--width, 245px);
  7523. display: flex;
  7524. flex-direction: column;
  7525. background: var(--background-color);
  7526. }
  7527. .lil-gui.root > .title {
  7528. background: var(--title-background-color);
  7529. color: var(--title-text-color);
  7530. }
  7531. .lil-gui.root > .children {
  7532. overflow-x: hidden;
  7533. overflow-y: auto;
  7534. }
  7535. .lil-gui.root > .children::-webkit-scrollbar {
  7536. width: var(--scrollbar-width);
  7537. height: var(--scrollbar-width);
  7538. background: var(--background-color);
  7539. }
  7540. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7541. border-radius: var(--scrollbar-width);
  7542. background: var(--focus-color);
  7543. }
  7544. @media (pointer: coarse) {
  7545. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7546. --widget-height: 28px;
  7547. --padding: 6px;
  7548. --spacing: 6px;
  7549. --font-size: 13px;
  7550. --input-font-size: 16px;
  7551. --folder-indent: 10px;
  7552. --scrollbar-width: 7px;
  7553. --slider-input-min-width: 50px;
  7554. --color-input-min-width: 65px;
  7555. }
  7556. }
  7557. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7558. --widget-height: 28px;
  7559. --padding: 6px;
  7560. --spacing: 6px;
  7561. --font-size: 13px;
  7562. --input-font-size: 16px;
  7563. --folder-indent: 10px;
  7564. --scrollbar-width: 7px;
  7565. --slider-input-min-width: 50px;
  7566. --color-input-min-width: 65px;
  7567. }
  7568. .lil-gui.autoPlace {
  7569. max-height: 100%;
  7570. position: fixed;
  7571. top: 0;
  7572. right: 15px;
  7573. z-index: 1001;
  7574. }
  7575. .lil-gui .controller {
  7576. display: flex;
  7577. align-items: center;
  7578. padding: 0 var(--padding);
  7579. margin: var(--spacing) 0;
  7580. }
  7581. .lil-gui .controller.disabled {
  7582. opacity: 0.5;
  7583. }
  7584. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7585. pointer-events: none !important;
  7586. }
  7587. .lil-gui .controller > .name {
  7588. min-width: var(--name-width);
  7589. flex-shrink: 0;
  7590. white-space: pre;
  7591. padding-right: var(--spacing);
  7592. line-height: var(--widget-height);
  7593. }
  7594. .lil-gui .controller .widget {
  7595. position: relative;
  7596. display: flex;
  7597. align-items: center;
  7598. width: 100%;
  7599. min-height: var(--widget-height);
  7600. }
  7601. .lil-gui .controller.string input {
  7602. color: var(--string-color);
  7603. }
  7604. .lil-gui .controller.boolean {
  7605. cursor: pointer;
  7606. }
  7607. .lil-gui .controller.color .display {
  7608. width: 100%;
  7609. height: var(--widget-height);
  7610. border-radius: var(--widget-border-radius);
  7611. position: relative;
  7612. }
  7613. @media (hover: hover) {
  7614. .lil-gui .controller.color .display:hover:before {
  7615. content: " ";
  7616. display: block;
  7617. position: absolute;
  7618. border-radius: var(--widget-border-radius);
  7619. border: 1px solid #fff9;
  7620. top: 0;
  7621. right: 0;
  7622. bottom: 0;
  7623. left: 0;
  7624. }
  7625. }
  7626. .lil-gui .controller.color input[type=color] {
  7627. opacity: 0;
  7628. width: 100%;
  7629. height: 100%;
  7630. cursor: pointer;
  7631. }
  7632. .lil-gui .controller.color input[type=text] {
  7633. margin-left: var(--spacing);
  7634. font-family: var(--font-family-mono);
  7635. min-width: var(--color-input-min-width);
  7636. width: var(--color-input-width);
  7637. flex-shrink: 0;
  7638. }
  7639. .lil-gui .controller.option select {
  7640. opacity: 0;
  7641. position: absolute;
  7642. width: 100%;
  7643. max-width: 100%;
  7644. }
  7645. .lil-gui .controller.option .display {
  7646. position: relative;
  7647. pointer-events: none;
  7648. border-radius: var(--widget-border-radius);
  7649. height: var(--widget-height);
  7650. line-height: var(--widget-height);
  7651. max-width: 100%;
  7652. overflow: hidden;
  7653. word-break: break-all;
  7654. padding-left: 0.55em;
  7655. padding-right: 1.75em;
  7656. background: var(--widget-color);
  7657. }
  7658. @media (hover: hover) {
  7659. .lil-gui .controller.option .display.focus {
  7660. background: var(--focus-color);
  7661. }
  7662. }
  7663. .lil-gui .controller.option .display.active {
  7664. background: var(--focus-color);
  7665. }
  7666. .lil-gui .controller.option .display:after {
  7667. font-family: "lil-gui";
  7668. content: "↕";
  7669. position: absolute;
  7670. top: 0;
  7671. right: 0;
  7672. bottom: 0;
  7673. padding-right: 0.375em;
  7674. }
  7675. .lil-gui .controller.option .widget,
  7676. .lil-gui .controller.option select {
  7677. cursor: pointer;
  7678. }
  7679. @media (hover: hover) {
  7680. .lil-gui .controller.option .widget:hover .display {
  7681. background: var(--hover-color);
  7682. }
  7683. }
  7684. .lil-gui .controller.number input {
  7685. color: var(--number-color);
  7686. }
  7687. .lil-gui .controller.number.hasSlider input {
  7688. margin-left: var(--spacing);
  7689. width: var(--slider-input-width);
  7690. min-width: var(--slider-input-min-width);
  7691. flex-shrink: 0;
  7692. }
  7693. .lil-gui .controller.number .slider {
  7694. width: 100%;
  7695. height: var(--widget-height);
  7696. background: var(--widget-color);
  7697. border-radius: var(--widget-border-radius);
  7698. padding-right: var(--slider-knob-width);
  7699. overflow: hidden;
  7700. cursor: ew-resize;
  7701. touch-action: pan-y;
  7702. }
  7703. @media (hover: hover) {
  7704. .lil-gui .controller.number .slider:hover {
  7705. background: var(--hover-color);
  7706. }
  7707. }
  7708. .lil-gui .controller.number .slider.active {
  7709. background: var(--focus-color);
  7710. }
  7711. .lil-gui .controller.number .slider.active .fill {
  7712. opacity: 0.95;
  7713. }
  7714. .lil-gui .controller.number .fill {
  7715. height: 100%;
  7716. border-right: var(--slider-knob-width) solid var(--number-color);
  7717. box-sizing: content-box;
  7718. }
  7719. .lil-gui-dragging .lil-gui {
  7720. --hover-color: var(--widget-color);
  7721. }
  7722. .lil-gui-dragging * {
  7723. cursor: ew-resize !important;
  7724. }
  7725. .lil-gui-dragging.lil-gui-vertical * {
  7726. cursor: ns-resize !important;
  7727. }
  7728. .lil-gui .title {
  7729. height: var(--title-height);
  7730. line-height: calc(var(--title-height) - 4px);
  7731. font-weight: 600;
  7732. padding: 0 var(--padding);
  7733. -webkit-tap-highlight-color: transparent;
  7734. cursor: pointer;
  7735. outline: none;
  7736. text-decoration-skip: objects;
  7737. }
  7738. .lil-gui .title:before {
  7739. font-family: "lil-gui";
  7740. content: "▾";
  7741. padding-right: 2px;
  7742. display: inline-block;
  7743. }
  7744. .lil-gui .title:active {
  7745. background: var(--title-background-color);
  7746. opacity: 0.75;
  7747. }
  7748. @media (hover: hover) {
  7749. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7750. background: var(--title-background-color);
  7751. opacity: 0.85;
  7752. }
  7753. .lil-gui .title:focus {
  7754. text-decoration: underline var(--focus-color);
  7755. }
  7756. }
  7757. .lil-gui.root > .title:focus {
  7758. text-decoration: none !important;
  7759. }
  7760. .lil-gui.closed > .title:before {
  7761. content: "▸";
  7762. }
  7763. .lil-gui.closed > .children {
  7764. transform: translateY(-7px);
  7765. opacity: 0;
  7766. }
  7767. .lil-gui.closed:not(.transition) > .children {
  7768. display: none;
  7769. }
  7770. .lil-gui.transition > .children {
  7771. transition-duration: 300ms;
  7772. transition-property: height, opacity, transform;
  7773. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7774. overflow: hidden;
  7775. pointer-events: none;
  7776. }
  7777. .lil-gui .children:empty:before {
  7778. content: "Empty";
  7779. padding: 0 var(--padding);
  7780. margin: var(--spacing) 0;
  7781. display: block;
  7782. height: var(--widget-height);
  7783. font-style: italic;
  7784. line-height: var(--widget-height);
  7785. opacity: 0.5;
  7786. }
  7787. .lil-gui.root > .children > .lil-gui > .title {
  7788. border: 0 solid var(--widget-color);
  7789. border-width: 1px 0;
  7790. transition: border-color 300ms;
  7791. }
  7792. .lil-gui.root > .children > .lil-gui.closed > .title {
  7793. border-bottom-color: transparent;
  7794. }
  7795. .lil-gui + .controller {
  7796. border-top: 1px solid var(--widget-color);
  7797. margin-top: 0;
  7798. padding-top: var(--spacing);
  7799. }
  7800. .lil-gui .lil-gui .lil-gui > .title {
  7801. border: none;
  7802. }
  7803. .lil-gui .lil-gui .lil-gui > .children {
  7804. border: none;
  7805. margin-left: var(--folder-indent);
  7806. border-left: 2px solid var(--widget-color);
  7807. }
  7808. .lil-gui .lil-gui .controller {
  7809. border: none;
  7810. }
  7811. .lil-gui label, .lil-gui input, .lil-gui button {
  7812. -webkit-tap-highlight-color: transparent;
  7813. }
  7814. .lil-gui input {
  7815. border: 0;
  7816. outline: none;
  7817. font-family: var(--font-family);
  7818. font-size: var(--input-font-size);
  7819. border-radius: var(--widget-border-radius);
  7820. height: var(--widget-height);
  7821. background: var(--widget-color);
  7822. color: var(--text-color);
  7823. width: 100%;
  7824. }
  7825. @media (hover: hover) {
  7826. .lil-gui input:hover {
  7827. background: var(--hover-color);
  7828. }
  7829. .lil-gui input:active {
  7830. background: var(--focus-color);
  7831. }
  7832. }
  7833. .lil-gui input:disabled {
  7834. opacity: 1;
  7835. }
  7836. .lil-gui input[type=text],
  7837. .lil-gui input[type=number] {
  7838. padding: var(--widget-padding);
  7839. -moz-appearance: textfield;
  7840. }
  7841. .lil-gui input[type=text]:focus,
  7842. .lil-gui input[type=number]:focus {
  7843. background: var(--focus-color);
  7844. }
  7845. .lil-gui input[type=checkbox] {
  7846. appearance: none;
  7847. width: var(--checkbox-size);
  7848. height: var(--checkbox-size);
  7849. border-radius: var(--widget-border-radius);
  7850. text-align: center;
  7851. cursor: pointer;
  7852. }
  7853. .lil-gui input[type=checkbox]:checked:before {
  7854. font-family: "lil-gui";
  7855. content: "✓";
  7856. font-size: var(--checkbox-size);
  7857. line-height: var(--checkbox-size);
  7858. }
  7859. @media (hover: hover) {
  7860. .lil-gui input[type=checkbox]:focus {
  7861. box-shadow: inset 0 0 0 1px var(--focus-color);
  7862. }
  7863. }
  7864. .lil-gui button {
  7865. outline: none;
  7866. cursor: pointer;
  7867. font-family: var(--font-family);
  7868. font-size: var(--font-size);
  7869. color: var(--text-color);
  7870. width: 100%;
  7871. height: var(--widget-height);
  7872. text-transform: none;
  7873. background: var(--widget-color);
  7874. border-radius: var(--widget-border-radius);
  7875. border: none;
  7876. }
  7877. @media (hover: hover) {
  7878. .lil-gui button:hover {
  7879. background: var(--hover-color);
  7880. }
  7881. .lil-gui button:focus {
  7882. box-shadow: inset 0 0 0 1px var(--focus-color);
  7883. }
  7884. }
  7885. .lil-gui button:active {
  7886. background: var(--focus-color);
  7887. }
  7888. @font-face {
  7889. font-family: "lil-gui";
  7890. 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");
  7891. }`;function EBe(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 G7=!1;class NS{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:o=!1,injectStyles:l=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!G7&&l&&(EBe(NBe),G7=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(e,n,r,i,a){if(Object(r)===r)return new SBe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new wBe(this,e,n,r,i,a);case"boolean":return new pBe(this,e,n);case"string":return new MBe(this,e,n);case"function":return new jk(this,e,n)}console.error(`gui.add failed
  7892. property:`,n,`
  7893. object:`,e,`
  7894. value:`,o)}addColor(e,n,r=1){return new _Be(this,e,n,r)}addFolder(e){const n=new NS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof jk||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 jk)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function Pk(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class DO{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 DO(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 OO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class W7 extends OO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Zu extends OO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class q7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class ES{constructor(e){this.lines=[],this.preamble=new q7(-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(`
  7895. `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,o]of Object.entries(i))this.metadata.thumbnails[a]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],o=n&&i[1]||void 0,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new W7(e,c,u,o);case"t0":return new Zu(e,c,o,0);case"t1":return new Zu(e,c,o,1);case"t2":return new Zu(e,c,o,2);case"t3":return new Zu(e,c,o,3);case"t4":return new Zu(e,c,o,4);case"t5":return new Zu(e,c,o,5);case"t6":return new Zu(e,c,o,6);case"t7":return new Zu(e,c,o,7);default:return new OO(e,c,u,o)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,a)=>{if(i%2==0)return n;let o=a[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof W7){const a=i.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new q7(this.layers.length,[],r,o))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const a=i.comment;if(!a)continue;const o=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");o>-1?r=DO.parse(a.slice(o+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}ES.prototype.parseGcode=ES.prototype.parseGCode;const K7={type:"change"},Rk={type:"start"},X7={type:"end"},u1=new CO,Y7=new ad,ABe=Math.cos(70*vJ.DEG2RAD);class TBe extends Xf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ue,this.cursor=new Ue,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:Km.ROTATE,MIDDLE:Km.DOLLY,RIGHT:Km.PAN},this.touches={ONE:Xm.ROTATE,TWO:Xm.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(H){H.addEventListener("keydown",Re),this._domElementKeyEvents=H},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Re),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(K7),r.update(),a=i.NONE},this.update=(function(){const H=new Ue,W=new Lf().setFromUnitVectors(e.up,new Ue(0,1,0)),z=W.clone().invert(),V=new Ue,Q=new Lf,Te=new Ue,ke=2*Math.PI;return function(Ae=null){const $=r.object.position;H.copy($).sub(r.target),H.applyQuaternion(W),l.setFromVector3(H),r.autoRotate&&a===i.NONE&&P((function(xe){return xe!==null?2*Math.PI/60*r.autoRotateSpeed*xe:2*Math.PI/60/60*r.autoRotateSpeed})(Ae)),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,oe=r.maxAzimuthAngle;isFinite(L)&&isFinite(oe)&&(L<-Math.PI?L+=ke:L>Math.PI&&(L-=ke),oe<-Math.PI?oe+=ke:oe>Math.PI&&(oe-=ke),l.theta=L<=oe?Math.max(L,Math.min(oe,l.theta)):l.theta>(L+oe)/2?Math.max(L,l.theta):Math.min(oe,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&k||r.object.isOrthographicCamera?l.radius=Z(l.radius):l.radius=Z(l.radius*u),H.setFromSpherical(l),H.applyQuaternion(z),$.copy(r.target).add(H),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let ce=!1;if(r.zoomToCursor&&k){let xe=null;if(r.object.isPerspectiveCamera){const ve=H.length();xe=Z(ve*u);const _e=ve-xe;r.object.position.addScaledVector(A,_e),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ve=new Ue(E.x,E.y,0);ve.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ce=!0;const _e=new Ue(E.x,E.y,0);_e.unproject(r.object),r.object.position.sub(_e).add(ve),r.object.updateMatrixWorld(),xe=H.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;xe!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(xe).add(r.object.position):(u1.origin.copy(r.object.position),u1.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(u1.direction))<ABe?e.lookAt(r.target):(Y7.setFromNormalAndCoplanarPoint(r.object.up,r.target),u1.intersectPlane(Y7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ce=!0);return u=1,k=!1,!!(ce||V.distanceToSquared(r.object.position)>o||8*(1-Q.dot(r.object.quaternion))>o||Te.distanceToSquared(r.target)>0)&&(r.dispatchEvent(K7),V.copy(r.object.position),Q.copy(r.object.quaternion),Te.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",te),r.domElement.removeEventListener("pointerdown",he),r.domElement.removeEventListener("pointercancel",ge),r.domElement.removeEventListener("wheel",Ne),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",ge),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Re),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const o=1e-6,l=new H7,c=new H7;let u=1;const d=new Ue,f=new rn,m=new rn,p=new rn,x=new rn,v=new rn,b=new rn,y=new rn,M=new rn,S=new rn,A=new Ue,E=new rn;let k=!1;const C=[],R={};function T(){return Math.pow(.95,r.zoomSpeed)}function P(H){c.theta-=H}function F(H){c.phi-=H}const I=(function(){const H=new Ue;return function(W,z){H.setFromMatrixColumn(z,0),H.multiplyScalar(-W),d.add(H)}})(),X=(function(){const H=new Ue;return function(W,z){r.screenSpacePanning===!0?H.setFromMatrixColumn(z,1):(H.setFromMatrixColumn(z,0),H.crossVectors(r.object.up,H)),H.multiplyScalar(W),d.add(H)}})(),D=(function(){const H=new Ue;return function(W,z){const V=r.domElement;if(r.object.isPerspectiveCamera){const Q=r.object.position;H.copy(Q).sub(r.target);let Te=H.length();Te*=Math.tan(r.object.fov/2*Math.PI/180),I(2*W*Te/V.clientHeight,r.object.matrix),X(2*z*Te/V.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(I(W*(r.object.right-r.object.left)/r.object.zoom/V.clientWidth,r.object.matrix),X(z*(r.object.top-r.object.bottom)/r.object.zoom/V.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function K(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function Y(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function q(H){if(!r.zoomToCursor)return;k=!0;const W=r.domElement.getBoundingClientRect(),z=H.clientX-W.left,V=H.clientY-W.top,Q=W.width,Te=W.height;E.x=z/Q*2-1,E.y=-V/Te*2+1,A.set(E.x,E.y,1).unproject(r.object).sub(r.object.position).normalize()}function Z(H){return Math.max(r.minDistance,Math.min(r.maxDistance,H))}function re(H){f.set(H.clientX,H.clientY)}function ie(H){x.set(H.clientX,H.clientY)}function U(){if(C.length===1)f.set(C[0].pageX,C[0].pageY);else{const H=.5*(C[0].pageX+C[1].pageX),W=.5*(C[0].pageY+C[1].pageY);f.set(H,W)}}function G(){if(C.length===1)x.set(C[0].pageX,C[0].pageY);else{const H=.5*(C[0].pageX+C[1].pageX),W=.5*(C[0].pageY+C[1].pageY);x.set(H,W)}}function ee(){const H=C[0].pageX-C[1].pageX,W=C[0].pageY-C[1].pageY,z=Math.sqrt(H*H+W*W);y.set(0,z)}function ne(H){if(C.length==1)m.set(H.pageX,H.pageY);else{const z=B(H),V=.5*(H.pageX+z.x),Q=.5*(H.pageY+z.y);m.set(V,Q)}p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const W=r.domElement;P(2*Math.PI*p.x/W.clientHeight),F(2*Math.PI*p.y/W.clientHeight),f.copy(m)}function se(H){if(C.length===1)v.set(H.pageX,H.pageY);else{const W=B(H),z=.5*(H.pageX+W.x),V=.5*(H.pageY+W.y);v.set(z,V)}b.subVectors(v,x).multiplyScalar(r.panSpeed),D(b.x,b.y),x.copy(v)}function de(H){const W=B(H),z=H.pageX-W.x,V=H.pageY-W.y,Q=Math.sqrt(z*z+V*V);M.set(0,Q),S.set(0,Math.pow(M.y/y.y,r.zoomSpeed)),K(S.y),y.copy(M)}function he(H){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(H.pointerId),r.domElement.addEventListener("pointermove",Ee),r.domElement.addEventListener("pointerup",ge)),(function(W){C.push(W)})(H),H.pointerType==="touch"?(function(W){switch(Je(W),C.length){case 1:switch(r.touches.ONE){case Xm.ROTATE:if(r.enableRotate===!1)return;U(),a=i.TOUCH_ROTATE;break;case Xm.PAN:if(r.enablePan===!1)return;G(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Xm.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ee(),r.enablePan&&G(),a=i.TOUCH_DOLLY_PAN;break;case Xm.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ee(),r.enableRotate&&U(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(Rk)})(H):(function(W){let z;switch(W.button){case 0:z=r.mouseButtons.LEFT;break;case 1:z=r.mouseButtons.MIDDLE;break;case 2:z=r.mouseButtons.RIGHT;break;default:z=-1}switch(z){case Km.DOLLY:if(r.enableZoom===!1)return;(function(V){q(V),y.set(V.clientX,V.clientY)})(W),a=i.DOLLY;break;case Km.ROTATE:if(W.ctrlKey||W.metaKey||W.shiftKey){if(r.enablePan===!1)return;ie(W),a=i.PAN}else{if(r.enableRotate===!1)return;re(W),a=i.ROTATE}break;case Km.PAN:if(W.ctrlKey||W.metaKey||W.shiftKey){if(r.enableRotate===!1)return;re(W),a=i.ROTATE}else{if(r.enablePan===!1)return;ie(W),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(Rk)})(H))}function Ee(H){r.enabled!==!1&&(H.pointerType==="touch"?(function(W){switch(Je(W),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ne(W),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;se(W),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(z){r.enableZoom&&de(z),r.enablePan&&se(z)})(W),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(z){r.enableZoom&&de(z),r.enableRotate&&ne(z)})(W),r.update();break;default:a=i.NONE}})(H):(function(W){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(z){m.set(z.clientX,z.clientY),p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const V=r.domElement;P(2*Math.PI*p.x/V.clientHeight),F(2*Math.PI*p.y/V.clientHeight),f.copy(m),r.update()})(W);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(z){M.set(z.clientX,z.clientY),S.subVectors(M,y),S.y>0?K(T()):S.y<0&&Y(T()),y.copy(M),r.update()})(W);break;case i.PAN:if(r.enablePan===!1)return;(function(z){v.set(z.clientX,z.clientY),b.subVectors(v,x).multiplyScalar(r.panSpeed),D(b.x,b.y),x.copy(v),r.update()})(W)}})(H))}function ge(H){(function(W){delete R[W.pointerId];for(let z=0;z<C.length;z++)if(C[z].pointerId==W.pointerId)return void C.splice(z,1)})(H),C.length===0&&(r.domElement.releasePointerCapture(H.pointerId),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",ge)),r.dispatchEvent(X7),a=i.NONE}function Ne(H){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(H.preventDefault(),r.dispatchEvent(Rk),(function(W){q(W),W.deltaY<0?Y(T()):W.deltaY>0&&K(T()),r.update()})(H),r.dispatchEvent(X7))}function Re(H){r.enabled!==!1&&r.enablePan!==!1&&(function(W){let z=!1;switch(W.code){case r.keys.UP:W.ctrlKey||W.metaKey||W.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,r.keyPanSpeed),z=!0;break;case r.keys.BOTTOM:W.ctrlKey||W.metaKey||W.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,-r.keyPanSpeed),z=!0;break;case r.keys.LEFT:W.ctrlKey||W.metaKey||W.shiftKey?P(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(r.keyPanSpeed,0),z=!0;break;case r.keys.RIGHT:W.ctrlKey||W.metaKey||W.shiftKey?P(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(-r.keyPanSpeed,0),z=!0}z&&(W.preventDefault(),r.update())})(H)}function te(H){r.enabled!==!1&&H.preventDefault()}function Je(H){let W=R[H.pointerId];W===void 0&&(W=new rn,R[H.pointerId]=W),W.set(H.pageX,H.pageY)}function B(H){const W=H.pointerId===C[0].pointerId?C[1]:C[0];return R[W.pointerId]}r.domElement.addEventListener("contextmenu",te),r.domElement.addEventListener("pointerdown",he),r.domElement.addEventListener("pointercancel",ge),r.domElement.addEventListener("wheel",Ne,{passive:!1}),this.update()}}kt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new rn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},ss.line={uniforms:kO.merge([kt.common,kt.fog,kt.line]),vertexShader:`
  7896. #include <common>
  7897. #include <color_pars_vertex>
  7898. #include <fog_pars_vertex>
  7899. #include <logdepthbuf_pars_vertex>
  7900. #include <clipping_planes_pars_vertex>
  7901. uniform float linewidth;
  7902. uniform vec2 resolution;
  7903. attribute vec3 instanceStart;
  7904. attribute vec3 instanceEnd;
  7905. attribute vec3 instanceColorStart;
  7906. attribute vec3 instanceColorEnd;
  7907. #ifdef WORLD_UNITS
  7908. varying vec4 worldPos;
  7909. varying vec3 worldStart;
  7910. varying vec3 worldEnd;
  7911. #ifdef USE_DASH
  7912. varying vec2 vUv;
  7913. #endif
  7914. #else
  7915. varying vec2 vUv;
  7916. #endif
  7917. #ifdef USE_DASH
  7918. uniform float dashScale;
  7919. attribute float instanceDistanceStart;
  7920. attribute float instanceDistanceEnd;
  7921. varying float vLineDistance;
  7922. #endif
  7923. void trimSegment( const in vec4 start, inout vec4 end ) {
  7924. // trim end segment so it terminates between the camera plane and the near plane
  7925. // conservative estimate of the near plane
  7926. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7927. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7928. float nearEstimate = - 0.5 * b / a;
  7929. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7930. end.xyz = mix( start.xyz, end.xyz, alpha );
  7931. }
  7932. void main() {
  7933. #ifdef USE_COLOR
  7934. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7935. #endif
  7936. #ifdef USE_DASH
  7937. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7938. vUv = uv;
  7939. #endif
  7940. float aspect = resolution.x / resolution.y;
  7941. // camera space
  7942. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7943. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7944. #ifdef WORLD_UNITS
  7945. worldStart = start.xyz;
  7946. worldEnd = end.xyz;
  7947. #else
  7948. vUv = uv;
  7949. #endif
  7950. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7951. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7952. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7953. // perhaps there is a more elegant solution -- WestLangley
  7954. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7955. if ( perspective ) {
  7956. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7957. trimSegment( start, end );
  7958. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7959. trimSegment( end, start );
  7960. }
  7961. }
  7962. // clip space
  7963. vec4 clipStart = projectionMatrix * start;
  7964. vec4 clipEnd = projectionMatrix * end;
  7965. // ndc space
  7966. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7967. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7968. // direction
  7969. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7970. // account for clip-space aspect ratio
  7971. dir.x *= aspect;
  7972. dir = normalize( dir );
  7973. #ifdef WORLD_UNITS
  7974. // get the offset direction as perpendicular to the view vector
  7975. vec3 worldDir = normalize( end.xyz - start.xyz );
  7976. vec3 offset;
  7977. if ( position.y < 0.5 ) {
  7978. offset = normalize( cross( start.xyz, worldDir ) );
  7979. } else {
  7980. offset = normalize( cross( end.xyz, worldDir ) );
  7981. }
  7982. // sign flip
  7983. if ( position.x < 0.0 ) offset *= - 1.0;
  7984. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7985. // don't extend the line if we're rendering dashes because we
  7986. // won't be rendering the endcaps
  7987. #ifndef USE_DASH
  7988. // extend the line bounds to encompass endcaps
  7989. start.xyz += - worldDir * linewidth * 0.5;
  7990. end.xyz += worldDir * linewidth * 0.5;
  7991. // shift the position of the quad so it hugs the forward edge of the line
  7992. offset.xy -= dir * forwardOffset;
  7993. offset.z += 0.5;
  7994. #endif
  7995. // endcaps
  7996. if ( position.y > 1.0 || position.y < 0.0 ) {
  7997. offset.xy += dir * 2.0 * forwardOffset;
  7998. }
  7999. // adjust for linewidth
  8000. offset *= linewidth * 0.5;
  8001. // set the world position
  8002. worldPos = ( position.y < 0.5 ) ? start : end;
  8003. worldPos.xyz += offset;
  8004. // project the worldpos
  8005. vec4 clip = projectionMatrix * worldPos;
  8006. // shift the depth of the projected points so the line
  8007. // segments overlap neatly
  8008. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  8009. clip.z = clipPose.z * clip.w;
  8010. #else
  8011. vec2 offset = vec2( dir.y, - dir.x );
  8012. // undo aspect ratio adjustment
  8013. dir.x /= aspect;
  8014. offset.x /= aspect;
  8015. // sign flip
  8016. if ( position.x < 0.0 ) offset *= - 1.0;
  8017. // endcaps
  8018. if ( position.y < 0.0 ) {
  8019. offset += - dir;
  8020. } else if ( position.y > 1.0 ) {
  8021. offset += dir;
  8022. }
  8023. // adjust for linewidth
  8024. offset *= linewidth;
  8025. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  8026. offset /= resolution.y;
  8027. // select end
  8028. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  8029. // back to clip space
  8030. offset *= clip.w;
  8031. clip.xy += offset;
  8032. #endif
  8033. gl_Position = clip;
  8034. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  8035. #include <logdepthbuf_vertex>
  8036. #include <clipping_planes_vertex>
  8037. #include <fog_vertex>
  8038. }
  8039. `,fragmentShader:`
  8040. uniform vec3 diffuse;
  8041. uniform float opacity;
  8042. uniform float linewidth;
  8043. #ifdef USE_DASH
  8044. uniform float dashOffset;
  8045. uniform float dashSize;
  8046. uniform float gapSize;
  8047. #endif
  8048. varying float vLineDistance;
  8049. #ifdef WORLD_UNITS
  8050. varying vec4 worldPos;
  8051. varying vec3 worldStart;
  8052. varying vec3 worldEnd;
  8053. #ifdef USE_DASH
  8054. varying vec2 vUv;
  8055. #endif
  8056. #else
  8057. varying vec2 vUv;
  8058. #endif
  8059. #include <common>
  8060. #include <color_pars_fragment>
  8061. #include <fog_pars_fragment>
  8062. #include <logdepthbuf_pars_fragment>
  8063. #include <clipping_planes_pars_fragment>
  8064. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  8065. float mua;
  8066. float mub;
  8067. vec3 p13 = p1 - p3;
  8068. vec3 p43 = p4 - p3;
  8069. vec3 p21 = p2 - p1;
  8070. float d1343 = dot( p13, p43 );
  8071. float d4321 = dot( p43, p21 );
  8072. float d1321 = dot( p13, p21 );
  8073. float d4343 = dot( p43, p43 );
  8074. float d2121 = dot( p21, p21 );
  8075. float denom = d2121 * d4343 - d4321 * d4321;
  8076. float numer = d1343 * d4321 - d1321 * d4343;
  8077. mua = numer / denom;
  8078. mua = clamp( mua, 0.0, 1.0 );
  8079. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8080. mub = clamp( mub, 0.0, 1.0 );
  8081. return vec2( mua, mub );
  8082. }
  8083. void main() {
  8084. #include <clipping_planes_fragment>
  8085. #ifdef USE_DASH
  8086. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8087. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8088. #endif
  8089. float alpha = opacity;
  8090. #ifdef WORLD_UNITS
  8091. // Find the closest points on the view ray and the line segment
  8092. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8093. vec3 lineDir = worldEnd - worldStart;
  8094. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8095. vec3 p1 = worldStart + lineDir * params.x;
  8096. vec3 p2 = rayEnd * params.y;
  8097. vec3 delta = p1 - p2;
  8098. float len = length( delta );
  8099. float norm = len / linewidth;
  8100. #ifndef USE_DASH
  8101. #ifdef USE_ALPHA_TO_COVERAGE
  8102. float dnorm = fwidth( norm );
  8103. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8104. #else
  8105. if ( norm > 0.5 ) {
  8106. discard;
  8107. }
  8108. #endif
  8109. #endif
  8110. #else
  8111. #ifdef USE_ALPHA_TO_COVERAGE
  8112. // artifacts appear on some hardware if a derivative is taken within a conditional
  8113. float a = vUv.x;
  8114. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8115. float len2 = a * a + b * b;
  8116. float dlen = fwidth( len2 );
  8117. if ( abs( vUv.y ) > 1.0 ) {
  8118. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8119. }
  8120. #else
  8121. if ( abs( vUv.y ) > 1.0 ) {
  8122. float a = vUv.x;
  8123. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8124. float len2 = a * a + b * b;
  8125. if ( len2 > 1.0 ) discard;
  8126. }
  8127. #endif
  8128. #endif
  8129. vec4 diffuseColor = vec4( diffuse, alpha );
  8130. #include <logdepthbuf_fragment>
  8131. #include <color_fragment>
  8132. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8133. #include <tonemapping_fragment>
  8134. #include <colorspace_fragment>
  8135. #include <fog_fragment>
  8136. #include <premultiplied_alpha_fragment>
  8137. }
  8138. `};class BJ extends Vd{constructor(e){super({type:"LineMaterial",uniforms:kO.clone(ss.line.uniforms),vertexShader:ss.line.vertexShader,fragmentShader:ss.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 Q7=new Mo,d1=new Ue;class $J extends hBe{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 si([-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 si([-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 YP(n,6,1);return this.setAttribute("instanceStart",new xd(r,3,0)),this.setAttribute("instanceEnd",new xd(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 YP(n,6,1);return this.setAttribute("instanceColorStart",new xd(r,3,0)),this.setAttribute("instanceColorEnd",new xd(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 aBe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Mo);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Q7.setFromBufferAttribute(n),this.boundingBox.union(Q7))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new jl),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)d1.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(d1)),d1.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(d1));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 Z7=new Ue,J7=new Ue,oa=new ur,la=new ur,pl=new ur,Dk=new Ue,Ok=new vr,ca=new fBe,e9=new Ue,h1=new Mo,f1=new jl,gl=new ur;let xl,zh;function t9(t,e,n){return gl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),gl.multiplyScalar(1/gl.w),gl.x=zh/n.width,gl.y=zh/n.height,gl.applyMatrix4(t.projectionMatrixInverse),gl.multiplyScalar(1/gl.w),Math.abs(Math.max(gl.x,gl.y))}class CBe extends Yo{constructor(e=new $J,n=new BJ({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)Z7.fromBufferAttribute(n,o),J7.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+Z7.distanceTo(J7);const a=new YP(i,2,1);return e.setAttribute("instanceDistanceStart",new xd(a,1,0)),e.setAttribute("instanceDistanceEnd",new xd(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;xl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;zh=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),f1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*zh:u=t9(i,Math.max(i.near,f1.distanceToPoint(xl.origin)),c.resolution),f1.radius+=u,xl.intersectsSphere(f1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),h1.copy(l.boundingBox).applyMatrix4(o),r?d=.5*zh:d=t9(i,Math.max(i.near,h1.distanceToPoint(xl.origin)),c.resolution),h1.expandByScalar(d),xl.intersectsBox(h1)!==!1&&(r?(function(f,m){const p=f.matrixWorld,x=f.geometry,v=x.attributes.instanceStart,b=x.attributes.instanceEnd;for(let y=0,M=Math.min(x.instanceCount,v.count);y<M;y++){ca.start.fromBufferAttribute(v,y),ca.end.fromBufferAttribute(b,y),ca.applyMatrix4(p);const S=new Ue,A=new Ue;xl.distanceSqToSegment(ca.start,ca.end,A,S),A.distanceTo(S)<.5*zh&&m.push({point:A,pointOnLine:S,distance:xl.origin.distanceTo(A),object:f,face:null,faceIndex:y,uv:null,uv1:null})}})(this,n):(function(f,m,p){const x=m.projectionMatrix,v=f.material.resolution,b=f.matrixWorld,y=f.geometry,M=y.attributes.instanceStart,S=y.attributes.instanceEnd,A=Math.min(y.instanceCount,M.count),E=-m.near;xl.at(1,pl),pl.w=1,pl.applyMatrix4(m.matrixWorldInverse),pl.applyMatrix4(x),pl.multiplyScalar(1/pl.w),pl.x*=v.x/2,pl.y*=v.y/2,pl.z=0,Dk.copy(pl),Ok.multiplyMatrices(m.matrixWorldInverse,b);for(let k=0,C=A;k<C;k++){if(oa.fromBufferAttribute(M,k),la.fromBufferAttribute(S,k),oa.w=1,la.w=1,oa.applyMatrix4(Ok),la.applyMatrix4(Ok),oa.z>E&&la.z>E)continue;if(oa.z>E){const I=oa.z-la.z,X=(oa.z-E)/I;oa.lerp(la,X)}else if(la.z>E){const I=la.z-oa.z,X=(la.z-E)/I;la.lerp(oa,X)}oa.applyMatrix4(x),la.applyMatrix4(x),oa.multiplyScalar(1/oa.w),la.multiplyScalar(1/la.w),oa.x*=v.x/2,oa.y*=v.y/2,la.x*=v.x/2,la.y*=v.y/2,ca.start.copy(oa),ca.start.z=0,ca.end.copy(la),ca.end.z=0;const R=ca.closestPointToPointParameter(Dk,!0);ca.at(R,e9);const T=vJ.lerp(oa.z,la.z,R),P=T>=-1&&T<=1,F=Dk.distanceTo(e9)<.5*zh;if(P&&F){ca.start.fromBufferAttribute(M,k),ca.end.fromBufferAttribute(S,k),ca.start.applyMatrix4(b),ca.end.applyMatrix4(b);const I=new Ue,X=new Ue;xl.distanceSqToSegment(ca.start,ca.end,X,I),p.push({point:X,pointOnLine:I,distance:xl.origin.distanceTo(X),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class kBe extends HM{constructor(e,n,r,i,a=4473924,o=8947848){a=new qt(a),o=new qt(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let m=-1*(e=l*n/2);m<=e;m+=n){c.push(m,0,-1*r,m,0,r);const p=m===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let m=-1*r;m<=r;m+=i){c.push(-1*e,0,m,e,0,m);const p=m===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new Pa;f.setAttribute("position",new si(c,3)),f.setAttribute("color",new si(u,3)),super(f,new Ty({vertexColors:!0,toneMapped:!1}))}}function jBe(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Pa,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 si(d,3)),u})(t,e,n),a=new HM(i,new oBe({color:new qt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var Ib=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,o=0,l=n(new Ib.Panel("FPS","#0ff","#002")),c=n(new Ib.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Ib.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(l.update(1e3*o/(d-a),100),a=d,o=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};Ib.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,m=15*o,p=74*o,x=30*o,v=document.createElement("canvas");v.width=l,v.height=c,v.style.cssText="width:80px;height:48px";var b=v.getContext("2d");return b.font="bold "+9*o+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=n,b.fillRect(0,0,l,c),b.fillStyle=e,b.fillText(t,u,d),b.fillRect(f,m,p,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f,m,p,x),{dom:v,update:function(y,M){r=Math.min(r,y),i=Math.max(i,y),b.fillStyle=n,b.globalAlpha=1,b.fillRect(0,0,l,m),b.fillStyle=e,b.fillText(a(y)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),b.drawImage(v,f+o,m,p-o,x,f,m,p-o,x),b.fillRect(f+p-o,m,o,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f+p-o,m,o,a((1-y/M)*x))}}};var PBe=Ib;class n9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new NS,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 NS,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 RBe extends Pa{constructor(e=[new Ue],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const a=new Ue,o=new Ue,l=new rn,c=[],u=[],d=[],f=[];function m(p){const[x,v,b]=(function(y){const M=e[y],S=new Ue,A=new Ue,E=new Ue,k=new Ue;S.copy(M).sub(e[y-1]||M).normalize().add((e[y+1]||M).clone().sub(M).normalize()).normalize();let C=Number.MAX_VALUE;const R=Math.abs(S.x),T=Math.abs(S.y),P=Math.abs(S.z);return R<=C&&(C=R,A.set(1,0,0)),T<=C&&(C=T,A.set(0,1,0)),P<=C&&A.set(0,0,1),k.crossVectors(S,A).normalize(),A.crossVectors(S,k),E.crossVectors(S,A),[M,A,E]})(p);for(let y=0;y<=i;y++){const M=y/i*Math.PI*2,S=Math.sin(M),A=-Math.cos(M);o.x=A*v.x+S*b.x,o.y=A*v.y+S*b.y,o.z=A*v.z+S*b.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=x.x+n*o.x*.5,a.y=x.y+n*o.y*.5,a.z=x.z+r*o.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let p=0;p<e.length;p++)m(p);m(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)l.x=p/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const v=(i+1)*(p-1)+(x-1),b=(i+1)*p+(x-1),y=(i+1)*p+x,M=(i+1)*(p-1)+x;f.push(v,b,M),f.push(b,y,M)}})()})(),this.setIndex(f),this.setAttribute("position",new si(c,3)),this.setAttribute("normal",new si(u,3)),this.setAttribute("uv",new si(d,2))}}class Fb{static get initial(){const e=new Fb;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const Lk={h:0,s:0,l:0};class Vp{constructor(e){var n,r,i,a,o,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Fb.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Vp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new qt(14737632),this._travelColor=new qt(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 ES(this.minLayerThreshold),this.scene=new Xze,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new qt(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(o=e.renderTravel)!==null&&o!==void 0?o:this.renderTravel,this.nonTravelmoves=(l=e.nonTravelMoves)!==null&&l!==void 0?l:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new PBe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new qt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new qt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new qt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new qt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+FM),console.debug("opts",e),this.targetId&&console.warn("`targetId` is deprecated and will removed in the future. Use `canvas` instead."),e.canvas)this.canvas=e.canvas,this.renderer=new XP({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const p=document.getElementById(this.targetId);if(!p)throw new Error("Unable to find element "+this.targetId);this.renderer=new XP({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new Ps(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,m=.8*f;this.scene.fog=new RO(this._backgroundColor,m,f),this.resize(),this.controls=new TBe(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 qt(r)}else this._extrusionColor=new qt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Vp.defaultExtrusionColor:this._extrusionColor instanceof qt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Vp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new qt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new qt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new qt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new qt(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 mBe(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 dBe(13421772,.3*Math.PI),n=new uBe(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 Sb;return n.name=e,n.quaternion.setFromEuler(new Ey(-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=Fb.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 Pk(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const m of d.commands)if(m.gcode!="g20"){if(m.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=m;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const p=m,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=p.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const v=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(m.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,x,v,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,x,v))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(Lk),a=new qt().setHSL(Lk.h,Lk.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:a,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:o,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.getHex()),this.addLine([...u,...c],l.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new kBe(this.buildVolume.x,10,this.buildVolume.y,10));const e=jBe(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 ES(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Fb.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,m=r.z;let p=r.r,x=r.i,v=r.j;if(p){const K=d-l,Y=f-c,q=Math.sqrt(Math.pow(K/2,2)+Math.pow(Y/2,2));p=Math.max(p,q);const Z=Math.pow(K,2)+Math.pow(Y,2),re=Math.pow(p,2)-Z/4;let ie=Math.sqrt(re/Z);(a&&p<0||!a&&p>0)&&(ie=-ie),x=K/2+Y*ie,v=Y/2-K*ie}const b=l==d&&c==f,y=l+x,M=c+v,S=Math.sqrt(x*x+v*v),A=Math.atan2(-v,-x),E=Math.atan2(f-M,d-y);let k;b?k=2*Math.PI:(k=a?A-E:E-A,k<0&&(k+=2*Math.PI));let C=S*k/1.8;this.inches&&(C*=25),C<1&&(C=1);let R=k/C;R*=a?-1:1;const T=[];T.push({x:l,y:c,z:u});const P=(u-m)/C;let F=l,I=c,X=u,D=A;for(let K=0;K<C-1;K++)D+=R,F=y+S*Math.cos(D),I=M+S*Math.sin(D),X+=P,T.push({x:F,y:I,z:X});T.push({x:r.x,y:r.y,z:r.z});for(let K=0;K<T.length-1;K++)o.push(T[K].x,T[K].y,T[K].z,T[K+1].x,T[K+1].y,T[K+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Pa;i.setAttribute("position",new si(e,3)),this.disposables.push(i);const a=new Ty({color:n});this.disposables.push(a);const o=new HM(i,a);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new Ue(l[0],l[1],l[2]),u=new Ue(l[3],l[4],l[5]),d=new Ue(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((o=>{var l;const c=new RBe(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 $J;this.disposables.push(i);const a=new BJ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new CBe(i,a);(r=this.group)===null||r===void 0||r.add(o)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>Pk(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 sBe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new rBe(r.length,a,void 0,i);return this.disposables.push(o),(n=this.group)===null||n===void 0||n.add(o),o}_readFromStream(e){var n,r;return Pk(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
  8139. `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new n9(this):typeof this.devMode=="object"&&(this.devGui=new n9(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())}}Vp.defaultExtrusionColor=new qt("hotpink");function DBe({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),a=w.useRef(null),o=w.useRef(null),l=w.useRef(!1),[c,u]=w.useState(!0),[d,f]=w.useState(null),[m,p]=w.useState(!1),[x,v]=w.useState(0),[b,y]=w.useState(0),M=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const E=i.current,k=E.parentElement?.getBoundingClientRect();k&&(E.width=k.width,E.height=k.height);const C=n&&n.length>1,R=n?.[0]||"#00ae42",T=new Vp({canvas:E,buildVolume:e,backgroundColor:1710618,extrusionColor:C?n:R,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=T,fetch(t).then(async F=>{if(!F.ok)throw F.status===404&&(await F.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return F.text()}).then(F=>{const I=new Set,X=/^(\s*)T(\d+)(\s*;.*)?$/gim;let D;for(;(D=X.exec(F))!==null;){const ie=parseInt(D[2],10);ie<=15&&I.add(ie)}const K=new Map,Y=Array.from(I).sort((ie,U)=>ie-U);Y.forEach((ie,U)=>{K.set(ie,U%8)});const q=[];Y.forEach((ie,U)=>{const G=n?.[ie]||"#00ae42";q[U%8]=G});const Z=F.split(`
  8140. `).map(ie=>{const U=ie.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(U){const G=parseInt(U[2],10);if(G>15)return`; FILTERED: ${ie.trim()}`;const ee=K.get(G)??0;return`${U[1]}T${ee}${U[3]||""}`}return ie}).join(`
  8141. `);q.length>0&&(T.extrusionColor=q),T.processGCode(Z);const re=T.layers?.length||0;y(re),v(re),T.render(),u(!1)}).catch(F=>{F.message!=="not_sliced"&&f(F.message),u(!1)});const P=()=>{if(E.parentElement&&a.current){const F=E.parentElement.getBoundingClientRect();E.width=F.width,E.height=F.height,a.current.resize()}};return window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,M]);const S=w.useCallback(E=>{if(!a.current)return;const k=Math.max(1,Math.min(E,b));v(k),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=k,a.current.render())})},[b]),A=E=>{S(parseInt(E.target.value,10))};return s.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[s.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center",children:[s.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),m&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center max-w-sm px-4",children:[s.jsx(aue,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),s.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer."})]})}),d&&!m&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("div",{className:"text-center text-red-400",children:s.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!m&&b>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>S(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(yf,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:b,value:x,onChange:A,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),s.jsx("button",{onClick:()=>S(x+1),disabled:x>=b,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Vs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",b]})]})})]})}function HJ({archiveId:t,title:e,onClose:n}){const[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(!0);w.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),w.useEffect(()=>{pe.getArchiveCapabilities(t).then(d=>{o(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{o({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${pe.getArchiveForSlicer(t,d)}`;Oc(f)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(Lr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Ut,{className:"w-5 h-5"})})]})]}),a&&s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(Rs,{className:"w-4 h-4"}),"3D Model",!a.has_model&&s.jsx("span",{className:"text-xs",children:"(not available)"})]}),s.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(Rce,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&s.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(jOe,{url:a.has_source?pe.getSource3mfDownloadUrl(t):pe.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(DBe,{gcodeUrl:pe.getArchiveGcode(t),filamentColors:a.filament_colors,className:"w-full h-full"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const r9={"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 OBe(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(a+o)/2;let c=0,u=0;if(a!==o){const d=a-o;u=l>.5?d/(2-a-o):d/(a+o);const f=n/255,m=r/255,p=i/255;a===f?c=((m-p)/d+(m<p?6:0))/6:a===m?c=((p-f)/d+2)/6:c=((f-m)/d+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":u<.15?l<.4?"Dark Gray":l>.6?"Light Gray":"Gray":c<15||c>=345?"Red":c<45?"Orange":c<70?"Yellow":c<150?"Green":c<200?"Cyan":c<260?"Blue":c<290?"Purple":c<345?"Pink":"Unknown"}function bg(t){const e=t.replace("#","").toLowerCase().substring(0,6);return r9[e]?r9[e]:OBe(t)}function AS(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function Yi(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Gd(t,e,n=40){const r=Yi(t),i=Yi(e);if(!r||!i||r.length<6||i.length<6)return!1;const a=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),l=parseInt(r.substring(4,6),16),c=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),d=parseInt(i.substring(4,6),16);return Math.abs(a-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function VJ(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function GJ(t,e,n){return t*4+e}function LBe(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 IBe(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function i9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function LO(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=AS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:bg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:VJ(n.id,i.id,r),globalTrayId:GJ(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=AS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:bg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function a9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=LO(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&Yi(m.color)===Yi(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&Gd(m.color,l.color)),d=!c&&!u&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()),f=c||u||d||void 0;return f&&r.add(f.globalTrayId),{slot_id:l.slot_id,globalTrayId:f?.globalTrayId??-1}}),a=Math.max(...i.map(l=>l.slot_id||0));if(a<=0)return;const o=new Array(a).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function FBe(t){return w.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=AS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:bg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:VJ(n.id,i.id,r),globalTrayId:GJ(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=AS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:bg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function WJ(t,e,n){const r=FBe(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 S=n[d],A=r.find(E=>E.globalTrayId===S);if(A){const E=A.type?.toUpperCase()===u.type?.toUpperCase(),k=Yi(A.color)===Yi(u.color)||Gd(A.color,u.color);let C;return E&&k?C="match":E?C="type_only":C="mismatch",{...u,loaded:A,hasFilament:!0,typeMatch:E,colorMatch:k,status:C,isManual:!0}}}const f=r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Yi(S.color)===Yi(u.color)),m=!f&&r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Gd(S.color,u.color)),p=!f&&!m&&r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()),x=f||m||p||void 0;x&&c.add(x.globalTrayId);const v=!!x,b=v,y=!!f||!!m;let M;return f||m?M="match":p?M="type_only":M="mismatch",{...u,loaded:x,hasFilament:v,typeMatch:b,colorMatch:y,status:M,isManual:!1}})},[t,r,n]),a=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:a,hasTypeMismatch:o,hasColorMismatch:l}}function UBe(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,a=0;const o=new Set(Object.values(n));for(const u of t){const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const v=n[d],b=e.find(y=>y.globalTrayId===v);if(b){const y=b.type?.toUpperCase()===u.type?.toUpperCase(),M=Yi(b.color)===Yi(u.color)||Gd(b.color,u.color);y&&M?r++:y?i++:a++;continue}}const f=e.find(v=>!o.has(v.globalTrayId)&&v.type?.toUpperCase()===u.type?.toUpperCase()&&Yi(v.color)===Yi(u.color)),m=f?void 0:e.find(v=>!o.has(v.globalTrayId)&&v.type?.toUpperCase()===u.type?.toUpperCase()&&Gd(v.color,u.color)),p=f||m?void 0:e.find(v=>!o.has(v.globalTrayId)&&v.type?.toUpperCase()===u.type?.toUpperCase()),x=f??m??p;x&&o.add(x.globalTrayId),f||m?r++:p?i++:a++}const l=t.length;let c="full";return a>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:a,totalSlots:l,status:c}}function zBe(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=LO(e);if(r.length===0)return;const i=new Set(Object.values(n)),a=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){a.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&Yi(x.color)===Yi(c.color)),f=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&Gd(x.color,c.color)),m=d||f?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),p=d??f??m;p&&i.add(p.globalTrayId),a.push({slot_id:u,globalTrayId:p?.globalTrayId??-1})}const o=Math.max(...a.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return a.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const s9={useDefault:!0,manualMappings:{},autoConfigured:!1};function BBe(t,e,n,r,i,a){const o=Ple({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>pe.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((x,v)=>{const b=o[v],y=b?.data,S=e?.find(P=>P.id===x)?.name||`Printer ${x}`,A=LO(y),E=i[x]||s9,k=a9(n,y),C=E.useDefault?r:E.manualMappings,R=zBe(n,y,C),T=UBe(n?.filaments,A,C);return{printerId:x,printerName:S,status:y,isLoading:b?.isLoading??!1,loadedFilaments:A,autoMapping:k,finalMapping:R,matchStatus:T.status,exactMatches:T.exactMatches,typeOnlyMatches:T.typeOnlyMatches,missingTypes:T.missingTypes,totalSlots:T.totalSlots,config:E}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,v)=>{a(b=>({...b,[x]:{...b[x]||s9,...v}}))},d=x=>{const v=l.find(M=>M.printerId===x);if(!v||!v.status||!n?.filaments)return;const b=a9(n,v.status);if(!b)return;const y={};b.forEach((M,S)=>{M!==-1&&(y[S+1]=M)}),u(x,{useDefault:!1,manualMappings:y,autoConfigured:!0})},f=()=>{for(const x of t)d(x)},m=x=>l.find(b=>b.printerId===x)?.finalMapping,p=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:m,allPrintersReady:p}}function $Be({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=Qt(),[i,a]=w.useState(!1),o=(u,d)=>{if(u<=0)return;const f={...t.config.manualMappings};d===""?delete f[u]:f[u]=parseInt(d,10),n({useDefault:!1,manualMappings:f,autoConfigured:!1})},l=async()=>{a(!0);try{await pe.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{a(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let m,p=!1;if(f!==void 0)m=t.loadedFilaments.find(v=>v.globalTrayId===f),p=!0;else{const v=new Set(Object.values(t.config.manualMappings)),b=t.loadedFilaments.find(S=>!v.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Yi(S.color)===Yi(u.color)),y=b?void 0:t.loadedFilaments.find(S=>!v.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Gd(S.color,u.color)),M=b||y?void 0:t.loadedFilaments.find(S=>!v.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase());m=b??y??M}let x="mismatch";if(m){const v=m.type?.toUpperCase()===u.type?.toUpperCase(),b=Yi(m.color)===Yi(u.color)||Gd(m.color,u.color);v&&b?x="match":v&&(x="type_only")}return{req:u,loaded:m,status:x,isManual:p}});return s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),s.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:i,children:[s.jsx(yr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:m},p)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${u.type} - ${bg(u.color)}`,children:s.jsx(Fj,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),s.jsxs("span",{className:"text-white truncate",children:[u.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:d?.globalTrayId??"",onChange: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 ${f==="match"?"border-bambu-green/50 text-bambu-green":f==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${m?"ring-1 ring-blue-400/50":""}`,title:m?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(x=>s.jsxs("option",{value:x.globalTrayId,className:"bg-bambu-dark text-white",children:[x.label,": ",x.type," (",x.colorName,")"]},x.globalTrayId))]}),f==="match"?s.jsx(ps,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(En,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(En,{className:"w-3 h-3 text-orange-400"})})]},p))]})}function HBe({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u}){const d=a?t:t.filter(S=>S.is_active),f=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(d.length===0)return s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[s.jsx(ea,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const m=S=>{i?e.includes(S)?n(e.filter(A=>A!==S)):n([...e,S]):n([S])},p=()=>{n(d.map(S=>S.id))},x=()=>{n([])},v=(S,A,E)=>{E.stopPropagation(),!(!c||!u)&&(A?c(S):u(S,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},b=S=>e.includes(S),y=e.length,M=S=>o?.find(A=>A.printerId===S);return s.jsxs("div",{className:"space-y-2 mb-6",children:[i&&d.length>1&&s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[s.jsx("span",{children:y===0?"Select printers":`${y} printer${y!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[y<d.length&&s.jsx("button",{type:"button",onClick:p,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),y>0&&s.jsx("button",{type:"button",onClick:x,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d.map(S=>{const A=b(S.id),E=M(S.id),k=E&&!E.config.useDefault;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>m(S.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${A?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${S.is_active?"":"opacity-60"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${A?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Ir,{className:`w-5 h-5 ${A?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsxs("p",{className:"text-white font-medium",children:[S.name,!S.is_active&&s.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[S.model||"Unknown model"," • ",S.ip_address]})]}),i&&s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${A?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:A&&s.jsx(ps,{className:"w-3 h-3 text-white"})})]}),A&&f&&E&&s.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:C=>C.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:k,onChange:C=>v(S.id,C.target.checked,C),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),s.jsxs("span",{className:`text-xs ml-2 ${E.matchStatus==="full"?"text-bambu-green":E.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",E.exactMatches,"/",E.totalSlots," matched)"]}),E.isLoading&&s.jsx(yr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),k&&s.jsxs("button",{type:"button",onClick:C=>{C.stopPropagation(),c(S.id)},className:"ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",children:[s.jsx(Uhe,{className:"w-3 h-3"}),"Auto"]})]}),k&&s.jsx($Be,{printerResult:E,filamentReqs:l.filaments,onUpdateConfig:C=>u(S.id,C)})]})]},S.id)}),y===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(ea,{className:"w-3 h-3"}),"Select at least one printer"]})]})}function VBe({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(En,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>s.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?s.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx(tl,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[i.objects.length>0?i.objects.slice(0,3).join(", ")+(i.objects.length>3?"...":""):`${i.filaments.length} filament${i.filaments.length!==1?"s":""}`,i.print_time_seconds!=null?` • ${LBe(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(ps,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function GBe({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=Qt(),[o,l]=w.useState(!1),[c,u]=w.useState(i),{data:d}=lt({queryKey:["printer-status",t],queryFn:()=>pe.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:p,hasColorMismatch:x}=WJ(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const b=p?"#f97316":x?"#facc15":"#00ae42",y=(S,A)=>{if(S>0)if(A===""){const E={...n};delete E[S],r(E)}else r({...n,[S]:parseInt(A,10)})},M=async()=>{l(!0);try{await pe.refreshPrinterStatus(t),await new Promise(S=>setTimeout(S,500)),await a.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(Fj,{className:"w-4 h-4",fill:b,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),p?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):x?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?s.jsx(Jc,{className:"w-4 h-4 ml-auto"}):s.jsx(Ji,{className:"w-4 h-4 ml-auto"})]}),c&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.jsxs("button",{type:"button",onClick:M,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:o,children:[s.jsx(yr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),m.map((S,A)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${S.type} - ${bg(S.color)}`,children:s.jsx(Fj,{className:"w-3 h-3",fill:S.color,stroke:S.color})}),s.jsxs("span",{className:"text-white truncate",children:[S.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",S.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:S.loaded?.globalTrayId??"",onChange:E=>y(S.slot_id||0,E.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 ${S.status==="match"?"border-bambu-green/50 text-bambu-green":S.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${S.isManual?"ring-1 ring-blue-400/50":""}`,title:S.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(E=>s.jsxs("option",{value:E.globalTrayId,className:"bg-bambu-dark text-white",children:[E.label,": ",E.type," (",E.colorName,")"]},E.globalTrayId))]}),S.status==="match"?s.jsx(ps,{className:"w-3 h-3 text-bambu-green"}):S.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(En,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(En,{className:"w-3 h-3 text-orange-400"})})]},A)),p&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const WBe=[{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 qBe({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=w.useState(n),a=o=>{e({...t,[o]:!t[o]})};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(F2,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(Jc,{className:"w-4 h-4 ml-auto"}):s.jsx(Ji,{className:"w-4 h-4 ml-auto"})]}),r&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:WBe.map(({key:o,label:l,desc:c})=>s.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:l}),s.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>a(o),children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${t[o]?"translate-x-5":"translate-x-0.5"}`})})]},o))})]})}function KBe({options:t,onChange:e}){const n=r=>{e({...t,scheduleType:r})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("asap"),children:[s.jsx(Hn,{className:"w-4 h-4"}),"ASAP"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("scheduled"),children:[s.jsx(Qr,{className:"w-4 h-4"}),"Scheduled"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("manual"),children:[s.jsx(GW,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:t.scheduledTime,onChange:r=>e({...t,scheduledTime:r.target.value}),min:IBe(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:r=>e({...t,requirePreviousSuccess:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:t.autoOffAfter,onChange:r=>e({...t,autoOffAfter:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(uu,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:t.scheduleType==="asap"?"Print will start as soon as the printer is idle.":t.scheduleType==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."})]})}const fp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},XBe={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function Wd({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const l=Qt(),{showToast:c}=Un(),u=!!n&&!e,[d,f]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,p]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[x,v]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??fp.bed_levelling,flow_cali:i.flow_cali??fp.flow_cali,vibration_cali:i.vibration_cali??fp.vibration_cali,layer_inspect:i.layer_inspect??fp.layer_inspect,timelapse:i.timelapse??fp.timelapse}:fp),[b,y]=w.useState(()=>{if(t==="edit-queue-item"&&i){let $="asap";i.manual_start?$="manual":i.scheduled_time&&!i9(i.scheduled_time)&&($="scheduled");let L="";return i.scheduled_time&&!i9(i.scheduled_time)&&(L=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:$,scheduledTime:L,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return XBe}),[M,S]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const $={};return i.ams_mapping.forEach((L,oe)=>{L!==-1&&($[oe+1]=L)}),$}return{}}),[A,E]=w.useState({}),[k]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[C]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[R,T]=w.useState(!1),[P,F]=w.useState({current:0,total:0}),[I,X]=w.useState(new Set),D=d.length,K=d.length>0?d[0]:null,{data:Y}=lt({queryKey:["settings"],queryFn:pe.getSettings}),{data:q,isLoading:Z}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:re,isError:ie}=lt({queryKey:["archive-plates",e],queryFn:()=>pe.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:U}=lt({queryKey:["library-file-plates",n],queryFn:()=>pe.getLibraryFilePlates(n),enabled:u&&!!n}),G=u?U:re,{data:ee,isError:ne}=lt({queryKey:["archive-filaments",e,m],queryFn:()=>pe.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!G?.is_multi_plate),retry:!1}),{data:se}=lt({queryKey:["library-file-filaments",n,m],queryFn:()=>pe.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!G?.is_multi_plate)}),de=!u&&(ie||ne),he=u?se:ee,{data:Ee}=lt({queryKey:["printer-status",K],queryFn:()=>pe.getPrinterStatus(K),enabled:!!K}),{amsMapping:ge}=WJ(he,Ee,M),Ne=BBe(d,q,he,M,A,E);w.useEffect(()=>{G?.plates?.length===1&&!m&&p(G.plates[0].index)},[G,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const $=q?.filter(L=>L.is_active)||[];$.length===1&&d.length===0&&f([$[0].id])},[t,q,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(k.sort())||m!==C)&&(S({}),E({}),X(new Set)):(S({}),E({}),X(new Set))},[t,d,m,k,C]),w.useEffect(()=>{if(!Y?.per_printer_mapping_expanded||d.length<=1)return;const $=d.filter(L=>{if(I.has(L))return!1;const oe=Ne.printerResults.find(ce=>ce.printerId===L);return oe&&oe.status&&!oe.isLoading});$.length>0&&(X(L=>{const oe=new Set(L);return $.forEach(ce=>oe.add(ce)),oe}),$.forEach(L=>{Ne.autoConfigurePrinter(L)}))},[Y?.per_printer_mapping_expanded,d,I,Ne]),w.useEffect(()=>{const $=L=>{L.key==="Escape"&&!R&&a()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,R]);const Re=G?.is_multi_plate??!1,te=G?.plates??[],Je=ft({mutationFn:$=>pe.addToQueue($)}),B=ft({mutationFn:$=>pe.updateQueueItem(i.id,$),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),a()},onError:$=>{c($.message||"Failed to update queue item","error")}}),H=async $=>{if($?.preventDefault(),d.length===0){c("Please select at least one printer","error");return}T(!0),F({current:0,total:d.length});const L={success:0,failed:0,errors:[]},oe=xe=>{if(d.length>1){const ve=A[xe];if(ve&&!ve.useDefault)return Ne.getFinalMapping(xe)}return ge},ce=xe=>({printer_id:xe,archive_id:u?void 0:e,library_file_id:u?n:void 0,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:oe(xe),plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():void 0,...x});for(let xe=0;xe<d.length;xe++){const ve=d[xe];F({current:xe+1,total:d.length});try{if(t==="reprint"){const _e=oe(ve);u?await pe.printLibraryFile(n,ve,{ams_mapping:_e,...x}):await pe.reprintArchive(e,ve,{plate_id:m??void 0,ams_mapping:_e,...x})}else if(t==="edit-queue-item"&&xe===0){const _e=oe(ve),Ie={printer_id:ve,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:_e,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():null,...x};await B.mutateAsync(Ie)}else await Je.mutateAsync(ce(ve));L.success++}catch(_e){L.failed++;const Ie=q?.find(We=>We.id===ve)?.name||`Printer ${ve}`;L.errors.push(`${Ie}: ${_e.message}`)}}if(T(!1),L.failed===0){const xe=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";L.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${xe} printer`):c(`Print ${xe} ${L.success} printers`),l.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else L.success===0?c(`Failed: ${L.errors[0]}`,"error"):(c(`${L.success} succeeded, ${L.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},W=R||B.isPending,z=w.useMemo(()=>!(W||d.length===0||!u&&Re&&!m),[d.length,Re,m,W,u]),Q=(()=>{const $=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Ir,submitText:$>1?`Print to ${$} Printers`:"Print",submitIcon:Ir,loadingText:P.total>1?`Sending ${P.current}/${P.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:Qr,submitText:$>1?`Queue to ${$} Printers`:"Add to Queue",submitIcon:Qr,loadingText:P.total>1?`Adding ${P.current}/${P.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:Ha,submitText:"Save",submitIcon:Ha,loadingText:P.total>1?`Saving ${P.current}/${P.total}...`:"Saving..."}})(),Te=Q.icon,ke=Q.submitIcon,Ae=K&&(u||(Re?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:R?void 0:a,children:s.jsx(wt,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:$=>$.stopPropagation(),children:s.jsxs(Mt,{className:t==="reprint"?"":"p-0",children:[s.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:Q.title})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:a,disabled:R,children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:H,className:t==="reprint"?"":"p-4 space-y-4",children:[s.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?s.jsxs(s.Fragment,{children:["Send ",s.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),s.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),s.jsx(VBe,{plates:te,isMultiPlate:Re,selectedPlate:m,onSelect:p}),s.jsx(HBe,{printers:q||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:Z,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:Ne.printerResults,filamentReqs:he,onAutoConfigurePrinter:Ne.autoConfigurePrinter,onUpdatePrinterConfig:Ne.updatePrinterConfig}),de&&s.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[s.jsx(ea,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),Ae&&!de&&d.length===1&&s.jsx(GBe,{printerId:K,filamentReqs:he,manualMappings:M,onManualMappingChange:S,defaultExpanded:Y?.per_printer_mapping_expanded??!1}),(t==="reprint"||D>0)&&s.jsx(qBe,{options:x,onChange:v}),t!=="reprint"&&s.jsx(KBe,{options:b,onChange:y}),B.isError&&s.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:B.error?.message||"Failed to complete operation"}),s.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:R,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!z,className:"flex-1",children:W?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),Q.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(ke,{className:"w-4 h-4"}),Q.submitText]})})]})]})]})})})}function YBe({onClose:t,initialFiles:e}){const n=Qt(),{showToast:r}=Un(),i=w.useRef(null),[a,o]=w.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(),[f,m]=w.useState(null);w.useEffect(()=>{const C=R=>{R.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const{data:p}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),x=ft({mutationFn:C=>pe.uploadArchivesBulk(C,u),onSuccess:C=>{m(C),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(R=>R.map(T=>{const P=C.results.find(I=>I.filename===T.file.name),F=C.errors.find(I=>I.filename===T.file.name);return P?{...T,status:"success",archiveId:P.id}:F?{...T,status:"error",error:F.error}:T})),C.failed===0?r(`${C.uploaded} file${C.uploaded!==1?"s":""} uploaded`):C.uploaded===0?r(`Failed to upload ${C.failed} file${C.failed!==1?"s":""}`,"error"):r(`${C.uploaded} uploaded, ${C.failed} failed`,"warning")},onError:()=>{o(C=>C.map(R=>({...R,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),v=w.useCallback(C=>{C.preventDefault(),c(!0)},[]),b=w.useCallback(C=>{C.preventDefault(),c(!1)},[]),y=w.useCallback(C=>{C.preventDefault(),c(!1);const R=Array.from(C.dataTransfer.files).filter(T=>T.name.endsWith(".3mf"));R.length>0&&o(T=>[...T,...R.map(P=>({file:P,status:"pending"}))])},[]),M=w.useCallback(C=>{const R=Array.from(C.target.files||[]).filter(T=>T.name.endsWith(".3mf"));R.length>0&&o(T=>[...T,...R.map(P=>({file:P,status:"pending"}))]),i.current&&(i.current.value="")},[]),S=w.useCallback(C=>{o(R=>R.filter((T,P)=>P!==C))},[]),A=()=>{if(a.length===0)return;const C=a.filter(R=>R.status==="pending");C.length!==0&&(o(R=>R.map(T=>T.status==="pending"?{...T,status:"uploading"}:T)),x.mutate(C.map(R=>R.file)))},E=a.filter(C=>C.status==="pending").length,k=x.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(wt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:v,onDragLeave:b,onDrop:y,children:[s.jsx(bi,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),s.jsx(Me,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),s.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),s.jsxs("div",{className:"px-4 pb-4",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange:C=>d(C.target.value?Number(C.target.value):void 0),disabled:k,children:[s.jsx("option",{value:"",children:"No printer"}),p?.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))]})]}),a.length>0&&s.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:s.jsx("div",{className:"space-y-2",children:a.map((C,R)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(C2,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&s.jsx("button",{onClick:()=>S(R),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:s.jsx(Ut,{className:"w-4 h-4"})}),C.status==="uploading"&&s.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&s.jsx(kn,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:C.error}),s.jsx(ea,{className:"w-4 h-4 text-red-400"})]})]},`${C.file.name}-${R}`))})}),f&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[s.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Me,{onClick:A,disabled:E===0||k,className:"flex-1",children:k?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bi,{className:"w-4 h-4"}),"Upload ",E>0&&`(${E})`]})})]})]})})})}const QBe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],ZBe=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function qJ({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const se=de=>{de.key==="Escape"&&e()};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[e]);const r=Qt(),[i,a]=w.useState(t.print_name||""),[o,l]=w.useState(t.printer_id),[c,u]=w.useState(t.project_id??null),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.tags||""),[x,v]=w.useState(t.failure_reason||""),[b,y]=w.useState(t.status),[M,S]=w.useState(t.quantity??1),[A,E]=w.useState(t.photos||[]),[k,C]=w.useState(!1),[R,T]=w.useState(!1),P=w.useRef(null),F=w.useRef(null),I=w.useRef(null),{data:X}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:D}=lt({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:K}=lt({queryKey:["archives"],queryFn:()=>pe.getArchives(void 0,1e3,0),enabled:n.length===0}),Y=n.length>0?n:[...new Set(K?.flatMap(se=>se.tags?.split(",").map(de=>de.trim())||[]).filter(Boolean)||[])].sort(),q=m.split(",").map(se=>se.trim()).filter(Boolean),Z=Y.filter(se=>!q.includes(se)),re=se=>{if(!q.includes(se)){const de=[...q,se].join(", ");p(de)}I.current!==null&&clearTimeout(I.current),P.current?.focus()},ie=se=>{const de=q.filter(he=>he!==se).join(", ");p(de)},U=ft({mutationFn:se=>pe.updateArchive(t.id,se),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),G=async se=>{const de=se.target.files?.[0];if(de){C(!0);try{const he=await pe.uploadArchivePhoto(t.id,de);E(he.photos),r.invalidateQueries({queryKey:["archives"]})}catch(he){console.error("Failed to upload photo:",he)}finally{C(!1),F.current&&(F.current.value="")}}},ee=async se=>{try{const de=await pe.deleteArchivePhoto(t.id,se);E(de.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(de){console.error("Failed to delete photo:",de)}},ne=se=>{se.preventDefault();const de={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:m||void 0,quantity:M};b!==t.status&&(de.status=b),b==="failed"||b==="aborted"?de.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(de.failure_reason=null),U.mutate(de)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:se=>se.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ne,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",value:i,onChange:se=>a(se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsxs("select",{value:o??"",onChange:se=>l(se.target.value?Number(se.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No printer"}),X?.map(se=>s.jsx("option",{value:se.id,children:se.name},se.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(xa,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:se=>u(se.target.value?Number(se.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No project"}),D?.map(se=>s.jsx("option",{value:se.id,children:se.name},se.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(kue,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:M,onChange:se=>S(Math.max(1,parseInt(se.target.value)||1)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of items produced in this print job"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:se=>f(se.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),q.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:q.map(se=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[s.jsx(Zp,{className:"w-3 h-3"}),se,s.jsx("button",{type:"button",onClick:()=>ie(se),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-3 h-3"})})]},se))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:P,type:"text",value:m,onChange:se=>p(se.target.value),onFocus:()=>{I.current!==null&&clearTimeout(I.current),T(!0)},onBlur:()=>{I.current=window.setTimeout(()=>T(!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:q.length>0?"Add more tags...":"Add tags..."}),R&&Z.length>0&&s.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[s.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),s.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:Z.map(se=>s.jsx("button",{type:"button",onClick:()=>re(se),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:se},se))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:b,onChange:se=>{y(se.target.value),se.target.value==="completed"&&v("")},className:"w-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:ZBe.map(se=>s.jsx("option",{value:se.value,children:se.label},se.value))})]}),(b==="failed"||b==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),s.jsxs("select",{value:x,onChange:se=>v(se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"Select reason..."}),QBe.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Xp,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[A.map(se=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:pe.getArchivePhotoUrl(t.id,se),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>ee(se),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(Jt,{className:"w-3 h-3 text-white"})})]},se)),s.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[s.jsx("input",{ref:F,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:G,className:"hidden",disabled:k}),k?s.jsx(pt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(qn,{className:"w-6 h-6 text-bambu-gray"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:U.isPending,className:"flex-1",children:[s.jsx(cs,{className:"w-4 h-4"}),U.isPending?"Saving...":"Save"]})]})]})]})})}function KJ({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[a,o]=w.useState(null),l=w.useRef(null),[c,u]=w.useState({x:t,y:e,visible:!1}),[d,f]=w.useState(!1),[m,p]=w.useState({});w.useEffect(()=>{const b=S=>{i.current&&!i.current.contains(S.target)&&r()},y=S=>{S.key==="Escape"&&r()},M=()=>{r()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",y),document.addEventListener("scroll",M,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",y),document.removeEventListener("scroll",M,!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(),y=window.innerWidth,M=window.innerHeight,S=8;let A=t,E=e;t+b.width>y-S&&(A=Math.max(S,y-b.width-S)),A<S&&(A=S),e+b.height>M-S&&(E=Math.max(S,M-b.height-S)),E<S&&(E=S);const k=180,C=y-A-b.width,R=A;f(C<k&&R>k),u({x:A,y:E,visible:!0})}},[t,e]);const x=(b,y)=>{l.current&&(clearTimeout(l.current),l.current=null);const M=y.getBoundingClientRect(),S=window.innerHeight,A=300,C=S-M.top-8<A&&M.top>A;p(R=>({...R,[b]:C?"bottom":"top"})),o(b)},v=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return s.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((b,y)=>{if(b.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},y);const M=b.submenu&&b.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:S=>M&&x(y,S.currentTarget),onMouseLeave:()=>M&&v(),children:[s.jsxs("button",{onMouseEnter:S=>M&&x(y,S.currentTarget.parentElement),onClick:()=>{M?o(a===y?null:y):b.disabled||(b.onClick(),r())},disabled:b.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${b.disabled?"text-bambu-gray cursor-not-allowed":b.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${M&&a===y?"bg-bambu-dark-tertiary":""}`,children:[b.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),s.jsx("span",{className:"flex-1",children:b.label}),M&&s.jsx(Vs,{className:"w-4 h-4 text-bambu-gray"})]}),M&&a===y&&s.jsx("div",{className:`absolute min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"} ${m[y]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>v(),children:b.submenu.map((S,A)=>s.jsxs("button",{onClick:()=>{S.disabled||(S.onClick(),r())},disabled:S.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${S.disabled?"text-bambu-gray cursor-not-allowed":S.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[S.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:S.icon}),S.label]},A))})]},y)})})}function JBe({selectedIds:t,existingTags:e,onClose:n}){const r=Qt(),{showToast:i}=Un(),[a,o]=w.useState(""),[l,c]=w.useState(new Set),[u,d]=w.useState("add");w.useEffect(()=>{const v=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=ft({mutationFn:async()=>{const v=Array.from(l);let b=0;for(const y of t)try{const M=await pe.getArchive(y),S=M.tags?M.tags.split(",").map(E=>E.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...S,...v])]:A=S.filter(E=>!l.has(E)),await pe.updateArchive(y,{tags:A.join(", ")}),b++}catch(M){throw console.error(`Failed to update archive ${y}:`,M),new Error(`Failed on archive ${y}: ${M instanceof Error?M.message:"Unknown error"}`)}return{count:b,mode:u,tags:v}},onSuccess:({count:v,mode:b,tags:y})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${b==="add"?"Added":"Removed"} ${y.length} tag${y.length!==1?"s":""} ${b==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),m=v=>{c(b=>{const y=new Set(b);return y.has(v)?y.delete(v):y.add(v),y})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(v=>new Set([...v,a.trim()])),o(""))},x=v=>{v.key==="Enter"&&(v.preventDefault(),p())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(wt,{className:"w-full max-w-md",children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Me,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:v=>o(v.target.value),onKeyDown:x}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:s.jsx(qn,{className:"w-4 h-4"})})]}),e.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(v=>s.jsx("button",{onClick:()=>m(v),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),l.size>0&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(v=>s.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[v,s.jsx("button",{onClick:()=>m(v),className:"hover:opacity-70",children:s.jsx(Ut,{className:"w-3 h-3"})})]},v))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Me,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Zp,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function e8e({selectedIds:t,onClose:e}){const n=Qt(),{showToast:r}=Un(),{data:i,isLoading:a}=lt({queryKey:["projects"],queryFn:()=>pe.getProjects()});w.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=ft({mutationFn:async d=>(await pe.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(m=>m.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=ft({mutationFn:async()=>{for(const d of t)await pe.updateArchive(d,{project_id:null});return t.length},onSuccess:d=>{o(),r(`Removed ${d} archive${d!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),u=l.isPending||c.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(wt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xa,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),a?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:()=>c.mutate(),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:s.jsx(qi,{className:"w-4 h-4 text-red-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),s.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&s.jsx(pt,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&s.jsxs("div",{className:"flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>s.jsxs("button",{onClick:()=>l.mutate(d.id),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{backgroundColor:d.color?`${d.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:s.jsx(xa,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:d.name}),s.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[d.archive_count," archive",d.archive_count!==1?"s":"",d.status&&` • ${d.status}`]})]}),l.isPending&&l.variables===d.id&&s.jsx(pt,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&s.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:s.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function t8e(t,e){return new Date(t,e+1,0).getDate()}function n8e(t,e){return new Date(t,e,1).getDay()}const r8e=["January","February","March","April","May","June","July","August","September","October","November","December"],i8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function a8e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,u]=w.useState(null),[d,f]=w.useState(null),m=w.useMemo(()=>{const E=new Map;return t.forEach(k=>{const C=mi(k.completed_at||k.created_at)||new Date,R=`${C.getFullYear()}-${String(C.getMonth()+1).padStart(2,"0")}-${String(C.getDate()).padStart(2,"0")}`,T=E.get(R)||[];T.push(k),E.set(R,T)}),E},[t]),p=t8e(o,i),x=n8e(o,i),v=()=>{i===0?(a(11),l(o-1)):a(i-1)},b=()=>{i===11?(a(0),l(o+1)):a(i+1)},y=()=>{a(r.getMonth()),l(r.getFullYear())},M=[];for(let E=0;E<x;E++)M.push(null);for(let E=1;E<=p;E++)M.push(E);const S=c?m.get(c)||[]:[],A=E=>{E!==c&&f(null),u(E)};return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(yf,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:[r8e[i]," ",o]}),s.jsx("button",{onClick:y,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Vs,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:i8e.map(E=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:E},E))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:M.map((E,k)=>{if(E===null)return s.jsx("div",{className:"aspect-square"},`empty-${k}`);const C=`${o}-${String(i+1).padStart(2,"0")}-${String(E).padStart(2,"0")}`,R=m.get(C)||[],T=R.length>0,P=E===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),F=C===c,I=R.filter(D=>D.status==="completed").length,X=R.filter(D=>D.status==="failed").length;return s.jsxs("button",{onClick:()=>A(F?null:C),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${F?"bg-bambu-green text-white":P?"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:[s.jsx("span",{className:`text-sm font-medium ${P&&!F?"text-bambu-green":""}`,children:E}),T&&s.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${X>0&&I===0?"bg-red-400":X>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:R.length})]})]},E)})}),s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(E=>{const k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.getFullYear()===o}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(E=>{const k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.getFullYear()===o&&E.status==="completed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(E=>{const k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.getFullYear()===o&&E.status==="failed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),s.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),S.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:S.map(E=>{const k=E.id===d||E.id===n;return s.jsxs("button",{onClick:()=>{f(E.id),e?.(E)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${k?"":"hover:bg-bambu-dark-tertiary"}`,style:k?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[E.thumbnail_path?s.jsx("img",{src:pe.getArchiveThumbnail(E.id),alt:"",className:"w-12 h-12 rounded object-cover"}):s.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:E.print_name||E.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:E.status==="failed"?"text-red-400":"text-green-400",children:E.status==="failed"?"Failed":"Completed"}),E.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:E.filament_color.split(",").map((C,R)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:C}},R))})]})]})]},E.id)})}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function XJ({archiveId:t,archiveName:e,onClose:n}){const r=pe.getArchiveQRCodeUrl(t,300);w.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 flex flex-col items-center",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),s.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:s.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),s.jsxs(Me,{onClick:i,className:"w-full",children:[s.jsx(Jr,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function YJ({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(v=>Math.max(0,v-1)),x.key==="ArrowRight"&&o(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),w.useEffect(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=pe.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},m=()=>{i&&c(!0)};return s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[s.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(Jr,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Me,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-6 h-6"})})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&s.jsx("button",{onClick:()=>o(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(yf,{className:"w-8 h-8 text-white"})}),s.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&s.jsx("button",{onClick:()=>o(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Vs,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,x)=>s.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:pe.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&s.jsx(Rn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function da(t){this.content=t}da.prototype={constructor:da,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new da(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new da(n)},addToStart:function(t,e){return new da([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new da(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new da(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=da.from(t),t.size?new da(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=da.from(t),t.size?new da(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=da.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}};da.from=function(t){if(t instanceof da)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new da(e)};function QJ(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=QJ(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function ZJ(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=t.child(--i),l=e.child(--a),c=o.nodeSize;if(o==l){n-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=ZJ(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class St{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;if(u>e&&r(c,i+l,a||null,o)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",o=!0;return this.nodesBetween(e,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new St(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,o=0;o<n;a++){let l=this.content[a],c=o+l.nodeSize;c>e&&((o<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=c}return new St(r,i)}cutByIndex(e,n){return e==n?St.empty:e==0&&n==this.content.length?this:new St(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new St(i,a)}addToStart(e){return new St([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new St(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 QJ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return ZJ(this,e,n,r)}findIndex(e){if(e==0)return m1(0,e);if(e==this.size)return m1(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?m1(n+1,a):m1(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return St.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new St(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return St.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new St(n||e,r)}static from(e){if(!e)return St.empty;if(e instanceof St)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new St([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}St.empty=new St([],0);const Ik={index:0,offset:0};function m1(t,e){return Ik.index=t,Ik.offset=e,Ik}function TS(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(!TS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!TS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let pr=class ZP{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&TS(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 ZP.none;if(e instanceof ZP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};pr.none=[];class CS extends Error{}class Dt{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=eee(this.content,e+this.openStart,n);return r&&new Dt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Dt(JJ(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Dt.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Dt(St.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new Dt(e,r,i)}}Dt.empty=new Dt(St.empty,0,0);function JJ(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||a.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(JJ(a.content,e-i-1,n-i-1)))}function eee(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=eee(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function s8e(t,e,n){if(n.openStart>t.depth)throw new CS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new CS("Inconsistent open depths");return tee(t,e,n,0)}function tee(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=tee(t,e,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return hf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=o8e(n,t);return hf(a,ree(t,o,l,e,r))}else return hf(a,kS(t,e,r))}function nee(t,e){if(!e.type.compatibleContent(t.type))throw new CS("Cannot join "+e.type.name+" onto "+t.type.name)}function JP(t,e,n){let r=t.node(n);return nee(r,e.node(n)),r}function df(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 Ub(t,e,n,r){let i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(df(t.nodeAfter,r),a++));for(let l=a;l<o;l++)df(i.child(l),r);e&&e.depth==n&&e.textOffset&&df(e.nodeBefore,r)}function hf(t,e){return t.type.checkContent(e),t.copy(e)}function ree(t,e,n,r,i){let a=t.depth>i&&JP(t,e,i+1),o=r.depth>i&&JP(n,r,i+1),l=[];return Ub(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(nee(a,o),df(hf(a,ree(t,e,n,r,i+1)),l)):(a&&df(hf(a,kS(t,e,i+1)),l),Ub(e,n,i,l),o&&df(hf(o,kS(n,r,i+1)),l)),Ub(r,null,i,l),new St(l)}function kS(t,e,n){let r=[];if(Ub(null,t,n,r),t.depth>n){let i=JP(t,e,n+1);df(hf(i,kS(t,e,n+1)),r)}return Ub(e,null,n,r),new St(r)}function o8e(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(St.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class R0{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return pr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let a=r.marks;for(var o=0;o<a.length;o++)a[o].type.spec.inclusive===!1&&(!i||!a[o].isInSet(i.marks))&&(a=a[o--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new jS(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(a),u=a-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;a=u-1,i+=c+1}return new R0(n,r,a)}static resolveCached(e,n){let r=o9.get(e);if(r)for(let a=0;a<r.elts.length;a++){let o=r.elts[a];if(o.pos==n)return o}else o9.set(e,r=new l8e);let i=r.elts[r.i]=R0.resolve(e,n);return r.i=(r.i+1)%c8e,i}}class l8e{constructor(){this.elts=[],this.i=0}}const c8e=12,o9=new WeakMap;class jS{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 u8e=Object.create(null);let kd=class eR{constructor(e,n,r,i=pr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||St.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&&TS(this.attrs,n||e.defaultAttrs||u8e)&&pr.sameSet(this.marks,r||pr.none)}copy(e=null){return e==this.content?this:new eR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new eR(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Dt.empty;let i=this.resolve(e),a=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,a.pos-l);return new Dt(u,i.depth-o,a.depth-o)}replace(e,n,r){return s8e(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 R0.resolveCached(this,e)}resolveNoCache(e){return R0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),iee(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=St.empty,i=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),o=a&&a.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=pr.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!pr.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=St.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};kd.prototype.text=void 0;class PS extends kd{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):iee(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 PS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new PS(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 iee(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class If{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new d8e(e,n);if(r.next==null)return If.empty;let i=aee(r);r.next&&r.err("Unexpected trailing text");let a=b8e(x8e(i));return y8e(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return St.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:f}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let m=a(f,l.concat(d));if(m)return m}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:l,next:c}=a.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
  8142. `)}}If.empty=new If(!0);class d8e{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 aee(t){let e=[];do e.push(h8e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function h8e(t){let e=[];do e.push(f8e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function f8e(t){let e=g8e(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=m8e(t,e);else break;return e}function l9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function m8e(t,e){let n=l9(t),r=n;return t.eat(",")&&(t.next!="}"?r=l9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function p8e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function g8e(t){if(t.eat("(")){let e=aee(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=p8e(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 x8e(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let u={term:c,to:l};return e[o].push(u),u}function i(o,l){o.forEach(c=>c.to=l)}function a(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(a(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=a(o.exprs[c],l);if(c==o.exprs.length-1)return u;i(u,l=n())}else if(o.type=="star"){let c=n();return r(l,c),i(a(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(a(o.expr,l),c),i(a(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(a(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(a(o.expr,c),d),c=d}if(o.max==-1)i(a(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(a(o.expr,c),d),c=d}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function see(t,e){return e-t}function c9(t,e){let n=[];return r(e),n.sort(see);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let o=0;o<a.length;o++){let{term:l,to:c}=a[o];!l&&n.indexOf(c)==-1&&r(c)}}}function b8e(t){let e=Object.create(null);return n(c9(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]);c9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new If(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(see);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function y8e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function oee(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 lee(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function cee(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function uee(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new _8e(t,r,e[r]);return n}let u9=class dee{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=uee(e,r.attrs),this.defaultAttrs=oee(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==If.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:lee(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new kd(this,this.computeAttrs(e),St.from(n),pr.setFrom(r))}createChecked(e=null,n,r){return n=St.from(n),this.checkContent(n),new kd(this,this.computeAttrs(e),n,pr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=St.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(St.empty,!0);return a?new kd(this,e,n.append(a),pr.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){cee(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:pr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new dee(a,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function v8e(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class _8e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?v8e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class VM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=uee(e,i.attrs),this.excluded=null;let a=oee(this.attrs);this.instance=a?new pr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new pr(this,lee(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new VM(a,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){cee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class hee{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=da.from(e.nodes),n.marks=da.from(e.marks||{}),this.nodes=u9.compile(this.spec.nodes,this),this.marks=VM.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=If.parse(o,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=l=="_"?null:l?d9(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:d9(this,o.split(" "))}this.nodeFromJSON=i=>kd.fromJSON(this,i),this.markFromJSON=i=>pr.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof u9){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 PS(r,r.defaultAttrs,e,pr.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function d9(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],o=a;if(a)n.push(a);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function w8e(t){return t.tag!=null}function S8e(t){return t.style!=null}let zb=class tR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(w8e(i))this.tags.push(i);else if(S8e(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new f9(this,n,!1);return r.addAll(e,pr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new f9(this,n,!0);return r.addAll(e,pr.none,n.from,n.to),Dt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(E8e(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let o=a.getAttrs(e);if(o===!1)continue;a.attrs=o||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let o=this.styles[a],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let c=o.getAttrs(n);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<a)break}n.splice(o,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(o=>{r(o=m9(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=m9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new tR(e,tR.schemaRules(e)))}};const fee={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},M8e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},mee={ol:!0,ul:!0},D0=1,nR=2,Bb=4;function h9(t,e,n){return e!=null?(e?D0:0)|(e==="full"?nR:0):t&&t.whitespace=="pre"?D0|nR:n&~Bb}class p1{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=pr.none,this.match=a||(o&Bb?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(St.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&D0)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=St.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(St.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&&!fee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class f9{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=h9(null,n.preserveWhitespace,0)|(r?Bb:0);i?a=new p1(i.type,i.attrs,pr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new p1(null,null,pr.none,!0,null,o):a=new p1(e.schema.topNodeType,null,pr.none,!0,null,o),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&nR?"full":this.localPreserveWS||(i.options&D0)>0,{schema:o}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
  8143. `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;mee.hasOwnProperty(o)&&this.parser.normalizeLists&&N8e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:M8e.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(fee.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
  8144. `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let a,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=pr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):p9(l.type,e.type))&&(o=l.addToSet(o));return a.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=h9(e,a,o.options);o.options&Bb&&o.content.length==0&&(l|=Bb);let c=pr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):p9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new p1(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|=D0)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=a;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function N8e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&mee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function E8e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function m9(t){let e={};for(let n in t)e[n]=t[n];return e}function p9(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=l=>{a.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||a.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class Yf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Fk(n).createDocumentFragment());let i=r,a=[];return e.forEach(o=>{if(a.length||o.marks.length){let l=0,c=0;for(;l<a.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<a.length;)i=a.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=Q1(Fk(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Q1(Fk(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Q1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Yf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=g9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return g9(e.marks)}}function g9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Fk(t){return t.document||window.document}const x9=new WeakMap;function A8e(t){let e=x9.get(t);return e===void 0&&x9.set(t,e=T8e(t)),e}function T8e(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 Q1(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=A8e(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let m=f.indexOf(" ");m>0?c.setAttributeNS(f.slice(0,m),f.slice(m+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let m=e[f];if(m===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:x}=Q1(t,m,n,r);if(c.appendChild(p),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const pee=65535,gee=Math.pow(2,16);function C8e(t,e){return t+e*gee}function b9(t){return t&pee}function k8e(t){return(t-(t&pee))/gee}const xee=1,bee=2,Z1=4,yee=8;class rR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&yee)>0}get deletedBefore(){return(this.delInfo&(xee|Z1))>0}get deletedAfter(){return(this.delInfo&(bee|Z1))>0}get deletedAcross(){return(this.delInfo&Z1)>0}}class Os{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Os.empty)return Os.empty}recover(e){let n=0,r=b9(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+k8e(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+a],d=this.ranges[l+o],f=c+u;if(e<=f){let m=u?e==c?-1:e==f?1:n:n,p=c+i+(m<0?0:d);if(r)return p;let x=e==(n<0?c:f)?null:C8e(l/3,e-c),v=e==c?bee:e==f?xee:Z1;return(n<0?e!=c:e!=f)&&(v|=yee),new rR(p,v,x)}i+=d-u}return r?e+i:new rR(e+i,0,null)}touches(e,n){let r=0,i=b9(n),a=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+a],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?a:0),c=o+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),a+=d-u}}invert(){return new Os(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Os.empty:new Os(e<0?[0,-e,0]:[0,0,e])}}Os.empty=new Os([]);class O0{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 O0(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 O0;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let o=this._maps[a],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new rR(e,i,null)}}const Uk=Object.create(null);class Ra{getMap(){return Os.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Uk[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 Uk)throw new RangeError("Duplicate use of step JSON ID "+e);return Uk[e]=n,n.prototype.jsonID=e,n}}class xi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new xi(e,null)}static fail(e){return new xi(null,e)}static fromReplace(e,n,r,i){try{return xi.ok(e.replace(n,r,i))}catch(a){if(a instanceof CS)return xi.fail(a.message);throw a}}}function IO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(IO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return St.fromArray(r)}class bd extends Ra{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new Dt(IO(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 xi.fromReplace(e,this.from,this.to,a)}invert(){return new Qo(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 bd(n.pos,r.pos,this.mark)}merge(e){return e instanceof bd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new bd(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 bd(n.from,n.to,e.markFromJSON(n.mark))}}Ra.jsonID("addMark",bd);class Qo extends Ra{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Dt(IO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return xi.fromReplace(e,this.from,this.to,r)}invert(){return new bd(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 Qo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Qo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Qo(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 Qo(n.from,n.to,e.markFromJSON(n.mark))}}Ra.jsonID("removeMark",Qo);class yd extends Ra{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return xi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return xi.fromReplace(e,this.pos,this.pos+1,new Dt(St.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 yd(this.pos,n.marks[i]);return new yd(this.pos,this.mark)}}return new Ff(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new yd(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 yd(n.pos,e.markFromJSON(n.mark))}}Ra.jsonID("addNodeMark",yd);class Ff extends Ra{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return xi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return xi.fromReplace(e,this.pos,this.pos+1,new Dt(St.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new yd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ff(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 Ff(n.pos,e.markFromJSON(n.mark))}}Ra.jsonID("removeNodeMark",Ff);class Ki extends Ra{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&iR(e,this.from,this.to)?xi.fail("Structure replace would overwrite content"):xi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Os([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ki(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 Ki(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ki)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Dt.empty:new Dt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ki(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Dt.empty:new Dt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ki(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 Ki(n.from,n.to,Dt.fromJSON(e,n.slice),!!n.structure)}}Ra.jsonID("replace",Ki);class Qi extends Ra{constructor(e,n,r,i,a,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=o,this.structure=l}apply(e){if(this.structure&&(iR(e,this.from,this.gapFrom)||iR(e,this.gapTo,this.to)))return xi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return xi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?xi.fromReplace(e,this.from,this.to,r):xi.fail("Content does not fit in gap")}getMap(){return new Os([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 Qi(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new Qi(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Qi(n.from,n.to,n.gapFrom,n.gapTo,Dt.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ra.jsonID("replaceAround",Qi);function iR(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function j8e(t,e,n,r){let i=[],a=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let m=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(x)||(o&&o.to==m&&o.mark.eq(f[v])?o.to=p:i.push(o=new Qo(m,p,f[v])));l&&l.to==m?l.to=p:a.push(l=new bd(m,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function P8e(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;a++;let c=null;if(r instanceof VM){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],m;for(let p=0;p<i.length;p++){let x=i[p];x.step==a-1&&f.eq(i[p].style)&&(m=x)}m?(m.to=u,m.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new Qo(o.from,o.to,o.style)))}function FO(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new Ki(l,d,Dt.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new Qo(l,d,u.marks[m]));if(i&&u.isText&&n.whitespace!="pre"){let m,p=/\r?\n|\r/g,x;for(;m=p.exec(u.text);)x||(x=new Dt(St.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Ki(l+m.index,l+m.index+m[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(St.empty,!0);t.replace(l,l,new Dt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function R8e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Xg(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!R8e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function D8e(t,e,n){let{$from:r,$to:i,depth:a}=e,o=r.before(a+1),l=i.after(a+1),c=o,u=l,d=St.empty,f=0;for(let x=a,v=!1;x>n;x--)v||r.index(x)>0?(v=!0,d=St.from(r.node(x).copy(d)),f++):c--;let m=St.empty,p=0;for(let x=a,v=!1;x>n;x--)v||i.after(x+1)<i.end(x)?(v=!0,m=St.from(i.node(x).copy(m)),p++):u++;t.step(new Qi(c,u,o,l,new Dt(d.append(m),f,p),d.size-f,!0))}function UO(t,e,n=null,r=t){let i=O8e(t,e),a=i&&L8e(r,e);return a?i.map(y9).concat({type:e,attrs:n}).concat(a.map(y9)):null}function y9(t){return{type:t,attrs:null}}function O8e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let o=a.length?a[0]:e;return n.canReplaceWith(r,i,o)?a:null}function L8e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),o=e.contentMatch.findWrapping(a.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:o}function I8e(t,e,n){let r=St.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=St.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new Qi(i,a,i,a,new Dt(r,0,0),n.length,!0))}function F8e(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&U8e(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&_ee(t,o,l,a),FO(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),m=d.map(l+o.nodeSize,1);return t.step(new Qi(f,m,f+1,m-1,new Dt(St.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&vee(t,o,l,a),!1}})}function vee(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function _ee(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
  8145. `))}})}function U8e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function z8e(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let o=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Qi(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Dt(St.from(o),0,0),1,!0))}function Yc(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),m=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(m,f.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let v=r&&r[d]||f;if(!f.canReplace(m+1,f.childCount)||!v.type.validContent(p))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function B8e(t,e,n=1,r){let i=t.doc.resolve(e),a=St.empty,o=St.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=St.from(i.node(l).copy(a));let d=r&&r[u];o=St.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Ki(e,e,new Dt(a.append(o),n,n),!0))}function eh(t,e){let n=t.resolve(e),r=n.index();return wee(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function $8e(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let a=e.child(i),o=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function wee(t,e){return!!(t&&e&&!t.isLeaf&&$8e(t,e))}function GM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,o,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,o=r.nodeAfter):n>0?(a=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),o=r.node(i+1)),a&&!a.isTextblock&&wee(a,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function H8e(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);_ee(t,d.node(),d.before(),l)}o.inlineContent&&FO(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new Ki(u,c.map(e+n,-1),Dt.empty,!0)),r===!0){let d=t.doc.resolve(u);vee(t,d.node(),d.before(),t.steps.length)}return t}function V8e(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a<r.node(i).childCount)return null}return null}function See(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function WM(t,e,n=e,r=Dt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return Mee(i,a,r)?new Ki(e,n,r):new G8e(i,a,r).fit()}function Mee(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class G8e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=St.empty;for(let i=0;i<=e.depth;i++){let a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=St.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,o=r.depth,l=i.depth;for(;o&&l&&a.childCount==1;)a=a.firstChild.content,o--,l--;let c=new Dt(a,o,l);return e>-1?new Qi(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Ki(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=zk(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(o?u.matchType(o.type)||(f=u.fillBefore(St.from(o),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:l,parent:a,inject:f};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=zk(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Dt(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=zk(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Dt(Mb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Dt(Mb(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let v=0;v<a.length;v++)this.openFrontierNode(a[v]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:m}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let v=l.child(u),b=f.matchType(v.type);if(!b)break;u++,(u>1||c==0||v.content.size)&&(f=b,d.push(Nee(v.mark(m.allowedMarks(v.marks)),u==1?c:0,u==l.childCount?p:-1)))}let x=u==l.childCount;x||(p=-1),this.placed=Nb(this.placed,n,St.from(d)),this.frontier[n].match=f,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,b=l;v<p;v++){let y=b.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),b=y.content}this.unplaced=x?e==0?Dt.empty:new Dt(Mb(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new Dt(Mb(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||!Bk(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Bk(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=Bk(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Nb(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Nb(this.placed,this.depth,St.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(St.empty,!0);n.childCount&&(this.placed=Nb(this.placed,this.frontier.length,n))}}function Mb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Mb(t.firstChild.content,e-1,n)))}function Nb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Nb(t.lastChild.content,e-1,n)))}function zk(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Nee(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Nee(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(St.empty,!0)))),t.copy(r)}function Bk(t,e,n,r,i){let a=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let l=r.fillBefore(a.content,!0,o);return l&&!W8e(n,a.content,o)?l:null}function W8e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function q8e(t){return t.spec.defining||t.spec.definingForContent}function K8e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(Mee(i,a,r))return t.step(new Ki(e,n,r));let o=Aee(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let m=i.depth,p=i.pos-1;m>0;m--,p--){let x=i.node(m).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(m)>-1?l=m:i.before(m)==p&&o.splice(1,0,-m)}let c=o.indexOf(l),u=[],d=r.openStart;for(let m=r.content,p=0;;p++){let x=m.firstChild;if(u.push(x),p==r.openStart)break;m=x.content}for(let m=d-1;m>=0;m--){let p=u[m],x=q8e(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=m;else if(x||!p.type.isTextblock)break}for(let m=r.openStart;m>=0;m--){let p=(m+d+1)%(r.openStart+1),x=u[p];if(x)for(let v=0;v<o.length;v++){let b=o[(v+c)%o.length],y=!0;b<0&&(y=!1,b=-b);let M=i.node(b-1),S=i.index(b-1);if(M.canReplaceWith(S,S,x.type,x.marks))return t.replace(i.before(b),y?a.after(b):n,new Dt(Eee(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let m=o.length-1;m>=0&&(t.replace(e,n,r),!(t.steps.length>f));m--){let p=o[m];p<0||(e=i.before(p),n=a.after(p))}}function Eee(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(Eee(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(St.empty,!0))}return t}function X8e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=V8e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Dt(St.from(r),0,0))}function Y8e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=Aee(r,i);for(let o=0;o<a.length;o++){let l=a[o],c=o==a.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Aee(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class Gp extends Ra{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 xi.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return xi.fromReplace(e,this.pos,this.pos+1,new Dt(St.from(i),0,n.isLeaf?0:1))}getMap(){return Os.empty}invert(e){return new Gp(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 Gp(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 Gp(n.pos,n.attr,n.value)}}Ra.jsonID("attr",Gp);class L0 extends Ra{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 xi.ok(r)}getMap(){return Os.empty}invert(e){return new L0(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 L0(n.attr,n.value)}}Ra.jsonID("docAttr",L0);let yg=class extends Error{};yg=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};yg.prototype=Object.create(Error.prototype);yg.prototype.constructor=yg;yg.prototype.name="TransformError";class Tee{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new O0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new yg(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Dt.empty){let i=WM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Dt(St.from(r),0,0))}delete(e,n){return this.replace(e,n,Dt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return K8e(this,e,n,r),this}replaceRangeWith(e,n,r){return X8e(this,e,n,r),this}deleteRange(e,n){return Y8e(this,e,n),this}lift(e,n){return D8e(this,e,n),this}join(e,n=1){return H8e(this,e,n),this}wrap(e,n){return I8e(this,e,n),this}setBlockType(e,n=e,r,i=null){return F8e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return z8e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Gp(e,n,r)),this}setDocAttribute(e,n){return this.step(new L0(e,n)),this}addNodeMark(e,n){return this.step(new yd(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof pr)n.isInSet(r.marks)&&this.step(new Ff(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new Ff(e,a)),i=a.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return B8e(this,e,n,r),this}addMark(e,n,r){return j8e(this,e,n,r),this}removeMark(e,n,r){return P8e(this,e,n,r),this}clearIncompatible(e,n,r){return FO(this,e,n,r),this}}const $k=Object.create(null);class xn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Q8e(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Dt.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let a=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Dt.empty:n),l==0&&w9(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:l}=i[a],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),w9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new en(e):wp(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let o=n<0?wp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):wp(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new $s(e.node(0))}static atStart(e){return wp(e,e,0,0,1)||new $s(e)}static atEnd(e){return wp(e,e,e.content.size,e.childCount,-1)||new $s(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=$k[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 $k)throw new RangeError("Duplicate use of selection JSON ID "+e);return $k[e]=n,n.prototype.jsonID=e,n}getBookmark(){return en.between(this.$anchor,this.$head).getBookmark()}}xn.prototype.visible=!0;class Q8e{constructor(e,n){this.$from=e,this.$to=n}}let v9=!1;function _9(t){!v9&&!t.parent.inlineContent&&(v9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class en extends xn{constructor(e,n=e){_9(e),_9(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 xn.near(r);let i=e.resolve(n.map(this.anchor));return new en(i.parent.inlineContent?i:r,r)}replace(e,n=Dt.empty){if(super.replace(e,n),n==Dt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof en&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new qM(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 en(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=xn.findFrom(n,r,!0)||xn.findFrom(n,-r,!0);if(a)n=a.$head;else return xn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(xn.findFrom(e,-r,!0)||xn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new en(e,n)}}xn.jsonID("text",en);class qM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new qM(e.map(this.anchor),e.map(this.head))}resolve(e){return en.between(e.resolve(this.anchor),e.resolve(this.head))}}class Wt extends xn{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?xn.near(a):new Wt(a)}content(){return new Dt(St.from(this.node),0,0)}eq(e){return e instanceof Wt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new zO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Wt(e.resolve(n.anchor))}static create(e,n){return new Wt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Wt.prototype.visible=!1;xn.jsonID("node",Wt);class zO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new qM(r,r):new zO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Wt.isSelectable(r)?new Wt(n):xn.near(n)}}class $s extends xn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Dt.empty){if(n==Dt.empty){e.delete(0,e.doc.content.size);let r=xn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new $s(e)}map(e){return new $s(e)}eq(e){return e instanceof $s}getBookmark(){return Z8e}}xn.jsonID("all",$s);const Z8e={map(){return this},resolve(t){return new $s(t)}};function wp(t,e,n,r,i,a=!1){if(e.inlineContent)return en.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!a&&Wt.isSelectable(l))return Wt.create(t,n-(i<0?l.nodeSize:0))}else{let c=wp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function w9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ki||i instanceof Qi))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(xn.near(t.doc.resolve(o),n))}const S9=1,g1=2,M9=4;class J8e extends Tee{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|S9)&~g1,this.storedMarks=null,this}get selectionSet(){return(this.updated&S9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=g1,this}ensureMarks(e){return pr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&g1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~g1,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||pr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(xn.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|=M9,this}get scrolledIntoView(){return(this.updated&M9)>0}}function N9(t,e){return!e||!t?t:t.bind(e)}class Eb{constructor(e,n,r){this.name=e,this.init=N9(n.init,r),this.apply=N9(n.apply,r)}}const e6e=[new Eb("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Eb("selection",{init(t,e){return t.selection||xn.atStart(e.doc)},apply(t){return t.selection}}),new Eb("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Eb("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Hk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=e6e.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 Eb(r.key,r.spec.state,r))})}}class Pp{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let a=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,u=i?i[o].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[o]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Pp(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let a=r[i];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new J8e(this)}static create(e){let n=new Hk(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Pp(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new Hk(this.schema,e.plugins),r=n.fields,i=new Pp(n);for(let a=0;a<r.length;a++){let o=r[a].name;i[o]=this.hasOwnProperty(o)?this[o]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Hk(e.schema,e.plugins),a=new Pp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=kd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=xn.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[o.name]=u.fromJSON.call(c,e,n[l],a);return}}a[o.name]=o.init(e,a)}}),a}}function Cee(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Cee(i,e,{})),n[r]=i}return n}class Br{constructor(e){this.spec=e,this.props={},e.props&&Cee(e.props,this,this.props),this.key=e.key?e.key.key:kee("plugin")}getState(e){return e[this.key]}}const Vk=Object.create(null);function kee(t){return t in Vk?t+"$"+ ++Vk[t]:(Vk[t]=0,t+"$")}class Li{constructor(e="key"){this.key=kee(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const BO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function jee(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Pee=(t,e,n)=>{let r=jee(t,n);if(!r)return!1;let i=$O(r);if(!i){let o=r.blockRange(),l=o&&Xg(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(Bee(t,i,e,-1))return!0;if(r.parent.content.size==0&&(vg(a,"end")||Wt.isSelectable(a)))for(let o=r.depth;;o--){let l=WM(t.doc,r.before(o),r.after(o),Dt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(vg(a,"end")?xn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Wt.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},t6e=(t,e,n)=>{let r=jee(t,n);if(!r)return!1;let i=$O(r);return i?Ree(t,i,e):!1},n6e=(t,e,n)=>{let r=Oee(t,n);if(!r)return!1;let i=HO(r);return i?Ree(t,i,e):!1};function Ree(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=WM(t.doc,a,c,Dt.empty);if(!u||u.from!=a||u instanceof Ki&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(en.create(d.doc,a)),n(d.scrollIntoView())}return!0}function vg(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 Dee=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=$O(r)}let o=a&&a.nodeBefore;return!o||!Wt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Wt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function $O(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 Oee(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Lee=(t,e,n)=>{let r=Oee(t,n);if(!r)return!1;let i=HO(r);if(!i)return!1;let a=i.nodeAfter;if(Bee(t,i,e,1))return!0;if(r.parent.content.size==0&&(vg(a,"start")||Wt.isSelectable(a))){let o=WM(t.doc,r.before(),r.after(),Dt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(vg(a,"start")?xn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Wt.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},Iee=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=HO(r)}let o=a&&a.nodeAfter;return!o||!Wt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Wt.create(t.doc,a.pos)).scrollIntoView()),!0)};function HO(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 r6e=(t,e)=>{let n=t.selection,r=n instanceof Wt,i;if(r){if(n.node.isTextblock||!eh(t.doc,n.from))return!1;i=n.from}else if(i=GM(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Wt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},i6e=(t,e)=>{let n=t.selection,r;if(n instanceof Wt){if(n.node.isTextblock||!eh(t.doc,n.to))return!1;r=n.to}else if(r=GM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},a6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Xg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},Fee=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8146. `).scrollIntoView()),!0)};function VO(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 s6e=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=VO(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(xn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Uee=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof $s||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=VO(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,a.createAndFill());l.setSelection(en.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},zee=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(Yc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Xg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function o6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Wt&&e.selection.node.isBlock)return!r.parentOffset||!Yc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,l,c=!1,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),l=VO(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),a.unshift(c&&l?{type:l}:null),o=p;break}else{if(p==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof en||e.selection instanceof $s)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=Yc(d.doc,f,a.length,a);if(m||(a[0]=l?{type:l}:null,m=Yc(d.doc,f,a.length,a)),!m)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let p=d.mapping.map(r.before(o)),x=d.doc.resolve(p);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const l6e=o6e(),c6e=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Wt.create(t.doc,i))),!0)};function u6e(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||eh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Bee(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&u6e(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&l.matchType(o[0]||a.type).validEnd){if(n){let p=e.pos+a.nodeSize,x=St.empty;for(let y=o.length-1;y>=0;y--)x=St.from(o[y].create(null,x));x=St.from(i.copy(x));let v=t.tr.step(new Qi(e.pos-1,p,e.pos,p,new Dt(x,1,0),o.length,!0)),b=v.doc.resolve(p+2*o.length);b.nodeAfter&&b.nodeAfter.type==i.type&&eh(v.doc,b.pos)&&v.join(b.pos),n(v.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:xn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&Xg(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&vg(a,"start",!0)&&vg(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let v=a,b=1;for(;!v.isTextblock;v=v.firstChild)b++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let y=St.empty;for(let S=x.length-1;S>=0;S--)y=St.from(x[S].copy(y));let M=t.tr.step(new Qi(e.pos-x.length,e.pos+a.nodeSize,e.pos+b,e.pos+a.nodeSize-b,new Dt(y,x.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function $ee(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(en.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const d6e=$ee(-1),h6e=$ee(1);function f6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&UO(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function E9(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function GO(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}GO(BO,Pee,Dee);GO(BO,Lee,Iee);GO(Fee,Uee,zee,l6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function m6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let l=r?n.tr:null;return p6e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function p6e(t,e,n,r=null){let i=!1,a=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);a=new jS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new jS(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=UO(a,n,r,e);return l?(t&&g6e(t,e,l,i,n),!0):!1}function g6e(t,e,n,r,i){let a=St.empty;for(let d=n.length-1;d>=0;d--)a=St.from(n[d].type.create(n[d].attrs,a));t.step(new Qi(e.start-(r?2:0),e.end,e.start,e.end,new Dt(a,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,m=!0;d<f;d++,m=!1)!m&&Yc(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function x6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?b6e(e,n,t,a):y6e(e,n,a):!0:!1}}function b6e(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Qi(a-1,o,a,o,new Dt(St.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new jS(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Xg(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return eh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function y6e(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,v=n.startIndex;x>v;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?St.empty:St.from(i))))return!1;let f=a.pos,m=f+o.nodeSize;return r.step(new Qi(f-(l?1:0),m+(c?1:0),f+1,m-1,new Dt((l?St.empty:St.from(i.copy(St.empty))).append(c?St.empty:St.from(i.copy(St.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function v6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let l=a.parent,c=l.child(o-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=St.from(u?t.create():null),f=new Dt(St.from(t.create(null,St.from(l.type.create(null,d)))),u?3:1,0),m=a.start,p=a.end;n(e.tr.step(new Qi(m-(u?3:1),p,m,p,f,1,!0)).scrollIntoView())}return!0}}const pa=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},_g=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let aR=null;const jc=function(t,e,n){let r=aR||(aR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},_6e=function(){aR=null},Uf=function(t,e,n,r){return n&&(A9(t,e,n,r,-1)||A9(t,e,n,r,1))},w6e=/^(img|br|input|textarea|hr)$/i;function A9(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:vo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Cy(t)||w6e.test(t.nodeName)||t.contentEditable=="false")return!1;e=pa(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?vo(t):0}else return!1}}function vo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function S6e(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=vo(t)}else if(t.parentNode&&!Cy(t))e=pa(t),t=t.parentNode;else return null}}function M6e(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&&!Cy(t))e=pa(t)+1,t=t.parentNode;else return null}}function N6e(t,e,n){for(let r=e==0,i=e==vo(t);r||i;){if(t==n)return!0;let a=pa(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==vo(t)}}function Cy(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 KM=function(t){return t.focusNode&&Uf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Bh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function E6e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function A6e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(vo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(vo(r.startContainer),r.startOffset)}}}const $l=typeof navigator<"u"?navigator:null,T9=typeof document<"u"?document:null,th=$l&&$l.userAgent||"",sR=/Edge\/(\d+)/.exec(th),Hee=/MSIE \d/.exec(th),oR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(th),ms=!!(Hee||oR||sR),jd=Hee?document.documentMode:oR?+oR[1]:sR?+sR[1]:0,No=!ms&&/gecko\/(\d+)/i.test(th);No&&+(/Firefox\/(\d+)/.exec(th)||[0,0])[1];const lR=!ms&&/Chrome\/(\d+)/.exec(th),Ca=!!lR,Vee=lR?+lR[1]:0,Wa=!ms&&!!$l&&/Apple Computer/.test($l.vendor),wg=Wa&&(/Mobile\/\w+/.test(th)||!!$l&&$l.maxTouchPoints>2),mo=wg||($l?/Mac/.test($l.platform):!1),T6e=$l?/Win/.test($l.platform):!1,Hc=/Android \d/.test(th),ky=!!T9&&"webkitFontSmoothing"in T9.documentElement.style,C6e=ky?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function k6e(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 Nc(t,e){return typeof t=="number"?t:t[e]}function j6e(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 C9(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=_g(o);continue}let l=o,c=l==a.body,u=c?k6e(a):j6e(l),d=0,f=0;if(e.top<u.top+Nc(r,"top")?f=-(u.top-e.top+Nc(i,"top")):e.bottom>u.bottom-Nc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Nc(i,"top")-u.top:e.bottom-u.bottom+Nc(i,"bottom")),e.left<u.left+Nc(r,"left")?d=-(u.left-e.left+Nc(i,"left")):e.right>u.right-Nc(r,"right")&&(d=e.right-u.right+Nc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let v=l.scrollLeft-p,b=l.scrollTop-x;e={left:e.left-v,top:e.top-b,right:e.right-v,bottom:e.bottom-b}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:_g(o)}}function P6e(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(a,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:Gee(t.dom)}}function Gee(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=_g(r));return e}function R6e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Wee(n,r==0?0:r-e)}function Wee(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let mp=null;function D6e(t){if(t.setActive)return t.setActive();if(mp)return t.focus(mp);let e=Gee(t);t.focus(mp==null?{get preventScroll(){return mp={preventScroll:!0},!0}}:void 0),mp||(mp=!1,Wee(e,0))}function qee(t,e){let n,r=2e8,i,a=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let m;if(d.nodeType==1)m=d.getClientRects();else if(d.nodeType==3)m=jc(d).getClientRects();else continue;for(let p=0;p<m.length;p++){let x=m[p];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let v=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&v&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?O6e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:qee(n,i)}function O6e(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=td(r,1);if(a.top!=a.bottom&&WO(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function WO(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function L6e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function I6e(t,e,n){let{node:r,offset:i}=qee(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();a=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function F6e(t,e,n,r){let i=-1;for(let a=e,o=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;a=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Kee(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let o=t.childNodes[a];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(WO(e,u))return Kee(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function U6e(t,e){let n=t.dom.ownerDocument,r,i=0,a=A6e(n,e.left,e.top);a&&({node:r,offset:i}=a);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=t.dom.getBoundingClientRect();if(!WO(e,u)||(o=Kee(t.dom,e,u),!o))return null}if(Wa)for(let u=o;r&&u;u=_g(u))u.draggable&&(r=void 0);if(o=L6e(o,e),r){if(No&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;ky&&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=F6e(t,r,i,e))}l==null&&(l=I6e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function k9(t){return t.top<t.bottom||t.left<t.right}function td(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(k9(r))return r}return Array.prototype.find.call(n,k9)||t.getBoundingClientRect()}const z6e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Xee(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=ky||No;if(r.nodeType==3)if(o&&(z6e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=td(jc(r,i,i),n);if(No&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=td(jc(r,i-1,i-1),-1);if(u.top==c.top){let d=td(jc(r,i,i+1),-1);if(d.top!=c.top)return hb(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++,hb(td(jc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==vo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Gk(c.getBoundingClientRect(),!1)}if(a==null&&i<vo(r)){let c=r.childNodes[i];if(c.nodeType==1)return Gk(c.getBoundingClientRect(),!0)}return Gk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==vo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?jc(c,vo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return hb(td(u,1),!1)}if(a==null&&i<vo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?jc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return hb(td(u,-1),!0)}return hb(td(r.nodeType==3?jc(r):r,-n),n>=0)}function hb(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 Gk(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 Yee(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 B6e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Yee(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(a,!0);if(!l)break;if(l.node.isBlock){a=l.contentDOM||l.dom;break}a=l.dom.parentNode}let o=Xee(t,i.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=jc(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 $6e=/[\u0590-\u08ac]/;function H6e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!$6e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:Yee(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:v}=t.domSelectionRange(),b=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==v;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return m!=null&&(l.caretBidiLevel=m),b}):r.pos==r.start()||r.pos==r.end()}let j9=null,P9=null,R9=!1;function V6e(t,e,n){return j9==e&&P9==n?R9:(j9=e,P9=n,R9=n=="up"||n=="down"?B6e(t,e,n):H6e(t,e,n))}const Eo=0,D9=1,Yh=2,Hl=3;class jy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Eo,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>pa(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let o=this.children[r],l=a+o.size;if(l>e||o instanceof Zee){i=e-a;break}a=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof Qee&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?pa(a.dom)+1:0}}else{let a,o=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,o=!1);return a&&o&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?pa(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=o;for(let f=l;f>0;f--){let m=this.children[f-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){i=pa(m.dom)+1;break}e-=m.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let d=l+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=pa(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),o=Math.max(e,n);for(let p=0,x=0;p<this.children.length;p++){let v=this.children[p],b=x+v.size;if(a>x&&o<b)return v.setSelection(e-x-v.border,n-x-v.border,r,i);x=b}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((No||Wa)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(f=!!(x&&p.nodeValue[x-1]==`
  8147. `),f&&x==p.nodeValue.length)for(let v=p,b;v;v=v.parentNode){if(b=v.nextSibling){b.nodeName=="BR"&&(l=c={node:b.parentNode,offset:pa(b)+1});break}let y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let v=p.childNodes[x-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(No&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Wa)&&Uf(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Uf(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&No)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>n){let x=l;l=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+a.border,c=o-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Yh:D9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Hl:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Yh:Hl}r=o}this.dirty=Yh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Yh:D9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Qee extends jy{constructor(e,n,r,i){let a,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==Eo&&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 G6e extends jy{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class zf extends jy{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=Yf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new zf(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Hl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Hl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Eo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Eo}}slice(e,n,r){let i=zf.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=uR(a,n,o,r)),e>0&&(a=uR(a,0,e,r));for(let l=0;l<a.length;l++)a[l].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Pd extends jy{constructor(e,n,r,i,a,o,l,c,u){super(e,[],a,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,a,o){let l=a.nodeViews[n.type.name],c,u=l&&l(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=Yf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let m=d;return d=tte(d,r,n),u?c=new W6e(e,n,r,i,d,f||null,m,u,a,o+1):n.isText?new XM(e,n,r,i,d,m,a):new Pd(e,n,r,i,d,f||null,m,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>St.empty)}return e}matchesNode(e,n,r){return this.dirty==Eo&&e.eq(this.node)&&RS(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,l=a&&a.pos<0,c=new K6e(this,o&&o.node,e);Q6e(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?pr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,m)=>{c.syncToMarks(u.marks,r,e);let p;c.findNodeMatch(u,d,f,m)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,m,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Yh)&&(o&&this.protectLocalComposition(e,o),Jee(this.contentDOM,this.children,e),wg&&Z6e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof en)||r<n||i>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let o=a.nodeValue,l=J6e(this.node.content,o,r-n,i-n);return l<0?null:{node:a,pos:l,text:o}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let o=new G6e(this,a,n,i);e.input.compositionNodes.push(o),this.children=uR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Hl||!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=Eo}updateOuterDeco(e){if(RS(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ete(this.dom,this.nodeDOM,cR(this.outerDeco,this.node,n),cR(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 O9(t,e,n,r,i){tte(r,e,t);let a=new Pd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class XM extends Pd{constructor(e,n,r,i,a,o,l){super(e,n,r,i,a,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Hl||this.dirty!=Eo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Eo||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=Eo,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new XM(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Hl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Zee extends jy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Eo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class W6e extends Pd{constructor(e,n,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==Hl)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Jee(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let o=e[a],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=L9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof zf){let c=r?r.previousSibling:t.lastChild;Jee(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=L9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const $b=function(t){t&&(this.nodeName=t)};$b.prototype=Object.create(null);const Qh=[new $b];function cR(t,e,n){if(t.length==0)return Qh;let r=n?Qh[0]:new $b,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new $b(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new $b(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 ete(t,e,n,r){if(n==Qh&&r==Qh)return e;let i=e;for(let a=0;a<r.length;a++){let o=r[a],l=n[a];if(a){let c;l&&l.nodeName==o.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Qh[0]),i=c}q6e(i,l||Qh[0],o)}return i}function q6e(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function tte(t,e,n){return ete(t,t,Qh,cR(e,n,t.nodeType!=1))}function RS(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 L9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class K6e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=X6e(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Eo,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=zf.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let o=this.top.children[i];return o.dirty==Hl&&o.dom==o.contentDOM&&(o.dirty=Yh),o.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Pd){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,m=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Hl&&RS(n,c.outerDeco));if(!m&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!m&&(f=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Yh,f.updateChildren(i,o+1),f.dirty=Eo),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!RS(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Pd.create(this.top,n,r,i,a,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,i,a){let o=Pd.create(this.top,e,n,r,i,a);o.contentDOM&&o.updateChildren(i,a+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let a=new Qee(this.top,e,n,r);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof zf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof XM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Wa||Ca)&&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 Zee(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 X6e(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof zf)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,a.set(l,i),o.push(l)}}return{index:i,matched:a,matches:o.reverse()}}function Y6e(t,e){return t.type.side-e.type.side}function Q6e(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==a;){let b=i[o++];b.widget&&(d?(f||(f=[d])).push(b):d=b)}if(d)if(f){f.sort(Y6e);for(let b=0;b<f.length;b++)n(f[b],u,!!c)}else n(d,u,!!c);let m,p;if(c)p=-1,m=c,c=null;else if(u<t.childCount)p=u,m=t.child(u++);else break;for(let b=0;b<l.length;b++)l[b].to<=a&&l.splice(b--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let x=a+m.nodeSize;if(m.isText){let b=x;o<i.length&&i[o].from<b&&(b=i[o].from);for(let y=0;y<l.length;y++)l[y].to<b&&(b=l[y].to);b<x&&(c=m.cut(b-a),m=m.cut(0,b-a),x=b,p=-1)}else for(;o<i.length&&i[o].to<x;)o++;let v=m.isInline&&!m.isLeaf?l.filter(b=>!b.inline):l.slice();r(m,v,e.forChild(a,m),p),a=x}}function Z6e(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 J6e(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let o=t.child(i++),l=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function uR(t,e,n,r,i){let a=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function qO(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(KM(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Wt.isSelectable(f)&&i.parent&&!(f.isInline&&N6e(n.focusNode,n.focusOffset,i.dom))){let m=i.posBefore;u=new Wt(o==m?l:r.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,m=o;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=m==t.state.selection.anchor?[m,f]:[f,m],l=r.resolve(o)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!a?1:-1;u=KO(t,d,l,f)}return u}function nte(t){return t.editable?t.hasFocus():ite(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Qc(t,e=!1){let n=t.state.selection;if(rte(t,n),!!nte(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ca){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Uf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)t$e(t);else{let{anchor:r,head:i}=n,a,o;I9&&!(n instanceof en)&&(n.$from.parent.inlineContent||(a=F9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=F9(t,n.to))),t.docView.setSelection(r,i,t,e),I9&&(a&&U9(a),o&&U9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&e$e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const I9=Wa||Ca&&Vee<63;function F9(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(Wa&&i&&i.contentEditable=="false")return Wk(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return Wk(i);if(a)return Wk(a)}}function Wk(t){return t.contentEditable="true",Wa&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function U9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function e$e(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(()=>{(!nte(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function t$e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,pa(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&ms&&jd<=11&&(n.disabled=!0,n.disabled=!1)}function rte(t,e){if(e instanceof Wt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(z9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else z9(t)}function z9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function KO(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||en.between(e,n,r)}function B9(t){return t.editable&&!t.hasFocus()?!1:ite(t)}function ite(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 n$e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Uf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function dR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&xn.findFrom(a,e)}function sd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function $9(t,e,n){let r=t.state.selection;if(r instanceof en)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return sd(t,new en(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=dR(t.state,e);return i&&i instanceof Wt?sd(t,i):!1}else if(!(mo&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Wt.isSelectable(a)?sd(t,new Wt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):ky?sd(t,new en(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Wt&&r.node.isInline)return sd(t,new en(e>0?r.$to:r.$from));{let i=dR(t.state,e);return i?sd(t,i):!1}}}function DS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Hb(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function pp(t,e){return e<0?r$e(t):i$e(t)}function r$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(No&&n.nodeType==1&&r<DS(n)&&Hb(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Hb(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(ate(n))break;{let l=n.previousSibling;for(;l&&Hb(l,-1);)i=n.parentNode,a=pa(l),l=l.previousSibling;if(l)n=l,r=DS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?hR(t,n,r):i&&hR(t,i,a)}function i$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=DS(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Hb(l,1))a=n,o=++r;else break}else{if(ate(n))break;{let l=n.nextSibling;for(;l&&Hb(l,1);)a=l.parentNode,o=pa(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=DS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&hR(t,a,o)}function ate(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function a$e(t,e){for(;t&&e==t.childNodes.length&&!Cy(t);)e=pa(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 s$e(t,e){for(;t&&!e&&!Cy(t);)e=pa(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 hR(t,e,n){if(e.nodeType!=3){let a,o;(o=a$e(e,n))?(e=o,n=0):(a=s$e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(KM(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Qc(t)},50)}function H9(t,e){let n=t.state.doc.resolve(e);if(!(Ca||T6e)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function V9(t,e,n){let r=t.state.selection;if(r instanceof en&&!r.empty||n.indexOf("s")>-1||mo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=dR(t.state,e);if(o&&o instanceof Wt)return sd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof $s?xn.near(o,e):xn.findFrom(o,e);return l?sd(t,l):!1}return!1}function G9(t,e){if(!(t.state.selection instanceof en))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function W9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function o$e(t){if(!Wa||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;W9(t,r,"true"),setTimeout(()=>W9(t,r,"false"),20)}return!1}function l$e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function c$e(t,e){let n=e.keyCode,r=l$e(e);if(n==8||mo&&n==72&&r=="c")return G9(t,-1)||pp(t,-1);if(n==46&&!e.shiftKey||mo&&n==68&&r=="c")return G9(t,1)||pp(t,1);if(n==13||n==27)return!0;if(n==37||mo&&n==66&&r=="c"){let i=n==37?H9(t,t.state.selection.from)=="ltr"?-1:1:-1;return $9(t,i,r)||pp(t,i)}else if(n==39||mo&&n==70&&r=="c"){let i=n==39?H9(t,t.state.selection.from)=="ltr"?1:-1:1;return $9(t,i,r)||pp(t,i)}else{if(n==38||mo&&n==80&&r=="c")return V9(t,-1,r)||pp(t,-1);if(n==40||mo&&n==78&&r=="c")return o$e(t)||V9(t,1,r)||pp(t,1);if(r==(mo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function XO(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=t.someProp("clipboardSerializer")||Yf.fromSchema(t.state.schema),l=dte(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=ute[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=l.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
  8148. `);return{dom:c,text:m,slice:e}}function ste(t,e,n,r,i){let a=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",m=>{e=m(e,a||r,t)}),a)return l=new Dt(St.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8149. `))),0,0),t.someProp("transformPasted",m=>{l=m(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",m=>m(e,i,r,t));if(f)l=f;else{let m=i.marks(),{schema:p}=t.state,x=Yf.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let b=o.appendChild(document.createElement("p"));v&&b.appendChild(x.serializeNode(p.text(v,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=f$e(n),ky&&m$e(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||zb.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!u$e.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=p$e(q9(l,+d[1],+d[2]),d[4]);else if(l=Dt.maxOpen(d$e(l.content,i),!0),l.openStart||l.openEnd){let f=0,m=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;m<l.openEnd&&!p.type.spec.isolating;m++,p=p.lastChild);l=q9(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const u$e=/^(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 d$e(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&a.length&&lte(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=cte(o[o.length-1],a.length));let d=ote(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return St.from(o)}return t}function ote(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,St.from(t));return t}function lte(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=lte(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(St.from(ote(n,t,i+1))))}}function cte(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,cte(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(St.empty,!0);return t.copy(n.append(r))}function fR(t,e,n,r,i,a){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(a=0),i<r-1&&(l=fR(l,e,n,r,i+1,a)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,a<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(St.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function q9(t,e,n){return e<t.openStart&&(t=new Dt(fR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Dt(fR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const ute={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 K9=null;function dte(){return K9||(K9=document.implementation.createHTMLDocument("title"))}let qk=null;function h$e(t){let e=window.trustedTypes;return e?(qk||(qk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),qk.createHTML(t)):t}function f$e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=dte().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&ute[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=h$e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function m$e(t){let e=t.querySelectorAll(Ca?"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 p$e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=St.from(c.create(r[l+1],i)),a++,o++}return new Dt(i,a,o)}const qa={},Ka={},g$e={touchstart:!0,touchmove:!0};class x$e{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 b$e(t){for(let e in qa){let n=qa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{v$e(t,r)&&!YO(t,r)&&(t.editable||!(r.type in Ka))&&n(t,r)},g$e[e]?{passive:!0}:void 0)}Wa&&t.dom.addEventListener("input",()=>null),mR(t)}function vd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function y$e(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 mR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>YO(t,r))})}function YO(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function v$e(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 _$e(t,e){!YO(t,e)&&qa[e.type]&&(t.editable||!(e.type in Ka))&&qa[e.type](t,e)}Ka.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!fte(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Hc&&Ca&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),wg&&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,Bh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||c$e(t,n)?n.preventDefault():vd(t,"key")};Ka.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ka.keypress=(t,e)=>{let n=e;if(fte(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||mo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof en)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function YM(t){return{left:t.clientX,top:t.clientY}}function w$e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function QO(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,l=>o>a.depth?l(t,n,a.nodeAfter,a.before(o),i,!0):l(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Wp(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 S$e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Wt.isSelectable(r)?(Wp(t,new Wt(n)),!0):!1}function M$e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Wt&&(r=n.node);let a=t.state.doc.resolve(e);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o);if(Wt.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Wp(t,Wt.create(t.state.doc,i)),!0):!1}function N$e(t,e,n,r,i){return QO(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?M$e(t,n):S$e(t,n))}function E$e(t,e,n,r){return QO(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function A$e(t,e,n,r){return QO(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||T$e(t,n,r)}function T$e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Wp(t,en.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),l=i.before(a);if(o.inlineContent)Wp(t,en.create(r,l+1,l+1+o.content.size));else if(Wt.isSelectable(o))Wp(t,Wt.create(r,l));else continue;return!0}}function ZO(t){return OS(t)}const hte=mo?"metaKey":"ctrlKey";qa.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=ZO(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&w$e(n,t.input.lastClick)&&!n[hte]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(YM(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new C$e(t,o,n,!!r)):(a=="doubleClick"?E$e:A$e)(t,o.pos,o.inside,n)?n.preventDefault():vd(t,"pointer"))};class C$e{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[hte],this.allowDefault=r.shiftKey;let a,o;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,o=d.depth?d.before():0}const l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof Wt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&No&&!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)),vd(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(()=>Qc(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(YM(e))),this.updateAllowDefault(e),this.allowDefault||!n?vd(this.view,"pointer"):N$e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Wa&&this.mightDrag&&!this.mightDrag.node.isAtom||Ca&&!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)?(Wp(this.view,xn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):vd(this.view,"pointer")}move(e){this.updateAllowDefault(e),vd(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)}}qa.touchstart=t=>{t.input.lastTouch=Date.now(),ZO(t),vd(t,"pointer")};qa.touchmove=t=>{t.input.lastTouch=Date.now(),vd(t,"pointer")};qa.contextmenu=t=>ZO(t);function fte(t,e){return t.composing?!0:Wa&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const k$e=Hc?5e3:-1;Ka.compositionstart=Ka.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof en&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),OS(t,!0),t.markCursor=null;else if(OS(t,!e.selection.empty),No&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}mte(t,k$e)};Ka.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++,mte(t,20))};function mte(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>OS(t),e))}function pte(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=P$e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function j$e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=S6e(e.focusNode,e.focusOffset),r=M6e(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function P$e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function OS(t,e=!1){if(!(Hc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),pte(t),e||t.docView&&t.docView.dirty){let n=qO(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 R$e(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 I0=ms&&jd<15||wg&&C6e<604;qa.copy=Ka.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=I0?null:n.clipboardData,o=r.content(),{dom:l,text:c}=XO(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):R$e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function D$e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function O$e(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?F0(t,r.value,null,i,e):F0(t,r.textContent,r.innerHTML,i,e)},50)}function F0(t,e,n,r,i){let a=ste(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Dt.empty)))return!0;if(!a)return!1;let o=D$e(a),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gte(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," "):""}Ka.paste=(t,e)=>{let n=e;if(t.composing&&!Hc)return;let r=I0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&F0(t,gte(r),r.getData("text/html"),i,n)?n.preventDefault():O$e(t,n)};class xte{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const L$e=mo?"altKey":"ctrlKey";function bte(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[L$e]}qa.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(YM(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Wt?i.to-1:i.to))){if(r&&r.mightDrag)o=Wt.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(o=Wt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=XO(t,l);(!n.dataTransfer.files.length||!Ca||Vee>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(I0?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",I0||n.dataTransfer.setData("text/plain",u),t.dragging=new xte(d,bte(t,n),o)};qa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ka.dragover=Ka.dragenter=(t,e)=>e.preventDefault();Ka.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(YM(n));if(!i)return;let a=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=ste(t,gte(n.dataTransfer),I0?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&bte(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Dt.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?See(t.state.doc,a.pos,o):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(m))return;let p=u.doc.resolve(d);if(f&&Wt.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Wt(p));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,b,y,M)=>x=M),u.setSelection(KO(t,p,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};qa.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())&&Qc(t)},20))};qa.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)};qa.beforeinput=(t,e)=>{if(Ca&&Hc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Bh(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 Ka)qa[t]=Ka[t];function U0(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 LS{constructor(e,n){this.toDOM=e,this.spec=n||ff,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Ba(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof LS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&U0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Rd{constructor(e,n){this.attrs=e,this.spec=n||ff}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new Ba(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Rd&&U0(this.attrs,e.attrs)&&U0(this.spec,e.spec)}static is(e){return e.type instanceof Rd}destroy(){}}class JO{constructor(e,n){this.attrs=e,this.spec=n||ff}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=a.pos?null:new Ba(a.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof JO&&U0(this.attrs,e.attrs)&&U0(this.spec,e.spec)}destroy(){}}class Ba{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ba(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 Ba(e,e,new LS(n,r))}static inline(e,n,r,i){return new Ba(e,n,new Rd(r,i))}static node(e,n,r,i){return new Ba(e,n,new JO(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Rd}get widget(){return this.type instanceof LS}}const Sp=[],ff={};class Or{constructor(e,n){this.local=e.length?e:Sp,this.children=n.length?n:Sp}static create(e,n){return n.length?IS(n,e,0,ff):Ea}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!a||a(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,a)}}map(e,n,r){return this==Ea||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ff)}mapInner(e,n,r,i,a){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(o||(o=[])).push(c):a.onRemove&&a.onRemove(this.local[l].spec)}return this.children.length?I$e(this.children,o||[],e,n,r,i,a):o?new Or(o.sort(mf),Sp):Ea}add(e,n){return n.length?this==Ea?Or.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((l,c)=>{let u=c+r,d;if(d=vte(n,l,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(l,d,u+1):i.splice(a,0,c,c+l.nodeSize,IS(d,l,u+1,ff)),a+=3}});let o=yte(a?_te(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Or(o.length?this.local.concat(o).sort(mf):this.local,i||this.children)}remove(e){return e.length==0||this==Ea?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let o,l=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(o,l+1);u!=Ea?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,o;a<e.length;a++)if(o=e[a])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Or(i,r):Ea}forChild(e,n){if(this==Ea)return this;if(n.isLeaf)return Or.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let a=e+1,o=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>a&&c.type instanceof Rd){let u=Math.max(a,c.from)-a,d=Math.min(o,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new Or(i.sort(mf),Sp);return r?new hd([l,r]):l}return r||Ea}eq(e){if(this==e)return!0;if(!(e instanceof Or)||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 eL(this.localsInner(e))}localsInner(e){if(this==Ea)return Sp;if(e.inlineContent||!this.local.some(Rd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Rd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Or.empty=new Or([],[]);Or.removeOverlap=eL;const Ea=Or.empty;class hd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,ff));return hd.from(r)}forChild(e,n){if(n.isLeaf)return Or.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Ea&&(a instanceof hd?r=r.concat(a.members):r.push(a))}return hd.from(r)}eq(e){if(!(e instanceof hd)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let o=0;o<a.length;o++)n.push(a[o])}}return n?eL(r?n:n.sort(mf)):Sp}static from(e){switch(e.length){case 0:return Ea;case 1:return e[0];default:return new hd(e.every(n=>n instanceof Or)?e:e.reduce((n,r)=>n.concat(r instanceof Or?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function I$e(t,e,n,r,i,a,o){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((m,p,x,v)=>{let b=v-x-(p-m);for(let y=0;y<l.length;y+=3){let M=l[y+1];if(M<0||m>M+d-f)continue;let S=l[y]+d-f;p>=S?l[y+1]=m<=S?-2:-1:m>=d&&b&&(l[y]+=b,l[y+1]+=b)}f+=b}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let m=n.map(t[u+1]+a,-1),p=m-i,{index:x,offset:v}=r.content.findIndex(f),b=r.maybeChild(x);if(b&&v==f&&v+b.nodeSize==p){let y=l[u+2].mapInner(n,b,d+1,t[u]+a+1,o);y!=Ea?(l[u]=f,l[u+1]=p,l[u+2]=y):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=F$e(l,t,e,n,i,a,o),d=IS(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,m=0;f<d.children.length;f+=3){let p=d.children[f];for(;m<l.length&&l[m]<p;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Or(e.sort(mf),l)}function yte(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 Ba(i.from+e,i.to+e,i.type))}return n}function F$e(t,e,n,r,i,a,o){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+a+1);return n}function vte(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,o;a<t.length;a++)(o=t[a])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[a]=null);return i}function _te(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function IS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=vte(t,l,c+n);if(u){a=!0;let d=IS(u,l,n+c+1,r);d!=Ea&&i.push(c,c+l.nodeSize,d)}});let o=yte(a?_te(t):t,-n).sort(mf);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 Or(o,i):Ea}function mf(t,e){return t.from-e.from||t.to-e.to}function eL(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),X9(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),X9(e,i,r.copy(a.from,r.to)));break}}}return e}function X9(t,e,n){for(;e<t.length&&mf(n,t[e])>0;)e++;t.splice(e,0,n)}function Kk(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ea&&e.push(r)}),t.cursorWrapper&&e.push(Or.create(t.state.doc,[t.cursorWrapper.deco])),hd.from(e)}const U$e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},z$e=ms&&jd<=11;class B$e{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 $$e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new B$e,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]);ms&&jd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),z$e&&(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,U$e)),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(B9(this.view)){if(this.suppressingSelectionUpdates)return Qc(this.view);if(ms&&jd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Uf(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=_g(a))n.add(a);for(let a=e.anchorNode;a;a=_g(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&B9(e)&&!this.ignoreSelectionChange(r),a=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(No&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,m]=d;f.parentNode&&f.parentNode.parentNode==m.parentNode?m.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let m of d){let p=m.parentNode;p&&p.nodeName=="LI"&&(!f||G$e(e,f)!=p)&&m.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&KM(r)&&(u=qO(e))&&u.eq(xn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),H$e(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Qc(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(ms&&jd<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:m}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(a=m)}let o=i&&i.parentNode==e.target?pa(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?pa(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Y9=new WeakMap,Q9=!1;function H$e(t){if(!Y9.has(t)&&(Y9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=No,Q9)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."),Q9=!0}}function Z9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Uf(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function V$e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Z9(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?Z9(t,n):null}function G$e(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 W$e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],KM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ca&&t.input.lastKeyCode===8)for(let b=a;b>i;b--){let y=r.childNodes[b-1],M=y.pmViewDesc;if(y.nodeName=="BR"&&!M){a=b;break}if(!M||M.size)break}let f=t.state.doc,m=t.someProp("domParser")||zb.fromSchema(t.state.schema),p=f.resolve(o),x=null,v=m.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:q$e,context:p});if(u&&u[0].pos!=null){let b=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=b),x={anchor:b+o,head:y+o}}return{doc:v,sel:x,from:o,to:l}}function q$e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Wa&&/^(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||Wa&&/^(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 K$e=/^(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 X$e(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,R=qO(t,C);if(R&&!t.state.selection.eq(R)){if(Ca&&Hc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",P=>P(t,Bh(13,"Enter"))))return;let T=t.state.tr.setSelection(R);C=="pointer"?T.setMeta("pointer",!0):C=="key"&&T.scrollIntoView(),a&&T.setMeta("composition",a),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=W$e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),m,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,p="end"):(m=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=Z$e(f.content,u.doc.content,u.from,m,p);if(x&&t.input.domChangeCount++,(wg&&t.input.lastIOSEnter>Date.now()-225||Hc)&&i.some(C=>C.nodeType==1&&!K$e.test(C.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",C=>C(t,Bh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof en&&!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 C=J9(t,t.state.doc,u.sel);if(C&&!C.eq(t.state.selection)){let R=t.state.tr.setSelection(C);a&&R.setMeta("composition",a),t.dispatch(R)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof en&&(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)),ms&&jd<=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 v=u.doc.resolveNoCache(x.start-u.from),b=u.doc.resolveNoCache(x.endB-u.from),y=d.resolve(x.start),M=v.sameParent(b)&&v.parent.inlineContent&&y.end()>=x.endA;if((wg&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!M&&v.pos<u.doc.content.size&&(!v.sameParent(b)||!v.parent.inlineContent)&&v.pos<b.pos&&!/\S/.test(u.doc.textBetween(v.pos,b.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,Bh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&Q$e(d,x.start,x.endA,v,b)&&t.someProp("handleKeyDown",C=>C(t,Bh(8,"Backspace")))){Hc&&Ca&&t.domObserver.suppressSelectionUpdates();return}Ca&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Hc&&!M&&v.start()!=b.start()&&b.parentOffset==0&&v.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(C){return C(t,Bh(13,"Enter"))})},20));let S=x.start,A=x.endA,E=C=>{let R=C||t.state.tr.replace(S,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let T=J9(t,R.doc,u.sel);T&&!(Ca&&t.composing&&T.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==S||T.head==R.mapping.map(A)-1)||ms&&T.empty&&T.head==S)&&R.setSelection(T)}return a&&R.setMeta("composition",a),R.scrollIntoView()},k;if(M)if(v.pos==b.pos){ms&&jd<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qc(t),20));let C=E(t.state.tr.delete(S,A)),R=d.resolve(x.start).marksAcross(d.resolve(x.endA));R&&C.ensureMarks(R),t.dispatch(C)}else if(x.endA==x.endB&&(k=Y$e(v.parent.content.cut(v.parentOffset,b.parentOffset),y.parent.content.cut(y.parentOffset,x.endA-y.start())))){let C=E(t.state.tr);k.type=="add"?C.addMark(S,A,k.mark):C.removeMark(S,A,k.mark),t.dispatch(C)}else if(v.parent.child(v.index()).isText&&v.index()==b.index()-(b.textOffset?0:1)){let C=v.parent.textBetween(v.parentOffset,b.parentOffset),R=()=>E(t.state.tr.insertText(C,S,A));t.someProp("handleTextInput",T=>T(t,S,A,C,R))||t.dispatch(R())}else t.dispatch(E());else t.dispatch(E())}function J9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:KO(t,e.resolve(n.anchor),e.resolve(n.head))}function Y$e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,o,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(St.from(u).eq(t))return{mark:l,type:o}}function Q$e(t,e,n,r,i){if(n-e<=i.pos-r.pos||Xk(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let l=a.nodeAfter;return l!=null&&n==e+l.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=t.resolve(Xk(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Xk(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Xk(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function Z$e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(o,l));r-=o+c-a}if(o<a&&t.size<e.size){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<e.size&&eG(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-o),o=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&eG(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function eG(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 wte{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 x$e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(aG),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=rG(this),nG(this),this.nodeViews=iG(this),this.docView=O9(this.state.doc,tG(this),Kk(this),this.dom,this),this.domObserver=new $$e(this,(r,i,a,o)=>X$e(this,r,i,a,o)),this.domObserver.start(),b$e(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&&mR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(aG),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(pte(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=iG(this);eHe(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&mR(this),this.editable=rG(this),nG(this);let c=Kk(this),u=tG(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let m=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&P6e(this);if(o){this.domObserver.stop();let p=f&&(ms||Ca)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&J$e(i.selection,e.selection);if(f){let x=Ca?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=j$e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=O9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&n$e(this))?Qc(this,p):(rte(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():m&&R6e(m)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Wt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&C9(this,n.getBoundingClientRect(),e)}else C9(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new xte(e.slice,e.move,i<0?void 0:Wt.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(ms){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&&D6e(this.dom),Qc(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 U6e(this,e)}coordsAtPos(e,n=1){return Xee(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 V6e(this,n||this.state,e)}pasteHTML(e,n){return F0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return F0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return XO(this,e)}destroy(){this.docView&&(y$e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Kk(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,_6e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return _$e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Wa&&this.root.nodeType===11&&E6e(this.dom.ownerDocument)==this.dom&&V$e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}wte.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function tG(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"),[Ba.node(0,t.state.doc.content.size,e)]}function nG(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:Ba.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function rG(t){return!t.someProp("editable",e=>e(t.state)===!1)}function J$e(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 iG(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 eHe(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 aG(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 qd={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:"'"},FS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},tHe=typeof navigator<"u"&&/Mac/.test(navigator.platform),nHe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ga=0;ga<10;ga++)qd[48+ga]=qd[96+ga]=String(ga);for(var ga=1;ga<=24;ga++)qd[ga+111]="F"+ga;for(var ga=65;ga<=90;ga++)qd[ga]=String.fromCharCode(ga+32),FS[ga]=String.fromCharCode(ga);for(var Yk in qd)FS.hasOwnProperty(Yk)||(FS[Yk]=qd[Yk]);function rHe(t){var e=tHe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||nHe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?FS:qd)[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 iHe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),aHe=typeof navigator<"u"&&/Win/.test(navigator.platform);function sHe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))iHe?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function oHe(t){let e=Object.create(null);for(let n in t)e[sHe(n)]=t[n];return e}function Qk(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 lHe(t){return new Br({props:{handleKeyDown:Ste(t)}})}function Ste(t){let e=oHe(t);return function(n,r){let i=rHe(r),a,o=e[Qk(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Qk(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(aHe&&r.ctrlKey&&r.altKey)&&(a=qd[r.keyCode])&&a!=i){let l=e[Qk(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var cHe=Object.defineProperty,tL=(t,e)=>{for(var n in e)cHe(t,n,{get:e[n],enumerable:!0})};function QM(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var ZM=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,m])=>[f,(...x)=>{const v=this.buildProps(c,e),b=m(...x)(v);return o.push(b),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:QM({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}},Mte={};tL(Mte,{blur:()=>uHe,clearContent:()=>dHe,clearNodes:()=>hHe,command:()=>fHe,createParagraphNear:()=>mHe,cut:()=>pHe,deleteCurrentNode:()=>gHe,deleteNode:()=>xHe,deleteRange:()=>bHe,deleteSelection:()=>yHe,enter:()=>vHe,exitCode:()=>_He,extendMarkRange:()=>wHe,first:()=>SHe,focus:()=>NHe,forEach:()=>EHe,insertContent:()=>AHe,insertContentAt:()=>kHe,joinBackward:()=>RHe,joinDown:()=>PHe,joinForward:()=>DHe,joinItemBackward:()=>OHe,joinItemForward:()=>LHe,joinTextblockBackward:()=>IHe,joinTextblockForward:()=>FHe,joinUp:()=>jHe,keyboardShortcut:()=>zHe,lift:()=>BHe,liftEmptyBlock:()=>$He,liftListItem:()=>HHe,newlineInCode:()=>VHe,resetAttributes:()=>GHe,scrollIntoView:()=>WHe,selectAll:()=>qHe,selectNodeBackward:()=>KHe,selectNodeForward:()=>XHe,selectParentNode:()=>YHe,selectTextblockEnd:()=>QHe,selectTextblockStart:()=>ZHe,setContent:()=>JHe,setMark:()=>xVe,setMeta:()=>bVe,setNode:()=>yVe,setNodeSelection:()=>vVe,setTextDirection:()=>_Ve,setTextSelection:()=>wVe,sinkListItem:()=>SVe,splitBlock:()=>MVe,splitListItem:()=>NVe,toggleList:()=>EVe,toggleMark:()=>AVe,toggleNode:()=>TVe,toggleWrap:()=>CVe,undoInputRule:()=>kVe,unsetAllMarks:()=>jVe,unsetMark:()=>PVe,unsetTextDirection:()=>RVe,updateAttributes:()=>DVe,wrapIn:()=>OVe,wrapInList:()=>LVe});var uHe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),dHe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),hHe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),m=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(m);if(!p)return;const x=Xg(p);if(l.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(x||x===0)&&e.lift(p,x)})}),!0},fHe=t=>e=>t(e),mHe=()=>({state:t,dispatch:e})=>Uee(t,e),pHe=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,a.content),r.setSelection(new en(r.doc.resolve(Math.max(o-1,0)))),!0},gHe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const l=i.before(a),c=i.after(a);t.delete(l,c).scrollIntoView()}return!0}return!1};function _i(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 xHe=t=>({tr:e,state:n,dispatch:r})=>{const i=_i(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const c=a.before(o),u=a.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},bHe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},yHe=()=>({state:t,dispatch:e})=>BO(t,e),vHe=()=>({commands:t})=>t.keyboardShortcut("Enter"),_He=()=>({state:t,dispatch:e})=>s6e(t,e);function nL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function US(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:nL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Nte(t,e,n={}){return t.find(r=>r.type===e&&US(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function sG(t,e,n={}){return!!Nte(t,e,n)}function rL(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),!Nte([...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&&sG([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&sG([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function pu(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var wHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=pu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=rL(c,a,e);if(f&&f.from<=u&&f.to>=d){const m=en.create(o,f.from,f.to);n.setSelection(m)}}return!0},SHe=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 Ete(t){return t instanceof en}function Zh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ate(t,e=null){if(!e)return null;const n=xn.atStart(t),r=xn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?en.create(t,Zh(0,i,a),Zh(t.content.size,i,a)):en.create(t,Zh(e,i,a),Zh(e,i,a))}function MHe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function iL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var NHe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(iL()||MHe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!Ete(n.state.selection))return o(),!0;const l=Ate(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return a&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},EHe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),AHe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Tte=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&&Tte(r)}return t};function x1(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 Tte(n)}function z0(t,e,n){if(t instanceof kd||t instanceof St)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 St.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),z0("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new hee({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?zb.fromSchema(c).parseSlice(x1(t),n.parseOptions):zb.fromSchema(c).parse(x1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=zb.fromSchema(e);return n.slice?a.parseSlice(x1(t),n.parseOptions).content:a.parse(x1(t),n.parseOptions)}return z0("",e,n)}function THe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ki||i instanceof Qi))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(xn.near(t.doc.resolve(o),n))}var CHe=t=>!("type"in t),kHe=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=b=>{a.emit("contentError",{editor:a,error:b,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{z0(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){c(b)}try{l=z0(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(b){return c(b),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,p=!0;if((CHe(l)?l:[l]).forEach(b=>{b.check(),m=m?b.isText&&b.marks.length===0:!1,p=p?b.isBlock:!1}),d===f&&p){const{parent:b}=r.doc.resolve(d);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(d-=1,f+=1)}let v;if(m){if(Array.isArray(e))v=e.map(b=>b.text||"").join("");else if(e instanceof St){let b="";e.forEach(y=>{y.text&&(b+=y.text)}),v=b}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else{v=l;const b=r.doc.resolve(d),y=b.node(),M=b.parentOffset===0,S=y.isText||y.isTextblock,A=y.content.size>0;M&&S&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,v)}n.updateSelection&&THe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},jHe=()=>({state:t,dispatch:e})=>r6e(t,e),PHe=()=>({state:t,dispatch:e})=>i6e(t,e),RHe=()=>({state:t,dispatch:e})=>Pee(t,e),DHe=()=>({state:t,dispatch:e})=>Lee(t,e),OHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=GM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},LHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=GM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},IHe=()=>({state:t,dispatch:e})=>t6e(t,e),FHe=()=>({state:t,dispatch:e})=>n6e(t,e);function Cte(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function UHe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))iL()||Cte()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var zHe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=UHe(t).split(/-(?!$)/),o=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Kd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?_i(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,m)=>{if(f.isText)return;const p=Math.max(r,m),x=Math.min(i,m+f.nodeSize);l.push({node:f,from:p,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>US(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var BHe=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return Kd(n,i,e)?a6e(n,r):!1},$He=()=>({state:t,dispatch:e})=>zee(t,e),HHe=t=>({state:e,dispatch:n})=>{const r=_i(t,e.schema);return x6e(r)(e,n)},VHe=()=>({state:t,dispatch:e})=>Fee(t,e);function JM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function oG(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 GHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=JM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=_i(t,r.schema)),l==="mark"&&(o=pu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,oG(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(m=>{o===m.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(oG(m.attrs,e))))})})}),c},WHe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),qHe=()=>({tr:t,dispatch:e})=>{if(e){const n=new $s(t.doc);t.setSelection(n)}return!0},KHe=()=>({state:t,dispatch:e})=>Dee(t,e),XHe=()=>({state:t,dispatch:e})=>Iee(t,e),YHe=()=>({state:t,dispatch:e})=>c6e(t,e),QHe=()=>({state:t,dispatch:e})=>h6e(t,e),ZHe=()=>({state:t,dispatch:e})=>d6e(t,e);function pR(t,e,n={},r={}){return z0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var JHe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:l})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=pR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function kte(t,e){const n=pu(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function jte(t,e){const n=new Tee(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function eVe(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 tVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function nVe(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 eN(t){return e=>nVe(e.$from,t)}function Gt(t,e,n){return t.config[e]===void 0&&t.parent?Gt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Gt(t.parent,e,n):null}):t.config[e]}function aL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Gt(e,"addExtensions",n);return r?[e,...aL(r())]:e}).flat(10)}function sL(t,e){const n=Yf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Pte(t){return typeof t=="function"}function Zn(t,e=void 0,...n){return Pte(t)?e?t.bind(e)(...n):t(...n):t}function rVe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Sg(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 Rte(t){const e=[],{nodeExtensions:n,markExtensions:r}=Sg(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=Gt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([m,p])=>{e.push({type:f,name:m,attribute:{...a,...p}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Gt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const m={...a,...f};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:o.name,name:d,attribute:m})})}),e}function ei(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const l=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),l.forEach(d=>{const[f,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function zS(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)=>ei(n,r),{})}function iVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function lG(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):iVe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function cG(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&rVe(n)?!1:n!=null))}function uG(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 aVe(t,e){var n;const r=Rte(t),{nodeExtensions:i,markExtensions:a}=Sg(t),o=(n=i.find(u=>Gt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((y,M)=>{const S=Gt(M,"extendNodeSchema",f);return{...y,...S?S(u):{}}},{}),p=cG({...m,content:Zn(Gt(u,"content",f)),marks:Zn(Gt(u,"marks",f)),group:Zn(Gt(u,"group",f)),inline:Zn(Gt(u,"inline",f)),atom:Zn(Gt(u,"atom",f)),selectable:Zn(Gt(u,"selectable",f)),draggable:Zn(Gt(u,"draggable",f)),code:Zn(Gt(u,"code",f)),whitespace:Zn(Gt(u,"whitespace",f)),linebreakReplacement:Zn(Gt(u,"linebreakReplacement",f)),defining:Zn(Gt(u,"defining",f)),isolating:Zn(Gt(u,"isolating",f)),attrs:Object.fromEntries(d.map(uG))}),x=Zn(Gt(u,"parseHTML",f));x&&(p.parseDOM=x.map(y=>lG(y,d)));const v=Gt(u,"renderHTML",f);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:zS(y,d)}));const b=Gt(u,"renderText",f);return b&&(p.toText=b),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((b,y)=>{const M=Gt(y,"extendMarkSchema",f);return{...b,...M?M(u):{}}},{}),p=cG({...m,inclusive:Zn(Gt(u,"inclusive",f)),excludes:Zn(Gt(u,"excludes",f)),group:Zn(Gt(u,"group",f)),spanning:Zn(Gt(u,"spanning",f)),code:Zn(Gt(u,"code",f)),attrs:Object.fromEntries(d.map(uG))}),x=Zn(Gt(u,"parseHTML",f));x&&(p.parseDOM=x.map(b=>lG(b,d)));const v=Gt(u,"renderHTML",f);return v&&(p.toDOM=b=>v({mark:b,HTMLAttributes:zS(b,d)})),[u.name,p]}));return new hee({topNode:o,nodes:l,marks:c})}function sVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function oL(t){return t.sort((n,r)=>{const i=Gt(n,"priority")||100,a=Gt(r,"priority")||100;return i>a?-1:i<a?1:0})}function Dte(t){const e=oL(aL(t)),n=sVe(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 Ote(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8150. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var m;c.isBlock&&u>r&&(l+=a);const p=o?.[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(m=c?.text)==null?void 0:m.slice(Math.max(r,u)-u,i-u))}),l}function oVe(t,e){const n={from:0,to:t.content.size};return Ote(t,n,e)}function Lte(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function lVe(t,e){const n=_i(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,l=>{a.push(l)});const o=a.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Ite(t,e){const n=JM(typeof e=="string"?e:e.name,t.schema);return n==="node"?lVe(t,e):n==="mark"?kte(t,e):{}}function cVe(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 uVe(t){const e=cVe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function Fte(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),m=e.invert().map(d);r.push({oldRange:{from:f,to:m},newRange:{from:u,to:d}})})}),uVe(r)}function lL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=rL(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var dVe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const l=i.node(a);l?.type.name===e?o=l:a-=1}return[o,a]};function Zk(t,e){return e.nodes[t]||e.marks[t]||null}function J1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var hVe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function gR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?pu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>US(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:m})=>{const p=f.pos,x=m.pos;t.doc.nodesBetween(p,x,(v,b)=>{if(!v.isText&&!v.marks.length)return;const y=Math.max(p,b),M=Math.min(x,b+v.nodeSize),S=M-y;o+=S,l.push(...v.marks.map(A=>({mark:A,from:y,to:M})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>US(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,m)=>f+m.to-m.from,0);return(c>0?c+u:c)>=o}function fVe(t,e,n={}){if(!e)return Kd(t,null,n)||gR(t,null,n);const r=JM(e,t.schema);return r==="node"?Kd(t,e,n):r==="mark"?gR(t,e,n):!1}var mVe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=eN(l=>l.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},pVe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function dG(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function hG(t,e){const{nodeExtensions:n}=Sg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Zn(Gt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function tN(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(tN(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Ute(t){return t instanceof Wt}function gVe(t,e,n){var r;const{selection:i}=e;let a=null;if(Ete(i)&&(a=i.$cursor),a){const l=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,m)=>{if(u)return!1;if(d.isInline){const p=!m||m.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=p&&x}return!u}),u})}var xVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=pu(t,r.schema);if(i)if(o){const u=kte(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(m,p)=>{const x=Math.max(p,d),v=Math.min(p+m.nodeSize,f);m.marks.find(y=>y.type===c)?m.marks.forEach(y=>{c===y.type&&n.addMark(x,v,c.create({...y.attrs,...e}))}):n.addMark(x,v,c.create(e))})});return gVe(r,n,c)},bVe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),yVe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=_i(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>E9(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>E9(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},vVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Zh(t,0,r.content.size),a=Wt.create(r,i);e.setSelection(a)}return!0},_Ve=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=a.from,l=a.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},wVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=en.atStart(r).from,l=en.atEnd(r).to,c=Zh(i,o,l),u=Zh(a,o,l),d=en.create(r,c,u);e.setSelection(d)}return!0},SVe=t=>({state:e,dispatch:n})=>{const r=_i(t,e.schema);return v6e(r)(e,n)};function fG(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 MVe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=J1(u,l.node().type.name,l.node().attrs);if(a instanceof Wt&&a.node.isBlock)return!l.parentOffset||!Yc(o,l.pos)?!1:(r&&(t&&fG(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:eVe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&m?[{type:m,attrs:d}]:void 0,x=Yc(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&Yc(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(x=!0,p=m?[{type:m,attrs:d}]:void 0),r){if(x&&(a instanceof en&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const v=e.mapping.map(l.before()),b=e.doc.resolve(v);l.node(-1).canReplaceWith(b.index(),b.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&fG(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},NVe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=_i(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const m=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let y=St.empty;const M=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-M;R>=c.depth-3;R-=1)y=St.from(c.node(R).copy(y));const S=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...J1(m,c.node().type.name,c.node().attrs),...e},E=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(A))||void 0;y=y.append(St.from(l.createAndFill(null,E)||void 0));const k=c.before(c.depth-(M-1));n.replace(k,c.after(-S),new Dt(y,4-M,0));let C=-1;n.doc.nodesBetween(k,n.doc.content.size,(R,T)=>{if(C>-1)return!1;R.isTextblock&&R.content.size===0&&(C=T+1)}),C>-1&&n.setSelection(en.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...J1(m,f.type.name,f.attrs),...e},v={...J1(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const b=p?[{type:l,attrs:x},{type:p,attrs:v}]:[{type:l,attrs:x}];if(!Yc(n.doc,c.pos,2))return!1;if(i){const{selection:y,storedMarks:M}=r,{splittableMarks:S}=a.extensionManager,A=M||y.$to.parentOffset&&y.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!A||!i)return!0;const E=A.filter(k=>S.includes(k.type.name));n.ensureMarks(E)}return!0},Jk=(t,e)=>{const n=eN(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&&eh(t.doc,n.pos)&&t.join(n.pos),!0},ej=(t,e)=>{const n=eN(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&&eh(t.doc,r)&&t.join(r),!0},EVe=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:m}=i.extensionManager,p=_i(t,o.schema),x=_i(e,o.schema),{selection:v,storedMarks:b}=o,{$from:y,$to:M}=v,S=y.blockRange(M),A=b||v.$to.parentOffset&&v.$from.marks();if(!S)return!1;const E=eN(k=>hG(k.type.name,f))(v);if(S.depth>=1&&E&&S.depth-E.depth<=1){if(E.node.type===p)return u.liftListItem(x);if(hG(E.node.type.name,f)&&p.validContent(E.node.content)&&l)return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>Jk(a,p)).command(()=>ej(a,p)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Jk(a,p)).command(()=>ej(a,p)).run():c().command(()=>{const k=d().wrapInList(p,r),C=A.filter(R=>m.includes(R.type.name));return a.ensureMarks(C),k?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Jk(a,p)).command(()=>ej(a,p)).run()},AVe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=pu(t,r.schema);return gR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},TVe=(t,e,n={})=>({state:r,commands:i})=>{const a=_i(t,r.schema),o=_i(e,r.schema),l=Kd(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(a,{...c,...n})},CVe=(t,e={})=>({state:n,commands:r})=>{const i=_i(t,n.schema);return Kd(n,i,e)?r.lift(i):r.wrapIn(i,e)},kVe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const o=t.tr,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(a.text){const c=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else o.delete(a.from,a.to)}return!0}}return!1},jVe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},PVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=pu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:m,to:p}=l;const x=(a=u.marks().find(b=>b.type===c))==null?void 0:a.attrs,v=rL(u,c,x);v&&(m=v.from,p=v.to),n.removeMark(m,p,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},RVe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=i.from,o=i.to),r&&e.doc.nodesBetween(a,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},DVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=JM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=_i(t,r.schema)),l==="mark"&&(o=pu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let m,p,x,v;n.selection.empty?r.doc.nodesBetween(d,f,(b,y)=>{a&&a===b.type&&(c=!0,x=Math.max(y,d),v=Math.min(y+b.nodeSize,f),m=y,p=b)}):r.doc.nodesBetween(d,f,(b,y)=>{y<d&&a&&a===b.type&&(c=!0,x=Math.max(y,d),v=Math.min(y+b.nodeSize,f),m=y,p=b),y>=d&&y<=f&&(a&&a===b.type&&(c=!0,i&&n.setNodeMarkup(y,void 0,{...b.attrs,...e})),o&&b.marks.length&&b.marks.forEach(M=>{if(o===M.type&&(c=!0,i)){const S=Math.max(y,d),A=Math.min(y+b.nodeSize,f);n.addMark(S,A,o.create({...M.attrs,...e}))}}))}),p&&(m!==void 0&&i&&n.setNodeMarkup(m,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(b=>{o===b.type&&i&&n.addMark(x,v,o.create({...b.attrs,...e}))}))}),c},OVe=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return f6e(i,e)(n,r)},LVe=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return m6e(i,e)(n,r)},IVe=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={}}},nN=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},FVe=(t,e)=>{if(nL(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 b1(t){var e;const{editor:n,from:r,to:i,text:a,rules:o,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(m=>m.type.spec.code))return!1;let d=!1;const f=hVe(u)+a;return o.forEach(m=>{if(d)return;const p=FVe(f,m.find);if(!p)return;const x=c.state.tr,v=QM({state:c.state,transaction:x}),b={from:r-(p[0].length-a.length),to:i},{commands:y,chain:M,can:S}=new ZM({editor:n,state:v});m.handler({state:v,range:b,match:p,commands:y,chain:M,can:S})===null||!x.steps.length||(m.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function UVe(t){const{editor:e,rules:n}=t,r=new Br({state:{init(){return null},apply(i,a,o){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=sL(St.from(d),o.schema);const{from:f}=c,m=f+d.length;b1({editor:e,from:f,to:m,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return b1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&b1({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?b1({editor:e,from:o.pos,to:o.pos,text:`
  8151. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function zVe(t){return Object.prototype.toString.call(t).slice(8,-1)}function y1(t){return zVe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function zte(t,e){const n={...t};return y1(t)&&y1(e)&&Object.keys(e).forEach(r=>{y1(e[r])&&y1(t[r])?n[r]=zte(t[r],e[r]):n[r]=e[r]}),n}var cL=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{...Zn(Gt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Zn(Gt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>zte(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}},nh=class Bte extends cL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Bte(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 BVe(t){return typeof t=="number"}var $Ve=class{constructor(t){this.find=t.find,this.handler=t.handler}},HVe=(t,e,n)=>{if(nL(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function VVe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new ZM({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,x)=>{var v,b,y,M,S;if((b=(v=p.type)==null?void 0:v.spec)!=null&&b.code||!(p.isText||p.isTextblock||p.isInline))return;const A=(S=(M=(y=p.content)==null?void 0:y.size)!=null?M:p.nodeSize)!=null?S:0,E=Math.max(r,x),k=Math.min(i,x+A);if(E>=k)return;const C=p.isText?p.text||"":p.textBetween(E-x,k-x,void 0,"");HVe(C,a.find,o).forEach(T=>{if(T.index===void 0)return;const P=E+T.index+1,F=P+T[0].length,I={from:n.tr.mapping.map(P),to:n.tr.mapping.map(F)},X=a.handler({state:n,range:I,match:T,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(X)})}),f.every(p=>p!==null)}var v1=null,GVe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function WVe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:m,rule:p,pasteEvt:x})=>{const v=d.tr,b=QM({state:d,transaction:v});if(!(!VVe({editor:e,state:b,from:Math.max(f-1,0),to:m.b-1,rule:p,pasteEvent:x,dropEvent:l})||!v.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new Br({view(f){const m=x=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(x.target)?f.dom.parentElement:null,r&&(v1=e)},p=()=>{v1&&(v1=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,m)=>{if(a=r===f.dom.parentElement,l=m,!a){const p=v1;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,m)=>{var p;const x=(p=m.clipboardData)==null?void 0:p.getData("text/html");return o=m,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,m,p)=>{const x=f[0],v=x.getMeta("uiEvent")==="paste"&&!i,b=x.getMeta("uiEvent")==="drop"&&!a,y=x.getMeta("applyPasteRules"),M=!!y;if(!v&&!b&&!M)return;if(M){let{text:E}=y;typeof E=="string"?E=E:E=sL(St.from(E),p.schema);const{from:k}=y,C=k+E.length,R=GVe(E);return c({rule:d,state:p,from:k,to:{b:C},pasteEvt:R})}const S=m.doc.content.findDiffStart(p.doc.content),A=m.doc.content.findDiffEnd(p.doc.content);if(!(!BVe(S)||!A||S===A.b))return c({rule:d,state:p,from:S,to:A,pasteEvt:o})}}))}var rN=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Dte(t),this.schema=aVe(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:Zk(e.name,this.schema)},r=Gt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return oL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Zk(r.name,this.schema)},a=[],o=Gt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Gt(r,"exitable",i)&&(l.ArrowRight=()=>nh.handleExit({editor:t,mark:r})),o){const m=Object.fromEntries(Object.entries(o()).map(([p,x])=>[p,()=>x({editor:t})]));l={...l,...m}}const c=lHe(l);a.push(c);const u=Gt(r,"addInputRules",i);if(dG(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const p=UVe({editor:t,rules:m}),x=Array.isArray(p)?p:[p];a.push(...x)}}const d=Gt(r,"addPasteRules",i);if(dG(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const p=WVe({editor:t,rules:m});a.push(...p)}}const f=Gt(r,"addProseMirrorPlugins",i);if(f){const m=f();a.push(...m)}return a})}get attributes(){return Rte(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Sg(this.extensions);return Object.fromEntries(e.filter(n=>!!Gt(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:_i(n.name,this.schema)},a=Gt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,m)=>{const p=zS(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:m,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Sg(this.extensions);return Object.fromEntries(e.filter(n=>!!Gt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pu(n.name,this.schema)},a=Gt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=zS(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{o7e(l,t,f)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Zk(e.name,this.schema)};e.type==="mark"&&((n=Zn(Gt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Gt(e,"onBeforeCreate",r),a=Gt(e,"onCreate",r),o=Gt(e,"onUpdate",r),l=Gt(e,"onSelectionUpdate",r),c=Gt(e,"onTransaction",r),u=Gt(e,"onFocus",r),d=Gt(e,"onBlur",r),f=Gt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};rN.resolve=Dte;rN.sort=oL;rN.flatten=aL;var qVe={};tL(qVe,{ClipboardTextSerializer:()=>Hte,Commands:()=>Vte,Delete:()=>Gte,Drop:()=>Wte,Editable:()=>qte,FocusEvents:()=>Xte,Keymap:()=>Yte,Paste:()=>Qte,Tabindex:()=>Zte,TextDirection:()=>Jte,focusEventsPluginKey:()=>Kte});var dr=class $te extends cL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new $te(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Hte=dr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Br({key:new Li("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(d=>d.$from.pos)),l=Math.max(...a.map(d=>d.$to.pos)),c=Lte(n);return Ote(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Vte=dr.create({name:"commands",addCommands(){return{...Mte}}}),Gte=dr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var o,l,c,u;if((u=(c=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=jte(t.before,[t,...e]);Fte(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,v)=>{const b=v+x.nodeSize-2,y=p.oldRange.from<=v&&b<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:v,to:b,newFrom:d.mapping.map(v),newTo:d.mapping.map(b),deletedRange:p.oldRange,newRange:p.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((p,x)=>{var v,b;if(p instanceof Qo){const y=m.slice(x).map(p.from,-1),M=m.slice(x).map(p.to),S=m.invert().map(y,-1),A=m.invert().map(M),E=(v=d.doc.nodeAt(y-1))==null?void 0:v.marks.some(C=>C.eq(p.mark)),k=(b=d.doc.nodeAt(M))==null?void 0:b.marks.some(C=>C.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:S,to:A},newRange:{from:y,to:M},partial:!!(k||E),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),Wte=dr.create({name:"drop",addProseMirrorPlugins(){return[new Br({key:new Li("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),qte=dr.create({name:"editable",addProseMirrorPlugins(){return[new Br({key:new Li("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Kte=new Li("focusEvents"),Xte=dr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Br({key:Kte,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}}}})]}}),Yte=dr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:m,parent:p}=f,x=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,v=x.parent.type.spec.isolating,b=f.pos-f.parentOffset,y=v&&x.parent.childCount===1?b===f.pos:xn.atStart(u).from===m;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return iL()||Cte()?a:i},addProseMirrorPlugins(){return[new Br({key:new Li("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=xn.atStart(e.doc).from,u=xn.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!tN(n.doc))return;const m=n.tr,p=QM({state:n,transaction:m}),{commands:x}=new ZM({editor:this.editor,state:p});if(x.clearNodes(),!!m.steps.length)return m}})]}}),Qte=dr.create({name:"paste",addProseMirrorPlugins(){return[new Br({key:new Li("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Zte=dr.create({name:"tabindex",addProseMirrorPlugins(){return[new Br({key:new Li("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Jte=dr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Sg(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 Br({key:new Li("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),KVe=class Mp{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 Mp(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 Mp(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 Mp(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+(a?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const c=new Mp(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Mp(l,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&a.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},XVe=`.ProseMirror {
  8152. position: relative;
  8153. }
  8154. .ProseMirror {
  8155. word-wrap: break-word;
  8156. white-space: pre-wrap;
  8157. white-space: break-spaces;
  8158. -webkit-font-variant-ligatures: none;
  8159. font-variant-ligatures: none;
  8160. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8161. }
  8162. .ProseMirror [contenteditable="false"] {
  8163. white-space: normal;
  8164. }
  8165. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8166. white-space: pre-wrap;
  8167. }
  8168. .ProseMirror pre {
  8169. white-space: pre-wrap;
  8170. }
  8171. img.ProseMirror-separator {
  8172. display: inline !important;
  8173. border: none !important;
  8174. margin: 0 !important;
  8175. width: 0 !important;
  8176. height: 0 !important;
  8177. }
  8178. .ProseMirror-gapcursor {
  8179. display: none;
  8180. pointer-events: none;
  8181. position: absolute;
  8182. margin: 0;
  8183. }
  8184. .ProseMirror-gapcursor:after {
  8185. content: "";
  8186. display: block;
  8187. position: absolute;
  8188. top: -2px;
  8189. width: 20px;
  8190. border-top: 1px solid black;
  8191. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8192. }
  8193. @keyframes ProseMirror-cursor-blink {
  8194. to {
  8195. visibility: hidden;
  8196. }
  8197. }
  8198. .ProseMirror-hideselection *::selection {
  8199. background: transparent;
  8200. }
  8201. .ProseMirror-hideselection *::-moz-selection {
  8202. background: transparent;
  8203. }
  8204. .ProseMirror-hideselection * {
  8205. caret-color: transparent;
  8206. }
  8207. .ProseMirror-focused .ProseMirror-gapcursor {
  8208. display: block;
  8209. }`;function YVe(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 QVe=class extends IVe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Ate(e,this.options.autofocus);this.editorState=Pp.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=YVe(XVe,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=Pte(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const a=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[qte,Hte.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Vte,Xte,Yte,Zte,Wte,Qte,Gte,Jte.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 rN(r,this)}createCommandManager(){this.commandManager=new ZM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=pR(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=pR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new wte(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Ite(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return fVe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return sL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8210. `,textSerializers:n={}}=t||{};return oVe(this.state.doc,{blockSeparator:e,textSerializers:{...Lte(this.schema),...n}})}get isEmpty(){return tN(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 KVe(e,this)}get $doc(){return this.$pos(0)}};function Mg(t){return new nN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Zn(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(lL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const m=n.from+c+o.length;a.addMark(n.from+c,m,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function ene(t){return new nN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Zn(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,o+r[0].length-1),a.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(o),a.mapping.map(l))}a.scrollIntoView()},undoable:t.undoable})}function xR(t){return new nN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Zn(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function Ng(t){return new nN({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Zn(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&UO(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:m}=e,{splittableMarks:p}=t.editor.extensionManager,x=m||f.$to.parentOffset&&f.$from.marks();if(x){const v=x.filter(b=>p.includes(b.type.name));o.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&eh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var ZVe=t=>"touches"in t,JVe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,ZVe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,o;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function e7e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Wt){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var t7e={};tL(t7e,{createAtomBlockMarkdownSpec:()=>n7e,createBlockMarkdownSpec:()=>r7e,createInlineMarkdownSpec:()=>s7e,parseAttributes:()=>uL,parseIndentedBlocks:()=>bR,renderNestedMarkdownContent:()=>hL,serializeAttributes:()=>dL});function uL(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const m=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[m];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function dL(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 n7e(t){const{nodeName:e,name:n,parseAttributes:r=uL,serializeAttributes:i=dL,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(m=>{m in d&&(f[m]=d[m])}),f};return{parseMarkdown:(d,f)=>{const m={...a,...d.attributes};return f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const m=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(m))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,m){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const v=x[1]||"",b=r(v);if(!o.find(M=>!(M in b)))return{type:e,raw:x[0],attributes:b}}},renderMarkdown:d=>{const f=u(d.attrs||{}),m=i(f),p=m?` {${m}}`:"";return`:::${c}${p} :::`}}}function r7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=uL,serializeAttributes:a=dL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const m={};return c.forEach(p=>{p in f&&(m[p]=f[p])}),m};return{parseMarkdown:(f,m)=>{let p;if(r){const v=r(f);p=typeof v=="string"?[{type:"text",text:v}]:v}else l==="block"?p=m.parseChildren(f.tokens||[]):p=m.parseInline(f.tokens||[]);const x={...o,...f.attributes};return m.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(f){var m;const p=new RegExp(`^:::${u}`,"m"),x=(m=f.match(p))==null?void 0:m.index;return x!==void 0?x:-1},tokenize(f,m,p){var x;const v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=f.match(v);if(!b)return;const[y,M=""]=b,S=i(M);let A=1;const E=y.length;let k="";const C=/^:::([\w-]*)(\s.*)?/gm,R=f.slice(E);for(C.lastIndex=0;;){const T=C.exec(R);if(T===null)break;const P=T.index,F=T[1];if(!((x=T[2])!=null&&x.endsWith(":::"))){if(F)A+=1;else if(A-=1,A===0){const I=R.slice(0,P);k=I.trim();const X=f.slice(0,E+P+T[0].length);let D=[];if(k)if(l==="block")for(D=p.blockTokens(I),D.forEach(K=>{K.text&&(!K.tokens||K.tokens.length===0)&&(K.tokens=p.inlineTokens(K.text))});D.length>0;){const K=D[D.length-1];if(K.type==="paragraph"&&(!K.text||K.text.trim()===""))D.pop();else break}else D=p.inlineTokens(k);return{type:e,raw:X,attributes:S,content:k,tokens:D}}}}}},renderMarkdown:(f,m)=>{const p=d(f.attrs||{}),x=a(p),v=x?` {${x}}`:"",b=m.renderChildren(f.content||[],`
  8211. `);return`:::${u}${v}
  8212. ${b}
  8213. :::`}}}function i7e(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function a7e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function s7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=i7e,serializeAttributes:a=a7e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=m=>{if(!c)return m;const p={};return c.forEach(x=>{x in m&&(p[x]=m[x])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,p)=>{const x={...o,...m.attributes};if(l)return p.createNode(e,x);const v=r?r(m):m.content||"";return v?p.createNode(e,x,[p.createTextNode(v)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(m){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=m.match(p),v=x?.index;return v!==void 0?v:-1},tokenize(m,p,x){const v=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),b=m.match(v);if(!b)return;let y="",M="";if(l){const[,A]=b;M=A}else{const[,A,E]=b;M=A,y=E||""}const S=i(M.trim());return{type:e,raw:b[0],content:y.trim(),attributes:S}}},renderMarkdown:m=>{let p="";r?p=r(m):m.content&&m.content.length>0&&(p=m.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const x=d(m.attrs||{}),v=a(x),b=v?` ${v}`:"";return l?`[${u}${b}]`:`[${u}${b}]${p}[/${u}]`}}}function bR(t,e,n){var r,i,a,o;const l=t.split(`
  8214. `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const m=l[d],p=m.match(e.itemPattern);if(!p){if(c.length>0)break;if(m.trim()===""){d+=1,u=`${u}${m}
  8215. `;continue}else return}const x=e.extractItemData(p),{indentLevel:v,mainContent:b}=x;u=`${u}${m}
  8216. `;const y=[b];for(d+=1;d<l.length;){const E=l[d];if(E.trim()===""){const C=l.slice(d+1).findIndex(P=>P.trim()!=="");if(C===-1)break;if((((i=(r=l[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){y.push(E),u=`${u}${E}
  8217. `,d+=1;continue}else break}if((((o=(a=E.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>v)y.push(E),u=`${u}${E}
  8218. `,d+=1;else break}let M;const S=y.slice(1);if(S.length>0){const E=S.map(k=>k.slice(v+f)).join(`
  8219. `);E.trim()&&(e.customNestedParser?M=e.customNestedParser(E):M=n.blockTokens(E))}const A=e.createToken(x,M);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function hL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
  8220. `).map(m=>m?e.indent(m):"").join(`
  8221. `);c.push(f)}}),c.join(`
  8222. `)}function o7e(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.descendants((l,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(p=>{if(p!==o)return!1;f=p}),!f)return;let m=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(m=!0)}),m){const p=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,p)}}),a.docChanged&&e.view.dispatch(a)}var bs=class tne extends cL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new tne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Bf(t){return new $Ve({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Zn(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),m=f+l.length;if(lL(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(b=>b===t.type&&b!==x.mark.type)).filter(x=>x.to>f).length)return null;m<n.to&&o.delete(m,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}var tj,mG;function l7e(){return mG||(mG=1,tj=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),tj}var c7e=l7e();const u7e=ko(c7e);var d7e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},h7e=({contentComponent:t})=>{const e=UR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function f7e(){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]:ile.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 m7e=class extends jr.Component{constructor(t){var e;super(t),this.editorContentRef=jr.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=f7e(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:d7e(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(h7e,{contentComponent:t.contentComponent})]})}},p7e=w.forwardRef((t,e)=>{const n=jr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return jr.createElement(m7e,{key:n,innerRef:e,...t})}),g7e=jr.memo(p7e),x7e=typeof window<"u"?w.useLayoutEffect:w.useEffect,b7e=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 y7e(t){var e;const[n]=w.useState(()=>new b7e(t.editor)),r=Gq.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:u7e);return x7e(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var v7e=!1,yR=typeof window>"u",_7e=yR||!!(typeof window<"u"&&window.next),w7e=class nne{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?yR||_7e?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new QVe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var o;return i===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?nne.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 S7e(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new w7e(n)),i=UR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),y7e({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var M7e=w.createContext({editor:null});M7e.Consumer;var N7e=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),E7e=()=>w.useContext(N7e);jr.forwardRef((t,e)=>{const{onDragStart:n}=E7e(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});jr.createContext({markViewContentRef:()=>{}});var BS=(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]},A7e=/^\s*>\s$/,T7e=bs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return BS("blockquote",{...ei(this.options.HTMLAttributes,t),children:BS("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(`
  8223. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8224. `))}),r.join(`
  8225. ${n}
  8226. `)},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[Ng({find:A7e,type:this.type})]}}),C7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,k7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,j7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,P7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,R7e=nh.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 BS("strong",{...ei(this.options.HTMLAttributes,t),children:BS("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[Mg({find:C7e,type:this.type}),Mg({find:j7e,type:this.type})]},addPasteRules(){return[Bf({find:k7e,type:this.type}),Bf({find:P7e,type:this.type})]}}),D7e=/(^|[^`])`([^`]+)`(?!`)$/,O7e=/(^|[^`])`([^`]+)`(?!`)/g,L7e=nh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",ei(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[Mg({find:D7e,type:this.type})]},addPasteRules(){return[Bf({find:O7e,type:this.type})]}}),nj=4,I7e=/^```([a-z]+)?[\s\n]$/,F7e=/^~~~([a-z]+)?[\s\n]$/,U7e=bs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:nj,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",ei(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(`
  8227. `):r=`\`\`\`${i}
  8228. \`\`\``,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:nj,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;if(a.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,p=r.doc.textBetween(u,d,`
  8229. `,`
  8230. `).split(`
  8231. `).map(x=>l+x).join(`
  8232. `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:nj,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;return a.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),p=r.doc.textBetween(d,f,`
  8233. `,`
  8234. `).split(`
  8235. `);let x=0,v=0;const b=u-d;for(let k=0;k<p.length;k+=1){if(v+p[k].length>=b){x=k;break}v+=p[k].length+1}const M=((c=p[x].match(/^ */))==null?void 0:c[0])||"",S=Math.min(M.length,n);if(S===0)return!0;let A=d;for(let k=0;k<x;k+=1)A+=p[k].length+1;return l.delete(A,A+S),u-A<=S&&l.setSelection(en.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
  8236. `,`
  8237. `).split(`
  8238. `).map(p=>{var x;const v=((x=p.match(/^ */))==null?void 0:x[0])||"",b=Math.min(v.length,n);return p.slice(b)}).join(`
  8239. `);return l.replaceWith(c,u,r.schema.text(m)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
  8240. `);return!a||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(xn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[xR({find:I7e,type:this.type,getAttributes:t=>({language:t[1]})}),xR({find:F7e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Br({key:new Li("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
  8241. `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(en.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),z7e=bs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8242. `):""}),B7e=bs.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",ei(this.options.HTMLAttributes,t)]},renderText(){return`
  8243. `},renderMarkdown:()=>`
  8244. `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const f=c.filter(m=>l.includes(m.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),$7e=bs.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]}`,ei(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}}))}}),H7e=bs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",ei(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!e7e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Ute(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(en.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Wt.create(o.doc,c.pos)):o.setSelection(en.create(o.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(o.insert(u,f),o.setSelection(en.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ene({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),V7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,G7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,W7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,q7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,K7e=nh.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",ei(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[Mg({find:V7e,type:this.type}),Mg({find:W7e,type:this.type})]},addPasteRules(){return[Bf({find:G7e,type:this.type}),Bf({find:q7e,type:this.type})]}});const X7e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Y7e="ελ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",vR="numeric",_R="ascii",wR="alpha",Vb="asciinumeric",Ab="alphanumeric",SR="domain",rne="emoji",Q7e="scheme",Z7e="slashscheme",rj="whitespace";function J7e(t,e){return t in e||(e[t]=[]),e[t]}function Jh(t,e,n){e[vR]&&(e[Vb]=!0,e[Ab]=!0),e[_R]&&(e[Vb]=!0,e[wR]=!0),e[Vb]&&(e[Ab]=!0),e[wR]&&(e[Ab]=!0),e[Ab]&&(e[SR]=!0),e[rne]&&(e[SR]=!0);for(const r in e){const i=J7e(r,n);i.indexOf(t)<0&&i.push(t)}}function e9e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ls(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ls.groups={};ls.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||ls.groups;let i;return e&&e.j?i=e:(i=new ls(e),n&&r&&Jh(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let o=0;o<a-1;o++)i=i.tt(t[o]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||ls.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let o,l=i.go(t);if(l?(o=new ls,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new ls,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(e9e(o.t,r),n);Jh(a,c,r)}else n&&Jh(a,n,r);o.t=a}return i.j[t]=o,o}};const hn=(t,e,n,r,i)=>t.ta(e,n,r,i),Wr=(t,e,n,r,i)=>t.tr(e,n,r,i),pG=(t,e,n,r,i)=>t.ts(e,n,r,i),At=(t,e,n,r,i)=>t.tt(e,n,r,i),kc="WORD",MR="UWORD",ine="ASCIINUMERICAL",ane="ALPHANUMERICAL",B0="LOCALHOST",NR="TLD",ER="UTLD",ew="SCHEME",Np="SLASH_SCHEME",fL="NUM",AR="WS",mL="NL",Gb="OPENBRACE",Wb="CLOSEBRACE",$S="OPENBRACKET",HS="CLOSEBRACKET",VS="OPENPAREN",GS="CLOSEPAREN",WS="OPENANGLEBRACKET",qS="CLOSEANGLEBRACKET",KS="FULLWIDTHLEFTPAREN",XS="FULLWIDTHRIGHTPAREN",YS="LEFTCORNERBRACKET",QS="RIGHTCORNERBRACKET",ZS="LEFTWHITECORNERBRACKET",JS="RIGHTWHITECORNERBRACKET",e2="FULLWIDTHLESSTHAN",t2="FULLWIDTHGREATERTHAN",n2="AMPERSAND",r2="APOSTROPHE",i2="ASTERISK",od="AT",a2="BACKSLASH",s2="BACKTICK",o2="CARET",fd="COLON",pL="COMMA",l2="DOLLAR",bl="DOT",c2="EQUALS",gL="EXCLAMATION",uo="HYPHEN",qb="PERCENT",u2="PIPE",d2="PLUS",h2="POUND",Kb="QUERY",xL="QUOTE",sne="FULLWIDTHMIDDLEDOT",bL="SEMI",yl="SLASH",Xb="TILDE",f2="UNDERSCORE",one="EMOJI",m2="SYM";var lne=Object.freeze({__proto__:null,ALPHANUMERICAL:ane,AMPERSAND:n2,APOSTROPHE:r2,ASCIINUMERICAL:ine,ASTERISK:i2,AT:od,BACKSLASH:a2,BACKTICK:s2,CARET:o2,CLOSEANGLEBRACKET:qS,CLOSEBRACE:Wb,CLOSEBRACKET:HS,CLOSEPAREN:GS,COLON:fd,COMMA:pL,DOLLAR:l2,DOT:bl,EMOJI:one,EQUALS:c2,EXCLAMATION:gL,FULLWIDTHGREATERTHAN:t2,FULLWIDTHLEFTPAREN:KS,FULLWIDTHLESSTHAN:e2,FULLWIDTHMIDDLEDOT:sne,FULLWIDTHRIGHTPAREN:XS,HYPHEN:uo,LEFTCORNERBRACKET:YS,LEFTWHITECORNERBRACKET:ZS,LOCALHOST:B0,NL:mL,NUM:fL,OPENANGLEBRACKET:WS,OPENBRACE:Gb,OPENBRACKET:$S,OPENPAREN:VS,PERCENT:qb,PIPE:u2,PLUS:d2,POUND:h2,QUERY:Kb,QUOTE:xL,RIGHTCORNERBRACKET:QS,RIGHTWHITECORNERBRACKET:JS,SCHEME:ew,SEMI:bL,SLASH:yl,SLASH_SCHEME:Np,SYM:m2,TILDE:Xb,TLD:NR,UNDERSCORE:f2,UTLD:ER,UWORD:MR,WORD:kc,WS:AR});const Ec=/[a-z]/,fb=new RegExp("\\p{L}","u"),ij=new RegExp("\\p{Emoji}","u"),Ac=/\d/,aj=/\s/,gG="\r",sj=`
  8245. `,t9e="️",n9e="‍",oj="";let _1=null,w1=null;function r9e(t=[]){const e={};ls.groups=e;const n=new ls;_1==null&&(_1=xG(X7e)),w1==null&&(w1=xG(Y7e)),At(n,"'",r2),At(n,"{",Gb),At(n,"}",Wb),At(n,"[",$S),At(n,"]",HS),At(n,"(",VS),At(n,")",GS),At(n,"<",WS),At(n,">",qS),At(n,"(",KS),At(n,")",XS),At(n,"「",YS),At(n,"」",QS),At(n,"『",ZS),At(n,"』",JS),At(n,"<",e2),At(n,">",t2),At(n,"&",n2),At(n,"*",i2),At(n,"@",od),At(n,"`",s2),At(n,"^",o2),At(n,":",fd),At(n,",",pL),At(n,"$",l2),At(n,".",bl),At(n,"=",c2),At(n,"!",gL),At(n,"-",uo),At(n,"%",qb),At(n,"|",u2),At(n,"+",d2),At(n,"#",h2),At(n,"?",Kb),At(n,'"',xL),At(n,"/",yl),At(n,";",bL),At(n,"~",Xb),At(n,"_",f2),At(n,"\\",a2),At(n,"・",sne);const r=Wr(n,Ac,fL,{[vR]:!0});Wr(r,Ac,r);const i=Wr(r,Ec,ine,{[Vb]:!0}),a=Wr(r,fb,ane,{[Ab]:!0}),o=Wr(n,Ec,kc,{[_R]:!0});Wr(o,Ac,i),Wr(o,Ec,o),Wr(i,Ac,i),Wr(i,Ec,i);const l=Wr(n,fb,MR,{[wR]:!0});Wr(l,Ec),Wr(l,Ac,a),Wr(l,fb,l),Wr(a,Ac,a),Wr(a,Ec),Wr(a,fb,a);const c=At(n,sj,mL,{[rj]:!0}),u=At(n,gG,AR,{[rj]:!0}),d=Wr(n,aj,AR,{[rj]:!0});At(n,oj,d),At(u,sj,c),At(u,oj,d),Wr(u,aj,d),At(d,gG),At(d,sj),Wr(d,aj,d),At(d,oj,d);const f=Wr(n,ij,one,{[rne]:!0});At(f,"#"),Wr(f,ij,f),At(f,t9e,f);const m=At(f,n9e);At(m,"#"),Wr(m,ij,f);const p=[[Ec,o],[Ac,i]],x=[[Ec,null],[fb,l],[Ac,a]];for(let v=0;v<_1.length;v++)Ju(n,_1[v],NR,kc,p);for(let v=0;v<w1.length;v++)Ju(n,w1[v],ER,MR,x);Jh(NR,{tld:!0,ascii:!0},e),Jh(ER,{utld:!0,alpha:!0},e),Ju(n,"file",ew,kc,p),Ju(n,"mailto",ew,kc,p),Ju(n,"http",Np,kc,p),Ju(n,"https",Np,kc,p),Ju(n,"ftp",Np,kc,p),Ju(n,"ftps",Np,kc,p),Jh(ew,{scheme:!0,ascii:!0},e),Jh(Np,{slashscheme:!0,ascii:!0},e),t=t.sort((v,b)=>v[0]>b[0]?1:-1);for(let v=0;v<t.length;v++){const b=t[v][0],M=t[v][1]?{[Q7e]:!0}:{[Z7e]:!0};b.indexOf("-")>=0?M[SR]=!0:Ec.test(b)?Ac.test(b)?M[Vb]=!0:M[_R]=!0:M[vR]=!0,pG(n,b,b,M)}return pG(n,"localhost",B0,{ascii:!0}),n.jd=new ls(m2),{start:n,tokens:Object.assign({groups:e},lne)}}function cne(t,e){const n=i9e(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,m=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,m=0,d=l):f>=0&&(f+=n[o].length,m++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=m,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function i9e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Ju(t,e,n,r,i){let a;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new ls(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new ls(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function xG(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const $0={defaultProtocol:"http",events:null,format:bG,formatHref:bG,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function yL(t,e=null){let n=Object.assign({},$0);t&&(n=Object.assign(n,t instanceof yL?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}yL.prototype={o:$0,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]:$0[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 bG(t){return t}function une(t,e){this.t="token",this.v=t,this.tk=e}une.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=$0.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),o={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:a,eventListeners:f}}};function iN(t,e){class n extends une{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const yG=iN("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),vG=iN("text"),a9e=iN("nl"),S1=iN("url",{isLink:!0,toHref(t=$0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==B0&&t[1].t===fd}}),oo=t=>new ls(t);function s9e({groups:t}){const e=t.domain.concat([n2,i2,od,a2,s2,o2,l2,c2,uo,fL,qb,u2,d2,h2,yl,m2,Xb,f2]),n=[r2,fd,pL,bl,gL,qb,Kb,xL,bL,WS,qS,Gb,Wb,HS,$S,VS,GS,KS,XS,YS,QS,ZS,JS,e2,t2],r=[n2,r2,i2,a2,s2,o2,l2,c2,uo,Gb,Wb,qb,u2,d2,h2,Kb,yl,m2,Xb,f2],i=oo(),a=At(i,Xb);hn(a,r,a),hn(a,t.domain,a);const o=oo(),l=oo(),c=oo();hn(i,t.domain,o),hn(i,t.scheme,l),hn(i,t.slashscheme,c),hn(o,r,a),hn(o,t.domain,o);const u=At(o,od);At(a,od,u),At(l,od,u),At(c,od,u);const d=At(a,bl);hn(d,r,a),hn(d,t.domain,a);const f=oo();hn(u,t.domain,f),hn(f,t.domain,f);const m=At(f,bl);hn(m,t.domain,f);const p=oo(yG);hn(m,t.tld,p),hn(m,t.utld,p),At(u,B0,p);const x=At(f,uo);At(x,uo,x),hn(x,t.domain,f),hn(p,t.domain,f),At(p,bl,m),At(p,uo,x);const v=At(p,fd);hn(v,t.numeric,yG);const b=At(o,uo),y=At(o,bl);At(b,uo,b),hn(b,t.domain,o),hn(y,r,a),hn(y,t.domain,o);const M=oo(S1);hn(y,t.tld,M),hn(y,t.utld,M),hn(M,t.domain,o),hn(M,r,a),At(M,bl,y),At(M,uo,b),At(M,od,u);const S=At(M,fd),A=oo(S1);hn(S,t.numeric,A);const E=oo(S1),k=oo();hn(E,e,E),hn(E,n,k),hn(k,e,E),hn(k,n,k),At(M,yl,E),At(A,yl,E);const C=At(l,fd),R=At(c,fd),T=At(R,yl),P=At(T,yl);hn(l,t.domain,o),At(l,bl,y),At(l,uo,b),hn(c,t.domain,o),At(c,bl,y),At(c,uo,b),hn(C,t.domain,E),At(C,yl,E),At(C,Kb,E),hn(P,t.domain,E),hn(P,e,E),At(P,yl,E);const F=[[Gb,Wb],[$S,HS],[VS,GS],[WS,qS],[KS,XS],[YS,QS],[ZS,JS],[e2,t2]];for(let I=0;I<F.length;I++){const[X,D]=F[I],K=At(E,X);At(k,X,K),At(K,D,E);const Y=oo(S1);hn(K,e,Y);const q=oo();hn(K,n),hn(Y,e,Y),hn(Y,n,q),hn(q,e,Y),hn(q,n,q),At(Y,D,E),At(q,D,E)}return At(i,B0,M),At(i,mL,a9e),{start:i,tokens:lne}}function o9e(t,e,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,m=-1;for(;i<r&&!(c=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(u=c||l.go(n[i].t));)c=null,l=u,l.accepts()?(m=0,f=l):m>=0&&m++,i++,d++;if(m<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(lj(vG,e,o)),o=[]),i-=m,d-=m;const p=f.t,x=n.slice(i-d,i);a.push(lj(p,e,x))}}return o.length>0&&a.push(lj(vG,e,o)),a}function lj(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const l9e=typeof console<"u"&&console&&console.warn||(()=>{}),c9e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Nr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function u9e(){return ls.groups={},Nr.scanner=null,Nr.parser=null,Nr.tokenQueue=[],Nr.pluginQueue=[],Nr.customSchemes=[],Nr.initialized=!1,Nr}function _G(t,e=!1){if(Nr.initialized&&l9e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${c9e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8246. 1. Must only contain digits, lowercase ASCII letters or "-"
  8247. 2. Cannot start or end with "-"
  8248. 3. "-" cannot repeat`);Nr.customSchemes.push([t,e])}function d9e(){Nr.scanner=r9e(Nr.customSchemes);for(let t=0;t<Nr.tokenQueue.length;t++)Nr.tokenQueue[t][1]({scanner:Nr.scanner});Nr.parser=s9e(Nr.scanner.tokens);for(let t=0;t<Nr.pluginQueue.length;t++)Nr.pluginQueue[t][1]({scanner:Nr.scanner,parser:Nr.parser});return Nr.initialized=!0,Nr}function vL(t){return Nr.initialized||d9e(),o9e(Nr.parser.start,t,cne(Nr.scanner.start,t))}vL.scan=cne;function dne(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 yL(n),i=vL(t),a=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var _L="[\0-   ᠎ -\u2029  ]",h9e=new RegExp(_L),f9e=new RegExp(`${_L}$`),m9e=new RegExp(_L,"g");function p9e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function g9e(t){return new Br({key:new Li("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,l=jte(n.doc,[...e]);if(Fte(l).forEach(({newRange:u})=>{const d=tVe(r.doc,u,p=>p.isTextblock);let f,m;if(d.length>1)f=d[0],m=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!f9e.test(p))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const p=m.split(h9e).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],v=f.pos+m.lastIndexOf(x);if(!x)return!1;const b=vL(x).map(y=>y.toObject(t.defaultProtocol));if(!p9e(b))return!1;b.filter(y=>y.isLink).map(y=>({...y,from:v+y.start+1,to:v+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{lL(y.from,y.to,r.doc).some(M=>M.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function x9e(t){return new Br({key:new Li("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;o=f.find(m=>m.nodeName==="A")}if(!o)return!1;const l=Ite(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(a=o?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function b9e(t){return new Br({key:new Li("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:o}=a,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=dne(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 kh(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(m9e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var hne=nh.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"){_G(t);return}_G(t.scheme,t.optionalSlashes)})},onDestroy(){u9e()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!kh(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!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=>!!kh(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!kh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ei(this.options.HTMLAttributes,t),0]:["a",ei(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!kh(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!kh(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Bf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=dne(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!kh(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(g9e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!kh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(x9e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(b9e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),y9e=hne,v9e=Object.defineProperty,_9e=(t,e)=>{for(var n in e)v9e(t,n,{get:e[n],enumerable:!0})},w9e="listItem",wG="textStyle",SG=/^\s*([-+*])\s$/,fne=bs.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",ei(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,`
  8249. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(w9e,this.editor.getAttributes(wG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ng({find:SG,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ng({find:SG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(wG),editor:this.editor})),[t]}}),mne=bs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",ei(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)=>hL(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)}}}),S9e={};_9e(S9e,{findListItemPos:()=>Py,getNextListDepth:()=>wL,handleBackspace:()=>TR,handleDelete:()=>CR,hasListBefore:()=>pne,hasListItemAfter:()=>M9e,hasListItemBefore:()=>gne,listItemHasSubList:()=>xne,nextListIsDeeper:()=>bne,nextListIsHigher:()=>yne});var Py=(t,e)=>{const{$from:n}=e.selection,r=_i(t,e.schema);let i=null,a=n.depth,o=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},wL=(t,e)=>{const n=Py(t,e);if(!n)return!1;const[,r]=dVe(e,t,n.$pos.pos+4);return r},pne=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},gne=(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)},xne=(t,e,n)=>{if(!n)return!1;const r=_i(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},TR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Kd(t.state,e)&&pne(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((m,p)=>{m.type.name===e&&u.push({node:m,pos:p})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Kd(t.state,e)||!pVe(t.state))return!1;const r=Py(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=xne(e,t.state,a);return gne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},bne=(t,e)=>{const n=wL(t,e),r=Py(t,e);return!r||!n?!1:n>r.depth},yne=(t,e)=>{const n=wL(t,e),r=Py(t,e);return!r||!n?!1:n<r.depth},CR=(t,e)=>{if(!Kd(t.state,e)||!mVe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:bne(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():yne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},M9e=(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)},vne=dr.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&&CR(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&&CR(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&&TR(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&&TR(t,n,r)&&(e=!0)}),e}}}}),MG=/^(\s*)(\d+)\.\s+(.*)$/,N9e=/^\s/;function E9e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(MG);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const m=[i];for(;f<t.length;){const p=t[f];if(p.match(MG))break;if(p.trim()==="")m.push(p),d+=`
  8250. `,f+=1;else if(p.match(N9e))m.push(p),d+=`
  8251. ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:m.join(`
  8252. `)}),r=f,n=f}return[e,r]}function _ne(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const o=t[a];if(o.indent===e){const l=o.content.split(`
  8253. `),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(`
  8254. `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=a+1;const m=[];for(;f<t.length&&t[f].indent>e;)m.push(t[f]),f+=1;if(m.length>0){const p=Math.min(...m.map(v=>v.indent)),x=_ne(m,p,n);u.push({type:"list",ordered:!0,start:m[0].number,items:x,raw:m.map(v=>v.raw).join(`
  8255. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function A9e(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var T9e="listItem",NG="textStyle",EG=/^(\d+)\.\s$/,wne=bs.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",ei(this.options.HTMLAttributes,n),0]:["ol",ei(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?A9e(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,`
  8256. `):"",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(`
  8257. `),[a,o]=E9e(i);if(a.length===0)return;const l=_ne(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
  8258. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(T9e,this.editor.getAttributes(NG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ng({find:EG,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=Ng({find:EG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(NG)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),C9e=/^\s*(\[([( |x])?\])\s$/,k9e=bs.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",ei(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 hL(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,m;l.ariaLabel=((m=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:m.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const p=n();if(typeof p!="number")return!1;const x=m.doc.nodeAt(p);return m.setNodeMarkup(p,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,o),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[Ng({find:C9e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),j9e=bs.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",ei(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,`
  8259. `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const o=bR(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(a)},i=bR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,o)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});dr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(fne.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(mne.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(vne.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(wne.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(k9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(j9e.configure(this.options.taskList)),t}});var P9e=bs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",ei(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()}}}),R9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,D9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,O9e=nh.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",ei(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[Mg({find:R9e,type:this.type})]},addPasteRules(){return[Bf({find:D9e,type:this.type})]}}),L9e=bs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Sne=nh.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",ei(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),I9e=Sne;function F9e(t={}){return new Br({view(e){return new U9e(e,t)}})}class U9e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,m=e.nodeAfter;if(f||m){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let x=p.getBoundingClientRect(),v=f?x.bottom:x.top;f&&m&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;r={left:x.left,right:x.right,top:v-b,bottom:v+b}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),m=f.width/c.offsetWidth,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*m,d=f.top-c.scrollTop*p}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=See(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 Xr extends xn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Xr.valid(r)?new Xr(r):xn.near(r)}content(){return Dt.empty}eq(e){return e instanceof Xr&&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 Xr(e.resolve(n.pos))}getBookmark(){return new SL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!z9e(e)||!B9e(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&&Xr.valid(e))return e;let i=e.pos,a=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){a=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let c=e.doc.resolve(i);if(Xr.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Wt.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,i+=n;let l=e.doc.resolve(i);if(Xr.valid(l))return l}return null}}}Xr.prototype.visible=!1;Xr.findFrom=Xr.findGapCursorFrom;xn.jsonID("gapcursor",Xr);class SL{constructor(e){this.pos=e}map(e){return new SL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Xr.valid(n)?new Xr(n):xn.near(n)}}function Mne(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function z9e(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||Mne(i.type))return!0;if(i.inlineContent)return!1}}return!0}function B9e(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||Mne(i.type))return!0;if(i.inlineContent)return!1}}return!0}function $9e(){return new Br({props:{decorations:W9e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Xr.valid(n)?new Xr(n):null},handleClick:V9e,handleKeyDown:H9e,handleDOMEvents:{beforeinput:G9e}}})}const H9e=Ste({ArrowLeft:M1("horiz",-1),ArrowRight:M1("horiz",1),ArrowUp:M1("vert",-1),ArrowDown:M1("vert",1)});function M1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof en){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Xr.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Xr(u))),!0):!1}}function V9e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Xr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Wt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Xr(r))),!0)}function G9e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Xr))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=St.empty;for(let o=r.length-1;o>=0;o--)i=St.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Dt(i,0,0));return a.setSelection(en.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function W9e(t){if(!(t.selection instanceof Xr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Or.create(t.doc,[Ba.widget(t.selection.head,e,{key:"gapcursor"})])}var p2=200,Zi=function(){};Zi.prototype.append=function(e){return e.length?(e=Zi.from(e),!this.length&&e||e.length<p2&&this.leafAppend(e)||this.length<p2&&e.leafPrepend(this)||this.appendInner(e)):this};Zi.prototype.prepend=function(e){return e.length?Zi.from(e).append(this):this};Zi.prototype.appendInner=function(e){return new q9e(this,e)};Zi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Zi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Zi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Zi.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)};Zi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};Zi.from=function(e){return e instanceof Zi?e:e&&e.length?new Nne(e):Zi.empty};var Nne=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,o,l){for(var c=a;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,o,l){for(var c=a-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=p2)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=p2)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})(Zi);Zi.empty=new Nne([]);var q9e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),o)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,o+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Zi);const K9e=500;class Ko{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,m)=>{if(!f.step){i||(i=this.remapping(r,m+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new vl(f.map));let p=f.step.map(i.slice(a)),x;p&&o.maybeStep(p).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new vl(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new Ko(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let a=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),m=new vl(e.mapping.maps[d],f,n),p;(p=c&&c.merge(m))&&(m=p,d?a.pop():l=l.slice(0,l.length-1)),a.push(m),n&&(o++,n=void 0),i||(c=m)}let u=o-r.depth;return u>Y9e&&(l=X9e(l,u),o-=u),new Ko(l.append(a),o)}remapping(e,n){let r=new O0;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ko(this.items.append(e.map(n=>new vl(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(m=>{m.selection&&l--},i);let c=n;this.items.forEach(m=>{let p=a.getMirror(--c);if(p==null)return;o=Math.min(o,p);let x=a.maps[p];if(m.step){let v=e.steps[p].invert(e.docs[p]),b=m.selection&&m.selection.map(a.slice(c+1,p));b&&l++,r.push(new vl(x,v,b))}else r.push(new vl(x))},i);let u=[];for(let m=n;m<o;m++)u.push(new vl(a.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new Ko(d,l);return f.emptyItemCount()>K9e&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&a++;else if(o.step){let c=o.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=o.selection&&o.selection.map(n.slice(r));d&&a++;let f=new vl(u.invert(),c,d),m,p=i.length-1;(m=i.length&&i[p].merge(f))?i[p]=m:i.push(f)}}else o.map&&r--},this.items.length,0),new Ko(Zi.from(i.reverse()),a)}}Ko.empty=new Ko(Zi.empty,0);function X9e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class vl{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 vl(n.getMap().invert(),n,this.selection)}}}class ld{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const Y9e=20;function Q9e(t,e,n,r){let i=n.getMeta(pf),a;if(i)return i.historyState;n.getMeta(eGe)&&(t=new ld(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(pf))return o.getMeta(pf).redo?new ld(t.done.addTransform(n,void 0,r,tw(e)),t.undone,AG(n.mapping.maps),t.prevTime,t.prevComposition):new ld(t.done,t.undone.addTransform(n,void 0,r,tw(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||!Z9e(n,t.prevRanges)),u=o?cj(t.prevRanges,n.mapping):AG(n.mapping.maps);return new ld(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,tw(e)),Ko.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new ld(t.done.rebased(n,a),t.undone.rebased(n,a),cj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ld(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),cj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Z9e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function AG(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function cj(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function J9e(t,e,n){let r=tw(e),i=pf.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new ld(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(pf,{redo:n,historyState:c})}let uj=!1,TG=null;function tw(t){let e=t.plugins;if(TG!=e){uj=!1,TG=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){uj=!0;break}}return uj}const pf=new Li("history"),eGe=new Li("closeHistory");function tGe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Br({key:pf,state:{init(){return new ld(Ko.empty,Ko.empty,null,0,-1)},apply(e,n,r){return Q9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Ane:r=="historyRedo"?Tne:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Ene(t,e){return(n,r)=>{let i=pf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=J9e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const Ane=Ene(!1,!0),Tne=Ene(!0,!0);dr.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 Br({key:new Li("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-i,l=0,c=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=a-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var nGe=dr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[F9e(this.options)]}});dr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Br({key:new Li("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Or.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";a.push(Ba.node(u,u+c.nodeSize,{class:this.options.className}))}),Or.create(t,a)}}})]}});var rGe=dr.create({name:"gapCursor",addProseMirrorPlugins(){return[$9e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Zn(Gt(t,"allowGapCursor",n)))!=null?e:null}}});dr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Br({key:new Li("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&tN(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ba.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Or.create(t,i)}}})]}});dr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Br({key:new Li("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Ute(n.selection)||t.view.dragging?null:Or.create(n.doc,[Ba.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function CG({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var iGe=dr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Li(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 Br({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,m=u.nodes[n];if(d)return c.insert(f,m.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!CG({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!CG({node:o,types:r})}}})]}}),aGe=dr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Ane(t,e),redo:()=>({state:t,dispatch:e})=>Tne(t,e)}},addProseMirrorPlugins(){return[tGe(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()}}}),sGe=dr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(R7e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(T7e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(fne.configure(this.options.bulletList)),this.options.code!==!1&&i.push(L7e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(U7e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(z7e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(nGe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(rGe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(B7e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push($7e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(aGe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(H7e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(K7e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(mne.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(vne.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(hne.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(wne.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(P9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(O9e.configure(this.options.strike)),this.options.text!==!1&&i.push(L9e.configure(this.options.text)),this.options.underline!==!1&&i.push(Sne.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(iGe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),oGe=sGe,lGe=dr.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")}}}),cGe=lGe,uGe=20,Cne=(t,e=0)=>{const n=[];return!t.children.length||e>uGe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Cne(r,e+1))}),n},dGe=t=>{if(!t.children.length)return;const e=Cne(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${a}`)})},kne=nh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&dGe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",ei(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),hGe=dr.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),jne=dr.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),fGe=dr.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()}}}),mGe=dr.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()}}}),pGe=dr.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()}}});dr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(hGe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(jne.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(fGe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(mGe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(pGe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(kne.configure(this.options.textStyle)),t}});var gGe=jne,xGe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,bGe=bs.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",ei(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(a=t.attrs)==null?void 0:a.title)!=null?o:"";return u?`![${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:a,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new JVe({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const m=a();m!==void 0&&this.editor.chain().setNodeSelection(m).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,m)=>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[ene({find:xGe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),yGe=bGe;function kR({content:t,onChange:e,placeholder:n}){const r=S7e({extensions:[oGe.configure({heading:!1,codeBlock:!1,code:!1}),I9e,y9e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),cGe.configure({types:["paragraph"]}),kne,gGe,yGe.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:o})=>{e(o.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:o,isActive:l=!1,children:c,title:u})=>s.jsx("button",{type:"button",onClick:o,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${l?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),a=()=>{const o=window.prompt("Enter URL:");o&&r.chain().focus().setLink({href:o}).run()};return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[s.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:s.jsx(Jle,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(zue,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(The,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:s.jsx(O2,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(WW,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:s.jsx(vhe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:s.jsx(ghe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:s.jsx(bhe,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:s.jsx(Y0,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(aD,{className:"w-4 h-4"})})]}),s.jsx(g7e,{editor:r})]})}function Pne({archiveId:t,archiveName:e,onClose:n}){const r=Qt(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:f,error:m}=lt({queryKey:["archive-project-page",t],queryFn:()=>pe.getArchiveProjectPage(t)}),p=ft({mutationFn:E=>pe.updateArchiveProjectPage(t,E),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});w.useEffect(()=>{const E=k=>{k.key==="Escape"&&(o!==null?l(null):i?y():n())};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],v=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},b=()=>{p.mutate(c)},y=()=>{a(!1),u({})},M=E=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(E,"text/html"),R=T=>{if(T.nodeType===Node.TEXT_NODE)return T.textContent||"";if(T.nodeType===Node.ELEMENT_NODE){const P=T,F=P.tagName.toLowerCase();if(!k.includes(F))return Array.from(P.childNodes).map(R).join("");let I="";if(F==="a"&&P.getAttribute("href")){const D=P.getAttribute("href");D?.toLowerCase().startsWith("http")&&(I=` href="${D}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const D=P.getAttribute("src");if(!D?.toLowerCase().startsWith("http"))return"";I=` src="${D}" style="max-width: 100%; height: auto;"`}const X=Array.from(P.childNodes).map(R).join("");return["br","img"].includes(F)?`<${F}${I} />`:`<${F}${I}>${X}</${F}>`}return""};return Array.from(C.body.childNodes).map(R).join("")},S=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=E=>{E.target===E.currentTarget&&n()};return s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ua,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&s.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&S&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:v,children:[s.jsx(_f,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:y,children:"Cancel"}),s.jsxs(Me,{variant:"primary",size:"sm",onClick:b,disabled:p.isPending,children:[s.jsx(cs,{className:"w-4 h-4 mr-1"}),"Save"]})]}),s.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ut,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),m&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!S&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Ua,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"No project page data found in this 3MF file."}),s.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&S&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange:E=>u({...c,title:E.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&s.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),s.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Gj,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:E=>u({...c,designer:E.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Gj,{className:"w-4 h-4"}),s.jsx("span",{children:d.designer}),d.designer_user_id&&s.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:s.jsx(Lr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Qr,{className:"w-4 h-4"}),s.jsx("span",{children:d.creation_date})]}),i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ua,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:E=>u({...c,license:E.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Ua,{className:"w-4 h-4"}),s.jsx("span",{children:d.license})]}),d.origin&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?s.jsx(kR,{content:c.description||"",onChange:E=>u({...c,description:E}),placeholder:"Enter description..."}):s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&s.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:c.profile_title||"",onChange:E=>u({...c,profile_title:E.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),s.jsx(kR,{content:c.profile_description||"",onChange:E=>u({...c,profile_description:E}),placeholder:"Profile description..."})]}):s.jsxs(s.Fragment,{children:[d.profile_title&&s.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(d.profile_description)}}),d.profile_user_name&&s.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[s.jsx(X0,{className:"w-4 h-4"}),"Images (",x.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((E,k)=>s.jsx("button",{onClick:()=>l(k),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:E.url,alt:E.name,className:"w-full h-full object-cover"})},E.path))})]}),d.design_model_id&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[s.jsx(Lr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[s.jsx("button",{onClick:E=>{E.stopPropagation(),l(Math.max(0,o-1))},disabled:o===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(yf,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:E=>E.stopPropagation()}),s.jsx("button",{onClick:E=>{E.stopPropagation(),l(Math.min(x.length-1,o+1))},disabled:o===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(Vs,{className:"w-6 h-6 text-white"})}),s.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:s.jsx(Ut,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const vGe=[.25,.5,.75,1,1.5,2,3,4];function gp(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function _Ge({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Un(),a=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[f,m]=w.useState(0),[p,x]=w.useState(0),[v,b]=w.useState(0),[y,M]=w.useState(1),[S,A]=w.useState(null),[E,k]=w.useState(null),[C,R]=w.useState(.8),[T,P]=w.useState(!1),{data:F,isLoading:I}=lt({queryKey:["timelapse-info",t],queryFn:()=>pe.getTimelapseInfo(t)}),{data:X}=lt({queryKey:["timelapse-thumbnails",t],queryFn:()=>pe.getTimelapseThumbnails(t,15)}),D=ft({mutationFn:()=>pe.processTimelapse(t,{trimStart:p,trimEnd:v,speed:y,saveMode:"replace"},S||void 0),onSuccess:U=>{i(U.message,"success"),r?.(),n()},onError:U=>{i(U.message||"Processing failed","error")}});w.useEffect(()=>{F?.duration&&v===0&&b(F.duration)},[F?.duration,v]),w.useEffect(()=>{const U=G=>{G.key==="Escape"&&n()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[n]),w.useEffect(()=>{const U=a.current;if(!U)return;const G=()=>{const de=U.currentTime;d(de),de>=v&&(U.currentTime=p)},ee=()=>{m(U.duration),v===0&&b(U.duration)},ne=()=>c(!0),se=()=>c(!1);return U.addEventListener("timeupdate",G),U.addEventListener("durationchange",ee),U.addEventListener("play",ne),U.addEventListener("pause",se),()=>{U.removeEventListener("timeupdate",G),U.removeEventListener("durationchange",ee),U.removeEventListener("play",ne),U.removeEventListener("pause",se)}},[p,v]),w.useEffect(()=>{const U=o.current,G=a.current;!U||!G||!E||(U.currentTime=G.currentTime,U.playbackRate=G.playbackRate,l&&!T?U.play().catch(()=>{}):U.pause())},[l,E,T]),w.useEffect(()=>{o.current&&(o.current.volume=T?0:C)},[C,T]),w.useEffect(()=>{a.current&&(a.current.playbackRate=y),o.current&&(o.current.playbackRate=y)},[y]);const K=w.useCallback(()=>{const U=a.current;U&&(l?U.pause():(U.currentTime<p&&(U.currentTime=p),U.play()))},[l,p]),Y=U=>{const G=a.current;G&&(G.currentTime=Math.max(p,Math.min(v,U)))},q=U=>{const G=U.target.files?.[0];G&&(E&&URL.revokeObjectURL(E),A(G),k(URL.createObjectURL(G)))},Z=()=>{E&&URL.revokeObjectURL(E),A(null),k(null)};w.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]);const re=v-p,ie=re/y;return I?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(pt,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Sd,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>D.mutate(),disabled:D.isPending,children:D.isPending?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(cs,{className:"w-4 h-4"}),"Save"]})}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Ut,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:K,muted:!!E}),!l&&s.jsx("button",{onClick:K,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:s.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:s.jsx(nl,{className:"w-8 h-8 text-white"})})}),E&&s.jsx("audio",{ref:o,src:E,loop:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Wde,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[gp(p)," - ",gp(v)," (",gp(re),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:X?.thumbnails.map((U,G)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${U})`}},G))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-v)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-v)/f*100}%`}}),s.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:p,onChange:U=>{const G=parseFloat(U.target.value);G<v-1&&(x(G),a.current&&a.current.currentTime<G&&(a.current.currentTime=G))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:v,onChange:U=>{const G=parseFloat(U.target.value);G>p+1&&b(G)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:U=>Y(parseFloat(U.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8260. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8261. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8262. [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:K,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(rD,{className:"w-5 h-5 text-white"}):s.jsx(nl,{className:"w-5 h-5 text-white"})})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(j2,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[y,"x (output: ",gp(ie),")"]})]}),s.jsx("div",{className:"flex gap-1",children:vGe.map(U=>s.jsxs("button",{onClick:()=>M(U),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${y===U?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[U,"x"]},U))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Vj,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),S?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(Vj,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:S.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(S.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>P(!T),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:T?s.jsx(Ihe,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Ohe,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:C,onChange:U=>R(parseFloat(U.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8263. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8264. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:Z,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(Jt,{className:"w-4 h-4 text-red-400"})})]}):s.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[s.jsx(bi,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:q,className:"hidden"})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Original:"})," ",gp(f)," @ ",F?.width,"x",F?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",gp(ie)," @ ",y,"x speed",S&&" + music overlay"]})]})]}),D.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(pt,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const wGe=[.25,.5,.75,1,1.5,2,3,4];function Rne({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=w.useRef(null),[l,c]=w.useState(!0),[u,d]=w.useState(1),[f,m]=w.useState(0),[p,x]=w.useState(0),[v,b]=w.useState(!1);w.useEffect(()=>{const C=o.current;C&&(C.playbackRate=u)},[u]),w.useEffect(()=>{const C=R=>{R.key==="Escape"&&i()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[i]),w.useEffect(()=>{const C=o.current;if(!C)return;const R=()=>m(C.currentTime),T=()=>x(C.duration),P=()=>c(!0),F=()=>c(!1);return C.addEventListener("timeupdate",R),C.addEventListener("durationchange",T),C.addEventListener("play",P),C.addEventListener("pause",F),()=>{C.removeEventListener("timeupdate",R),C.removeEventListener("durationchange",T),C.removeEventListener("play",P),C.removeEventListener("pause",F)}},[]);const y=()=>{const C=o.current;C&&(l?C.pause():C.play())},M=C=>{const R=o.current;R&&(R.currentTime=parseFloat(C.target.value))},S=()=>{const C=o.current;C&&(C.currentTime=Math.max(0,C.currentTime-5))},A=()=>{const C=o.current;C&&(C.currentTime=Math.min(p,C.currentTime+5))},E=C=>{const R=Math.floor(C/60),T=Math.floor(C%60);return`${R}:${T.toString().padStart(2,"0")}`},k=()=>{const C=document.createElement("a");C.href=t,C.download=n,C.click()};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Sd,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>b(!0),children:[s.jsx(Ha,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:k,children:[s.jsx(Jr,{className:"w-4 h-4"}),"Download"]}),s.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Ut,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:y}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:E(f)}),s.jsx("input",{type:"range",min:0,max:p||100,value:f,onChange:M,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8265. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8266. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8267. [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:E(p)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:S,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(rhe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:y,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(rD,{className:"w-5 h-5 text-white"}):s.jsx(nl,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:A,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(mw,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),s.jsx("div",{className:"flex gap-1",children:wGe.map(C=>s.jsxs("button",{onClick:()=>d(C),className:`px-2 py-1 text-xs rounded transition-colors ${u===C?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[C,"x"]},C))})]})]})]})]})]}),v&&r&&s.jsx(_Ge,{archiveId:r,timelapseSrc:t,onClose:()=>b(!1),onSave:a})]})}function SGe({archiveIds:t,onClose:e}){w.useEffect(()=>{const a=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=lt({queryKey:["archive-comparison",t],queryFn:()=>pe.compareArchives(t)});return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?s.jsxs("div",{className:"text-center py-12 text-red-400",children:[s.jsx(En,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"Failed to load comparison"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?s.jsx(MGe,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Me,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function MGe({comparison:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>s.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[s.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),s.jsx("div",{className:`text-xs ${e.status==="completed"?"text-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),s.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>s.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[s.jsx("td",{className:"py-2 pr-4 text-sm",children:s.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&s.jsx(En,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),s.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>s.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??s.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&s.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&s.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[s.jsx(En,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),s.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>s.jsxs("li",{children:[s.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&s.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[s.jsx(ps,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[s.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),s.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?s.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>s.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[s.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",s.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):s.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:s.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function NGe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function EGe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function AGe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=w.useState(!1),[c,u]=w.useState(t.tags||""),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.project_id),[x,v]=w.useState(!1);return s.jsx(wt,{children:s.jsxs(Mt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(tf,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:t.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx("span",{children:NGe(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Hn,{className:"w-3 h-3"}),EGe(t.uploaded_at)]}),t.source_ip&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?s.jsx(Jc,{className:"w-5 h-5"}):s.jsx(Ji,{className:"w-5 h-5"})}),s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Is,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:a,children:a?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jt,{className:"w-4 h-4 text-red-400"})})]})]}),x&&s.jsx(Rn,{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),v(!1)},onCancel:()=>v(!1)}),o&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.jsx("input",{type:"text",value:c,onChange:b=>u(b.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:b=>f(b.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.jsxs("select",{value:m||"",onChange:b=>p(b.target.value?Number(b.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[s.jsx("option",{value:"",children:"No project"}),e.map(b=>s.jsx("option",{value:b.id,children:b.name},b.id))]})]})]})]})})}function TGe(){const t=Qt(),{showToast:e}=Un(),[n,r]=w.useState(!1),[i,a]=w.useState(!1),[o,l]=w.useState(new Set),[c,u]=w.useState(new Set),{data:d,isLoading:f}=lt({queryKey:["pending-uploads"],queryFn:yp.list,refetchInterval:1e4}),{data:m}=lt({queryKey:["projects"],queryFn:()=>pe.getProjects()}),p=ft({mutationFn:({id:y,data:M})=>yp.archive(y,M),onMutate:({id:y})=>{l(M=>new Set(M).add(y))},onSettled:(y,M,{id:S})=>{l(A=>{const E=new Set(A);return E.delete(S),E})},onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${y.print_name}`)},onError:y=>{e(y.message||"Failed to archive","error")}}),x=ft({mutationFn:y=>yp.discard(y),onMutate:y=>{u(M=>new Set(M).add(y))},onSettled:(y,M,S)=>{u(A=>{const E=new Set(A);return E.delete(S),E})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:y=>{e(y.message||"Failed to discard","error")}}),v=ft({mutationFn:yp.archiveAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${y.archived} files${y.failed>0?`, ${y.failed} failed`:""}`)},onError:y=>{e(y.message||"Failed to archive all","error")}}),b=ft({mutationFn:yp.discardAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${y.discarded} files`)},onError:y=>{e(y.message||"Failed to discard all","error")}});return f?s.jsx(wt,{children:s.jsx(Mt,{className:"py-8 flex justify-center",children:s.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(wt,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bi,{className:"w-5 h-5 text-yellow-500"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:v.isPending,children:v.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Is,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:b.isPending,children:b.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Jt,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Mt,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"These files were uploaded via the virtual printer. Review and archive them to add to your collection."}),s.jsx("div",{className:"space-y-3",children:d.map(y=>s.jsx(AGe,{upload:y,projects:m||[],onArchive:(M,S)=>p.mutate({id:M,data:S}),onDiscard:M=>x.mutate(M),isArchiving:o.has(y.id),isDiscarding:c.has(y.id)},y.id))})]})]}),n&&s.jsx(Rn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{v.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.jsx(Rn,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{b.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function g2(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function mb(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function $h(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function CGe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:l="system"}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const c=Qt(),{showToast:u}=Un(),d=sq(),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[v,b]=w.useState(!1),[y,M]=w.useState(!1),[S,A]=w.useState(!1),[E,k]=w.useState(!1),[C,R]=w.useState([]),[T,P]=w.useState(!1),[F,I]=w.useState(!1),[X,D]=w.useState(!1),[K,Y]=w.useState(!1),[q,Z]=w.useState(!1),[re,ie]=w.useState(!1),[U,G]=w.useState(null),ee=w.useRef(null),ne=w.useRef(null),se=ft({mutationFn:V=>pe.uploadSource3mf(t.id,V),onSuccess:V=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${V.filename}`)},onError:V=>{u(V.message||"Failed to upload source 3MF","error")}}),de=ft({mutationFn:()=>pe.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:V=>{u(V.message||"Failed to remove source 3MF","error")}}),he=ft({mutationFn:V=>pe.uploadF3d(t.id,V),onSuccess:V=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${V.filename}`)},onError:V=>{u(V.message||"Failed to upload F3D","error")}}),Ee=ft({mutationFn:()=>pe.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:V=>{u(V.message||"Failed to remove F3D","error")}}),ge=ft({mutationFn:()=>pe.scanArchiveTimelapse(t.id),onSuccess:V=>{V.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${V.filename}`)):V.status==="exists"?u("Timelapse already attached"):V.status==="not_found"&&V.available_files&&V.available_files.length>0?(R(V.available_files),k(!0)):u(V.message||"No matching timelapse found","warning")},onError:V=>{u(V.message||"Failed to scan for timelapse","error")}}),Ne=ft({mutationFn:V=>pe.selectArchiveTimelapse(t.id,V),onSuccess:V=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${V.filename}`),k(!1),R([])},onError:V=>{u(V.message||"Failed to attach timelapse","error")}}),Re=ft({mutationFn:()=>pe.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),te=ft({mutationFn:()=>pe.toggleFavorite(t.id),onSuccess:V=>{c.invalidateQueries({queryKey:["archives"]}),u(V.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Je}=lt({queryKey:["archive-folders",t.id],queryFn:()=>pe.getLibraryFoldersByArchive(t.id)}),B=ft({mutationFn:V=>pe.updateArchive(t.id,{project_id:V}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),H=V=>{V.preventDefault(),G({x:V.clientX,y:V.clientY})},z=[...$h(t.filename)?[{label:"Print",icon:s.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>Y(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Lr,{className:"w-4 h-4"}),onClick:()=>{const V=t.print_name||t.filename||"model",Q=`${window.location.origin}${pe.getArchiveForSlicer(t.id,V)}`;Oc(Q)}}]:[{label:"Slice",icon:s.jsx(Lr,{className:"w-4 h-4"}),onClick:()=>{const V=t.print_name||t.filename||"model",Q=`${window.location.origin}${pe.getArchiveForSlicer(t.id,V)}`;Oc(Q)}}],{label:"View on MakerWorld",icon:s.jsx(Md,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Rs,{className:"w-4 h-4"}),onClick:()=>m(!0)},{label:"View Timelapse",icon:s.jsx(Sd,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(YW,{className:"w-4 h-4"}),onClick:()=>ge.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ge.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(uw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const V=document.createElement("a");V.href=pe.getSource3mfDownloadUrl(t.id),V.download=`${t.print_name||t.filename}_source.3mf`,V.click()}else ee.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(bi,{className:"w-4 h-4"}),onClick:()=>ee.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(Jt,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Rs,{className:"w-4 h-4"}),onClick:()=>ne.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>{const V=document.createElement("a");V.href=pe.getF3dDownloadUrl(t.id),V.download=`${t.print_name||t.filename}.f3d`,V.click()}},{label:"Remove F3D",icon:s.jsx(Jt,{className:"w-4 h-4"}),onClick:()=>ie(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>{const V=document.createElement("a");V.href=pe.getArchiveDownload(t.id),V.download=`${t.print_name||t.filename}.3mf`,V.click()}},{label:"Copy Download Link",icon:s.jsx(Gs,{className:"w-4 h-4"}),onClick:()=>{const V=`${window.location.origin}${pe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(V).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(XW,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(Xp,{className:"w-4 h-4"}),onClick:()=>I(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ua,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(wf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>te.mutate()},{label:"Edit",icon:s.jsx(Ha,{className:"w-4 h-4"}),onClick:()=>M(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(xa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(xa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const V=[];if(t.project_id&&V.push({label:"Remove from Project",icon:s.jsx(Ut,{className:"w-4 h-4"}),onClick:()=>B.mutate(null)}),!a)V.push({label:"Loading...",icon:s.jsx(pt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Q=a.filter(Te=>Te.status==="active");Q.length===0?V.push({label:"No projects available",icon:s.jsx(xa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Q.forEach(Te=>{V.push({label:Te.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Te.color||"#888"}}),onClick:()=>B.mutate(Te.id),disabled:t.project_id===Te.id})})}return V})()},{label:n?"Deselect":"Select",icon:n?s.jsx(eu,{className:"w-4 h-4"}):s.jsx(Ol,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(Jt,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0}];return s.jsxs(wt,{"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:H,onClick:i?()=>r(t.id):void 0,children:[i&&s.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:V=>{V.stopPropagation(),r(t.id)},children:n?s.jsx(eu,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Ol,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?s.jsx("img",{src:pe.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(X0,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),s.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${d?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:V=>{V.stopPropagation();const Q=V.currentTarget.getBoundingClientRect();G({x:Q.left,y:Q.bottom+4})},title:"Right-click for more options",children:s.jsx(wd,{className:"w-5 h-5 text-white"})}),s.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:V=>{V.stopPropagation(),te.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(wf,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&s.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&s.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[s.jsx(Gs,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&s.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:V=>{V.stopPropagation();const Q=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Te=`${window.location.origin}${pe.getSource3mfForSlicer(t.id,Q)}`;Oc(Te)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(uw,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&s.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:V=>{V.stopPropagation(),window.location.href=pe.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:s.jsx(Rs,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&s.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:V=>{V.stopPropagation(),A(!0)},title:"View timelapse",children:s.jsx(Sd,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:V=>{V.stopPropagation(),I(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(Xp,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&s.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]}),Je&&Je.length>0&&s.jsx(as,{to:`/files?folder=${Je[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:V=>V.stopPropagation(),title:`Open folder: ${Je[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(el,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Mt,{className:"p-4 flex-1 flex flex-col",children:[s.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:e}),s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${$h(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:$h(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:$h(t.filename)?"GCODE":"SOURCE"}),t.project_name&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(V=>V.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(V=>V.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${mb(t.print_time_seconds||0)}
  8268. Actual: ${mb(t.actual_time_seconds||0)}
  8269. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${mb(t.actual_time_seconds)}`:`Estimated: ${mb(t.print_time_seconds||0)}`,children:[s.jsx(Hn,{className:"w-3 h-3"}),mb(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&s.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Dl,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(tl,{className:"w-3 h-3"}),t.total_layers&&s.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&s.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`${t.object_count} object${t.object_count>1?"s":""}`,children:[s.jsx(Rs,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[s.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((V,Q)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:V},title:V},Q))})]})]}),(t.tags||t.notes)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&s.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:s.jsx(ZW,{className:"w-3 h-3"})}),t.tags?.split(",").map((V,Q)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:V.trim()},Q))]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[s.jsx("span",{children:eg(t.created_at,l)}),s.jsx("span",{children:g2(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[$h(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>x(!0),children:[s.jsx(Ir,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const V=t.print_name||t.filename||"model",Q=`${window.location.origin}${pe.getArchiveForSlicer(t.id,V)}`;Oc(Q)},title:"Open in Bambu Studio",children:s.jsx(Lr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const V=t.print_name||t.filename||"model",Q=`${window.location.origin}${pe.getArchiveForSlicer(t.id,V)}`;Oc(Q)},title:"Open in Bambu Studio to slice",children:[s.jsx(Lr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:s.jsx(Md,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"3D Preview",children:s.jsx(Rs,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const V=document.createElement("a");V.href=pe.getArchiveDownload(t.id),V.download=`${t.print_name||t.filename}.3mf`,V.click()},title:"Download",children:s.jsx(Jr,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>M(!0),title:"Edit",children:s.jsx(Ha,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Delete",children:s.jsx(Jt,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),y&&s.jsx(qJ,{archive:t,onClose:()=>M(!1)}),f&&s.jsx(HJ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),p&&s.jsx(Wd,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),v&&s.jsx(Rn,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{Re.mutate(),b(!1)},onCancel:()=>b(!1)}),q&&s.jsx(Rn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{de.mutate(),Z(!1)},onCancel:()=>Z(!1)}),re&&s.jsx(Rn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{Ee.mutate(),ie(!1)},onCancel:()=>ie(!1)}),U&&s.jsx(KJ,{x:U.x,y:U.y,items:z,onClose:()=>G(null)}),S&&t.timelapse_path&&s.jsx(Rne,{src:pe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>A(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),A(!1)}}),E&&C.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{k(!1),R([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(V=>s.jsxs("button",{onClick:()=>Ne.mutate(V.name),disabled:Ne.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[s.jsx(Sd,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:V.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[g2(V.size),V.mtime&&` • ${eg(V.mtime,l)}`]})]})]},V.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Me,{variant:"secondary",onClick:()=>{k(!1),R([])},className:"w-full",children:"Cancel"})})]})}),T&&s.jsx(XJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),F&&t.photos&&t.photos.length>0&&s.jsx(YJ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>I(!1),onDelete:async V=>{try{await pe.deleteArchivePhoto(t.id,V),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),X&&s.jsx(Pne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),K&&s.jsx(Wd,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Y(!1)}),s.jsx("input",{ref:ee,type:"file",accept:".3mf",className:"hidden",onChange:V=>{const Q=V.target.files?.[0];Q&&se.mutate(Q),V.target.value=""}}),s.jsx("input",{ref:ne,type:"file",accept:".f3d",className:"hidden",onChange:V=>{const Q=V.target.files?.[0];Q&&he.mutate(Q),V.target.value=""}})]})}function kGe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=Qt(),{showToast:c}=Un(),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[v,b]=w.useState(!1),[y,M]=w.useState(!1),[S,A]=w.useState(!1),[E,k]=w.useState(!1),[C,R]=w.useState([]),[T,P]=w.useState(!1),[F,I]=w.useState(!1),[X,D]=w.useState(!1),[K,Y]=w.useState(!1),[q,Z]=w.useState(!1),[re,ie]=w.useState(null),U=w.useRef(null),G=w.useRef(null),ee=ft({mutationFn:W=>pe.uploadSource3mf(t.id,W),onSuccess:W=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${W.filename}`)},onError:W=>{c(W.message||"Failed to upload source 3MF","error")}}),ne=ft({mutationFn:()=>pe.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:W=>{c(W.message||"Failed to remove source 3MF","error")}}),se=ft({mutationFn:W=>pe.uploadF3d(t.id,W),onSuccess:W=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${W.filename}`)},onError:W=>{c(W.message||"Failed to upload F3D","error")}}),de=ft({mutationFn:()=>pe.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:W=>{c(W.message||"Failed to remove F3D","error")}}),he=ft({mutationFn:()=>pe.scanArchiveTimelapse(t.id),onSuccess:W=>{W.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${W.filename}`)):W.status==="exists"?c("Timelapse already attached"):W.status==="not_found"&&W.available_files&&W.available_files.length>0?(R(W.available_files),k(!0)):c(W.message||"No matching timelapse found","warning")},onError:W=>{c(W.message||"Failed to scan for timelapse","error")}}),Ee=ft({mutationFn:W=>pe.selectArchiveTimelapse(t.id,W),onSuccess:W=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${W.filename}`),k(!1),R([])},onError:W=>{c(W.message||"Failed to attach timelapse","error")}}),ge=ft({mutationFn:()=>pe.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),Ne=ft({mutationFn:()=>pe.toggleFavorite(t.id),onSuccess:W=>{l.invalidateQueries({queryKey:["archives"]}),c(W.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Re}=lt({queryKey:["archive-folders",t.id],queryFn:()=>pe.getLibraryFoldersByArchive(t.id)}),te=ft({mutationFn:W=>pe.updateArchive(t.id,{project_id:W}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),Je=W=>{W.preventDefault(),ie({x:W.clientX,y:W.clientY})},H=[...$h(t.filename)?[{label:"Print",icon:s.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Lr,{className:"w-4 h-4"}),onClick:()=>{const W=t.print_name||t.filename||"model",z=`${window.location.origin}${pe.getArchiveForSlicer(t.id,W)}`;Oc(z)}}]:[{label:"Slice",icon:s.jsx(Lr,{className:"w-4 h-4"}),onClick:()=>{const W=t.print_name||t.filename||"model",z=`${window.location.origin}${pe.getArchiveForSlicer(t.id,W)}`;Oc(z)}}],{label:"View on MakerWorld",icon:s.jsx(Md,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Rs,{className:"w-4 h-4"}),onClick:()=>M(!0)},{label:"View Timelapse",icon:s.jsx(Sd,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(YW,{className:"w-4 h-4"}),onClick:()=>he.mutate(),disabled:!t.printer_id||!!t.timelapse_path||he.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(uw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const W=document.createElement("a");W.href=pe.getSource3mfDownloadUrl(t.id),W.download=`${t.print_name||t.filename}_source.3mf`,W.click()}else U.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(bi,{className:"w-4 h-4"}),onClick:()=>U.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(Jt,{className:"w-4 h-4"}),onClick:()=>Y(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Rs,{className:"w-4 h-4"}),onClick:()=>G.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>{const W=document.createElement("a");W.href=pe.getF3dDownloadUrl(t.id),W.download=`${t.print_name||t.filename}.f3d`,W.click()}},{label:"Remove F3D",icon:s.jsx(Jt,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>{const W=document.createElement("a");W.href=pe.getArchiveDownload(t.id),W.download=`${t.print_name||t.filename}.3mf`,W.click()}},{label:"Copy Download Link",icon:s.jsx(Gs,{className:"w-4 h-4"}),onClick:()=>{const W=`${window.location.origin}${pe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(W).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(XW,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(Xp,{className:"w-4 h-4"}),onClick:()=>I(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ua,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(wf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ne.mutate()},{label:"Edit",icon:s.jsx(Ha,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(xa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(xa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const W=[];if(t.project_id&&W.push({label:"Remove from Project",icon:s.jsx(Ut,{className:"w-4 h-4"}),onClick:()=>te.mutate(null)}),!a)W.push({label:"Loading...",icon:s.jsx(pt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const z=a.filter(V=>V.status==="active");z.length===0?W.push({label:"No projects available",icon:s.jsx(xa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):z.forEach(V=>{W.push({label:V.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:V.color||"#888"}}),onClick:()=>te.mutate(V.id),disabled:t.project_id===V.id})})}return W})()},{label:n?"Deselect":"Select",icon:n?s.jsx(eu,{className:"w-4 h-4"}):s.jsx(Ol,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(Jt,{className:"w-4 h-4"}),onClick:()=>m(!0),danger:!0}];return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-archive-id":t.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?"bg-bambu-green/10":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"-4px"}:void 0,onContextMenu:Je,children:[s.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&s.jsx("button",{onClick:()=>r(t.id),children:n?s.jsx(eu,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Ol,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:pe.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):s.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:s.jsx(X0,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),s.jsxs("div",{className:"col-span-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&s.jsx("span",{title:"Has timelapse",children:s.jsx(Sd,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),Re&&Re.length>0&&s.jsx(as,{to:`/files?folder=${Re[0].id}`,className:"flex-shrink-0",title:`Open folder: ${Re[0].name}`,onClick:W=>W.stopPropagation(),children:s.jsx(el,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((W,z)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:W},title:W},z))})]})]}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:Jp(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:g2(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const W=t.print_name||t.filename||"model",z=`${window.location.origin}${pe.getArchiveForSlicer(t.id,W)}`;Oc(z)},title:"Open in Bambu Studio",children:s.jsx(Lr,{className:"w-4 h-4"})}),t.makerworld_url&&s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>window.open(t.makerworld_url,"_blank"),title:"MakerWorld",children:s.jsx(Md,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const W=document.createElement("a");W.href=pe.getArchiveDownload(t.id),W.download=`${t.print_name||t.filename}.3mf`,W.click()},title:"Download",children:s.jsx(Jr,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(Ha,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>m(!0),title:"Delete",children:s.jsx(Jt,{className:"w-4 h-4 text-red-400"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:W=>{const z=W.currentTarget.getBoundingClientRect();ie({x:z.left,y:z.bottom+4})},title:"More options",children:s.jsx(wd,{className:"w-4 h-4"})})]})]}),u&&s.jsx(qJ,{archive:t,onClose:()=>d(!1)}),y&&s.jsx(HJ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>M(!1)}),p&&s.jsx(Wd,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),f&&s.jsx(Rn,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{ge.mutate(),m(!1)},onCancel:()=>m(!1)}),K&&s.jsx(Rn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{ne.mutate(),Y(!1)},onCancel:()=>Y(!1)}),q&&s.jsx(Rn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{de.mutate(),Z(!1)},onCancel:()=>Z(!1)}),re&&s.jsx(KJ,{x:re.x,y:re.y,items:H,onClose:()=>ie(null)}),S&&t.timelapse_path&&s.jsx(Rne,{src:pe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>A(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),A(!1)}}),E&&C.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{k(!1),R([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(W=>s.jsxs("button",{onClick:()=>Ee.mutate(W.name),disabled:Ee.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[s.jsx("div",{className:"font-medium text-white",children:W.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:g2(W.size)}),W.mtime&&s.jsx("span",{children:Jp(W.mtime)})]})]},W.name))})]})}),T&&s.jsx(XJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),F&&t.photos&&s.jsx(YJ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>I(!1),onDelete:async W=>{try{await pe.deleteArchivePhoto(t.id,W),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),X&&s.jsx(Pne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),v&&s.jsx(Wd,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),s.jsx("input",{ref:U,type:"file",accept:".3mf",className:"hidden",onChange:W=>{const z=W.target.files?.[0];z&&ee.mutate(z),W.target.value=""}}),s.jsx("input",{ref:G,type:"file",accept:".f3d",className:"hidden",onChange:W=>{const z=W.target.files?.[0];z&&se.mutate(z),W.target.value=""}})]})}const jGe=[{id:"all",label:"All Archives",icon:s.jsx(el,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(Hn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(Qr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(Qr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(wf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(ea,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(Gs,{className:"w-4 h-4"})}];function PGe(){const t=Qt(),{showToast:e}=Un(),n=w.useRef(null),[r,i]=w.useState(""),[a,o]=w.useState(()=>{const ae=localStorage.getItem("archiveFilterPrinter");return ae?Number(ae):null}),[l,c]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=w.useState(()=>{const ae=localStorage.getItem("archiveFilterColors");return ae?new Set(JSON.parse(ae)):new Set}),[f,m]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,x]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[v,b]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[y,M]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[S,A]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[E,k]=w.useState(!1),[C,R]=w.useState([]),[T,P]=w.useState(!1),[F,I]=w.useState(new Set),[X,D]=w.useState(!1),[K,Y]=w.useState(!1),[q,Z]=w.useState(!1),[re,ie]=w.useState(!1),[U,G]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ee,ne]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[se,de]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[he,Ee]=w.useState(!1),[ge,Ne]=w.useState(!1),[Re,te]=w.useState(!1),[Je,B]=w.useState(null);w.useEffect(()=>{if(Je){const ae=setTimeout(()=>{const ye=document.querySelector(`[data-archive-id="${Je}"]`);ye&&ye.scrollIntoView({behavior:"smooth",block:"center"})},100),$e=setTimeout(()=>B(null),5e3);return()=>{clearTimeout(ae),clearTimeout($e)}}},[Je]);const{data:H,isLoading:W}=lt({queryKey:["archives",a],queryFn:()=>pe.getArchives(a||void 0)}),{data:z}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:V}=lt({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:Q}=lt({queryKey:["settings"],queryFn:pe.getSettings}),Te=Q?.time_format||"system",ke=ft({mutationFn:async ae=>(await Promise.all(ae.map($e=>pe.deleteArchive($e))),ae.length),onSuccess:ae=>{t.invalidateQueries({queryKey:["archives"]}),I(new Set),e(`${ae} archive${ae!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});w.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),w.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",p.toString())},[p]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",v.toString())},[v]),w.useEffect(()=>{y?localStorage.setItem("archiveFilterTag",y):localStorage.removeItem("archiveFilterTag")},[y]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",S)},[S]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",U)},[U]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",ee)},[ee]),w.useEffect(()=>{localStorage.setItem("archiveCollection",se)},[se]);const Ae=new Map(z?.map(ae=>[ae.id,ae.name])||[]),$=[...new Set(H?.flatMap(ae=>ae.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),L=[...new Set(H?.flatMap(ae=>ae.filament_color?.split(",")||[]).filter(Boolean)||[])],oe=[...new Set(H?.flatMap(ae=>ae.tags?.split(",").map($e=>$e.trim())||[]).filter(Boolean)||[])].sort(),ce=H?.filter(ae=>{const $e=new Date,ye=mi(ae.created_at)||new Date(0);let Be=!0;switch(se){case"recent":Be=$e.getTime()-ye.getTime()<1440*60*1e3;break;case"this-week":Be=$e.getTime()-ye.getTime()<10080*60*1e3;break;case"this-month":Be=ye.getMonth()===$e.getMonth()&&ye.getFullYear()===$e.getFullYear();break;case"favorites":Be=ae.is_favorite===!0;break;case"failed":Be=ae.status==="failed"||ae.status==="aborted";break;case"duplicates":Be=ae.duplicate_count>0;break}const De=(ae.print_name||ae.filename).toLowerCase().includes(r.toLowerCase()),we=!l||ae.filament_type?.split(", ").includes(l),Ve=ae.filament_color?.split(",")||[],dt=u.size===0||(f==="or"?Ve.some(Kn=>u.has(Kn)):[...u].every(Kn=>Ve.includes(Kn))),Tt=se==="favorites"||!p||ae.is_favorite,Ct=se==="failed"||!v||ae.status!=="failed"&&ae.status!=="aborted",Xt=ae.tags?.split(",").map(Kn=>Kn.trim())||[],Pt=!y||Xt.includes(y),an=$h(ae.filename);return Be&&De&&we&&dt&&Tt&&Ct&&Pt&&(S==="all"||S==="gcode"&&an||S==="source"&&!an)}).sort((ae,$e)=>{switch(ee){case"date-desc":return(mi($e.created_at)?.getTime()||0)-(mi(ae.created_at)?.getTime()||0);case"date-asc":return(mi(ae.created_at)?.getTime()||0)-(mi($e.created_at)?.getTime()||0);case"name-asc":return(ae.print_name||ae.filename).localeCompare($e.print_name||$e.filename);case"name-desc":return($e.print_name||$e.filename).localeCompare(ae.print_name||ae.filename);case"size-desc":return $e.file_size-ae.file_size;case"size-asc":return ae.file_size-$e.file_size;default:return 0}}),xe=X||F.size>0,ve=ae=>{I($e=>{const ye=new Set($e);return ye.has(ae)?ye.delete(ae):ye.add(ae),ye})},_e=()=>{ce&&I(new Set(ce.map(ae=>ae.id)))},Ie=()=>{I(new Set),D(!1)},We=ae=>{d($e=>{const ye=new Set($e);return ye.has(ae)?ye.delete(ae):ye.add(ae),ye})},ht=()=>{d(new Set)},qe=()=>{i(""),o(null),c(null),x(!1),b(!1),M(null),A("all")},me=r||a||l||p||v||y||S!=="all",rt=w.useCallback(ae=>{ae.preventDefault(),ae.dataTransfer.types.includes("Files")&&P(!0)},[]),Xe=w.useCallback(ae=>{ae.preventDefault(),ae.currentTarget===ae.target&&P(!1)},[]),nt=w.useCallback(ae=>{ae.preventDefault(),P(!1);const $e=Array.from(ae.dataTransfer.files).filter(ye=>ye.name.endsWith(".3mf"));$e.length>0?(R($e),k(!0)):ae.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ut=w.useCallback(ae=>{const $e=ae.target;if($e.tagName==="INPUT"||$e.tagName==="TEXTAREA"||$e.isContentEditable){ae.key==="Escape"&&$e.blur();return}switch(ae.key){case"/":ae.preventDefault(),n.current?.focus();break;case"u":case"U":!ae.metaKey&&!ae.ctrlKey&&(ae.preventDefault(),k(!0));break;case"Escape":xe&&Ie();break}},[xe]);return w.useEffect(()=>(document.addEventListener("keydown",ut),()=>document.removeEventListener("keydown",ut)),[ut]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:rt,onDragLeave:Xe,onDrop:nt,children:[T&&s.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:s.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[s.jsx(bi,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),xe&&s.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ie,children:[s.jsx(Ut,{className:"w-4 h-4"}),"Close"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("span",{className:"text-white font-medium",children:[F.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:_e,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[s.jsx(Zp,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ie(!0),children:[s.jsx(xa,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>{const ae=Array.from(F);Promise.all(ae.map($e=>pe.toggleFavorite($e))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ae.length} archive${ae.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(wf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Me,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Y(!0),children:[s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),s.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:se,onChange:ae=>de(ae.target.value),children:jGe.map(ae=>s.jsx("option",{value:ae.id,children:ae.label},ae.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[ce?.length||0," of ",H?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Me,{variant:"secondary",onClick:()=>Ee(!he),disabled:ge,children:[ge?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(dw,{className:"w-4 h-4"}),"Export"]}),he&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{Ee(!1),Ne(!0);try{const{blob:ae,filename:$e}=await pe.exportArchives({format:"csv",printerId:a||void 0,status:se==="failed"?"failed":void 0,search:r||void 0}),ye=URL.createObjectURL(ae),Be=document.createElement("a");Be.href=ye,Be.download=$e,Be.click(),URL.revokeObjectURL(ye),e("Export downloaded")}catch{e("Export failed","error")}finally{Ne(!1)}},children:[s.jsx(Ua,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{Ee(!1),Ne(!0);try{const{blob:ae,filename:$e}=await pe.exportArchives({format:"xlsx",printerId:a||void 0,status:se==="failed"?"failed":void 0,search:r||void 0}),ye=URL.createObjectURL(ae),Be=document.createElement("a");Be.href=ye,Be.download=$e,Be.click(),URL.revokeObjectURL(ye),e("Export downloaded")}catch{e("Export failed","error")}finally{Ne(!1)}},children:[s.jsx(dw,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),F.size>=2&&F.size<=5&&s.jsxs(Me,{variant:"secondary",onClick:()=>te(!0),children:[s.jsx(Rp,{className:"w-4 h-4"}),"Compare (",F.size,")"]}),!xe&&s.jsxs(Me,{variant:"secondary",onClick:()=>D(!0),children:[s.jsx(eu,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Me,{onClick:()=>k(!0),children:[s.jsx(bi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(wt,{className:"mb-6",children:s.jsxs(Mt,{className:"py-4",children:[s.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[s.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[s.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:ae=>i(ae.target.value)})]}),s.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(k2,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:ae=>o(ae.target.value?Number(ae.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),z?.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Dl,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:l||"",onChange:ae=>c(ae.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),$.map(ae=>s.jsx("option",{value:ae,children:ae},ae))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(uw,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:S,onChange:ae=>A(ae.target.value),children:[s.jsx("option",{value:"all",children:"All Files"}),s.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),s.jsx("option",{value:"source",children:"Source Only"})]})]}),s.jsxs("button",{onClick:()=>x(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[s.jsx(wf,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>b(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:v?"Show failed prints":"Hide failed prints",children:[s.jsx(ea,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),oe.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Zp,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:y||"",onChange:ae=>M(ae.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),oe.map(ae=>s.jsx("option",{value:ae,children:ae},ae))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(zW,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:ee,onChange:ae=>ne(ae.target.value),children:[s.jsx("option",{value:"date-desc",children:"Newest first"}),s.jsx("option",{value:"date-asc",children:"Oldest first"}),s.jsx("option",{value:"name-asc",children:"Name A-Z"}),s.jsx("option",{value:"name-desc",children:"Name Z-A"}),s.jsx("option",{value:"size-desc",children:"Largest first"}),s.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),s.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[s.jsx("button",{className:`p-2 ${U==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("grid"),title:"Grid view",children:s.jsx(D2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${U==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("list"),title:"List view",children:s.jsx(O2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${U==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("calendar"),title:"Calendar view",children:s.jsx(uce,{className:"w-4 h-4"})})]})]}),me&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:qe,className:"text-bambu-gray hover:text-white",children:[s.jsx(Ut,{className:"w-4 h-4"}),"Reset"]})]}),L.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&s.jsx("button",{onClick:()=>m(ae=>ae==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:L.map(ae=>s.jsx("button",{onClick:()=>We(ae),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ae)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ae},title:ae},ae))}),u.size>0&&s.jsxs("button",{onClick:ht,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Ut,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(TGe,{}),W?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ce?.length===0?s.jsx(wt,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):U==="calendar"?s.jsx(wt,{className:"p-6",children:s.jsx(a8e,{archives:ce||[],onArchiveClick:ae=>{i(""),G("grid"),B(ae.id)},highlightedArchiveId:Je})}):U==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:ce?.map(ae=>s.jsx(CGe,{archive:ae,printerName:ae.printer_id?Ae.get(ae.printer_id)||"Unknown":"No Printer",isSelected:F.has(ae.id),onSelect:ve,selectionMode:xe,projects:V,isHighlighted:ae.id===Je,timeFormat:Te},ae.id))}):U==="list"?s.jsx(wt,{children:s.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"col-span-1"}),s.jsx("div",{className:"col-span-4",children:"Name"}),s.jsx("div",{className:"col-span-2",children:"Printer"}),s.jsx("div",{className:"col-span-2",children:"Date"}),s.jsx("div",{className:"col-span-1",children:"Size"}),s.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),ce?.map(ae=>s.jsx(kGe,{archive:ae,printerName:ae.printer_id?Ae.get(ae.printer_id)||"Unknown":"No Printer",isSelected:F.has(ae.id),onSelect:ve,selectionMode:xe,projects:V,isHighlighted:ae.id===Je},ae.id))]})}):null,E&&s.jsx(YBe,{onClose:()=>{k(!1),R([])},initialFiles:C}),K&&s.jsx(Rn,{title:"Delete Archives",message:`Are you sure you want to delete ${F.size} archive${F.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${F.size}`,variant:"danger",onConfirm:()=>{ke.mutate(Array.from(F)),Y(!1)},onCancel:()=>Y(!1)}),q&&s.jsx(JBe,{selectedIds:Array.from(F),existingTags:oe,onClose:()=>Z(!1)}),re&&s.jsx(e8e,{selectedIds:Array.from(F),onClose:()=>ie(!1)}),Re&&F.size>=2&&F.size<=5&&s.jsx(SGe,{archiveIds:Array.from(F),onClose:()=>{te(!1),I(new Set),D(!1)}})]})}function RGe(){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 aN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Yg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function ML(t){return"nodeType"in t}function ys(t){var e,n;return t?Yg(t)?t:ML(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function NL(t){const{Document:e}=ys(t);return t instanceof e}function Ry(t){return Yg(t)?!1:t instanceof ys(t).HTMLElement}function Dne(t){return t instanceof ys(t).SVGElement}function Qg(t){return t?Yg(t)?t.document:ML(t)?NL(t)?t:Ry(t)||Dne(t)?t.ownerDocument:document:document:document}const Vl=aN?w.useLayoutEffect:w.useEffect;function EL(t){const e=w.useRef(t);return Vl(()=>{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 DGe(){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 H0(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return Vl(()=>{n.current!==t&&(n.current=t)},e),n}function Dy(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function x2(t){const e=EL(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function jR(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let dj={};function Oy(t,e){return w.useMemo(()=>{if(e)return e;const n=dj[t]==null?0:dj[t]+1;return dj[t]=n,t+"-"+n},[t,e])}function One(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const qp=One(1),V0=One(-1);function OGe(t){return"clientX"in t&&"clientY"in t}function AL(t){if(!t)return!1;const{KeyboardEvent:e}=ys(t.target);return e&&t instanceof e}function LGe(t){if(!t)return!1;const{TouchEvent:e}=ys(t.target);return e&&t instanceof e}function PR(t){if(LGe(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 OGe(t)?{x:t.clientX,y:t.clientY}:null}const Eg=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[Eg.Translate.toString(t),Eg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),kG="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function IGe(t){return t.matches(kG)?t:t.querySelector(kG)}const FGe={display:"none"};function UGe(t){let{id:e,value:n}=t;return jr.createElement("div",{id:e,style:FGe},n)}function zGe(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 jr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function BGe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Lne=w.createContext(null);function $Ge(t){const e=w.useContext(Lne);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function HGe(){const[t]=w.useState(()=>new Set),e=w.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[w.useCallback(r=>{let{type:i,event:a}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,a)})},[t]),e]}const VGe={draggable:`
  8270. To pick up a draggable item, press the space bar.
  8271. While dragging, use the arrow keys to move the item.
  8272. Press space again to drop the item in its new position, or press escape to cancel.
  8273. `},GGe={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 WGe(t){let{announcements:e=GGe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=VGe}=t;const{announce:a,announcement:o}=BGe(),l=Oy("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),$Ge(w.useMemo(()=>({onDragStart(f){let{active:m}=f;a(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:p}=f;e.onDragMove&&a(e.onDragMove({active:m,over:p}))},onDragOver(f){let{active:m,over:p}=f;a(e.onDragOver({active:m,over:p}))},onDragEnd(f){let{active:m,over:p}=f;a(e.onDragEnd({active:m,over:p}))},onDragCancel(f){let{active:m,over:p}=f;a(e.onDragCancel({active:m,over:p}))}}),[a,e])),!c)return null;const d=jr.createElement(jr.Fragment,null,jr.createElement(UGe,{id:r,value:i.draggable}),jr.createElement(zGe,{id:l,announcement:o}));return n?Ic.createPortal(d,n):d}var Ei;(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"})(Ei||(Ei={}));function b2(){}function y2(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Ine(){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 il=Object.freeze({x:0,y:0});function Fne(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Une(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function qGe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function jG(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 zne(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function PG(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 Bne=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=PG(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Fne(PG(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(Une)},KGe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=jG(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=jG(c),d=i.reduce((m,p,x)=>m+Fne(u[x],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(Une)};function XGe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=o*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const YGe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=XGe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(qGe)};function QGe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function $ne(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:il}function ZGe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const JGe=ZGe(1);function eWe(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 tWe(t,e,n){const r=eWe(e);if(!r)return t;const{scaleX:i,scaleY:a,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const nWe={ignoreTransform:!1};function Zg(t,e){e===void 0&&(e=nWe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=ys(t).getComputedStyle(t);u&&(n=tWe(n,u,d))}const{top:r,left:i,width:a,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:l,right:c}}function RG(t){return Zg(t,{ignoreTransform:!0})}function rWe(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=ys(t).getComputedStyle(t)),e.position==="fixed"}function aWe(t,e){e===void 0&&(e=ys(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function sN(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(NL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ry(i)||Dne(i)||n.includes(i))return n;const a=ys(t).getComputedStyle(i);return i!==t&&aWe(i,a)&&n.push(i),iWe(i,a)?n:r(i.parentNode)}return t?r(t):n}function Hne(t){const[e]=sN(t,1);return e??null}function hj(t){return!aN||!t?null:Yg(t)?t:ML(t)?NL(t)||t===Qg(t).scrollingElement?window:Ry(t)?t:null:null}function Vne(t){return Yg(t)?t.scrollX:t.scrollLeft}function Gne(t){return Yg(t)?t.scrollY:t.scrollTop}function RR(t){return{x:Vne(t),y:Gne(t)}}var Wi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Wi||(Wi={}));function Wne(t){return!aN||!t?!1:t===document.scrollingElement}function qne(t){const e={x:0,y:0},n=Wne(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const sWe={x:.2,y:.2};function oWe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=sWe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=qne(t),p={x:0,y:0},x={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+v.height?(p.y=Wi.Backward,x.y=r*Math.abs((e.top+v.height-a)/v.height)):!d&&c>=e.bottom-v.height&&(p.y=Wi.Forward,x.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!m&&l>=e.right-v.width?(p.x=Wi.Forward,x.x=r*Math.abs((e.right-v.width-l)/v.width)):!f&&o<=e.left+v.width&&(p.x=Wi.Backward,x.x=r*Math.abs((e.left+v.width-o)/v.width)),{direction:p,speed:x}}function lWe(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:o}=window;return{top:0,left:0,right:a,bottom:o,width:a,height:o}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function Kne(t){return t.reduce((e,n)=>qp(e,RR(n)),il)}function cWe(t){return t.reduce((e,n)=>e+Vne(n),0)}function uWe(t){return t.reduce((e,n)=>e+Gne(n),0)}function dWe(t,e){if(e===void 0&&(e=Zg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Hne(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const hWe=[["x",["left","right"],cWe],["y",["top","bottom"],uWe]];class TL{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=sN(n),i=Kne(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of hWe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Yb{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 fWe(t){const{EventTarget:e}=ys(t);return t instanceof e?t:Qg(t)}function fj(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 po;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(po||(po={}));function DG(t){t.preventDefault()}function mWe(t){t.stopPropagation()}var Pn;(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"})(Pn||(Pn={}));const Xne={start:[Pn.Space,Pn.Enter],cancel:[Pn.Esc],end:[Pn.Space,Pn.Enter,Pn.Tab]},pWe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Pn.Right:return{...n,x:n.x+25};case Pn.Left:return{...n,x:n.x-25};case Pn.Down:return{...n,y:n.y+25};case Pn.Up:return{...n,y:n.y-25}}};class oN{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 Yb(Qg(n)),this.windowListeners=new Yb(ys(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(po.Resize,this.handleCancel),this.windowListeners.add(po.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(po.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&dWe(r),n(il)}handleKeyDown(e){if(AL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Xne,coordinateGetter:o=pWe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:il;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=V0(f,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const v of x){const b=e.code,{isTop:y,isRight:M,isLeft:S,isBottom:A,maxScroll:E,minScroll:k}=qne(v),C=lWe(v),R={x:Math.min(b===Pn.Right?C.right-C.width/2:C.right,Math.max(b===Pn.Right?C.left:C.left+C.width/2,f.x)),y:Math.min(b===Pn.Down?C.bottom-C.height/2:C.bottom,Math.max(b===Pn.Down?C.top:C.top+C.height/2,f.y))},T=b===Pn.Right&&!M||b===Pn.Left&&!S,P=b===Pn.Down&&!A||b===Pn.Up&&!y;if(T&&R.x!==f.x){const F=v.scrollLeft+m.x,I=b===Pn.Right&&F<=E.x||b===Pn.Left&&F>=k.x;if(I&&!m.y){v.scrollTo({left:F,behavior:l});return}I?p.x=v.scrollLeft-F:p.x=b===Pn.Right?v.scrollLeft-E.x:v.scrollLeft-k.x,p.x&&v.scrollBy({left:-p.x,behavior:l});break}else if(P&&R.y!==f.y){const F=v.scrollTop+m.y,I=b===Pn.Down&&F<=E.y||b===Pn.Up&&F>=k.y;if(I&&!m.x){v.scrollTo({top:F,behavior:l});return}I?p.y=v.scrollTop-F:p.y=b===Pn.Down?v.scrollTop-E.y:v.scrollTop-k.y,p.y&&v.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,qp(V0(f,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}oN.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Xne,onActivation:i}=e,{active:a}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function OG(t){return!!(t&&"distance"in t)}function LG(t){return!!(t&&"delay"in t)}class CL{constructor(e,n,r){var i;r===void 0&&(r=fWe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:o}=a;this.props=e,this.events=n,this.document=Qg(o),this.documentListeners=new Yb(this.document),this.listeners=new Yb(r),this.windowListeners=new Yb(ys(o)),this.initialCoordinates=(i=PR(a))!=null?i:il,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(po.Resize,this.handleCancel),this.windowListeners.add(po.DragStart,DG),this.windowListeners.add(po.VisibilityChange,this.handleCancel),this.windowListeners.add(po.ContextMenu,DG),this.documentListeners.add(po.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(LG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(OG(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(po.Click,mWe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(po.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=PR(e))!=null?n:il,u=V0(i,c);if(!r&&l){if(OG(l)){if(l.tolerance!=null&&fj(u,l.tolerance))return this.handleCancel();if(fj(u,l.distance))return this.handleStart()}if(LG(l)&&fj(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===Pn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const gWe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class lN extends CL{constructor(e){const{event:n}=e,r=Qg(n.target);super(e,gWe,r)}}lN.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 xWe={move:{name:"mousemove"},end:{name:"mouseup"}};var DR;(function(t){t[t.RightClick=2]="RightClick"})(DR||(DR={}));class bWe extends CL{constructor(e){super(e,xWe,Qg(e.event.target))}}bWe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===DR.RightClick?!1:(r?.({event:n}),!0)}}];const mj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class yWe extends CL{constructor(e){super(e,mj)}static setup(){return window.addEventListener(mj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(mj.move.name,e)};function e(){}}}yWe.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 Qb;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Qb||(Qb={}));var v2;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(v2||(v2={}));function vWe(t){let{acceleration:e,activator:n=Qb.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=v2.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const p=wWe({delta:f,disabled:!a}),[x,v]=DGe(),b=w.useRef({x:0,y:0}),y=w.useRef({x:0,y:0}),M=w.useMemo(()=>{switch(n){case Qb.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Qb.DraggableRect:return i}},[n,i,c]),S=w.useRef(null),A=w.useCallback(()=>{const k=S.current;if(!k)return;const C=b.current.x*y.current.x,R=b.current.y*y.current.y;k.scrollBy(C,R)},[]),E=w.useMemo(()=>l===v2.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!a||!u.length||!M){v();return}for(const k of E){if(r?.(k)===!1)continue;const C=u.indexOf(k),R=d[C];if(!R)continue;const{direction:T,speed:P}=oWe(k,R,M,e,m);for(const F of["x","y"])p[F][T[F]]||(P[F]=0,T[F]=0);if(P.x>0||P.y>0){v(),S.current=k,x(A,o),b.current=P,y.current=T;return}}b.current={x:0,y:0},y.current={x:0,y:0},v()},[e,A,r,v,a,o,JSON.stringify(M),JSON.stringify(p),x,u,E,d,JSON.stringify(m)])}const _We={x:{[Wi.Backward]:!1,[Wi.Forward]:!1},y:{[Wi.Backward]:!1,[Wi.Forward]:!1}};function wWe(t){let{delta:e,disabled:n}=t;const r=jR(e);return Dy(i=>{if(n||!r||!i)return _We;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Wi.Backward]:i.x[Wi.Backward]||a.x===-1,[Wi.Forward]:i.x[Wi.Forward]||a.x===1},y:{[Wi.Backward]:i.y[Wi.Backward]||a.y===-1,[Wi.Forward]:i.y[Wi.Forward]||a.y===1}}},[n,e,r])}function SWe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Dy(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function MWe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...a]},[]),[t,e])}var G0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(G0||(G0={}));var OR;(function(t){t.Optimized="optimized"})(OR||(OR={}));const IG=new Map;function NWe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),f=b(),m=H0(f),p=w.useCallback(function(y){y===void 0&&(y=[]),!m.current&&o(M=>M===null?y:M.concat(y.filter(S=>!M.includes(S))))},[m]),x=w.useRef(null),v=Dy(y=>{if(f&&!n)return IG;if(!y||y===IG||d.current!==t||a!=null){const M=new Map;for(let S of t){if(!S)continue;if(a&&a.length>0&&!a.includes(S.id)&&S.rect.current){M.set(S.id,S.rect.current);continue}const A=S.node.current,E=A?new TL(c(A),A):null;S.rect.current=E,E&&M.set(S.id,E)}return M}return y},[t,a,n,f,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{f||p()},[n,f]),w.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),w.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,f,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:a!=null};function b(){switch(u){case G0.Always:return!1;case G0.BeforeDragging:return n;default:return!n}}}function Yne(t,e){return Dy(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function EWe(t,e){return Yne(t,e)}function AWe(t){let{callback:e,disabled:n}=t;const r=EL(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function cN(t){let{callback:e,disabled:n}=t;const r=EL(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function TWe(t){return new TL(Zg(t),t)}function FG(t,e,n){e===void 0&&(e=TWe);const[r,i]=w.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=AWe({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),l=cN({callback:a});return Vl(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function CWe(t){const e=Yne(t);return $ne(t,e)}const UG=[];function kWe(t){const e=w.useRef(t),n=Dy(r=>t?r&&r!==UG&&t&&e.current&&t.parentNode===e.current.parentNode?r:sN(t):UG,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function jWe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(a=>{const o=hj(a.target);o&&n(l=>l?(l.set(o,RR(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=hj(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(a)};function o(l){l.forEach(c=>{const u=hj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>qp(a,o),il):Kne(t):il,[t,e])}function zG(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==il;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?V0(t,n.current):il}function PWe(t){w.useEffect(()=>{if(!aN)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 RWe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function Qne(t){return w.useMemo(()=>t?rWe(t):null,[t])}const BG=[];function DWe(t,e){e===void 0&&(e=Zg);const[n]=t,r=Qne(n?ys(n):null),[i,a]=w.useState(BG);function o(){a(()=>t.length?t.map(c=>Wne(c)?r:new TL(e(c),c)):BG)}const l=cN({callback:o});return Vl(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function OWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Ry(e)?e:t}function LWe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Ry(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=cN({callback:i}),o=w.useCallback(u=>{const d=OWe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=x2(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const IWe=[{sensor:lN,options:{}},{sensor:oN,options:{}}],FWe={current:{}},nw={draggable:{measure:RG},droppable:{measure:RG,strategy:G0.WhileDragging,frequency:OR.Optimized},dragOverlay:{measure:Zg}};class Zb 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 UWe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Zb,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:b2},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:nw,measureDroppableContainers:b2,windowRect:null,measuringScheduled:!1},zWe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:b2,draggableNodes:new Map,over:null,measureDroppableContainers:b2},uN=w.createContext(zWe),Zne=w.createContext(UWe);function BWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Zb}}}function $We(t,e){switch(e.type){case Ei.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ei.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 Ei.DragEnd:case Ei.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ei.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Zb(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Ei.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new Zb(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Ei.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new Zb(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function HWe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(uN),a=jR(r),o=jR(n?.id);return w.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!AL(a)||document.activeElement===a.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=IGe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function VWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function GWe(t){return w.useMemo(()=>({draggable:{...nw.draggable,...t?.draggable},droppable:{...nw.droppable,...t?.droppable},dragOverlay:{...nw.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function WWe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Vl(()=>{if(!o&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=$ne(d,r);if(o||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=Hne(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const Jne=w.createContext({...il,scaleX:1,scaleY:1});var cd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(cd||(cd={}));const ere=w.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=IWe,collisionDetection:f=YGe,measuring:m,modifiers:p,...x}=e;const v=w.useReducer($We,void 0,BWe),[b,y]=v,[M,S]=HGe(),[A,E]=w.useState(cd.Uninitialized),k=A===cd.Initialized,{draggable:{active:C,nodes:R,translate:T},droppable:{containers:P}}=b,F=C!=null?R.get(C):null,I=w.useRef({initial:null,translated:null}),X=w.useMemo(()=>{var Be;return C!=null?{id:C,data:(Be=F?.data)!=null?Be:FWe,rect:I}:null},[C,F]),D=w.useRef(null),[K,Y]=w.useState(null),[q,Z]=w.useState(null),re=H0(x,Object.values(x)),ie=Oy("DndDescribedBy",o),U=w.useMemo(()=>P.getEnabled(),[P]),G=GWe(m),{droppableRects:ee,measureDroppableContainers:ne,measuringScheduled:se}=NWe(U,{dragging:k,dependencies:[T.x,T.y],config:G.droppable}),de=SWe(R,C),he=w.useMemo(()=>q?PR(q):null,[q]),Ee=ye(),ge=EWe(de,G.draggable.measure);WWe({activeNode:C!=null?R.get(C):null,config:Ee.layoutShiftCompensation,initialRect:ge,measure:G.draggable.measure});const Ne=FG(de,G.draggable.measure,ge),Re=FG(de?de.parentElement:null),te=w.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:R,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Je=P.getNodeFor((n=te.current.over)==null?void 0:n.id),B=LWe({measure:G.dragOverlay.measure}),H=(r=B.nodeRef.current)!=null?r:de,W=k?(i=B.rect)!=null?i:Ne:null,z=!!(B.nodeRef.current&&B.rect),V=CWe(z?null:Ne),Q=Qne(H?ys(H):null),Te=kWe(k?Je??de:null),ke=DWe(Te),Ae=VWe(p,{transform:{x:T.x-V.x,y:T.y-V.y,scaleX:1,scaleY:1},activatorEvent:q,active:X,activeNodeRect:Ne,containerNodeRect:Re,draggingNodeRect:W,over:te.current.over,overlayNodeRect:B.rect,scrollableAncestors:Te,scrollableAncestorRects:ke,windowRect:Q}),$=he?qp(he,T):null,L=jWe(Te),oe=zG(L),ce=zG(L,[Ne]),xe=qp(Ae,oe),ve=W?JGe(W,Ae):null,_e=X&&ve?f({active:X,collisionRect:ve,droppableRects:ee,droppableContainers:U,pointerCoordinates:$}):null,Ie=zne(_e,"id"),[We,ht]=w.useState(null),qe=z?Ae:qp(Ae,ce),me=QGe(qe,(a=We?.rect)!=null?a:null,Ne),rt=w.useRef(null),Xe=w.useCallback((Be,De)=>{let{sensor:we,options:Ve}=De;if(D.current==null)return;const dt=R.get(D.current);if(!dt)return;const Tt=Be.nativeEvent,Ct=new we({active:D.current,activeNode:dt,event:Tt,options:Ve,context:te,onAbort(Pt){if(!R.get(Pt))return;const{onDragAbort:bn}=re.current,Kn={id:Pt};bn?.(Kn),M({type:"onDragAbort",event:Kn})},onPending(Pt,an,bn,Kn){if(!R.get(Pt))return;const{onDragPending:Vn}=re.current,_r={id:Pt,constraint:an,initialCoordinates:bn,offset:Kn};Vn?.(_r),M({type:"onDragPending",event:_r})},onStart(Pt){const an=D.current;if(an==null)return;const bn=R.get(an);if(!bn)return;const{onDragStart:Kn}=re.current,zn={activatorEvent:Tt,active:{id:an,data:bn.data,rect:I}};Ic.unstable_batchedUpdates(()=>{Kn?.(zn),E(cd.Initializing),y({type:Ei.DragStart,initialCoordinates:Pt,active:an}),M({type:"onDragStart",event:zn}),Y(rt.current),Z(Tt)})},onMove(Pt){y({type:Ei.DragMove,coordinates:Pt})},onEnd:Xt(Ei.DragEnd),onCancel:Xt(Ei.DragCancel)});rt.current=Ct;function Xt(Pt){return async function(){const{active:bn,collisions:Kn,over:zn,scrollAdjustedTranslate:Vn}=te.current;let _r=null;if(bn&&Vn){const{cancelDrop:$r}=re.current;_r={activatorEvent:Tt,active:bn,collisions:Kn,delta:Vn,over:zn},Pt===Ei.DragEnd&&typeof $r=="function"&&await Promise.resolve($r(_r))&&(Pt=Ei.DragCancel)}D.current=null,Ic.unstable_batchedUpdates(()=>{y({type:Pt}),E(cd.Uninitialized),ht(null),Y(null),Z(null),rt.current=null;const $r=Pt===Ei.DragEnd?"onDragEnd":"onDragCancel";if(_r){const Tr=re.current[$r];Tr?.(_r),M({type:$r,event:_r})}})}}},[R]),nt=w.useCallback((Be,De)=>(we,Ve)=>{const dt=we.nativeEvent,Tt=R.get(Ve);if(D.current!==null||!Tt||dt.dndKit||dt.defaultPrevented)return;const Ct={active:Tt};Be(we,De.options,Ct)===!0&&(dt.dndKit={capturedBy:De.sensor},D.current=Ve,Xe(we,De))},[R,Xe]),ut=MWe(d,nt);PWe(d),Vl(()=>{Ne&&A===cd.Initializing&&E(cd.Initialized)},[Ne,A]),w.useEffect(()=>{const{onDragMove:Be}=re.current,{active:De,activatorEvent:we,collisions:Ve,over:dt}=te.current;if(!De||!we)return;const Tt={active:De,activatorEvent:we,collisions:Ve,delta:{x:xe.x,y:xe.y},over:dt};Ic.unstable_batchedUpdates(()=>{Be?.(Tt),M({type:"onDragMove",event:Tt})})},[xe.x,xe.y]),w.useEffect(()=>{const{active:Be,activatorEvent:De,collisions:we,droppableContainers:Ve,scrollAdjustedTranslate:dt}=te.current;if(!Be||D.current==null||!De||!dt)return;const{onDragOver:Tt}=re.current,Ct=Ve.get(Ie),Xt=Ct&&Ct.rect.current?{id:Ct.id,rect:Ct.rect.current,data:Ct.data,disabled:Ct.disabled}:null,Pt={active:Be,activatorEvent:De,collisions:we,delta:{x:dt.x,y:dt.y},over:Xt};Ic.unstable_batchedUpdates(()=>{ht(Xt),Tt?.(Pt),M({type:"onDragOver",event:Pt})})},[Ie]),Vl(()=>{te.current={activatorEvent:q,active:X,activeNode:de,collisionRect:ve,collisions:_e,droppableRects:ee,draggableNodes:R,draggingNode:H,draggingNodeRect:W,droppableContainers:P,over:We,scrollableAncestors:Te,scrollAdjustedTranslate:xe},I.current={initial:W,translated:ve}},[X,de,_e,ve,R,H,W,ee,P,We,Te,xe]),vWe({...Ee,delta:T,draggingRect:ve,pointerCoordinates:$,scrollableAncestors:Te,scrollableAncestorRects:ke});const ae=w.useMemo(()=>({active:X,activeNode:de,activeNodeRect:Ne,activatorEvent:q,collisions:_e,containerNodeRect:Re,dragOverlay:B,draggableNodes:R,droppableContainers:P,droppableRects:ee,over:We,measureDroppableContainers:ne,scrollableAncestors:Te,scrollableAncestorRects:ke,measuringConfiguration:G,measuringScheduled:se,windowRect:Q}),[X,de,Ne,q,_e,Re,B,R,P,ee,We,ne,Te,ke,G,se,Q]),$e=w.useMemo(()=>({activatorEvent:q,activators:ut,active:X,activeNodeRect:Ne,ariaDescribedById:{draggable:ie},dispatch:y,draggableNodes:R,over:We,measureDroppableContainers:ne}),[q,ut,X,Ne,y,ie,R,We,ne]);return jr.createElement(Lne.Provider,{value:S},jr.createElement(uN.Provider,{value:$e},jr.createElement(Zne.Provider,{value:ae},jr.createElement(Jne.Provider,{value:me},u)),jr.createElement(HWe,{disabled:l?.restoreFocus===!1})),jr.createElement(WGe,{...l,hiddenTextDescribedById:ie}));function ye(){const Be=K?.autoScrollEnabled===!1,De=typeof c=="object"?c.enabled===!1:c===!1,we=k&&!Be&&!De;return typeof c=="object"?{...c,enabled:we}:{enabled:we}}}),qWe=w.createContext(null),$G="button",KWe="Draggable";function XWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Oy(KWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(uN),{role:p=$G,roleDescription:x="draggable",tabIndex:v=0}=i??{},b=c?.id===e,y=w.useContext(b?Jne:qWe),[M,S]=x2(),[A,E]=x2(),k=RWe(o,e),C=H0(n);Vl(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:A,data:C}),()=>{const T=f.get(e);T&&T.key===a&&f.delete(e)}),[f,e]);const R=w.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":b&&p===$G?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,v,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:R,isDragging:b,listeners:r?void 0:k,node:M,over:m,setNodeRef:S,setActivatorNodeRef:E,transform:y}}function YWe(){return w.useContext(Zne)}const QWe="Droppable",ZWe={timeout:25};function JWe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Oy(QWe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(uN),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),p=w.useRef(null),{disabled:x,updateMeasurementsFor:v,timeout:b}={...ZWe,...i},y=H0(v??r),M=w.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),p.current=null},b)},[b]),S=cN({callback:M,disabled:x||!o}),A=w.useCallback((R,T)=>{S&&(T&&(S.unobserve(T),f.current=!1),R&&S.observe(R))},[S]),[E,k]=x2(A),C=H0(e);return w.useEffect(()=>{!S||!E.current||(S.disconnect(),f.current=!1,S.observe(E.current))},[E,S]),w.useEffect(()=>(l({type:Ei.RegisterDroppable,element:{id:r,key:a,disabled:n,node:E,rect:m,data:C}}),()=>l({type:Ei.UnregisterDroppable,key:a,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:Ei.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:m,isOver:c?.id===r,node:E,over:c,setNodeRef:k}}function dN(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function eqe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function N1(t){return t!==null&&t>=0}function tqe(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 nqe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const kL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=dN(e,r,n),o=e[i],l=a[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},E1={scaleX:1,scaleY:1},rqe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:o}=t;const l=(e=a[n])!=null?e:r;if(!l)return null;if(i===n){const u=a[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...E1}:null}const c=iqe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...E1}:i<n&&i>=o?{x:0,y:l.height+c,...E1}:{x:0,y:0,...E1}};function iqe(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return r?n<e?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const tre="Sortable",nre=jr.createContext({activeIndex:-1,containerId:tre,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:kL,disabled:{draggable:!1,droppable:!1}});function rre(t){let{children:e,id:n,items:r,strategy:i=kL,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=YWe(),f=Oy(tre,n),m=l.rect!==null,p=w.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),x=o!=null,v=o?p.indexOf(o.id):-1,b=u?p.indexOf(u.id):-1,y=w.useRef(p),M=!tqe(p,y.current),S=b!==-1&&v===-1||M,A=nqe(a);Vl(()=>{M&&x&&d(p)},[M,p,x,d]),w.useEffect(()=>{y.current=p},[p]);const E=w.useMemo(()=>({activeIndex:v,containerId:f,disabled:A,disableTransforms:S,items:p,overIndex:b,useDragOverlay:m,sortedRects:eqe(p,c),strategy:i}),[v,f,A.draggable,A.droppable,S,p,b,c,m,i]);return jr.createElement(nre.Provider,{value:E},e)}const aqe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return dN(n,r,i).indexOf(e)},sqe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==a&&i===o?!1:n?!0:o!==i&&e===c},oqe={duration:200,easing:"ease"},ire="transform",lqe=Eg.Transition.toString({property:ire,duration:0,easing:"linear"}),cqe={roleDescription:"sortable"};function uqe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=w.useState(null),l=w.useRef(n);return Vl(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Zg(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{a&&o(null)},[a]),a}function are(t){let{animateLayoutChanges:e=sqe,attributes:n,disabled:r,data:i,getNewIndex:a=aqe,id:o,strategy:l,resizeObserverConfig:c,transition:u=oqe}=t;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:x,sortedRects:v,overIndex:b,useDragOverlay:y,strategy:M}=w.useContext(nre),S=dqe(r,p),A=d.indexOf(o),E=w.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),k=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:C,node:R,isOver:T,setNodeRef:P}=JWe({id:o,data:E,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:F,activatorEvent:I,activeNodeRect:X,attributes:D,setNodeRef:K,listeners:Y,isDragging:q,over:Z,setActivatorNodeRef:re,transform:ie}=XWe({id:o,data:E,attributes:{...cqe,...n},disabled:S.draggable}),U=RGe(P,K),G=!!F,ee=G&&!x&&N1(m)&&N1(b),ne=!y&&q,se=ne&&ee?ie:null,he=ee?se??(l??M)({rects:v,activeNodeRect:X,activeIndex:m,overIndex:b,index:A}):null,Ee=N1(m)&&N1(b)?a({id:o,items:d,activeIndex:m,overIndex:b}):A,ge=F?.id,Ne=w.useRef({activeId:ge,items:d,newIndex:Ee,containerId:f}),Re=d!==Ne.current.items,te=e({active:F,containerId:f,isDragging:q,isSorting:G,id:o,index:A,items:d,newIndex:Ne.current.newIndex,previousItems:Ne.current.items,previousContainerId:Ne.current.containerId,transition:u,wasDragging:Ne.current.activeId!=null}),Je=uqe({disabled:!te,index:A,node:R,rect:C});return w.useEffect(()=>{G&&Ne.current.newIndex!==Ee&&(Ne.current.newIndex=Ee),f!==Ne.current.containerId&&(Ne.current.containerId=f),d!==Ne.current.items&&(Ne.current.items=d)},[G,Ee,f,d]),w.useEffect(()=>{if(ge===Ne.current.activeId)return;if(ge!=null&&Ne.current.activeId==null){Ne.current.activeId=ge;return}const H=setTimeout(()=>{Ne.current.activeId=ge},50);return()=>clearTimeout(H)},[ge]),{active:F,activeIndex:m,attributes:D,data:E,rect:C,index:A,newIndex:Ee,items:d,isOver:T,isSorting:G,isDragging:q,listeners:Y,node:R,overIndex:b,over:Z,setNodeRef:U,setActivatorNodeRef:re,setDroppableNodeRef:P,setDraggableNodeRef:K,transform:Je??he,transition:B()};function B(){if(Je||Re&&Ne.current.newIndex===A)return lqe;if(!(ne&&!AL(I)||!u)&&(G||te))return Eg.Transition.toString({...u,property:ire})}}function dqe(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 _2(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 hqe=[Pn.Down,Pn.Right,Pn.Up,Pn.Left],sre=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(hqe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=i.get(f.id);if(m)switch(t.code){case Pn.Down:r.top<m.top&&c.push(f);break;case Pn.Up:r.top>m.top&&c.push(f);break;case Pn.Left:r.left>m.left&&c.push(f);break;case Pn.Right:r.left<m.left&&c.push(f);break}});const u=KGe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=zne(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),m=a.get(d),p=m?i.get(m.id):null,x=m?.node.current;if(x&&p&&f&&m){const b=sN(x).some((k,C)=>l[C]!==k),y=ore(f,m),M=fqe(f,m),S=b||!y?{x:0,y:0}:{x:M?r.width-p.width:0,y:M?r.height-p.height:0},A={x:p.left,y:p.top};return S.x&&S.y?A:V0(A,S)}}}};function ore(t,e){return!_2(t)||!_2(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function fqe(t,e){return!_2(t)||!_2(e)||!ore(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function lre(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 mqe(t,e="system"){if(!t)return"ASAP";const n=mi(t);if(!n)return"ASAP";const r=new Date,i=n.getTime()-r.getTime();return i<-6e4?"Overdue":i<0?"Now":i<6e4?"In less than a minute":i<36e5?`In ${Math.round(i/6e4)} min`:i<864e5?`In ${Math.round(i/36e5)} hours`:eg(t,e)}function pqe({status:t}){const e={pending:{icon:Hn,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:nl,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:kn,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:qi,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:mw,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Ut,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[s.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function pj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system"}){const{attributes:u,listeners:d,setNodeRef:f,transform:m,transition:p,isDragging:x}=are({id:t.id,disabled:t.status!=="pending"}),v={transform:Eg.Transform.toString(m),transition:p},b=t.status==="printing",y=t.status==="pending",M=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:f,style:v,className:`
  8274. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8275. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8276. ${x?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8277. ${b?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8278. `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?s.jsx("div",{...u,...d,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:s.jsx(Qp,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?s.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):s.jsx("div",{className:"w-8"}),s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?s.jsx("img",{src:pe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:pe.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(tl,{className:"w-6 h-6"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?s.jsx(as,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:s.jsx(Lr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(as,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View in File Manager",children:s.jsx(Lr,{className:"w-3.5 h-3.5"})}):null]}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[s.jsxs("span",{className:`flex items-center gap-1.5 ${t.printer_id===null?"text-orange-400":""}`,children:[s.jsx(Ir,{className:"w-3.5 h-3.5"}),t.printer_id===null?"Unassigned":t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(md,{className:"w-3.5 h-3.5"}),lre(t.print_time_seconds)]}),y&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Hn,{className:"w-3.5 h-3.5"}),mqe(t.scheduled_time,c)]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&s.jsxs("span",{className:"text-xs px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[s.jsx(GW,{className:"w-3 h-3"}),"Staged"]}),t.require_previous_success&&s.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&s.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[s.jsx(uu,{className:"w-3 h-3"}),"Auto power off"]})]}),b&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx(ea,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(pqe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[b&&s.jsx(Me,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Ace,{className:"w-4 h-4"})}),y&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Me,{variant:"ghost",size:"sm",onClick:l,title:"Start Print",className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:s.jsx(nl,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(Ha,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),M&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:o,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:s.jsx(yr,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(Jt,{className:"w-4 h-4"})})]})]})]})})}function gqe(){const t=Qt(),{showToast:e}=Un(),[n,r]=w.useState(null),[i,a]=w.useState(""),[o,l]=w.useState(!1),[c,u]=w.useState(null),[d,f]=w.useState(null),[m,p]=w.useState(null),[x,v]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[b,y]=w.useState(()=>{const ee=localStorage.getItem("queue.historySortAsc");return ee!==null?ee==="true":!1}),[M,S]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[A,E]=w.useState(()=>{const ee=localStorage.getItem("queue.pendingSortAsc");return ee!==null?ee==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",x)},[x]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(b))},[b]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",M)},[M]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(A))},[A]);const k=Ine(y2(lN,{activationConstraint:{distance:8}}),y2(oN,{coordinateGetter:sre})),{data:C}=lt({queryKey:["settings"],queryFn:pe.getSettings}),R=C?.time_format||"system",{data:T,isLoading:P}=lt({queryKey:["queue",n,i],queryFn:()=>pe.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:F}=lt({queryKey:["printers"],queryFn:()=>pe.getPrinters()}),I=ft({mutationFn:ee=>pe.cancelQueueItem(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),X=ft({mutationFn:ee=>pe.removeFromQueue(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=ft({mutationFn:ee=>pe.stopQueueItem(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),K=ft({mutationFn:ee=>pe.startQueueItem(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),Y=ft({mutationFn:ee=>pe.reorderQueue(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),q=ft({mutationFn:async()=>{const ee=T?.filter(ne=>["completed","failed","skipped","cancelled"].includes(ne.status))||[];for(const ne of ee)await pe.removeFromQueue(ne.id);return ee.length},onSuccess:ee=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${ee} history item${ee!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),Z=w.useMemo(()=>{const ee=T?.filter(se=>se.status==="pending")||[],ne=se=>{if(!se.scheduled_time)return 0;const de=new Date(se.scheduled_time).getTime(),he=Date.now()+4320*60*60*1e3;return de>he?0:de};return[...ee].sort((se,de)=>{let he;if(M==="name"){const Ee=se.archive_name||se.library_file_name||"",ge=de.archive_name||de.library_file_name||"";he=Ee.localeCompare(ge)}else M==="printer"?he=(se.printer_name||"").localeCompare(de.printer_name||""):M==="time"?he=ne(se)-ne(de):he=se.position-de.position;return A?he:-he})},[T,M,A]),re=T?.filter(ee=>ee.status==="printing")||[],ie=w.useMemo(()=>[...T?.filter(ne=>["completed","failed","skipped","cancelled"].includes(ne.status))||[]].sort((ne,se)=>{let de;if(x==="name"){const he=ne.archive_name||ne.library_file_name||"",Ee=se.archive_name||se.library_file_name||"";de=he.localeCompare(Ee)}else x==="printer"?de=(ne.printer_name||"").localeCompare(se.printer_name||""):de=new Date(se.completed_at||se.created_at).getTime()-new Date(ne.completed_at||ne.created_at).getTime();return b?-de:de}),[T,x,b]),U=w.useMemo(()=>Z.reduce((ee,ne)=>ee+(ne.print_time_seconds||0),0),[Z]),G=ee=>{const{active:ne,over:se}=ee;if(!se||ne.id===se.id)return;const de=Z.findIndex(Ee=>Ee.id===ne.id),he=Z.findIndex(Ee=>Ee.id===se.id);if(de!==-1&&he!==-1){const ge=dN(Z,de,he).map((Ne,Re)=>({id:Ne.id,position:Re+1}));Y.mutate(ge)}};return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsx("div",{className:"flex items-center justify-between mb-8",children:s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx(WW,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),s.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[s.jsx(wt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:s.jsx(nl,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:re.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(wt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:s.jsx(Hn,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Z.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(wt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:s.jsx(md,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:lre(U)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(wt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:s.jsx(kn,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ie.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n===-1?"unassigned":n||"",onChange:ee=>{const ne=ee.target.value;r(ne==="unassigned"?-1:ne===""?null:Number(ne))},children:[s.jsx("option",{value:"",children:"All Printers"}),s.jsx("option",{value:"unassigned",children:"Unassigned"}),F?.map(ee=>s.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:ee=>a(ee.target.value),children:[s.jsx("option",{value:"",children:"All Status"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"printing",children:"Printing"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"skipped",children:"Skipped"}),s.jsx("option",{value:"cancelled",children:"Cancelled"})]}),s.jsx("div",{className:"flex-1"}),ie.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(Jt,{className:"w-4 h-4"}),"Clear History"]})]}),P?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?s.jsxs(wt,{className:"p-12 text-center border-dashed",children:[s.jsx(Qr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),s.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),s.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):s.jsxs("div",{className:"space-y-8",children:[re.length>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),s.jsx("div",{className:"space-y-3",children:re.map(ee=>s.jsx(pj,{item:ee,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:ee}),onRequeue:()=>{},onStart:()=>{},timeFormat:R},ee.id))})]}),Z.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Hn,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Z.length," item",Z.length!==1?"s":"",")"]}),s.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:M,onChange:ee=>S(ee.target.value),children:[s.jsx("option",{value:"position",children:"Sort by Position"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"}),s.jsx("option",{value:"time",children:"Sort by Schedule"})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>E(!A),title:A?"Ascending":"Descending",className:"px-2",children:A?s.jsx(Kp,{className:"w-4 h-4"}):s.jsx(i0,{className:"w-4 h-4"})})]})]}),s.jsx(ere,{sensors:k,collisionDetection:Bne,onDragEnd:G,children:s.jsx(rre,{items:Z.map(ee=>ee.id),strategy:rqe,children:s.jsx("div",{className:"space-y-3",children:Z.map((ee,ne)=>s.jsx(pj,{item:ee,position:ne+1,onEdit:()=>u(ee),onCancel:()=>p({type:"cancel",item:ee}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>K.mutate(ee.id),timeFormat:R},ee.id))})})})]}),ie.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(kn,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ie.length," item",ie.length!==1?"s":"",")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:x,onChange:ee=>v(ee.target.value),children:[s.jsx("option",{value:"date",children:"Sort by Date"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>y(!b),title:b?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:b?s.jsx(Kp,{className:"w-4 h-4"}):s.jsx(i0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:ie.slice(0,20).map((ee,ne)=>s.jsx(pj,{item:ee,position:ne+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:ee}),onStop:()=>{},onRequeue:()=>f(ee),onStart:()=>{},timeFormat:R},ee.id))})]})]}),c&&s.jsx(Wd,{mode:"edit-queue-item",archiveId:c.archive_id??void 0,libraryFileId:c.library_file_id??void 0,archiveName:c.archive_name||c.library_file_name||`File #${c.archive_id||c.library_file_id}`,queueItem:c,onClose:()=>u(null)}),d&&s.jsx(Wd,{mode:"add-to-queue",archiveId:d.archive_id??void 0,libraryFileId:d.library_file_id??void 0,archiveName:d.archive_name||d.library_file_name||`File #${d.archive_id||d.library_file_id}`,onClose:()=>f(null)}),m&&s.jsx(Rn,{title:m.type==="cancel"?"Cancel Scheduled Print":m.type==="stop"?"Stop Print":"Remove from History",message:m.type==="cancel"?`Are you sure you want to cancel "${m.item.archive_name||m.item.library_file_name||"this print"}"?`:m.type==="stop"?`Are you sure you want to stop the current print "${m.item.archive_name||m.item.library_file_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${m.item.archive_name||m.item.library_file_name||"this item"}" from the queue history?`,confirmText:m.type==="cancel"?"Cancel Print":m.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{m.type==="cancel"?I.mutate(m.item.id):m.type==="stop"?D.mutate(m.item.id):X.mutate(m.item.id),p(null)},onCancel:()=>p(null)}),o&&s.jsx(Rn,{title:"Clear History",message:`Are you sure you want to remove all ${ie.length} item${ie.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{q.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function xqe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const M=n.current;if(!M)return;const S=new ResizeObserver(A=>{const E=A[0]?.contentRect.width||0;i(E)});return S.observe(M),()=>S.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=w.useMemo(()=>{const M={};t.forEach(F=>{const I=F.split("T")[0];M[I]=(M[I]||0)+1});const S=new Date,A=new Date(S);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const E=[],k=[];let C=[],R=-1;const T=new Date(A);let P=0;for(;T<=S;)T.getDay()===0&&C.length>0&&(E.push(C),C=[],P++),T.getMonth()!==R&&(k.push({month:T.toLocaleDateString("en-US",{month:"short"}),weekIndex:P}),R=T.getMonth()),C.push(new Date(T)),T.setDate(T.getDate()+1);return C.length>0&&E.push(C),{weeks:E,monthLabels:k,printCounts:M}},[t,e]),c=Math.max(1,...Object.values(l)),u=M=>{if(M===0)return"bg-bambu-dark";const S=M/c;return S<=.25?"bg-bambu-green/30":S<=.5?"bg-bambu-green/50":S<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,m=32,p=2,x=r-m-16,v=f>0?Math.floor((x-(f-1)*p)/f):12,b=Math.max(8,Math.min(20,v)),y=b<=10?10:12;return s.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&s.jsxs("div",{children:[s.jsx("div",{className:"flex mb-1",style:{marginLeft:m+4},children:o.map(({month:M,weekIndex:S},A)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:y,marginLeft:A===0?0:`${(S-(o[A-1]?.weekIndex||0))*(b+p)-24}px`},children:M},A))}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:m},children:d.map((M,S)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:m,height:b,fontSize:y,visibility:S%2===1?"visible":"hidden"},children:M},M))}),a.map((M,S)=>s.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(A=>{const E=M.find(T=>T.getDay()===A);if(!E)return s.jsx("div",{style:{width:b,height:b}},A);const k=E.toISOString().split("T")[0],C=l[k]||0,R=k===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(C)} ${R?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${E.toLocaleDateString()}: ${C} print${C!==1?"s":""}`},A)})},S))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:y},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),s.jsx("span",{children:"More"})]})]})})}const A1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function bqe(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 yqe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=bqe(n);return t.filter(p=>(mi(p.completed_at||p.created_at)||new Date(0))>=m)},[t,n]),a=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const x=mi(p.completed_at||p.created_at)||new Date,v=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,b=m.get(v)||{date:v,filament:0,cost:0,prints:0};b.filament+=p.filament_used_grams||0,b.cost+=p.cost||0,b.prints+=1,m.set(v,b)}),Array.from(m.values()).sort((p,x)=>p.date.localeCompare(x.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return a;const m=new Map;return i.forEach(p=>{const x=mi(p.completed_at||p.created_at)||new Date,v=new Date(x);v.setDate(x.getDate()-x.getDay());const b=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`,y=m.get(b)||{week:b,filament:0,cost:0,prints:0};y.filament+=p.filament_used_grams||0,y.cost+=p.cost||0,y.prints+=1,m.set(b,y)}),Array.from(m.values()).sort((p,x)=>p.week.localeCompare(x.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),l=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const v=(p.filament_type||"Unknown").split(", ");v.forEach(b=>{const y=(p.filament_used_grams||0)/v.length;m.set(b,(m.get(b)||0)+y)})}),Array.from(m.entries()).map(([p,x])=>({name:p,value:Math.round(x)})).sort((p,x)=>x.value-p.value)},[i]),c=w.useMemo(()=>{const m=new Date,p=[];for(let x=5;x>=0;x--){const v=new Date(m.getFullYear(),m.getMonth()-x,1),b=new Date(m.getFullYear(),m.getMonth()-x+1,0),y=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(S=>{const A=mi(S.completed_at||S.created_at)||new Date(0);return A>=v&&A<=b});p.push({month:y,filament:Math.round(M.reduce((S,A)=>S+(A.filament_used_grams||0),0)),cost:M.reduce((S,A)=>S+(A.cost||0),0),prints:M.length})}return p},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((m,p)=>m+(p.filament_used_grams||0),0),f=i.reduce((m,p)=>m+(p.cost||0),0);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),s.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(m=>s.jsx("button",{onClick:()=>r(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),s.jsx(F1,{width:"100%",height:250,children:s.jsxs(gke,{data:u,children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),s.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),s.jsx(lS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(uS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(dS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(z1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${m.toFixed(0)}g`,"Filament"]}),s.jsx(sZ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):s.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(F1,{width:160,height:160,children:s.jsxs(mke,{children:[s.jsx(kQ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,p)=>s.jsx(wy,{fill:A1[p%A1.length]},`cell-${p}`))}),s.jsx(z1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,p)=>{const x=l.reduce((b,y)=>b+y.value,0),v=x>0?(m.value/x*100).toFixed(0):0;return s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:A1[p%A1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:m.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},m.name)})})]}):s.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),s.jsx(F1,{width:"100%",height:200,children:s.jsxs(nke,{data:c,children:[s.jsx(lS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(uS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(dS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(z1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,p)=>[p==="filament"?`${m}g`:p==="cost"?`${e}${m.toFixed(2)}`:m,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),s.jsx(RD,{}),s.jsx(LQ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function vqe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:m}=are({id:t}),p={transform:Eg.Transform.toString(d),transition:f,opacity:m?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...p,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${m?"ring-2 ring-bambu-green shadow-lg":""}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:s.jsx(Qp,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),s.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?s.jsx(KW,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(qW,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),s.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:s.jsx(T2,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),s.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function _qe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const A={};return t.forEach(E=>{A[E.id]=E.defaultSize||4}),A},[l,c]=w.useState(()=>{const A=localStorage.getItem(e);if(A)try{const E=JSON.parse(A);return E.sizes||(E.sizes=o()),E}catch{}return{order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()}}),[u,d]=w.useState(!1);w.useEffect(()=>{const A=()=>d(E=>!E);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const E=t.map(k=>k.id).filter(k=>!l.order.includes(k));E.length>0&&c(k=>({...k,order:[...k.order,...E]}))},[t,l.order]);const f=Ine(y2(lN,{activationConstraint:{distance:8}}),y2(oN,{coordinateGetter:sre})),m=A=>{const{active:E,over:k}=A;k&&E.id!==k.id&&c(C=>{const R=C.order.indexOf(E.id),T=C.order.indexOf(k.id);return{...C,order:dN(C.order,R,T)}})},p=A=>{c(E=>({...E,hidden:E.hidden.includes(A)?E.hidden.filter(k=>k!==A):[...E.hidden,A]}))},x=A=>{c(E=>{const k=E.sizes[A]||4,C=k===1?2:k===2?4:1;return{...E,sizes:{...E.sizes,[A]:C}}})},v=()=>{const A={order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()};c(A),i?.()},b=l.order.map(A=>t.find(E=>E.id===A)).filter(Boolean),y=b.filter(A=>!l.hidden.includes(A.id)),M=b.filter(A=>l.hidden.includes(A.id)),S=a?.({hiddenCount:M.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:v});return s.jsxs("div",{className:"space-y-4",children:[S,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:v,children:[s.jsx(Hf,{className:"w-4 h-4"}),"Reset Layout"]}),M.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(vf,{className:"w-4 h-4"}),M.length," Hidden"]})]}),u&&M.length>0&&s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(A=>s.jsxs("button",{onClick:()=>p(A.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[s.jsx(vf,{className:"w-3 h-3"}),A.title]},A.id))})]}),s.jsx(ere,{sensors:f,collisionDetection:Bne,onDragEnd:m,children:s.jsx(rre,{items:y.map(A=>A.id),strategy:kL,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:y.map(A=>s.jsx(vqe,{id:A.id,title:A.title,component:A.component,isHidden:l.hidden.includes(A.id),size:l.sizes[A.id]||2,onToggleVisibility:()=>p(A.id),onToggleSize:()=>x(A.id)},A.id))})})}),y.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Me,{className:"mt-4",onClick:v,children:"Reset Layout"})]})]})}function wqe({stats:t,currency:e}){return s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(Dl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),s.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:s.jsx(Hn,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:s.jsx(Dl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:s.jsx(Uj,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:s.jsx(Sf,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:s.jsx(Uj,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function Sqe({stats:t,printerMap:e,size:n=1}){const r=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,i=n===1?112:n===2?128:144,a=i/2-8,o=a*2*Math.PI;return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:i,height:i},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:i/2,cy:i/2,r:a,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:i/2,cy:i/2,r:a,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r/100*o} ${o}`})]}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r,"%"]})})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:"Prints by Printer"}),s.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([l,c])=>s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(l)||`Printer ${l}`}),s.jsx("span",{className:"text-white font-medium",children:c})]},l))})]})]})]})}function Mqe({stats:t,printerMap:e,size:n=1}){const r=t?.average_time_accuracy;if(r==null)return s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const a=(Math.min(150,Math.max(50,r))-50)/100*100,l=(x=>x>=95&&x<=105?"#00ae42":x>105?"#3b82f6":"#f97316")(r),c=r-100,u=n===1?112:n===2?128:144,d=u/2-8,f=d*2*Math.PI,m=n===1?3:n===2?6:999,p=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:u,height:u},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:l,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${a/100*f} ${f}`})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r.toFixed(0),"%"]}),s.jsxs("span",{className:`text-xs ${c>=0?"text-blue-400":"text-orange-400"}`,children:[c>=0?"+":"",c.toFixed(0),"%"]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx(JW,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:"100% = perfect estimate"})]}),p.length>0&&s.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:p.map(([x,v])=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(x)||`Printer ${x}`}),s.jsxs("span",{className:`font-medium ${v>=95&&v<=105?"text-bambu-green":v>105?"text-blue-400":"text-orange-400"}`,children:[v.toFixed(0),"%"]})]},x))})]})]})}function Nqe({stats:t,size:e=1}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const n=Object.entries(t.prints_by_filament_type).sort(([,o],[,l])=>l-o),r=e===1?5:e===2?8:999,i=n.slice(0,r),a=n.length>r;return e===4&&i.length>4?s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white truncate max-w-[120px]",children:o}),s.jsx("span",{className:"text-bambu-gray",children:l})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)})}):s.jsxs("div",{className:"space-y-3",children:[i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white",children:o}),s.jsxs("span",{className:"text-bambu-gray",children:[l," prints"]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)}),a&&s.jsxs("p",{className:"text-xs text-bambu-gray text-center pt-1",children:["+",n.length-r," more types"]})]})}function Eqe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(xqe,{printDates:t,months:n})}function Aqe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:s.jsx(Ir,{className:"w-4 h-4 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function Tqe({archives:t,currency:e}){return!t||t.length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):s.jsx(yqe,{archives:t,currency:e})}function Cqe({size:t=1}){const{data:e,isLoading:n}=lt({queryKey:["failureAnalysis"],queryFn:()=>pe.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!e||e.total_prints===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const r=t===1?5:t===2?8:999,i=Object.entries(e.failures_by_reason).sort(([,l],[,c])=>c-l),a=i.slice(0,r),o=i.length>r;return s.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[s.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(En,{className:`w-5 h-5 ${e.failure_rate>20?"text-red-400":e.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),s.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[e.failure_rate.toFixed(1),"%"]})]})}),s.jsxs("div",{className:"text-sm text-bambu-gray mt-1",children:[e.failed_prints," / ",e.total_prints," prints failed"]}),e.trend&&e.trend.length>=2&&s.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(tq,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),s.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",e.trend[e.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]}),a.length>0&&s.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?"Failure Reasons":"Top Failure Reasons"}),s.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:a.map(([l,c])=>s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:l||"Unknown"}),s.jsx("span",{className:"text-bambu-gray ml-2",children:c})]},l))}),o&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["+",i.length-r," more reasons"]})]})]})}function kqe(){const{showToast:t}=Un(),[e,n]=w.useState(!1),[r,i]=w.useState(!1),[a,o]=w.useState(0),[l,c]=w.useState(0);w.useEffect(()=>{const S=()=>{try{const E=localStorage.getItem("bambusy-dashboard-layout");if(E){const k=JSON.parse(E);c(k.hidden?.length||0)}}catch{c(0)}};S(),window.addEventListener("storage",S);const A=setInterval(S,500);return()=>{window.removeEventListener("storage",S),clearInterval(A)}},[a]);const{data:u,isLoading:d}=lt({queryKey:["archiveStats"],queryFn:pe.getArchiveStats}),{data:f}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:m}=lt({queryKey:["archives"],queryFn:()=>pe.getArchives(void 0,void 0,1e3,0)}),{data:p}=lt({queryKey:["settings"],queryFn:pe.getSettings}),x=async S=>{i(!1),n(!0);try{const{blob:A,filename:E}=await pe.exportStats({format:S,days:90}),k=URL.createObjectURL(A),C=document.createElement("a");C.href=k,C.download=E,C.click(),URL.revokeObjectURL(k),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},v=p?.currency||"$",b=new Map(f?.map(S=>[String(S.id),S.name])||[]),y=m?.map(S=>S.created_at)||[];if(d)return s.jsx("div",{className:"p-4 md:p-8",children:s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const M=[{id:"quick-stats",title:"Quick Stats",component:s.jsx(wqe,{stats:u,currency:v}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:S=>s.jsx(Sqe,{stats:u,printerMap:b,size:S}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:S=>s.jsx(Mqe,{stats:u,printerMap:b,size:S}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:S=>s.jsx(Nqe,{stats:u,size:S}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:S=>s.jsx(Cqe,{size:S}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:S=>s.jsx(Eqe,{printDates:y,size:S}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(Aqe,{stats:u,printerMap:b}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(Tqe,{archives:m||[],currency:v}),defaultSize:4}];return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),s.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&s.jsxs(Me,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(vf,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(S=>S+1),t("Layout reset")},children:[s.jsx(Hf,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Me,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(dw,{className:"w-4 h-4"}),"Export Stats"]}),r&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>x("csv"),children:[s.jsx(Ua,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>x("xlsx"),children:[s.jsx(dw,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(_qe,{widgets:M,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function jqe({plug:t,onEdit:e}){const n=Qt(),{showToast:r}=Un(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,f]=w.useState(!1),{data:m,isLoading:p}=lt({queryKey:["smart-plug-status",t.id],queryFn:()=>pe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),v=x?.find(R=>R.id===t.printer_id),b=ft({mutationFn:R=>pe.controlSmartPlug(t.id,R),onMutate:async R=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const T=n.getQueryData(["smart-plug-status",t.id]),P=R==="on"?"ON":R==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],F=>({...F,state:P})),{previousStatus:T}},onError:(R,T,P)=>{P?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],P.previousStatus),r(`Failed to turn ${T} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),y=ft({mutationFn:R=>pe.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=ft({mutationFn:()=>pe.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=m?.state==="ON",A=m?.reachable??!1,E=b.isPending,C=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const R=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${R}/`:`http://${R}/`})();return s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"relative",children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${A?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="homeassistant"?s.jsx(R2,{className:`w-5 h-5 ${A?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Fs,{className:`w-5 h-5 ${A?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[p?s.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Dp,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:S?"text-bambu-green":"text-bambu-gray",children:m?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[s.jsx(Pg,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),C&&s.jsxs("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:"Open plug admin page",children:[s.jsx(Lr,{className:"w-3 h-3"}),"Admin"]})]})]}),v&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),s.jsx("span",{className:"text-sm text-white",children:v.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[s.jsx(ef,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[s.jsx(Qr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(Me,{size:"sm",variant:S?"primary":"secondary",disabled:!A||E,onClick:()=>l(!0),className:"flex-1",children:[E?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(uu,{className:"w-4 h-4"}),"On"]}),s.jsxs(Me,{size:"sm",variant:S?"secondary":"primary",disabled:!A||E,onClick:()=>u(!0),className:"flex-1",children:[E?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(I2,{className:"w-4 h-4"}),"Off"]})]}),s.jsxs("button",{onClick:()=>f(!d),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Dd,{className:"w-4 h-4"}),"Automation Settings"]}),s.jsx("span",{children:d?"-":"+"})]}),d&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(D2,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:R=>y.mutate({show_in_switchbar:R.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:R=>y.mutate({enabled:R.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto On"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:R=>y.mutate({auto_on:R.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:R=>y.mutate({auto_off:R.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&s.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>y.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(Hn,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>y.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(U2,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:R=>y.mutate({off_delay_minutes:parseInt(R.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),s.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:R=>y.mutate({off_temp_threshold:parseInt(R.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(L2,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(Jt,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(Rn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),a(!1)},onCancel:()=>a(!1)}),o&&s.jsx(Rn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{b.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&s.jsx(Rn,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{b.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function Pqe({plug:t,onClose:e}){const n=Qt(),r=!!t,[i,a]=w.useState(t?.plug_type||"tasmota"),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.ip_address||""),[d,f]=w.useState(t?.username||""),[m,p]=w.useState(t?.password||""),[x,v]=w.useState(t?.ha_entity_id||""),[b,y]=w.useState(t?.ha_power_entity||""),[M,S]=w.useState(t?.ha_energy_today_entity||""),[A,E]=w.useState(t?.ha_energy_total_entity||""),[k,C]=w.useState(t?.printer_id||null),[R,T]=w.useState(null),[P,F]=w.useState(null),[I,X]=w.useState(t?.power_alert_enabled||!1),[D,K]=w.useState(t?.power_alert_high?.toString()||""),[Y,q]=w.useState(t?.power_alert_low?.toString()||""),[Z,re]=w.useState(t?.schedule_enabled||!1),[ie,U]=w.useState(t?.schedule_on_time||""),[G,ee]=w.useState(t?.schedule_off_time||""),[ne,se]=w.useState(t?.show_in_switchbar||!1),[de,he]=w.useState(!1),[Ee,ge]=w.useState({scanned:0,total:0}),[Ne,Re]=w.useState([]),te=w.useRef(null),{data:Je}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:B}=lt({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:H}=lt({queryKey:["settings"],queryFn:pe.getSettings}),W=!!(H?.ha_enabled&&H?.ha_url&&H?.ha_token),{data:z,isLoading:V}=lt({queryKey:["ha-entities"],queryFn:pe.getHAEntities,enabled:i==="homeassistant"&&W,retry:!1,staleTime:0}),{data:Q}=lt({queryKey:["ha-sensor-entities"],queryFn:pe.getHASensorEntities,enabled:i==="homeassistant"&&W,retry:!1,staleTime:0});w.useEffect(()=>{const _e=Ie=>{Ie.key==="Escape"&&e()};return window.addEventListener("keydown",_e),()=>{window.removeEventListener("keydown",_e),te.current&&clearInterval(te.current)}},[e]);const Te=async()=>{he(!0),Re([]),ge({scanned:0,total:0}),F(null);try{await pe.startTasmotaScan();const _e=async()=>{try{const Ie=await pe.getTasmotaScanStatus();ge({scanned:Ie.scanned,total:Ie.total});const We=await pe.getDiscoveredTasmotaDevices();Re(We),Ie.running||(he(!1),te.current&&(clearInterval(te.current),te.current=null))}catch(Ie){console.error("Polling error:",Ie)}};await _e(),te.current=setInterval(_e,500)}catch(_e){he(!1);const Ie=_e instanceof Error?_e.message:typeof _e=="string"?_e:JSON.stringify(_e);F(Ie||"Failed to start scan")}},ke=async()=>{try{await pe.stopTasmotaScan()}catch{}he(!1),te.current&&(clearInterval(te.current),te.current=null)},Ae=_e=>{u(_e.ip_address),l(_e.name),T(null)},$=ft({mutationFn:()=>pe.testSmartPlugConnection(c,d||null,m||null),onSuccess:_e=>{T(_e),F(null),!o&&_e.device_name&&l(_e.device_name)},onError:_e=>{T(null),F(_e.message)}}),L=ft({mutationFn:_e=>pe.createSmartPlug(_e),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:_e=>{F(_e.message)}}),oe=ft({mutationFn:_e=>pe.updateSmartPlug(t.id,_e),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:_e=>{F(_e.message)}}),ce=Je?.filter(_e=>!B?.some(We=>We.printer_id===_e.id&&We.id!==t?.id)),xe=_e=>{if(_e.preventDefault(),F(null),!o.trim()){F("Name is required");return}if(i==="tasmota"&&!c.trim()){F("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!x){F("Entity is required for Home Assistant plugs");return}const Ie={name:o.trim(),plug_type:i,ip_address:i==="tasmota"?c.trim():null,ha_entity_id:i==="homeassistant"?x:null,ha_power_entity:i==="homeassistant"&&b||null,ha_energy_today_entity:i==="homeassistant"&&M||null,ha_energy_total_entity:i==="homeassistant"&&A||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:k,power_alert_enabled:I,power_alert_high:D?parseFloat(D):null,power_alert_low:Y?parseFloat(Y):null,schedule_enabled:Z,schedule_on_time:ie||null,schedule_off_time:G||null,show_in_switchbar:ne};r?oe.mutate(Ie):L.mutate(Ie)},ve=L.isPending||oe.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:_e=>_e.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:xe,className:"p-6 space-y-4 overflow-y-auto",children:[P&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:P}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),T(null),F(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${i==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(Fs,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),T(null),F(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${i==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(R2,{className:"w-4 h-4"}),"Home Assistant"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[de?s.jsxs(Me,{type:"button",variant:"secondary",onClick:ke,className:"w-full",children:[s.jsx(Ut,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Me,{type:"button",variant:"primary",onClick:Te,className:"w-full",children:[s.jsx(Ws,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),de&&Ee.total>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[s.jsx("span",{children:"Scanning network..."}),s.jsxs("span",{children:[Ee.scanned," / ",Ee.total]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Ee.scanned/Ee.total*100}%`}})})]}),Ne.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Ne.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Ne.map(_e=>s.jsxs("button",{type:"button",onClick:()=>Ae(_e),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Fs,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:_e.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:_e.ip_address})]})]}),_e.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${_e.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(uu,{className:"w-3 h-3"}),_e.state]})]},_e.ip_address))})]}),!de&&Ne.length===0&&Ee.total>0&&s.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),i==="homeassistant"&&s.jsxs("div",{className:"space-y-3",children:[!W&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",s.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),s.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:s.jsx("option",{children:"Choose an entity..."})})]})]}),W&&s.jsxs(s.Fragment,{children:[V&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(pt,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),z&&z.length===0&&s.jsx("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:"No switch/light entities found in Home Assistant"}),z&&z.length>0&&(()=>{const _e=B?.filter(We=>We.ha_entity_id&&We.id!==t?.id).map(We=>We.ha_entity_id)||[],Ie=z.filter(We=>!_e.includes(We.entity_id));return s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("select",{value:x,onChange:We=>{v(We.target.value);const ht=z?.find(qe=>qe.entity_id===We.target.value);ht&&!o&&l(ht.friendly_name)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"Choose an entity..."}),Ie.map(We=>s.jsxs("option",{value:We.entity_id,children:[We.friendly_name," (",We.entity_id,") - ",We.state]},We.entity_id))]}),_e.length>0&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[_e.length," entity(s) already configured"]})]})})(),x&&z&&s.jsxs("div",{className:"p-3 bg-bambu-green/20 border border-bambu-green/50 rounded-lg text-sm text-bambu-green flex items-center gap-2",children:[s.jsx(kn,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Entity selected"}),s.jsxs("p",{className:"text-xs opacity-80",children:[z.find(_e=>_e.entity_id===x)?.friendly_name," - ",z.find(_e=>_e.entity_id===x)?.state]})]})]}),x&&Q&&Q.length>0&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Select sensors that provide power/energy data. These can be from any device in Home Assistant."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),s.jsxs("select",{value:b,onChange:_e=>y(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"None"}),Q.filter(_e=>_e.unit_of_measurement==="W"||_e.unit_of_measurement==="kW"||_e.unit_of_measurement==="mW").map(_e=>s.jsxs("option",{value:_e.entity_id,children:[_e.friendly_name," (",_e.state," ",_e.unit_of_measurement,")"]},_e.entity_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),s.jsxs("select",{value:M,onChange:_e=>S(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"None"}),Q.filter(_e=>_e.unit_of_measurement==="kWh"||_e.unit_of_measurement==="Wh"||_e.unit_of_measurement==="MWh").map(_e=>s.jsxs("option",{value:_e.entity_id,children:[_e.friendly_name," (",_e.state," ",_e.unit_of_measurement,")"]},_e.entity_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),s.jsxs("select",{value:A,onChange:_e=>E(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"None"}),Q.filter(_e=>_e.unit_of_measurement==="kWh"||_e.unit_of_measurement==="Wh"||_e.unit_of_measurement==="MWh").map(_e=>s.jsxs("option",{value:_e.entity_id,children:[_e.friendly_name," (",_e.state," ",_e.unit_of_measurement,")"]},_e.entity_id))]})]})]})]})]}),i==="tasmota"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:c,onChange:_e=>{u(_e.target.value),T(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>$.mutate(),disabled:!c.trim()||$.isPending,children:[$.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dp,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&R&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${R.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:R.success?s.jsxs(s.Fragment,{children:[s.jsx(kn,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Connected!"}),s.jsxs("p",{className:"text-sm opacity-80",children:[R.device_name&&`Device: ${R.device_name} - `,"State: ",R.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Pg,{className:"w-5 h-5"}),s.jsx("span",{children:"Connection failed"})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:_e=>l(_e.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i==="tasmota"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),s.jsx("input",{type:"text",value:d,onChange:_e=>f(_e.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:m,onChange:_e=>p(_e.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),s.jsxs("select",{value:k??"",onChange:_e=>C(_e.target.value?Number(_e.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No printer (manual control only)"}),ce?.map(_e=>s.jsx("option",{value:_e.id,children:_e.name},_e.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ef,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:I,onChange:_e=>X(_e.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),I&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),s.jsx("input",{type:"number",value:D,onChange:_e=>K(_e.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),s.jsx("input",{type:"number",value:Y,onChange:_e=>q(_e.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Z,onChange:_e=>re(_e.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Z&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),s.jsx("input",{type:"time",value:ie,onChange:_e=>U(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),s.jsx("input",{type:"time",value:G,onChange:_e=>ee(_e.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(D2,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ne,onChange:_e=>se(_e.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:ve,className:"flex-1",children:[ve?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(cs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function $n({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return s.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:s.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const Rqe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function Dqe({provider:t,onEdit:e}){const n=Qt(),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),d=u?.find(v=>v.id===t.printer_id),f=ft({mutationFn:v=>pe.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=ft({mutationFn:()=>pe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=ft({mutationFn:()=>pe.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),x=v=>v||"";return s.jsxs(s.Fragment,{children:[s.jsx(wt,{className:"relative",children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:s.jsx(ef,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:Rqe[t.provider_type]||t.provider_type})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&s.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",Jp(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(mi(t.last_error_at)?.getTime()||0)>(mi(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),s.jsx($n,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]})]}),d&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),s.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&s.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),s.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&s.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&s.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&s.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&s.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&s.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&s.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&s.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[s.jsx(fw,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[s.jsx(Qr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Me,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(iD,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&s.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?s.jsx(kn,{className:"w-4 h-4"}):s.jsx(qi,{className:"w-4 h-4"}),s.jsx("span",{children:l.message})]}),s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Dd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(Jc,{className:"w-4 h-4"}):s.jsx(Ji,{className:"w-4 h-4"})]}),a&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),s.jsx($n,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Started"}),s.jsx($n,{checked:t.on_print_start,onChange:v=>f.mutate({on_print_start:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx($n,{checked:t.on_print_complete,onChange:v=>f.mutate({on_print_complete:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx($n,{checked:t.on_print_failed,onChange:v=>f.mutate({on_print_failed:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx($n,{checked:t.on_print_stopped,onChange:v=>f.mutate({on_print_stopped:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),s.jsx($n,{checked:t.on_print_progress,onChange:v=>f.mutate({on_print_progress:v})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),s.jsx($n,{checked:t.on_printer_offline,onChange:v=>f.mutate({on_printer_offline:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx($n,{checked:t.on_printer_error,onChange:v=>f.mutate({on_printer_error:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx($n,{checked:t.on_filament_low,onChange:v=>f.mutate({on_filament_low:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),s.jsx($n,{checked:t.on_maintenance_due??!1,onChange:v=>f.mutate({on_maintenance_due:v})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_humidity_high??!1,onChange:v=>f.mutate({on_ams_humidity_high:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_temperature_high??!1,onChange:v=>f.mutate({on_ams_temperature_high:v})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_ht_humidity_high??!1,onChange:v=>f.mutate({on_ams_ht_humidity_high:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_ht_temperature_high??!1,onChange:v=>f.mutate({on_ams_ht_temperature_high:v})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fw,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx($n,{checked:t.quiet_hours_enabled,onChange:v=>f.mutate({quiet_hours_enabled:v})})]}),t.quiet_hours_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qr,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx($n,{checked:t.daily_digest_enabled,onChange:v=>f.mutate({daily_digest_enabled:v})})]}),t.daily_digest_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hn,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(L2,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(Jt,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Rn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{m.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const HG=[{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 Oqe({provider:t,onClose:e}){const n=Qt(),r=!!t,[i,a]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,f]=w.useState(t?.quiet_hours_enabled||!1),[m,p]=w.useState(t?.quiet_hours_start||"22:00"),[x,v]=w.useState(t?.quiet_hours_end||"07:00"),[b,y]=w.useState(t?.daily_digest_enabled||!1),[M,S]=w.useState(t?.daily_digest_time||"08:00"),[A,E]=w.useState(t?.on_print_start??!1),[k,C]=w.useState(t?.on_print_complete??!0),[R,T]=w.useState(t?.on_print_failed??!0),[P,F]=w.useState(t?.on_print_stopped??!0),[I,X]=w.useState(t?.on_print_progress??!1),[D,K]=w.useState(t?.on_printer_offline??!1),[Y,q]=w.useState(t?.on_printer_error??!1),[Z,re]=w.useState(t?.on_filament_low??!1),[ie,U]=w.useState(t?.on_maintenance_due??!1),[G,ee]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([z,V])=>[z,String(V)])):{}),[ne,se]=w.useState(null),[de,he]=w.useState(null),{data:Ee}=lt({queryKey:["printers"],queryFn:pe.getPrinters});w.useEffect(()=>{const z=V=>{V.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e]);const ge=ft({mutationFn:()=>pe.testNotificationConfig({provider_type:o,config:G}),onSuccess:z=>{se(z),he(null)},onError:z=>{se({success:!1,message:z.message})}}),Ne=ft({mutationFn:z=>pe.createNotificationProvider(z),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:z=>{he(z.message)}}),Re=ft({mutationFn:z=>pe.updateNotificationProvider(t.id,z),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:z=>{he(z.message)}}),te=z=>{if(z.preventDefault(),he(null),!i.trim()){he("Name is required");return}const V=H(o);for(const Te of V)if(!G[Te.key]?.trim()){he(`${Te.label} is required`);return}const Q={name:i.trim(),provider_type:o,config:G,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?m:null,quiet_hours_end:d?x:null,daily_digest_enabled:b,daily_digest_time:b?M:null,on_print_start:A,on_print_complete:k,on_print_failed:R,on_print_stopped:P,on_print_progress:I,on_printer_offline:D,on_printer_error:Y,on_filament_low:Z,on_maintenance_due:ie};r?Re.mutate(Q):Ne.mutate(Q)},Je=Ne.isPending||Re.isPending,B=z=>{switch(z){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},H=z=>B(z).filter(V=>V.required),W=B(o);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:z=>z.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:te,className:"p-6 space-y-4",children:[de&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:de}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:z=>a(z.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:z=>{l(z.target.value),ee({}),se(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:HG.map(z=>s.jsx("option",{value:z.value,children:z.label},z.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:HG.find(z=>z.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),W.map(z=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[z.label," ",z.required&&"*"]}),z.type==="select"&&z.options?s.jsx("select",{value:G[z.key]||z.options[0]?.value||"",onChange:V=>{ee({...G,[z.key]:V.target.value}),se(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:z.options.map(V=>s.jsx("option",{value:V.value,children:V.label},V.value))}):s.jsx("input",{type:z.type,value:G[z.key]||"",onChange:V=>{ee({...G,[z.key]:V.target.value}),se(null)},placeholder:z.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"})]},z.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>{se(null),ge.mutate()},disabled:ge.isPending||!G[H(o)[0]?.key],className:"flex-1",children:[ge.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(iD,{className:"w-4 h-4"}),"Test Configuration"]})}),ne&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ne.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ne.success?s.jsxs(s.Fragment,{children:[s.jsx(kn,{className:"w-5 h-5"}),s.jsx("span",{children:ne.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(qi,{className:"w-5 h-5"}),s.jsx("span",{children:ne.message})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),s.jsxs("select",{value:c??"",onChange:z=>u(z.target.value?Number(z.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"All printers"}),Ee?.map(z=>s.jsx("option",{value:z.id,children:z.name},z.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),s.jsx($n,{checked:d,onChange:f})]}),d&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),s.jsx("input",{type:"time",value:m,onChange:z=>p(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),s.jsx("input",{type:"time",value:x,onChange:z=>v(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),s.jsx($n,{checked:b,onChange:y})]}),b&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),s.jsx("input",{type:"time",value:M,onChange:z=>S(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Start"}),s.jsx($n,{checked:A,onChange:E})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx($n,{checked:k,onChange:C})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx($n,{checked:R,onChange:T})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx($n,{checked:P,onChange:F})]}),s.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Progress"}),s.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),s.jsx($n,{checked:I,onChange:X})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx($n,{checked:D,onChange:K})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx($n,{checked:Y,onChange:q})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx($n,{checked:Z,onChange:re})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx($n,{checked:ie,onChange:U})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:Je,className:"flex-1",children:[Je?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(cs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Lqe({template:t,onClose:e}){const n=Qt(),r=w.useRef(null),[i,a]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,f]=w.useState(!0),{data:m}=lt({queryKey:["template-variables"],queryFn:pe.getTemplateVariables}),p=m?.find(E=>E.event_type===t.event_type),{data:x,isLoading:v}=lt({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>pe.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const E=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const b=ft({mutationFn:E=>pe.updateNotificationTemplate(t.id,E),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:E=>{u(E.message)}}),y=ft({mutationFn:()=>pe.resetNotificationTemplate(t.id),onSuccess:E=>{a(E.title_template),l(E.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:E=>{u(E.message)}}),M=E=>{if(E.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})},S=E=>{const k=r.current;if(!k)return;const C=k.selectionStart,R=k.selectionEnd,T=o,P=T.substring(0,C),F=T.substring(R),I=P+`{${E}}`+F;l(I),setTimeout(()=>{k.focus();const X=C+E.length+2;k.setSelectionRange(X,X)},0)},A=i!==t.title_template||o!==t.body_template;return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:M,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange:E=>a(E.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),s.jsx("textarea",{ref:r,value:o,onChange:E=>l(E.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),p&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(E=>s.jsxs("button",{type:"button",onClick:()=>S(E),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(qn,{className:"w-3 h-3"}),E]},E))}),s.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(vf,{className:"w-4 h-4"}),"Live Preview"]}),s.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&s.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:v?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),s.jsx("div",{className:"text-white font-medium",children:x.title})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),s.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):s.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[s.jsxs(Me,{type:"button",variant:"ghost",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-orange-400 hover:text-orange-300",children:[y.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Hf,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Me,{onClick:M,disabled:b.isPending||!A,children:[b.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(cs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const Iqe={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"},Fqe={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 Uqe({onClose:t}){const e=Qt(),{showToast:n}=Un(),[r,i]=w.useState(7),[a,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=lt({queryKey:["settings"],queryFn:pe.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:p,isRefetching:x}=lt({queryKey:["notification-logs",r,l],queryFn:()=>pe.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:v}=lt({queryKey:["notification-log-stats",r],queryFn:()=>pe.getNotificationLogStats(r)}),b=ft({mutationFn:()=>pe.clearNotificationLogs(30),onSuccess:M=>{n(M.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:M=>{n(`Failed to clear logs: ${M.message}`,"error")}}),y=M=>{const S=mi(M);if(!S)return"";const E=new Date().getTime()-S.getTime();return E<6e4?"Just now":E<36e5?`${Math.floor(E/6e4)}m ago`:E<864e5?`${Math.floor(E/36e5)}h ago`:S.toLocaleDateString()+" "+sfe(S,d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(hw,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),v&&s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:s.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[s.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",s.jsx("span",{className:"text-white font-medium",children:v.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(kn,{className:"w-4 h-4"}),v.success_count," sent"]}),v.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(qi,{className:"w-4 h-4"}),v.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.jsxs("select",{value:r,onChange:M=>i(Number(M.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[s.jsx("option",{value:1,children:"Last 24 hours"}),s.jsx("option",{value:7,children:"Last 7 days"}),s.jsx("option",{value:30,children:"Last 30 days"}),s.jsx("option",{value:90,children:"Last 90 days"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:M=>c(M.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),s.jsx("div",{className:"flex-1"}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(yr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jt,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(M=>s.jsx(zqe,{log:M,isExpanded:a===M.id,onToggle:()=>o(a===M.id?null:M.id),formatDate:y,formatFullDate:S=>eg(S,d)},M.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(hw,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function zqe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return s.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[s.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?s.jsx(kn,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(qi,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${Fqe[t.event_type]||"text-bambu-gray"}`,children:Iqe[t.event_type]||t.event_type}),s.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),s.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?s.jsx(Jc,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Ji,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&s.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),s.jsx("p",{className:"text-sm text-white",children:t.title})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),s.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),s.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),s.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[s.jsxs("span",{children:["Provider: ",t.provider_type]}),s.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}const T1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(F2,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(ef,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(Ua,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(Fs,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Y0,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Ir,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:s.jsx(nD,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Od,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(Is,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:s.jsx(xa,{className:"w-4 h-4"}),default:!1,description:"Projects, BOM items, and attachments"},{id:"pending_uploads",labelKey:"backup.categories.pendingUploads",defaultLabel:"Pending Uploads",icon:s.jsx(bi,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"},{id:"api_keys",labelKey:"backup.categories.apiKeys",defaultLabel:"API Keys",icon:s.jsx(Vh,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function Bqe({onClose:t,onExport:e}){const{t:n}=Tg(),[r,i]=w.useState(()=>{const x={};return T1.forEach(v=>{x[v.id]=v.default}),x}),[a,o]=w.useState(!1),[l,c]=w.useState(!1);w.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(v=>({...v,[x]:!v[x]}))},d=()=>{const x={};T1.forEach(v=>{x[v.id]=!0}),i(x)},f=()=>{const x={};T1.forEach(v=>{x[v.id]=!1}),i(x)},m=Object.values(r).filter(Boolean).length,p=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:t,children:s.jsx(wt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:s.jsx(Jr,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),s.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[s.jsx("button",{onClick:d,disabled:l,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),s.jsx("span",{className:"text-bambu-gray",children:"|"}),s.jsx("button",{onClick:f,disabled:l,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),s.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${l?"opacity-50 pointer-events-none":""}`,children:T1.map(x=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[s.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:l,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),s.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&s.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Is,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[s.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),s.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&s.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Vh,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),s.jsx($n,{checked:a,onChange:o})]}),a&&s.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[s.jsx(En,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:m,defaultValue:`${m} categories selected`})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Me,{onClick:p,disabled:m===0||l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:l?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Jr,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const VG={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives",projects:"Projects",pending_uploads:"Pending Uploads",external_links:"External Links",api_keys:"API Keys"};function $qe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=w.useState("options"),[a,o]=w.useState(!1),[l,c]=w.useState(null),[u,d]=w.useState(null),[f,m]=w.useState(new Set),p=w.useRef(null);w.useEffect(()=>{const A=E=>{E.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,n,r,u]);const x=A=>{const E=A.target.files?.[0];E&&c(E)},v=async()=>{if(l){i("restoring");try{const A=await e(l,a);d(A),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},b=()=>{u?.success&&n(),t()},y=A=>{m(E=>{const k=new Set(E);return k.has(A)?k.delete(A):k.add(A),k})},M=u?.restored?Object.values(u.restored).reduce((A,E)=>A+E,0)+(u.files_restored||0):0,S=u?.total_skipped||0;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:A=>{A.target===A.currentTarget&&r!=="restoring"&&t()},children:s.jsx(wt,{className:"w-full max-w-lg",children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?s.jsx(kn,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(En,{className:"w-5 h-5"}):s.jsx(bi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),r==="options"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("input",{ref:p,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),s.jsx("button",{type:"button",onClick:()=>p.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:l?s.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[s.jsx(kn,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:l.name})]}):s.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[s.jsx(bi,{className:"w-8 h-8"}),s.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(En,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[s.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),s.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"Printers"})," - matched by serial number"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Pending Uploads"})," - matched by filename"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),s.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[a?s.jsx(yr,{className:"w-4 h-4 text-orange-400"}):s.jsx(mw,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),s.jsx($n,{checked:a,onChange:o})]})}),a&&s.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(En,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[s.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Me,{type:"button",onClick:v,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(bi,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&s.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[s.jsx(pt,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[s.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:M}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),s.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[s.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:S}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,A])=>A>0)&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),s.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,A])=>A>0).map(([A,E])=>s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:VG[A]||A}),s.jsx("span",{className:"text-bambu-green font-medium",children:E})]},A)),(u.files_restored||0)>0&&s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),s.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,A])=>A>0)&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(mw,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,A])=>A>0).map(([A,E])=>{const k=u.skipped_details?.[A]||[],C=f.has(A);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>k.length>0&&y(A),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${k.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[s.jsxs("span",{className:"text-white flex items-center gap-2",children:[VG[A]||A,k.length>0&&(C?s.jsx(Jc,{className:"w-3 h-3"}):s.jsx(Ji,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:E})]}),C&&k.length>0&&s.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[k.slice(0,10).map((R,T)=>s.jsx("div",{children:R},T)),k.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",k.length-10," more"]})]})]},A)})})]}),u.new_api_keys&&u.new_api_keys.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(En,{className:"w-4 h-4 text-orange-500"}),"New API Keys Generated"]}),s.jsxs("div",{className:"p-3 rounded bg-orange-500/10 border border-orange-500/30",children:[s.jsx("p",{className:"text-xs text-orange-200 mb-2",children:"These keys are only shown once. Copy them now!"}),s.jsx("div",{className:"space-y-2",children:u.new_api_keys.map((A,E)=>s.jsxs("div",{className:"p-2 rounded bg-bambu-dark",children:[s.jsx("div",{className:"text-sm text-white font-medium mb-1",children:A.name}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-xs text-bambu-green bg-bambu-dark-tertiary px-2 py-1 rounded font-mono flex-1 break-all",children:A.key}),s.jsx("button",{onClick:()=>navigator.clipboard.writeText(A.key),className:"text-xs text-bambu-gray hover:text-white px-2 py-1 rounded bg-bambu-dark-tertiary",children:"Copy"})]})]},E))})]})]}),M===0&&S===0&&s.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),s.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Me,{onClick:b,children:"Close"})})]})]})})})}async function Hqe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function Vqe(t){const e=await fetch("/api/v1/settings/spoolman",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error("Failed to save Spoolman settings");return e.json()}function Gqe(){const t=Qt(),[e,n]=w.useState(!1),[r,i]=w.useState(""),[a,o]=w.useState("auto"),[l,c]=w.useState(!1),[u,d]=w.useState("all"),[f,m]=w.useState(!1),[p,x]=w.useState(!1),{data:v,isLoading:b}=lt({queryKey:["spoolman-settings"],queryFn:Hqe}),{data:y,isLoading:M,refetch:S}=lt({queryKey:["spoolman-status"],queryFn:pe.getSpoolmanStatus,refetchInterval:3e4}),{data:A}=lt({queryKey:["printers"],queryFn:pe.getPrinters});w.useEffect(()=>{v&&(n(v.spoolman_enabled==="true"),i(v.spoolman_url||""),o(v.spoolman_sync_mode||"auto"),m(!0))},[v]),w.useEffect(()=>{if(!f||!v)return;if(v.spoolman_enabled==="true"!==e||(v.spoolman_url||"")!==r||(v.spoolman_sync_mode||"auto")!==a){const K=setTimeout(()=>{E.mutate()},500);return()=>clearTimeout(K)}},[e,r,a,f]);const E=ft({mutationFn:()=>Vqe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),k=ft({mutationFn:pe.connectSpoolman,onSuccess:()=>{S()}}),C=ft({mutationFn:pe.disconnectSpoolman,onSuccess:()=>{S()}}),R=ft({mutationFn:pe.syncAllPrintersAms,onSuccess:D=>{D.success}}),T=ft({mutationFn:D=>pe.syncPrinterAms(D),onSuccess:D=>{D.success}}),P=()=>{u==="all"?R.mutate():T.mutate(u)},F=R.isPending||T.isPending,I=u==="all"?R.data:T.data,X=u==="all"?R.isSuccess:T.isSuccess;return b?s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Yp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Mt,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Yp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),E.isPending&&s.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(ps,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Rl,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-xs text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),s.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[s.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),s.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),s.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),s.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),s.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Spoolman"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:D=>n(D.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),s.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:D=>i(D.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),s.jsxs("select",{value:a,onChange:D=>o(D.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[s.jsx("option",{value:"auto",children:"Automatic"}),s.jsx("option",{value:"manual",children:"Manual Only"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),M?s.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(ps,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Ut,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:y?.connected?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>C.mutate(),disabled:C.isPending,children:[C.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Wue,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Me,{size:"sm",onClick:()=>k.mutate(),disabled:k.isPending||!r,children:[k.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Cl,{className:"w-4 h-4"}),"Connect"]})})]}),k.isError&&s.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:k.error.message}),y?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsxs("select",{value:u,onChange:D=>d(D.target.value==="all"?"all":Number(D.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[s.jsx("option",{value:"all",children:"All Printers"}),A?.map(D=>s.jsx("option",{value:D.id,children:D.name},D.id))]}),s.jsx(Ji,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:P,disabled:F,children:[F?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(yr,{className:"w-4 h-4"}),"Sync"]})]})]}),X&&I&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${I.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:I.success?`Synced ${I.synced_count} spool${I.synced_count!==1?"s":""} successfully`:`Synced ${I.synced_count} spool${I.synced_count!==1?"s":""} with ${I.errors.length} error${I.errors.length!==1?"s":""}`}),I.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(En,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[I.skipped_count," spool",I.skipped_count!==1?"s":""," skipped"]})]}),I.skipped_count>5&&s.jsx("button",{onClick:()=>x(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?I.skipped:I.skipped.slice(0,5)).map((D,K)=>s.jsxs("li",{className:"flex items-center gap-2",children:[D.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${D.color}`}}),s.jsx("span",{children:D.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",D.reason]})]},K)),!p&&I.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",I.skipped_count-5," more"]})]})]}),I.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:I.errors.map((D,K)=>s.jsx("li",{children:D},K))})]})]})]})]})]})}function Wqe({link:t,onClose:e}){const n=Qt(),{mode:r}=Xd(),i=!!t,a=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,f]=w.useState(t?.icon||"link"),[m,p]=w.useState(!!t?.custom_icon),[x,v]=w.useState(t?.custom_icon?pe.getExternalLinkIconUrl(t.id):null),[b,y]=w.useState(null),[M,S]=w.useState(null);w.useEffect(()=>{const F=I=>{I.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const A=ft({mutationFn:async F=>{const I=await pe.createExternalLink(F);return b?await pe.uploadExternalLinkIcon(I.id,b):I},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),E=ft({mutationFn:async F=>{let I=await pe.updateExternalLink(t.id,F);return b?I=await pe.uploadExternalLinkIcon(t.id,b):!m&&t?.custom_icon&&(I=await pe.deleteExternalLinkIcon(t.id)),I},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),k=F=>{const I=F.target.files?.[0];if(I){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(I.type)){S("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(I.size>1024*1024){S("Image file must be less than 1MB");return}y(I),p(!0);const D=new FileReader;D.onload=K=>{v(K.target?.result)},D.readAsDataURL(I)}},C=()=>{y(null),v(null),p(!1),a.current&&(a.current.value="")},R=F=>{if(F.preventDefault(),S(null),!o.trim()){S("Name is required");return}if(!c.trim()){S("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){S("URL must start with http:// or https://");return}const I={name:o.trim(),url:c.trim(),icon:d};i?E.mutate(I):A.mutate(I)},T=A.isPending||E.isPending,P=z2(d);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:F=>F.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:m&&x?s.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(P,{className:"w-5 h-5"})}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:R,className:"p-6 space-y-4",children:[M&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:M}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:F=>l(F.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),s.jsx("input",{type:"text",value:c,onChange:F=>u(F.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),s.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:k}),m&&x?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),s.jsx("button",{type:"button",onClick:C,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(Jt,{className:"w-4 h-4"})})]}):s.jsxs(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(bi,{className:"w-4 h-4"}),"Upload"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!m&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(efe,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:T,className:"flex-1",children:[T?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(cs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function qqe(){const t=Qt(),[e,n]=w.useState(!1),[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(null),{data:u,isLoading:d}=lt({queryKey:["external-links"],queryFn:pe.getExternalLinks}),f=ft({mutationFn:M=>pe.deleteExternalLink(M),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=ft({mutationFn:M=>pe.reorderExternalLinks(M),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(M,S)=>{c(S),M.dataTransfer.effectAllowed="move"},x=M=>{M.preventDefault(),M.dataTransfer.dropEffect="move"},v=(M,S)=>{if(M.preventDefault(),l===null||l===S||!u)return;const A=u.map(R=>R.id),E=A.indexOf(l),k=A.indexOf(S);if(E===-1||k===-1)return;const C=[...A];C.splice(E,1),C.splice(k,0,l),m.mutate(C),c(null)},b=M=>{o(M)},y=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Cl,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Me,{size:"sm",onClick:()=>n(!0),children:[s.jsx(qn,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Mt,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(M=>{const S=z2(M.icon);return s.jsxs("div",{draggable:!0,onDragStart:A=>p(A,M.id),onDragOver:x,onDrop:A=>v(A,M.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===M.id?"opacity-50":""}`,children:[s.jsx(Qp,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:s.jsx(S,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-white font-medium truncate",children:M.name}),s.jsx(Lr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:M.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>i(M),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:s.jsx(Ha,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>b(M),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:s.jsx(Jt,{className:"w-4 h-4"})})]})]},M.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Cl,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No external links configured"}),s.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&s.jsx(Wqe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Rn,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:y,onCancel:()=>o(null)})]})}function Kqe(){const t=Qt(),{showToast:e}=Un(),[n,r]=w.useState(!1),[i,a]=w.useState(""),[o,l]=w.useState("immediate"),[c,u]=w.useState("3DPrinter-X1-Carbon"),[d,f]=w.useState(!1),[m,p]=w.useState(null),{data:x,isLoading:v}=lt({queryKey:["virtual-printer-settings"],queryFn:R1.getSettings,refetchInterval:1e4}),{data:b}=lt({queryKey:["virtual-printer-models"],queryFn:R1.getModels});w.useEffect(()=>{if(x){r(x.enabled);let R=x.mode==="queue"?"review":x.mode;R!=="immediate"&&R!=="review"&&R!=="print_queue"&&(R="immediate"),l(R),u(x.model)}},[x]);const y=ft({mutationFn:R=>R1.updateSettings(R),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:R=>{if(e(R.message||"Failed to update settings","error"),x){r(x.enabled);const T=x.mode==="queue"?"review":x.mode;l(T==="print_queue"||T==="review"?T:"immediate"),u(x.model)}p(null)}}),M=()=>{const R=!n;if(R&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(R),p("toggle"),y.mutate({enabled:R,access_code:i||void 0,mode:o})},S=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}p("accessCode"),y.mutate({access_code:i}),a("")},A=R=>{l(R),p("mode"),y.mutate({mode:R})},E=R=>{u(R),p("model"),y.mutate({model:R})};if(v)return s.jsx(wt,{children:s.jsx(Mt,{className:"py-8 flex justify-center",children:s.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const k=x?.status,C=k?.running||!1;return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ir,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),k&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${C?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${C?"bg-green-400 animate-pulse":"bg-gray-500"}`}),C?"Running":"Stopped"]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),s.jsx("div",{className:"text-sm text-bambu-gray",children:C?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:M,disabled:m==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${m==="toggle"?"opacity-50":""}`,children:s.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Printer Model"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:c,onChange:R=>E(R.target.value),disabled:m==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:b?.models&&Object.entries(b.models).sort(([,R],[,T])=>R.localeCompare(T)).map(([R,T])=>s.jsx("option",{value:R,children:T},R))}),s.jsx(Ji,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&C&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Rl,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:x?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(ps,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(En,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:d?"text":"password",value:i,onChange:R=>a(R.target.value),placeholder:x?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),s.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?s.jsx(T2,{className:"w-4 h-4"}):s.jsx(vf,{className:"w-4 h-4"})})]}),s.jsx(Me,{onClick:S,disabled:!i||m==="accessCode",variant:"primary",children:m==="accessCode"?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Save"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&s.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Mode"}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("button",{onClick:()=>A("immediate"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Archive"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files immediately"})]}),s.jsxs("button",{onClick:()=>A("review"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="review"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Review"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag before archiving"})]}),s.jsxs("button",{onClick:()=>A("print_queue"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="print_queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Queue"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive and add to print queue"})]})]})]})]})]})}),s.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[s.jsx(wt,{className:"border-l-4 border-l-yellow-500",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(En,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),s.jsx("p",{className:"text-bambu-gray mb-3",children:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings."}),s.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[s.jsx(Lr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(wt,{children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Rl,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:s.jsx("strong",{className:"text-white",children:"How it works:"})}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:"Complete the setup guide for your platform"}),s.jsx("li",{children:"Enable the virtual printer and set an access code"}),s.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),s.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),s.jsx("li",{children:"Connect using the access code you set"}),s.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),k&&C&&s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(Mt,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),s.jsx("div",{className:"text-white",children:k.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:k.model_name||k.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:k.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:k.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:k.pending_files})]})]})})]})]})]})}const Xqe={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 Yqe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Tb(t,e,n=0){if(n>5)return"...";if(e.$ref)return Tb(t,Yqe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=Tb(t,i,n+1);typeof a=="object"&&a!==null&&Object.assign(r,a)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[Tb(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=Tb(t,a,n+1);return r}return{};default:return null}}function Qqe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[f,m]=w.useState(null),[p,x]=w.useState(!1),[v,b]=w.useState(!1);w.useEffect(()=>{if(a&&n.parameters){const R={};for(const T of n.parameters)T.schema?.default!==void 0&&(R[T.name]=String(T.schema.default));c(T=>({...R,...T}))}},[a,n.parameters]),w.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const R=n.requestBody.content["application/json"].schema,T=Tb(r,R);d(JSON.stringify(T,null,2))}},[a,n.requestBody,r,u]);const M=(()=>{const R=[];for(const T of n.parameters||[])if(T.in==="path"||T.required){const P=l[T.name];(P===void 0||P==="")&&R.push(T.name)}return R})(),S=async()=>{if(M.length>0){m({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${M.join(", ")}`,duration:0});return}x(!0),m(null);try{let R=t;const T=new URLSearchParams;for(const ie of n.parameters||[]){const U=l[ie.name];U!==void 0&&U!==""&&(ie.in==="path"?R=R.replace(`{${ie.name}}`,encodeURIComponent(U)):ie.in==="query"&&T.append(ie.name,U))}const P=T.toString(),F=`${R}${P?`?${P}`:""}`,I={"Content-Type":"application/json"};i&&(I["X-API-Key"]=i);const X={method:e.toUpperCase(),headers:I};["post","put","patch"].includes(e)&&u&&(X.body=u);const D=performance.now(),K=await fetch(F,X),Y=Math.round(performance.now()-D),q={};K.headers.forEach((ie,U)=>{q[U]=ie});let Z;K.headers.get("content-type")?.includes("application/json")?Z=await K.json():Z=await K.text(),m({status:K.status,statusText:K.statusText,headers:q,body:Z,duration:Y})}catch(R){m({status:0,statusText:"Network Error",headers:{},body:R instanceof Error?R.message:"Unknown error",duration:0})}finally{x(!1)}},A=async()=>{if(f){const R=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(R),b(!0),setTimeout(()=>b(!1),2e3)}catch{const T=document.createElement("textarea");T.value=R,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)}}},E=(n.parameters||[]).filter(R=>R.in==="path"),k=(n.parameters||[]).filter(R=>R.in==="query"),C=["post","put","patch"].includes(e)&&n.requestBody;return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?s.jsx(Ji,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Vs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${Xqe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),s.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&s.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),a&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&s.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),E.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),s.jsx("div",{className:"space-y-2",children:E.map(R=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[R.name]||"",onChange:T=>c(P=>({...P,[R.name]:T.target.value})),placeholder:R.description||R.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"})]},R.name))})]}),k.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),s.jsx("div",{className:"space-y-2",children:k.map(R=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),R.schema?.enum?s.jsxs("select",{value:l[R.name]||"",onChange:T=>c(P=>({...P,[R.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:[s.jsx("option",{value:"",children:"-- Select --"}),R.schema.enum.map(T=>s.jsx("option",{value:T,children:T},T))]}):s.jsx("input",{type:"text",value:l[R.name]||"",onChange:T=>c(P=>({...P,[R.name]:T.target.value})),placeholder:R.description||R.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"})]},R.name))})]}),C&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),s.jsx("textarea",{value:u,onChange:R=>d(R.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{onClick:S,disabled:p,children:[p?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(nl,{className:"w-4 h-4"}),"Execute"]}),M.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(ea,{className:"w-3 h-3"}),"Fill in: ",M.join(", ")]})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",s.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:A,children:v?s.jsx(kn,{className:"w-3 h-3 text-green-400"}):s.jsx(Gs,{className:"w-3 h-3"})})]}),s.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2)})]})]})]})}function Zqe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[a,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function b(){try{const y=await fetch("/openapi.json");if(!y.ok)throw new Error("Failed to fetch OpenAPI schema");const M=await y.json();n(M)}catch(y){o(y instanceof Error?y.message:"Unknown error")}finally{i(!1)}}b()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(wt,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(ea,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:"Failed to load API schema"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[b,y]of Object.entries(e.paths))for(const[M,S]of Object.entries(y)){if(M==="parameters")continue;const A=S.tags||["Other"];for(const E of A)f[E]||(f[E]=[]),f[E].push({path:b,method:M,spec:S})}const m=Object.entries(f).map(([b,y])=>{if(!u)return{tag:b,endpoints:y};const M=y.filter(({path:S,method:A,spec:E})=>{const k=u.toLowerCase();return S.toLowerCase().includes(k)||A.toLowerCase().includes(k)||(E.summary?.toLowerCase()||"").includes(k)||(E.description?.toLowerCase()||"").includes(k)});return{tag:b,endpoints:M}}).filter(({endpoints:b})=>b.length>0).sort((b,y)=>b.tag.localeCompare(y.tag)),p=b=>{c(y=>{const M=new Set(y);return M.has(b)?M.delete(b):M.add(b),M})},x=()=>{c(new Set(m.map(b=>b.tag)))},v=()=>{c(new Set)};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx("input",{type:"text",value:u,onChange:b=>d(b.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:v,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(Lr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[m.reduce((b,y)=>b+y.endpoints.length,0)," endpoints in ",m.length," categories"]}),s.jsx("div",{className:"space-y-3",children:m.map(({tag:b,endpoints:y})=>s.jsxs(wt,{children:[s.jsx("button",{onClick:()=>p(b),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[l.has(b)?s.jsx(Ji,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Vs,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:b.replace(/-/g," ")}),s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:y.length})]})}),l.has(b)&&s.jsx(Mt,{className:"pt-0 space-y-2",children:y.map(({path:M,method:S,spec:A})=>s.jsx(Qqe,{path:M,method:S,spec:A,schema:e,apiKey:t},`${S}-${M}`))})]},b))})]})}const Jqe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users"];function eKe(){const t=Qt(),e=sl(),[n,r]=vW(),{t:i,i18n:a}=Tg(),{showToast:o,showPersistentToast:l,dismissToast:c}=Un(),{authEnabled:u,user:d,refreshAuth:f}=Vf(),{mode:m,darkStyle:p,darkBackground:x,darkAccent:v,lightStyle:b,lightBackground:y,lightAccent:M,setDarkStyle:S,setDarkBackground:A,setDarkAccent:E,setLightStyle:k,setLightBackground:C,setLightAccent:R}=Xd(),[T,P]=w.useState(null),[F,I]=w.useState(!1),[X,D]=w.useState(null),[K,Y]=w.useState(!1),[q,Z]=w.useState(null),[re,ie]=w.useState(null),[U,G]=w.useState(!1),[ee,ne]=w.useState(lq()),se=n.get("tab"),de=se&&Jqe.includes(se)?se:"general",[he,Ee]=w.useState(de),ge=be=>{Ee(be),be==="general"?n.delete("tab"):n.set("tab",be),r(n,{replace:!0})},[Ne,Re]=w.useState(!1),[te,Je]=w.useState(""),[B,H]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[W,z]=w.useState(null),[V,Q]=w.useState(null),[Te,ke]=w.useState(""),[Ae,$]=w.useState(!1),[L,oe]=w.useState(!1),[ce,xe]=w.useState(null),[ve,_e]=w.useState(!1),[Ie,We]=w.useState(!1),[ht,qe]=w.useState(!1),[me,rt]=w.useState(!1),[Xe,nt]=w.useState(!1),[ut,ae]=w.useState(null),[$e,ye]=w.useState(!1),Be=be=>{ne(be),ife(be)},De=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:we,isLoading:Ve}=lt({queryKey:["settings"],queryFn:pe.getSettings}),{data:dt,isLoading:Tt}=lt({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:Ct,isLoading:Xt}=lt({queryKey:["smart-plugs-energy",dt?.map(be=>be.id)],queryFn:async()=>{if(!dt||dt.length===0)return null;const be=await Promise.all(dt.filter($t=>$t.enabled).map(async $t=>{try{const Ht=await pe.getSmartPlugStatus($t.id);return{plug:$t,status:Ht}}catch{return{plug:$t,status:null}}}));let st=0,zt=0,Ot=0,tn=0,sn=0;for(const{status:$t}of be)$t?.reachable&&$t.energy&&(sn++,$t.energy.power!=null&&(st+=$t.energy.power),$t.energy.today!=null&&(zt+=$t.energy.today),$t.energy.yesterday!=null&&(Ot+=$t.energy.yesterday),$t.energy.total!=null&&(tn+=$t.energy.total));return{totalPower:st,totalToday:zt,totalYesterday:Ot,totalLifetime:tn,reachableCount:sn,totalPlugs:dt.filter($t=>$t.enabled).length}},enabled:he==="plugs"&&!!dt&&dt.length>0,refetchInterval:he==="plugs"?1e4:!1}),{data:Pt,isLoading:an}=lt({queryKey:["notification-providers"],queryFn:pe.getNotificationProviders}),{data:bn,isLoading:Kn}=lt({queryKey:["api-keys"],queryFn:pe.getAPIKeys}),zn=ft({mutationFn:be=>pe.createAPIKey(be),onSuccess:be=>{z(be.key||null),Re(!1),Je(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:be=>{o(`Failed to create API key: ${be.message}`,"error")}}),Vn=ft({mutationFn:be=>pe.deleteAPIKey(be),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:be=>{o(`Failed to delete API key: ${be.message}`,"error")}}),{data:_r}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:$r,isLoading:Tr}=lt({queryKey:["notification-templates"],queryFn:pe.getNotificationTemplates}),{data:hr}=lt({queryKey:["virtual-printer-settings"],queryFn:R1.getSettings,refetchInterval:1e4}),bt=hr?.status?.running??!1,{data:Yt}=lt({queryKey:["ffmpeg-status"],queryFn:pe.checkFfmpeg}),{data:yn}=lt({queryKey:["version"],queryFn:pe.getVersion}),{data:ue,refetch:ze,isRefetching:Ye}=lt({queryKey:["updateCheck"],queryFn:pe.checkForUpdates,staleTime:300*1e3}),{data:Ke,refetch:Qe}=lt({queryKey:["updateStatus"],queryFn:pe.getUpdateStatus,refetchInterval:be=>{const st=be.state.data;return st?.status==="downloading"||st?.status==="installing"?1e3:!1}}),{data:Nt}=lt({queryKey:["mqtt-status"],queryFn:pe.getMQTTStatus,refetchInterval:he==="network"?5e3:!1}),le=ft({mutationFn:pe.applyUpdate,onSuccess:be=>{be.is_docker?o(be.message,"error"):Qe()}}),[Se,Le]=w.useState(null),Oe=ft({mutationFn:pe.testAllNotificationProviders,onSuccess:be=>{Le(be),t.invalidateQueries({queryKey:["notification-providers"]}),be.failed===0?o(`All ${be.tested} providers tested successfully!`,"success"):o(`${be.success}/${be.tested} providers succeeded`,be.failed>0?"error":"success")},onError:be=>{o(`Failed to test providers: ${be.message}`,"error")}}),Pe=ft({mutationFn:async be=>{if(!dt)return{success:0,failed:0};const st=dt.filter(Ot=>Ot.enabled),zt=await Promise.all(st.map(async Ot=>{try{return await pe.controlSmartPlug(Ot.id,be),{success:!0}}catch{return{success:!1}}}));return{success:zt.filter(Ot=>Ot.success).length,failed:zt.filter(Ot=>!Ot.success).length}},onSuccess:(be,st)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),be.failed===0?o(`All ${be.success} plugs turned ${st}`,"success"):o(`${be.success} plugs turned ${st}, ${be.failed} failed`,"error")},onError:be=>{o(`Failed: ${be.message}`,"error")}}),ct=w.useRef(null),vt=w.useRef(!1),Et=w.useRef(!0);w.useEffect(()=>{if(we&&!T){const be={...we,external_url:we.external_url||window.location.origin};P(be),setTimeout(()=>{Et.current=!1},100)}},[we,T]);const _t=ft({mutationFn:pe.updateSettings,onSuccess:be=>{t.setQueryData(["settings"],be),P(be),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:be=>{o(`Failed to save: ${be.message}`,"error")},onSettled:()=>{vt.current=!1}});w.useEffect(()=>{if(!(Et.current||!T||!we||!(we.auto_archive!==T.auto_archive||we.save_thumbnails!==T.save_thumbnails||we.capture_finish_photo!==T.capture_finish_photo||we.default_filament_cost!==T.default_filament_cost||we.currency!==T.currency||we.energy_cost_per_kwh!==T.energy_cost_per_kwh||we.energy_tracking_mode!==T.energy_tracking_mode||we.check_updates!==T.check_updates||we.notification_language!==T.notification_language||we.telemetry_enabled!==T.telemetry_enabled||we.ams_humidity_good!==T.ams_humidity_good||we.ams_humidity_fair!==T.ams_humidity_fair||we.ams_temp_good!==T.ams_temp_good||we.ams_temp_fair!==T.ams_temp_fair||we.ams_history_retention_days!==T.ams_history_retention_days||we.per_printer_mapping_expanded!==T.per_printer_mapping_expanded||we.date_format!==T.date_format||we.time_format!==T.time_format||we.default_printer_id!==T.default_printer_id||we.ftp_retry_enabled!==T.ftp_retry_enabled||we.ftp_retry_count!==T.ftp_retry_count||we.ftp_retry_delay!==T.ftp_retry_delay||we.ftp_timeout!==T.ftp_timeout||we.mqtt_enabled!==T.mqtt_enabled||we.mqtt_broker!==T.mqtt_broker||we.mqtt_port!==T.mqtt_port||we.mqtt_username!==T.mqtt_username||we.mqtt_password!==T.mqtt_password||we.mqtt_topic_prefix!==T.mqtt_topic_prefix||we.mqtt_use_tls!==T.mqtt_use_tls||we.external_url!==T.external_url||we.ha_enabled!==T.ha_enabled||we.ha_url!==T.ha_url||we.ha_token!==T.ha_token||(we.library_archive_mode??"ask")!==(T.library_archive_mode??"ask")||Number(we.library_disk_warning_gb??5)!==Number(T.library_disk_warning_gb??5)||(we.camera_view_mode??"window")!==(T.camera_view_mode??"window")))&&!vt.current)return ct.current&&clearTimeout(ct.current),ct.current=setTimeout(()=>{if(vt.current)return;vt.current=!0;const st={auto_archive:T.auto_archive,save_thumbnails:T.save_thumbnails,capture_finish_photo:T.capture_finish_photo,default_filament_cost:T.default_filament_cost,currency:T.currency,energy_cost_per_kwh:T.energy_cost_per_kwh,energy_tracking_mode:T.energy_tracking_mode,check_updates:T.check_updates,notification_language:T.notification_language,telemetry_enabled:T.telemetry_enabled,ams_humidity_good:T.ams_humidity_good,ams_humidity_fair:T.ams_humidity_fair,ams_temp_good:T.ams_temp_good,ams_temp_fair:T.ams_temp_fair,ams_history_retention_days:T.ams_history_retention_days,per_printer_mapping_expanded:T.per_printer_mapping_expanded,date_format:T.date_format,time_format:T.time_format,default_printer_id:T.default_printer_id,ftp_retry_enabled:T.ftp_retry_enabled,ftp_retry_count:T.ftp_retry_count,ftp_retry_delay:T.ftp_retry_delay,ftp_timeout:T.ftp_timeout,mqtt_enabled:T.mqtt_enabled,mqtt_broker:T.mqtt_broker,mqtt_port:T.mqtt_port,mqtt_username:T.mqtt_username,mqtt_password:T.mqtt_password,mqtt_topic_prefix:T.mqtt_topic_prefix,mqtt_use_tls:T.mqtt_use_tls,external_url:T.external_url,ha_enabled:T.ha_enabled,ha_url:T.ha_url,ha_token:T.ha_token,library_archive_mode:T.library_archive_mode,library_disk_warning_gb:T.library_disk_warning_gb,camera_view_mode:T.camera_view_mode};_t.mutate(st)},500),()=>{ct.current&&clearTimeout(ct.current)}},[T,we,_t]);const yt=w.useCallback((be,st)=>{P(zt=>zt?{...zt,[be]:st}:null)},[]);return Ve||!T?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),s.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto",children:[s.jsx("button",{onClick:()=>ge("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${he==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:"General"}),s.jsxs("button",{onClick:()=>ge("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${he==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Fs,{className:"w-4 h-4"}),"Smart Plugs",dt&&dt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:dt.length})]}),s.jsxs("button",{onClick:()=>ge("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${he==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(ef,{className:"w-4 h-4"}),"Notifications",Pt&&Pt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Pt.length})]}),s.jsxs("button",{onClick:()=>ge("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${he==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Vce,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>ge("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${he==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Dp,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${Nt?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ge("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${he==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Vh,{className:"w-4 h-4"}),"API Keys",bn&&bn.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:bn.length})]}),s.jsxs("button",{onClick:()=>ge("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${he==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ir,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${bt?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ge("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${he==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Gh,{className:"w-4 h-4"}),"Users",u&&s.jsx("span",{className:`w-2 h-2 rounded-full ${u?"bg-green-400":"bg-gray-500"}`})]})]}),he==="general"&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Md,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsx("select",{value:a.language,onChange:be=>a.changeLanguage(be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:HU.map(be=>s.jsxs("option",{value:be.code,children:[be.nativeName," (",be.name,")"]},be.code))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),s.jsx("select",{value:ee,onChange:be=>Be(be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:s0.map(be=>s.jsx("option",{value:be.to,children:i(be.labelKey)},be.id))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),s.jsxs("select",{value:T.date_format||"system",onChange:be=>yt("date_format",be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"system",children:"System Default"}),s.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),s.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),s.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),s.jsxs("select",{value:T.time_format||"system",onChange:be=>yt("time_format",be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"system",children:"System Default"}),s.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),s.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),s.jsxs("select",{value:T.default_printer_id??"",onChange:be=>yt("default_printer_id",be.target.value?Number(be.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No default (ask each time)"}),_r?.map(be=>s.jsx("option",{value:be.id,children:be.name},be.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Sidebar order"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:De,children:[s.jsx(Hf,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(nD,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(Mt,{className:"space-y-6",children:[s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${m==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",m==="dark"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:x,onChange:be=>{A(be.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"}),s.jsx("option",{value:"oled",children:"OLED Black"}),s.jsx("option",{value:"slate",children:"Slate Blue"}),s.jsx("option",{value:"forest",children:"Forest Green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:v,onChange:be=>{E(be.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:p,onChange:be=>{S(be.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${m==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",m==="light"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:y,onChange:be=>{C(be.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:M,onChange:be=>{R(be.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:b,onChange:be=>{k(be.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Auto-archive prints"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.auto_archive,onChange:be=>yt("auto_archive",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Save thumbnails"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.save_thumbnails,onChange:be=>yt("save_thumbnails",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Capture finish photo"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.capture_finish_photo,onChange:be=>yt("capture_finish_photo",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),T.capture_finish_photo&&Yt&&!Yt.installed&&s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(En,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),s.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sD,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsx(Mt,{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),s.jsxs("select",{value:T.camera_view_mode??"window",onChange:be=>yt("camera_view_mode",be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"window",children:"New Window"}),s.jsx("option",{value:"embedded",children:"Embedded Overlay"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:T.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]})})]}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:T.default_filament_cost,onChange:be=>yt("default_filament_cost",parseFloat(be.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),s.jsxs("select",{value:T.currency,onChange:be=>yt("currency",be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"USD",children:"USD ($)"}),s.jsx("option",{value:"EUR",children:"EUR (€)"}),s.jsx("option",{value:"GBP",children:"GBP (£)"}),s.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),s.jsx("option",{value:"JPY",children:"JPY (¥)"}),s.jsx("option",{value:"CNY",children:"CNY (¥)"}),s.jsx("option",{value:"CAD",children:"CAD ($)"}),s.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:T.energy_cost_per_kwh,onChange:be=>yt("energy_cost_per_kwh",parseFloat(be.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),s.jsxs("select",{value:T.energy_tracking_mode||"total",onChange:be=>yt("energy_tracking_mode",be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"print",children:"Prints Only"}),s.jsx("option",{value:"total",children:"Total Consumption"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:T.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ua,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),s.jsxs("select",{value:T.library_archive_mode??"ask",onChange:be=>yt("library_archive_mode",be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"always",children:"Always create archive entry"}),s.jsx("option",{value:"never",children:"Never create archive entry"}),s.jsx("option",{value:"ask",children:"Ask each time"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:T.library_disk_warning_gb??5,onChange:be=>yt("library_disk_warning_gb",parseFloat(be.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[s.jsx(qqe,{}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Check for updates"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.check_updates,onChange:be=>yt("check_updates",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white",children:i("settings.telemetry")}),s.jsxs("button",{onClick:()=>qe(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-bambu-dark rounded-full text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsx(Rl,{className:"w-3 h-3"}),i("settings.telemetryLearnMore")]})]}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.telemetryDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.telemetry_enabled,onChange:be=>yt("telemetry_enabled",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Current version"}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",yn?.version||"..."]})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ze(),disabled:Ye,children:[Ye?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(yr,{className:"w-4 h-4"}),"Check now"]})]}),ue?.update_available?s.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:ue.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[ue.release_notes&&s.jsx("button",{onClick:()=>rt(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),ue.release_url&&s.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(Lr,{className:"w-4 h-4"})})]})]}),Ke?.status==="downloading"||Ke?.status==="installing"?s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:Ke.message})]}),s.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Ke.progress}%`}})})]}):Ke?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Ke.message}):Ke?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Ke.error||Ke.message}):ue?.is_docker?s.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),s.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):s.jsxs(Me,{className:"mt-3",onClick:()=>le.mutate(),disabled:le.isPending,children:[le.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jr,{className:"w-4 h-4"}),"Install Update"]})]}):ue?.error?s.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",ue.error]}):ue&&!ue.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Backup Data"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>_e(!0),children:[s.jsx(Jr,{className:"w-4 h-4"}),"Export"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Restore Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>We(!0),children:[s.jsx(bi,{className:"w-4 h-4"}),"Restore"]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>$(!0),children:[s.jsx(Jt,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>oe(!0),children:[s.jsx(Jt,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),he==="network"&&T&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Md,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),s.jsx("input",{type:"text",value:T.external_url??"",onChange:be=>yt("external_url",be.target.value),placeholder:"http://192.168.1.100:8000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(yr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable retry"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.ftp_retry_enabled??!0,onChange:be=>yt("ftp_retry_enabled",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),T.ftp_retry_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"10",value:T.ftp_retry_count??3,onChange:be=>yt("ftp_retry_count",Math.min(10,Math.max(1,parseInt(be.target.value)||3))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"times"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"30",value:T.ftp_retry_delay??2,onChange:be=>yt("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(be.target.value)||2))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"10",max:"120",value:T.ftp_timeout??30,onChange:be=>yt("ftp_timeout",Math.min(120,Math.max(10,parseInt(be.target.value)||30))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Socket timeout for slow connections. Increase for A1/A1 Mini printers with weak WiFi (10-120)"})]})]})]}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(R2,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),T.ha_enabled&&ut&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${ut.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${ut.success?"text-green-400":"text-red-400"}`,children:ut.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, and input_boolean entities."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Home Assistant"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Control smart plugs via Home Assistant"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.ha_enabled??!1,onChange:be=>yt("ha_enabled",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),T.ha_enabled&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Home Assistant URL"}),s.jsx("input",{type:"text",value:T.ha_url??"",onChange:be=>yt("ha_url",be.target.value),placeholder:"http://192.168.1.100:8123",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Long-Lived Access Token"}),s.jsx("input",{type:"password",value:T.ha_token??"",onChange:be=>yt("ha_token",be.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),T.ha_url&&T.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Me,{variant:"secondary",size:"sm",disabled:$e,onClick:async()=>{ye(!0),ae(null);try{const be=await pe.testHAConnection(T.ha_url,T.ha_token);ae(be)}catch(be){ae({success:!1,message:null,error:be instanceof Error?be.message:"Unknown error"})}finally{ye(!1)}},children:[$e?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dp,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]})]}),s.jsx("div",{className:"flex-1 lg:max-w-xl space-y-4",children:s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Dp,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Nt?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Nt.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Nt.connected?"text-green-400":"text-red-400"}`,children:Nt.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable MQTT"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.mqtt_enabled??!1,onChange:be=>yt("mqtt_enabled",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),T.mqtt_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),s.jsx("input",{type:"text",value:T.mqtt_broker??"",onChange:be=>yt("mqtt_broker",be.target.value),placeholder:"mqtt.example.com or 192.168.1.100",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-end gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),s.jsx("input",{type:"number",min:"1",max:"65535",value:T.mqtt_port??1883,onChange:be=>yt("mqtt_port",Math.min(65535,Math.max(1,parseInt(be.target.value)||1883))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.mqtt_use_tls??!1,onChange:be=>{const st=be.target.checked;yt("mqtt_use_tls",st);const zt=T.mqtt_port??1883;st&&zt===1883?yt("mqtt_port",8883):!st&&zt===8883&&yt("mqtt_port",1883)},className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),s.jsx("span",{className:"text-white text-sm",children:"Use TLS"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),s.jsx("input",{type:"text",value:T.mqtt_username??"",onChange:be=>yt("mqtt_username",be.target.value),placeholder:"Leave empty for anonymous",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),s.jsx("input",{type:"password",value:T.mqtt_password??"",onChange:be=>yt("mqtt_password",be.target.value),placeholder:"Leave empty for anonymous",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),s.jsx("input",{type:"text",value:T.mqtt_topic_prefix??"bambuddy",onChange:be=>yt("mqtt_topic_prefix",be.target.value),placeholder:"bambuddy",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",T.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Nt&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${Nt.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:Nt.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[Nt.broker,":",Nt.port]})]}):"Not connected"})]})})]})]})]})})]}),ut&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[ut.success?s.jsx(kn,{className:"w-8 h-8 text-green-400"}):s.jsx(qi,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:ut.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:ut.success?ut.message||"Successfully connected to Home Assistant.":ut.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Me,{variant:"primary",onClick:()=>ae(null),children:"OK"})})]})}),he==="plugs"&&s.jsxs("div",{className:"max-w-4xl",children:[s.jsxs("div",{className:"flex items-start justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Fs,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[dt&&dt.filter(be=>be.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>xe("on"),disabled:Pe.isPending,title:"Turn all plugs on",children:[Pe.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(uu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>xe("off"),disabled:Pe.isPending,title:"Turn all plugs off",children:[Pe.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(I2,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Me,{className:"whitespace-nowrap",onClick:()=>{D(null),I(!0)},children:[s.jsx(qn,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),dt&&dt.length>0&&s.jsxs(wt,{className:"mb-6",children:[s.jsx(mr,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(Sf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Xt&&s.jsx(pt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Mt,{children:Ct?s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(Sf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ct.totalPower.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Ct.reachableCount,"/",Ct.totalPlugs," plugs online"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(Qr,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ct.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ct.totalToday*T.energy_cost_per_kwh).toFixed(2)," ",T.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(nq,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ct.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ct.totalYesterday*T.energy_cost_per_kwh).toFixed(2)," ",T.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(Uj,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ct.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ct.totalLifetime*T.energy_cost_per_kwh).toFixed(2)," ",T.currency]})]})]}):Xt?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Tt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):dt&&dt.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:dt.map(be=>s.jsx(jqe,{plug:be,onEdit:st=>{D(st),I(!0)}},be.id))}):s.jsx(wt,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Fs,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),s.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),s.jsxs(Me,{onClick:()=>{D(null),I(!0)},children:[s.jsx(qn,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),he==="notifications"&&s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ef,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>G(!0),children:[s.jsx(hw,{className:"w-4 h-4"}),"Log"]}),Pt&&Pt.length>0&&s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>{Le(null),Oe.mutate()},disabled:Oe.isPending,children:[Oe.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(iD,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Me,{size:"sm",onClick:()=>{Z(null),Y(!0)},children:[s.jsx(qn,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(wt,{className:"mb-4",children:s.jsx(Mt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:T.notification_language||"en",onChange:be=>yt("notification_language",be.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:HU.map(be=>s.jsx("option",{value:be.code,children:be.nativeName},be.code))})]})})}),Se&&s.jsx(wt,{className:"mb-4",children:s.jsxs(Mt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),s.jsx("button",{onClick:()=>Le(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(kn,{className:"w-4 h-4"}),Se.success," passed"]}),Se.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(qi,{className:"w-4 h-4"}),Se.failed," failed"]})]}),Se.results.filter(be=>!be.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Se.results.filter(be=>!be.success).map(be=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[be.provider_name,":"]})," ",be.message]},be.provider_id))})]})}),an?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Pt&&Pt.length>0?s.jsx("div",{className:"space-y-3",children:Pt.map(be=>s.jsx(Dqe,{provider:be,onEdit:st=>{Z(st),Y(!0)}},be.id))}):s.jsx(wt,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(ef,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),s.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),s.jsxs(Me,{size:"sm",onClick:()=>{Z(null),Y(!0)},children:[s.jsx(qn,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(Ua,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),Tr?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):$r&&$r.length>0?s.jsx("div",{className:"space-y-2",children:$r.map(be=>s.jsx(wt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>ie(be),children:s.jsx(Mt,{className:"py-2.5 px-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium text-sm truncate",children:be.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:be.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:st=>{st.stopPropagation(),ie(be)},children:s.jsx(L2,{className:"w-4 h-4 text-bambu-gray"})})]})})},be.id))}):s.jsx(wt,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ua,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),he==="apikeys"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Vh,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks."})]}),s.jsxs(Me,{size:"sm",onClick:()=>Re(!0),className:"flex-shrink-0",children:[s.jsx(qn,{className:"w-4 h-4"}),"Create Key"]})]}),W&&s.jsx(wt,{className:"mb-6 border-bambu-green",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(kn,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),s.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[s.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:W}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(W);else{const be=document.createElement("textarea");be.value=W,be.style.position="fixed",be.style.left="-999999px",document.body.appendChild(be),be.select(),document.execCommand("copy"),document.body.removeChild(be)}o("Key copied to clipboard")}catch{o("Failed to copy key","error")}},children:s.jsx(Gs,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{ke(W),o("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>z(null),children:"Dismiss"})]})]})]})})}),Ne&&s.jsxs(wt,{className:"mb-6",children:[s.jsx(mr,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),s.jsx("input",{type:"text",value:te,onChange:be=>Je(be.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:B.can_read_status,onChange:be=>H(st=>({...st,can_read_status:be.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Read Status"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:B.can_queue,onChange:be=>H(st=>({...st,can_queue:be.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Manage Queue"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:B.can_control_printer,onChange:be=>H(st=>({...st,can_control_printer:be.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Control Printer"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsxs(Me,{onClick:()=>zn.mutate({name:te||"Unnamed Key",...B}),disabled:zn.isPending,children:[zn.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(qn,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Me,{variant:"secondary",onClick:()=>Re(!1),children:"Cancel"})]})]})]}),Kn?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):bn&&bn.length>0?s.jsx("div",{className:"space-y-3",children:bn.map(be=>s.jsx(wt,{children:s.jsx(Mt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Vh,{className:`w-5 h-5 ${be.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:be.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[be.key_prefix,"••••••••",be.last_used&&` · Last used: ${Jp(be.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[be.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),be.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),be.can_control_printer&&s.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>Q(be.id),children:s.jsx(Jt,{className:"w-4 h-4 text-red-400"})})]})]})})},be.id))}):s.jsx(wt,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Vh,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),s.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),s.jsxs(Me,{onClick:()=>Re(!0),children:[s.jsx(qn,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(wt,{className:"mt-6",children:[s.jsx(mr,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),s.jsxs(Mt,{className:"space-y-3 text-sm",children:[s.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",s.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),s.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),s.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),s.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-green-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),s.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),s.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),s.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-red-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),s.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Md,{className:"w-5 h-5 text-bambu-green"}),"API Browser"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Explore and test all available API endpoints."})]}),s.jsx(wt,{className:"mb-4",children:s.jsxs(Mt,{className:"py-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"API Key for Testing"}),s.jsx("input",{type:"text",value:Te,onChange:be=>ke(be.target.value),placeholder:"Paste your API key here to test authenticated endpoints...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["This key will be sent as ",s.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header with requests."]})]})}),s.jsx(Zqe,{apiKey:Te})]})]}),he==="virtual-printer"&&s.jsx(Kqe,{}),he==="filament"&&T&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(tD,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"font-medium",children:"Humidity"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:T.ams_humidity_good??40,onChange:be=>yt("ams_humidity_good",parseInt(be.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:T.ams_humidity_fair??60,onChange:be=>yt("ams_humidity_fair",parseInt(be.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),s.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(U2,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:"Temperature"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:T.ams_temp_good??28,onChange:be=>yt("ams_temp_good",parseFloat(be.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:T.ams_temp_fair??35,onChange:be=>yt("ams_temp_fair",parseFloat(be.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Yp,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"font-medium",children:"History Retention"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"365",value:T.ams_history_retention_days??30,onChange:be=>yt("ams_history_retention_days",parseInt(be.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Ir,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"font-medium",children:"Print Modal"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-white",children:"Expand custom mapping by default"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:"When printing to multiple printers, show per-printer AMS mapping expanded"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.per_printer_mapping_expanded??!1,onChange:be=>yt("per_printer_mapping_expanded",be.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})}),s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsx(Gqe,{})})]}),V!==null&&s.jsx(Rn,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{Vn.mutate(V),Q(null)},onCancel:()=>Q(null)}),F&&s.jsx(Pqe,{plug:X,onClose:()=>{I(!1),D(null)}}),K&&s.jsx(Oqe,{provider:q,onClose:()=>{Y(!1),Z(null)}}),re&&s.jsx(Lqe,{template:re,onClose:()=>ie(null)}),U&&s.jsx(Uqe,{onClose:()=>G(!1)}),Ae&&s.jsx(Rn,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{$(!1);try{const be=await pe.clearNotificationLogs(30);o(be.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>$(!1)}),L&&s.jsx(Rn,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{oe(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>oe(!1)}),ce&&s.jsx(Rn,{title:`Turn All Plugs ${ce==="on"?"On":"Off"}`,message:`This will turn ${ce==="on"?"ON":"OFF"} all ${dt?.filter(be=>be.enabled).length||0} enabled smart plugs. ${ce==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${ce==="on"?"On":"Off"}`,variant:ce==="off"?"danger":"warning",onConfirm:()=>{const be=ce;xe(null),Pe.mutate(be)},onCancel:()=>xe(null)}),ve&&s.jsx(Bqe,{onClose:()=>_e(!1),onExport:async be=>{_e(!1);const st="backup-progress",zt=be.archives;zt&&l(st,i("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:Ot,filename:tn}=await pe.exportBackup(be);zt&&c(st);const sn=URL.createObjectURL(Ot),$t=document.createElement("a");$t.href=sn,$t.download=tn,$t.click(),URL.revokeObjectURL(sn),o(i("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{zt&&c(st),o(i("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),Ie&&s.jsx($qe,{onClose:()=>We(!1),onRestore:async(be,st)=>await pe.importBackup(be,st),onSuccess:()=>{P(null),Et.current=!0,t.resetQueries({queryKey:["settings"]}),t.invalidateQueries({queryKey:["notification-providers"]}),t.invalidateQueries({queryKey:["notification-templates"]}),t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["external-links"]}),t.invalidateQueries({queryKey:["printers"]}),t.invalidateQueries({queryKey:["filaments"]}),t.invalidateQueries({queryKey:["maintenance-types"]}),t.invalidateQueries({queryKey:["api-keys"]})}}),ht&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>qe(!1),children:s.jsxs(wt,{className:"w-full max-w-lg",onClick:be=>be.stopPropagation(),children:[s.jsxs(mr,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(P1,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.telemetryInfoTitle")})]}),s.jsx("button",{onClick:()=>qe(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.telemetryInfoIntro")}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:i("settings.telemetryInfoCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoItem4")})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:i("settings.telemetryInfoNotCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoNotItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoNotItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoNotItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:i("settings.telemetryInfoNotItem4")})]})]})]}),s.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:i("settings.telemetryInfoFooter")}),s.jsx(Me,{onClick:()=>qe(!1),className:"w-full",children:i("common.close")})]})]})}),me&&ue?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>rt(!1),children:s.jsxs(wt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:be=>be.stopPropagation(),children:[s.jsxs(mr,{className:"flex flex-row items-center justify-between shrink-0",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:ue.release_name})]}),s.jsx("button",{onClick:()=>rt(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx(Mt,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:ue.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[ue.release_url&&s.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Me,{variant:"secondary",className:"w-full",children:[s.jsx(Lr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Me,{onClick:()=>rt(!1),className:"flex-1",children:"Close"})]})]})}),he==="users"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Gh,{className:"w-5 h-5 text-bambu-green"}),"User Authentication"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Enable authentication to secure your Bambuddy instance and manage user access."})]}),s.jsx(wt,{children:s.jsx(Mt,{className:"py-6",children:u?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center bg-green-500/20",children:s.jsx(kA,{className:"w-6 h-6 text-green-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Enabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is secured with authentication."})]})]}),d&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Current User"}),s.jsx("p",{className:"text-white font-medium",children:d.username}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Role: ",s.jsx("span",{className:"capitalize",children:d.role})]})]}),s.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${d.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:d.role==="admin"?"Admin":"User"})]})}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs(Me,{onClick:()=>e("/users"),className:"w-full",variant:"secondary",children:[s.jsx(Gh,{className:"w-4 h-4"}),"Manage Users"]}),d?.role==="admin"&&s.jsxs(Me,{onClick:()=>nt(!0),className:"w-full",variant:"secondary",children:[s.jsx(cz,{className:"w-4 h-4"}),"Disable Authentication"]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center ${u?"bg-green-500/20":"bg-gray-500/20"}`,children:u?s.jsx(kA,{className:"w-6 h-6 text-green-400"}):s.jsx(cz,{className:"w-6 h-6 text-gray-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Disabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is currently accessible without authentication."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Enable authentication to:"}),s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-4",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Require login to access the system"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage multiple users with different roles"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Control access to printer settings and user management"})]})]}),s.jsxs(Me,{onClick:()=>e("/setup"),className:"w-full",children:[s.jsx(kA,{className:"w-4 h-4"}),"Activate Authentication"]})]})]})})})]}),u&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(P1,{className:"w-5 h-5 text-bambu-green"}),"Role Permissions"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Overview of what each role can do."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center",children:s.jsx(P1,{className:"w-4 h-4 text-purple-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"Admin"})]})}),s.jsx(Mt,{children:s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage printer settings"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Create, edit, and delete users"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Access all system features"})]})]})})]}),s.jsxs(wt,{children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/20 flex items-center justify-center",children:s.jsx(Gh,{className:"w-4 h-4 text-blue-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"User"})]})}),s.jsx(Mt,{children:s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Send print jobs"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage files and archives"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(kn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage filament"})]})]})})]})]})]})]}),Xe&&s.jsx(Rn,{title:"Disable Authentication",message:"Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.",confirmText:"Disable Authentication",variant:"danger",onConfirm:async()=>{try{await pe.disableAuth(),o("Authentication disabled successfully","success"),await f(),nt(!1),window.location.href="/"}catch(be){const st=be instanceof Error?be.message:"Failed to disable authentication";o(st,"error")}},onCancel:()=>nt(!1)})]})}const cre=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},tKe=t=>t.startsWith("HH")?"HF":"S",nKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},LR=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 gj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=tKe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?s.jsx(eu,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Ol,{className:"w-4 h-4"})}),s.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:cre(t.k_value)}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&s.jsx("span",{title:"Has note",children:s.jsx(ZW,{className:"w-3 h-3 text-yellow-500"})}),s.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&s.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:s.jsx(Gs,{className:"w-4 h-4"})})]})}function xj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u}){const{showToast:d}=Un(),[f,m]=w.useState(t?.name||""),[p,x]=w.useState(t?.k_value?cre(t.k_value):"0.020"),[v,b]=w.useState(t?.filament_id||""),[y,M]=w.useState(t?.nozzle_id?nKe(t.nozzle_id):"HH00"),[S,A]=w.useState(t?.nozzle_diameter||n),[E,k]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,R]=w.useState(!1),[T,P]=w.useState({current:0,total:0}),[F,I]=w.useState(a),X=jr.useMemo(()=>{const ie=new Map;for(const U of r)if(U.filament_id&&!ie.has(U.filament_id)){const G=LR(U.name||"");ie.set(U.filament_id,{id:U.filament_id,name:G||U.filament_id})}return Array.from(ie.values()).sort((U,G)=>U.name.localeCompare(G.name))},[r]),D=ft({mutationFn:ie=>(console.log("[KProfile] Calling API..."),pe.setKProfile(e,ie)),onSuccess:ie=>{if(console.log("[KProfile] Save success:",ie),d("K-profile saved"),u&&F!==a){let U;F===""&&o?U=o:t&&t.slot_id>0?U=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:U=`name_${f}_${v}`,u(U,F)}R(!0),setTimeout(()=>{R(!1),c()},2500)},onError:ie=>{console.error("[KProfile] Save error:",ie),d(ie.message,"error"),R(!1)}}),K=ft({mutationFn:ie=>(console.log("[KProfile] Deleting profile..."),pe.deleteKProfile(e,ie)),onSuccess:ie=>{console.log("[KProfile] Delete success:",ie),d("K-profile deleted"),R(!0),setTimeout(()=>{R(!1),l()},4e3)},onError:ie=>{console.error("[KProfile] Delete error:",ie),d(ie.message,"error"),R(!1)}}),[Y,q]=w.useState(!1),Z=()=>{t&&K.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},re=async ie=>{if(ie.preventDefault(),i&&!t&&E.length===0){d("Please select at least one extruder","error");return}const U=parseFloat(p).toFixed(6),G=`${y}-${S}`;if(t||E.length===1){const ne={name:f,k_value:U,filament_id:v,nozzle_id:G,nozzle_diameter:S,extruder_id:t?t.extruder_id:E[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ne),D.mutate(ne);return}R(!0),P({current:1,total:E.length});const ee=E.map(ne=>({name:f,k_value:U,filament_id:v,nozzle_id:G,nozzle_diameter:S,extruder_id:ne,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ee.length} profiles in batch:`,ee);try{if(await pe.setKProfilesBatch(e,ee),d(`K-profile saved to ${E.length} extruders`),u&&F){const ne=`name_${f}_${v}`;u(ne,F)}}catch(ne){console.error("[KProfile] Failed to save batch:",ne),d("Failed to save K-profiles","error"),R(!1),P({current:0,total:0});return}P({current:E.length,total:E.length}),setTimeout(()=>{R(!1),P({current:0,total:0}),c()},3e3)};return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[s.jsxs(wt,{className:"w-full max-w-md relative",children:[C&&s.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:T.total>1?`Saving to extruder ${T.current}/${T.total}...`:"Syncing with printer..."}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),s.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:C,children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:re,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),s.jsx("input",{type:"text",value:f,onChange:ie=>m(ie.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),s.jsx("input",{type:"text",inputMode:"decimal",value:p,onChange:ie=>{const U=ie.target.value;(U===""||/^\d*\.?\d*$/.test(U))&&x(U)},onBlur:ie=>{const U=parseFloat(ie.target.value);isNaN(U)||x((Math.trunc(U*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),s.jsxs("select",{value:v,onChange:ie=>{const U=ie.target.value;if(b(U),!t&&U&&!f){const G=X.find(ee=>ee.id===U);G&&m(`${y==="HH00"?"HF":"S"} ${G.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[s.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:X.find(ie=>ie.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&X.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]}),!t&&X.length===0&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),s.jsxs("select",{value:y,onChange:ie=>{const U=ie.target.value;if(M(U),!t&&v&&!f){const G=X.find(ee=>ee.id===v);G&&m(`${U==="HS00"?"HF":"S"} ${G.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[s.jsx("option",{value:"HH00",children:"High Flow"}),s.jsx("option",{value:"HS00",children:"Standard"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),s.jsxs("select",{value:S,onChange:ie=>A(ie.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?s.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.includes(1),onChange:ie=>{ie.target.checked?k([...E,1]):k(E.filter(U=>U!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),s.jsx("span",{className:"text-white",children:"Left"})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.includes(0),onChange:ie=>{ie.target.checked?k([...E,0]):k(E.filter(U=>U!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),s.jsx("span",{className:"text-white",children:"Right"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),s.jsx("textarea",{value:F,onChange:ie=>I(ie.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),s.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&s.jsx(Me,{type:"button",variant:"secondary",onClick:()=>q(!0),disabled:K.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:K.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jt,{className:"w-4 h-4"})}),s.jsx(Me,{type:"button",variant:"secondary",onClick:l,disabled:C,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:D.isPending||C,className:"flex-1",children:[D.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(j2,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),Y&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(wt,{className:"w-full max-w-sm",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(Jt,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:()=>q(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>{q(!1),Z()},disabled:K.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[K.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const C1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function rKe(){const{showToast:t}=Un(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(C1.NOZZLE_DIAMETER)||"0.4"),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),[f,m]=w.useState(""),[p,x]=w.useState("all"),[v,b]=w.useState("all"),[y,M]=w.useState(()=>localStorage.getItem(C1.SORT_OPTION)||"name"),[S,A]=w.useState(!1),[E,k]=w.useState(new Set),[C,R]=w.useState(!1),[T,P]=w.useState(!1),F=w.useCallback(z=>`${z.slot_id}_${z.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(C1.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(C1.SORT_OPTION,y)},[y]);const{data:I,isLoading:X}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:D,isLoading:K,isFetching:Y,error:q,refetch:Z}=lt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const z=await pe.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",z?.profiles?.length||0,"profiles"),z},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:re}=lt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>pe.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ie,refetch:U}=lt({queryKey:["kprofile-notes",e],queryFn:()=>pe.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),G=q?.message?.includes("not connected");w.useEffect(()=>{if(!e&&I&&I.length>0){const z=I.find(V=>V.is_active);z&&n(z.id)}},[e,I]),w.useEffect(()=>{if(e){const z=setTimeout(()=>{Z()},150);return()=>clearTimeout(z)}},[e,r]);const ee=I?.filter(z=>z.is_active)||[],ne=jr.useMemo(()=>D?.profiles?D.profiles.filter(V=>{const Q=f.toLowerCase(),Te=!Q||V.name.toLowerCase().includes(Q)||V.filament_id.toLowerCase().includes(Q),ke=p==="all"||p==="left"&&V.extruder_id===1||p==="right"&&V.extruder_id===0,Ae=v==="all"||v==="hf"&&V.nozzle_id.startsWith("HH")||v==="s"&&V.nozzle_id.startsWith("HS");return Te&&ke&&Ae}).sort((V,Q)=>{switch(y){case"k_value":return parseFloat(V.k_value)-parseFloat(Q.k_value);case"filament":return LR(V.name).localeCompare(LR(Q.name));case"name":default:return V.name.localeCompare(Q.name)}}):[],[D?.profiles,f,p,v,y]),se=I?.find(z=>z.id===e),de=se?.nozzle_count===2;w.useEffect(()=>{const z=V=>{V.target instanceof HTMLInputElement||V.target instanceof HTMLTextAreaElement||V.target instanceof HTMLSelectElement||a||l||u||(V.key==="r"||V.key==="R"?(V.preventDefault(),Z()):V.key==="n"||V.key==="N"?(V.preventDefault(),c(!0)):V.key==="Escape"&&S&&(V.preventDefault(),A(!1),k(new Set)))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[a,l,u,S,Z]);const he=w.useCallback(()=>{if(!D?.profiles||D.profiles.length===0){t("No profiles to export","error");return}const z={version:1,exported_at:new Date().toISOString(),printer:se?.name||"Unknown",nozzle_diameter:r,profiles:D.profiles.map(ke=>({name:ke.name,k_value:ke.k_value,filament_id:ke.filament_id,nozzle_id:ke.nozzle_id,nozzle_diameter:ke.nozzle_diameter,extruder_id:ke.extruder_id}))},V=new Blob([JSON.stringify(z,null,2)],{type:"application/json"}),Q=URL.createObjectURL(V),Te=document.createElement("a");Te.href=Q,Te.download=`kprofiles_${se?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(Q),t(`Exported ${D.profiles.length} profiles`)},[D?.profiles,se,r,t]),Ee=w.useCallback(()=>{const z=document.createElement("input");z.type="file",z.accept=".json",z.onchange=async V=>{const Q=V.target.files?.[0];if(Q)try{const Te=await Q.text(),ke=JSON.parse(Te);if(!ke.profiles||!Array.isArray(ke.profiles)){t("Invalid file format","error");return}let Ae=0;for(const $ of ke.profiles)if(!(!$.name||!$.k_value||!$.filament_id))try{await pe.setKProfile(e,{name:$.name,k_value:parseFloat($.k_value).toFixed(6),filament_id:$.filament_id,nozzle_id:$.nozzle_id||`HH00-${r}`,nozzle_diameter:$.nozzle_diameter||r,extruder_id:$.extruder_id??0,slot_id:0}),Ae++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",$.name,L)}t(`Imported ${Ae} of ${ke.profiles.length} profiles`),Z()}catch(Te){console.error("Import error:",Te),t("Failed to parse import file","error")}},z.click()},[e,r,t,Z]),ge=w.useCallback(z=>{k(V=>{const Q=new Set(V);return Q.has(z)?Q.delete(z):Q.add(z),Q})},[]),Ne=w.useCallback(()=>{k(new Set(ne.map(z=>F(z))))},[ne,F]),Re=w.useCallback(()=>{E.size!==0&&R(!0)},[E.size]),te=w.useCallback(async()=>{const z=ne.filter(Q=>E.has(F(Q)));P(!0);let V=0;for(const Q of z)try{await pe.deleteKProfile(e,{slot_id:Q.slot_id,extruder_id:Q.extruder_id,nozzle_id:Q.nozzle_id,nozzle_diameter:Q.nozzle_diameter,filament_id:Q.filament_id,setting_id:Q.setting_id}),V++,await new Promise(Te=>setTimeout(Te,300))}catch(Te){console.error("Failed to delete profile:",Q.name,Te)}t(`Deleted ${V} profiles`),P(!1),R(!1),A(!1),k(new Set),Z()},[e,E,ne,t,Z,F]),Je=w.useCallback(z=>{const V=[];return z.setting_id&&V.push(z.setting_id),V.push(`slot_${z.slot_id}_${z.filament_id}_${z.extruder_id}`),V.push(`name_${z.name}_${z.filament_id}`),V},[]),B=w.useCallback(async(z,V)=>{if(e)try{await pe.setKProfileNote(e,z,V),U()}catch(Q){console.error("Failed to save note:",Q),t("Failed to save note","error")}},[e,U,t]),H=w.useCallback(z=>{if(!ie?.notes)return{note:"",key:null};const V=Je(z);for(const Q of V)if(ie.notes[Q])return{note:ie.notes[Q],key:Q};return{note:"",key:null}},[ie,Je]),W=w.useCallback(z=>H(z).note,[H]);return X?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!I||I.length===0?s.jsx(wt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(ea,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ee.length===0?s.jsx(wt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Ir,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),s.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):s.jsxs(s.Fragment,{children:[Y&&!K&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(pt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1 min-w-48",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsx("select",{value:e||"",onChange:z=>n(parseInt(z.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:ee.map(z=>s.jsx("option",{value:z.id,children:z.name},z.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),s.jsxs("select",{value:r,onChange:z=>i(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs(Me,{variant:"secondary",onClick:()=>Z(),disabled:Y,children:[s.jsx(yr,{className:`w-4 h-4 ${Y?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Me,{onClick:()=>c(!0),children:[s.jsx(qn,{className:"w-4 h-4"}),"Add Profile"]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-48 relative",children:[s.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:f,onChange:z=>m(z.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),de&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:p,onChange:z=>x(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:"All Extruders"}),s.jsx("option",{value:"left",children:"Left Only"}),s.jsx("option",{value:"right",children:"Right Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:v,onChange:z=>b(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:"All Flow"}),s.jsx("option",{value:"hf",children:"HF Only"}),s.jsx("option",{value:"s",children:"S Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:y,onChange:z=>M(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:"Sort: Name"}),s.jsx("option",{value:"k_value",children:"Sort: K-Value"}),s.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(Me,{variant:"secondary",onClick:he,disabled:!D?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx(Jr,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Me,{variant:"secondary",onClick:Ee,title:"Import profiles from JSON",children:[s.jsx(bi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),S?s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",onClick:Ne,title:"Select all visible profiles",children:[s.jsx(eu,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Me,{variant:"secondary",onClick:Re,disabled:E.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${E.size} selected profiles`,children:[s.jsx(Jt,{className:"w-4 h-4"}),"Delete (",E.size,")"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[s.jsx(Ut,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Me,{variant:"secondary",onClick:()=>A(!0),disabled:!ne.length,title:"Enter selection mode for bulk delete",children:[s.jsx(eu,{className:"w-4 h-4"}),"Select"]})]}),K?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):G?s.jsx(wt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Pg,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),s.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),s.jsxs(Me,{variant:"secondary",onClick:()=>Z(),children:[s.jsx(yr,{className:"w-4 h-4"}),"Retry"]})]})}):ne.length>0?de?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),s.jsx("div",{className:"space-y-1",children:ne.filter(z=>z.extruder_id===1).map(z=>s.jsx(gj,{profile:z,onEdit:()=>o(z),onCopy:()=>d(z),selectionMode:S,isSelected:E.has(F(z)),onToggleSelect:()=>ge(F(z)),note:W(z)},F(z)))})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),s.jsx("div",{className:"space-y-1",children:ne.filter(z=>z.extruder_id===0).map(z=>s.jsx(gj,{profile:z,onEdit:()=>o(z),onCopy:()=>d(z),selectionMode:S,isSelected:E.has(F(z)),onToggleSelect:()=>ge(F(z)),note:W(z)},F(z)))})]})]}):s.jsx("div",{className:"space-y-1",children:ne.map(z=>s.jsx(gj,{profile:z,onEdit:()=>o(z),onCopy:()=>d(z),selectionMode:S,isSelected:E.has(F(z)),onToggleSelect:()=>ge(F(z)),note:W(z)},F(z)))}):f||p!=="all"||v!=="all"?s.jsx(wt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Ws,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):s.jsx(wt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(j2,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),s.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),s.jsxs(Me,{onClick:()=>c(!0),children:[s.jsx(qn,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:z,key:V}=H(a);return s.jsx(xj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||D?.profiles,isDualNozzle:de,initialNote:z,initialNoteKey:V,onSaveNote:B,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),Z()},onSave:()=>{o(null),Z()}})})(),l&&e&&s.jsx(xj,{printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||D?.profiles,isDualNozzle:de,onSaveNote:B,onClose:()=>{c(!1),Z()},onSave:()=>{c(!1),Z()}}),u&&e&&s.jsx(xj,{printerId:e,nozzleDiameter:r,existingProfiles:re?.profiles||D?.profiles,isDualNozzle:de,onSaveNote:B,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),Z()},onSave:()=>{d(null),Z()}}),C&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(wt,{className:"w-full max-w-sm",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(Jt,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsx("span",{className:"text-white font-medium",children:E.size})," selected profiles from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:()=>R(!1),disabled:T,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:te,disabled:T,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[T?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function jL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=a?(a[1]||a[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:d}}function W0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function iKe(t){const e=mi(t);if(!e)return"";const r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),o=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:o<7?`${o}d ago`:e.toLocaleDateString()}function aKe({onSuccess:t}){const{showToast:e}=Un(),[n,r]=w.useState("email"),[i,a]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),[m,p]=w.useState("global"),x=ft({mutationFn:()=>pe.cloudLogin(i,o,m),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):S.needs_verification?(e("Verification code sent to your email"),r("code")):e(S.message,"error")},onError:S=>e(S.message,"error")}),v=ft({mutationFn:()=>pe.cloudVerify(i,c),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),b=ft({mutationFn:()=>pe.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:S=>e(S.message,"error")}),y=S=>{S.preventDefault(),n==="email"?x.mutate():n==="code"?v.mutate():n==="token"&&b.mutate()},M=x.isPending||v.isPending||b.isPending;return s.jsx(wt,{className:"max-w-md mx-auto",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:s.jsx(A2,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),s.jsxs("form",{onSubmit:y,className:"space-y-4",children:[n==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),s.jsx("input",{type:"email",value:i,onChange:S=>a(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:o,onChange:S=>l(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),s.jsxs("select",{value:m,onChange:S=>p(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"global",children:"Global"}),s.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),s.jsx("input",{type:"text",value:c,onChange:S=>u(S.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),s.jsx("textarea",{value:d,onChange:S=>f(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),s.jsxs("div",{className:"flex gap-2",children:[n==="code"&&s.jsx(Me,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Me,{type:"submit",disabled:M,className:"flex-1",children:[M?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(uz,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(Vh,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(uz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function xp({label:t,value:e,options:n,onChange:r}){const[i,a]=w.useState(!1),o=n.find(l=>l.value===e);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[s.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),s.jsx("span",{children:o?.label||"All"}),s.jsx(Ji,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(l=>s.jsxs("button",{onClick:()=>{r(l.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[s.jsx("span",{children:l.label}),l.count!==void 0&&s.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function sKe(){const[t,e]=w.useState(!1);w.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?s.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:s.jsx(Kp,{className:"w-5 h-5"})}):null}function bj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=jL(t.name),c=W0(t.setting_id);return s.jsxs("div",{className:"flex items-center gap-2 group",children:[s.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&s.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&c&&s.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),s.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:s.jsx(Gs,{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(`
  8279. `)){const i=t.replace(/\\n/g,`
  8280. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8281. `);if(i.length>1)return`"""
  8282. `+i.map(a=>n+" "+a).join(`
  8283. `)+`
  8284. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8285. `+t.map(i=>n+" "+IR(i,e+1)).join(`,
  8286. `)+`
  8287. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8288. `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+IR(o,e+1)).join(`,
  8289. `)+`
  8290. `+n+"}"}return String(t)}function oKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=Un(),o=Qt(),[l,c]=w.useState(!1),{data:u,isLoading:d}=lt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>pe.getCloudSettingDetail(t.setting_id)}),f=ft({mutationFn:()=>pe.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),m=W0(t.setting_id),p=jL(t.name,u?.setting?.inherits);return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(wt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),m&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),p.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:p.printer})]})]})]}),s.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:IR(u)}):s.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),l?s.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[s.jsx(En,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]})]}):s.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Me,{variant:"secondary",onClick:r,children:[s.jsx(Gs,{className:"w-4 h-4"}),"Duplicate"]}),m&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(Ha,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{variant:"danger",onClick:()=>c(!0),children:s.jsx(Jt,{className:"w-4 h-4"})})]})]})})]})})})}function ure(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function dre(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function lKe({onClose:t,onApply:e}){const{showToast:n}=Un(),[r,i]=w.useState(ure),[a,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[p,x]=w.useState("{}"),[v,b]=w.useState(null),[y,M]=w.useState(null),S=a==="all"?r:r.filter(I=>I.type===a),A=I=>{i(I),dre(I)},E=I=>{const X=r.filter(D=>D.id!==I);A(X),M(null),n("Template deleted")},k=I=>{c(I.id),d(I.name),m(I.description),x(JSON.stringify(I.settings,null,2)),b(null)},C=()=>{if(!(!l||!u.trim()))try{const I=JSON.parse(p),X=r.map(D=>D.id===l?{...D,name:u.trim(),description:f.trim(),settings:I}:D);A(X),c(null),n("Template updated")}catch(I){b(I.message)}},R=()=>{c(null),d(""),m(""),x("{}"),b(null)},T=I=>{const X=r.map(D=>D.id===I?{...D,showInModal:!D.showInModal}:D);A(X)},P={filament:{label:"Filament",icon:eD,color:"text-amber-400"},print:{label:"Process",icon:Dd,color:"text-blue-400"},printer:{label:"Printer",icon:Ir,color:"text-purple-400"}},F=y?r.find(I=>I.id===y):null;return w.useEffect(()=>{const I=X=>{X.key==="Escape"&&(y?M(null):l?R():t())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[y,l,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(wt,{className:"w-full max-w-md",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:s.jsx(En,{className:"w-6 h-6 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),s.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',s.jsx("span",{className:"font-medium",children:F.name}),'"?']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:()=>M(null),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>E(y),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(wt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(a0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(I=>s.jsx("button",{onClick:()=>o(I),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:I==="all"?"All":P[I].label},I))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:S.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(a0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:"No templates yet"}),s.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):s.jsx("div",{className:"space-y-2",children:S.map(I=>{const X=P[I.type],D=X.icon;return l===I.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:u,onChange:K=>d(K.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:f,onChange:K=>m(K.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),s.jsx("textarea",{value:p,onChange:K=>{x(K.target.value),b(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",onClick:C,disabled:!u.trim(),children:[s.jsx(cs,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:R,children:"Cancel"})]})]},I.id):s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[s.jsx(D,{className:`w-5 h-5 ${X.color} flex-shrink-0`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:I.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:I.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(I.settings).length," fields"]}),s.jsx("button",{onClick:()=>T(I.id),className:`p-1 transition-colors ${I.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:I.showInModal?"Shown in modals":"Hidden in modals",children:I.showInModal?s.jsx(vf,{className:"w-4 h-4"}):s.jsx(T2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(I),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>k(I),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(Ha,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>M(I.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(Jt,{className:"w-4 h-4"})})]},I.id)})})})]})})]})}function hre({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,o]=w.useState("changes"),[l,c]=w.useState(""),u=w.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const v of p){if(v==="inherits"||v==="version")continue;const b=e[v],y=n[v],M=v in e,S=v in n;let A;!M&&S?A="added":M&&!S?A="removed":JSON.stringify(b)!==JSON.stringify(y)?A="changed":A="same",x.push({key:v,left:b,right:y,status:A})}return x.sort((v,b)=>{const y={changed:0,added:1,removed:2,same:3};return y[v.status]!==y[b.status]?y[v.status]-y[b.status]:v.key.localeCompare(b.key)})},[e,n]),d=w.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();p=p.filter(v=>v.key.toLowerCase().includes(x)||String(v.left).toLowerCase().includes(x)||String(v.right).toLowerCase().includes(x))}return p},[u,a,l]),f=w.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),m=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const x=String(p);if(x.includes("\\n")||x.length>100){const v=x.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return w.useEffect(()=>{const p=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(wt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Rp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),s.jsx("p",{className:"text-white font-medium truncate",children:r})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),s.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(qn,{className:"w-3.5 h-3.5"}),f.added," added"]}),s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Hj,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[s.jsx(Ij,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[s.jsx(CA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Ws,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:l,onChange:p=>c(p.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>o("changes"),className:`px-3 py-1.5 text-sm transition-colors ${a==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),s.jsx("button",{onClick:()=>o("all"),className:`px-3 py-1.5 text-sm transition-colors ${a==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(CA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:s.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),s.jsx("th",{className:"text-left p-3 w-1/3",children:r}),s.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),s.jsx("tbody",{children:d.map(p=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],v={added:s.jsx(qn,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(Hj,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(Ij,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(CA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[v,s.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.right)})})]},p.key)})})]})})]})})})}function cKe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Un(),i=Qt(),a=!!e?.setting_id,[o,l]=w.useState("common"),[c,u]=w.useState(e?.type||"filament"),[d,f]=w.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[m,p]=w.useState(e?.base_id||""),[x,v]=w.useState(""),[b,y]=w.useState(e?.setting||{inherits:""}),[M,S]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,E]=w.useState(null),[k,C]=w.useState(""),[R,T]=w.useState(!1),[P,F]=w.useState(""),[I,X]=w.useState(!1),[D,K]=w.useState(ure),[Y,q]=w.useState(!1),[Z,re]=w.useState(""),[ie,U]=w.useState(""),[G,ee]=w.useState(!0),[ne,se]=w.useState(null),[de,he]=w.useState(!1),Ee=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),ge=w.useMemo(()=>Ee.filter(me=>W0(me.setting_id)),[Ee]),{data:Ne}=lt({queryKey:["cloudFields",c],queryFn:()=>pe.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Re}=lt({queryKey:["allPresetDetails",c,ge.map(me=>me.setting_id).join(",")],queryFn:async()=>{const me={};for(let Xe=0;Xe<ge.length;Xe+=5){const nt=ge.slice(Xe,Xe+5);(await Promise.all(nt.map(async ae=>{try{const $e=await pe.getCloudSettingDetail(ae.setting_id);return{id:ae.setting_id,detail:$e}}catch{return null}}))).forEach(ae=>{ae&&(me[ae.id]=ae.detail)})}return me},enabled:ge.length>0,staleTime:1e3*60*10}),{data:te,isLoading:Je}=lt({queryKey:["cloudSettingDetail",m],queryFn:()=>pe.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&S(JSON.stringify(b,null,2))},[b,o]);const B=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(rt=>!W0(rt.setting_id)).sort((rt,Xe)=>rt.name.localeCompare(Xe.name)),[n,c]);w.useEffect(()=>{if(!m)return;const me=B.find(rt=>rt.setting_id===m);me&&(v(me.name),a||(y({inherits:me.name}),S(JSON.stringify({inherits:me.name},null,2))))},[m,B,a]);const H=w.useMemo(()=>{const me=Ne?.fields||[],rt=new Set(me.map(ae=>ae.key)),Xe=new Set,nt=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Re&&Object.values(Re).forEach(ae=>{ae?.setting&&Object.keys(ae.setting).forEach($e=>{!rt.has($e)&&!nt.has($e)&&Xe.add($e)})}),Object.keys(b).forEach(ae=>{!rt.has(ae)&&!nt.has(ae)&&Xe.add(ae)});const ut=Array.from(Xe).sort().map(ae=>({key:ae,label:ae.replace(/_/g," ").replace(/\b\w/g,$e=>$e.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...me,...ut]},[Ne,Re,b]),W=H.filter(me=>me.label.toLowerCase().includes(k.toLowerCase())||me.key.toLowerCase().includes(k.toLowerCase())),z=()=>{if(P.trim()){const me=P.trim().toLowerCase().replace(/\s+/g,"_");V(me,""),F(""),X(!1),r(`Field "${me}" added`)}},V=(me,rt)=>{y(Xe=>{const nt={...Xe};return rt===""||rt===void 0?delete nt[me]:nt[me]=rt,nt})},Q=me=>{y(rt=>({...rt,...me.settings})),se(me.name),r("Template applied")},Te=()=>{if(!Z.trim())return;const me={...b};if(delete me.inherits,Object.keys(me).length===0){r("No overrides to save","error");return}const rt={id:Date.now().toString(),name:Z.trim(),description:ie.trim()||"Custom template",type:c,settings:me,showInModal:G},Xe=[...D,rt];K(Xe),dre(Xe),q(!1),re(""),U(""),ee(!0),r("Template saved")},ke=w.useMemo(()=>D.filter(me=>me.type===c&&me.showInModal),[c,D]),Ae=me=>{S(me);try{const rt=JSON.parse(me);y(rt),E(null)}catch(rt){E(rt.message)}},$=me=>{me.preventDefault(),T(!1);const rt=me.dataTransfer.files[0];if(rt&&rt.name.endsWith(".json")){const Xe=new FileReader;Xe.onload=nt=>{try{const ut=nt.target?.result,ae=JSON.parse(ut),$e=ae.setting||ae;y(ye=>({...ye,...$e})),S(JSON.stringify({...b,...$e},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Xe.readAsText(rt)}},L=ft({mutationFn:()=>{const me={...b},rt=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";me[rt]=`"${d}"`;const Xe={type:c,name:d,base_id:m,setting:me};return pe.createCloudSetting(Xe)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:me=>r(me.message,"error")}),oe=ft({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return pe.updateCloudSetting(e.setting_id,{name:d,setting:b})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:me=>r(me.message,"error")}),ce=a?oe:L,xe=te?.setting?.inherits,ve=xe?B.find(me=>me.name===xe):void 0,{data:_e}=lt({queryKey:["cloudSettingDetail",ve?.setting_id],queryFn:()=>pe.getCloudSettingDetail(ve.setting_id),enabled:!!ve?.setting_id}),Ie=w.useMemo(()=>{const me=_e?.setting||{},rt=te?.setting||{},Xe=m&&Re?.[m]?.setting?Re[m].setting:{};return{...me,...rt,...Xe}},[m,te,_e,Re]),We=me=>{if(me==null)return"";if(Array.isArray(me)){const rt=[...new Set(me.map(Xe=>String(Xe)))];return rt.length===1?rt[0]:me.join(", ")}return String(me)},ht=me=>{const rt=b[me.key],Xe=Ie[me.key],nt=We(Xe),ut=Je?"Loading...":nt||"",ae="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(me.type==="boolean"){const $e=rt==="1"||rt===void 0&&Xe==="1";return s.jsx("button",{type:"button",onClick:()=>V(me.key,rt==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${$e?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${$e?"translate-x-3.5":"translate-x-0.5"}`})})}return me.type==="select"?s.jsxs("select",{value:rt||"",onChange:$e=>V(me.key,$e.target.value),className:ae,children:[s.jsx("option",{value:"",children:ut}),me.options?.map($e=>s.jsx("option",{value:$e.value,children:$e.label},$e.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:me.type==="number"?"number":"text",value:rt!==void 0?String(rt):"",onChange:$e=>V(me.key,$e.target.value),step:me.step,min:me.min,max:me.max,placeholder:ut,className:ae}),me.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:me.unit})]})},qe=w.useMemo(()=>te?.setting?te.setting:{},[te]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:me=>{me.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:$,children:[de&&m&&s.jsx(hre,{onClose:()=>he(!1),leftPreset:qe,rightPreset:b,leftLabel:`Base: ${x||m}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(wt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[m&&s.jsxs("button",{onClick:()=>he(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Compare with base preset",children:[s.jsx(Rp,{className:"w-4 h-4"}),"Compare"]}),s.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ut,{className:"w-5 h-5"})})]})]}),R&&s.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(bi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),s.jsxs("select",{value:c,onChange:me=>{u(me.target.value),p("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"filament",children:"Filament"}),s.jsx("option",{value:"print",children:"Process"}),s.jsx("option",{value:"printer",children:"Printer"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),s.jsxs("select",{value:m,onChange:me=>p(me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"Select base preset..."}),B.map(me=>s.jsx("option",{value:me.setting_id,children:me.name},me.setting_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),s.jsx("input",{type:"text",value:d,onChange:me=>f(me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(ps,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:x}),Je&&s.jsx(pt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>l("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(dz,{className:"w-4 h-4"}),"Common"]}),s.jsxs("button",{onClick:()=>l("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(O2,{className:"w-4 h-4"}),"All Fields"]}),s.jsxs("button",{onClick:()=>l("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx($W,{className:"w-4 h-4"}),"JSON",A&&s.jsx(ea,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const me={name:d,type:c,base_id:m,setting:b},rt=new Blob([JSON.stringify(me,null,2)],{type:"application/json"}),Xe=URL.createObjectURL(rt),nt=document.createElement("a");nt.href=Xe,nt.download=`${d||"preset"}.json`,document.body.appendChild(nt),nt.click(),document.body.removeChild(nt),URL.revokeObjectURL(Xe),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[s.jsx(Jr,{className:"w-4 h-4"}),"Export"]}),s.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Import settings from JSON file",children:[s.jsx(bi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:me=>{const rt=me.target.files?.[0];if(rt){const Xe=new FileReader;Xe.onload=nt=>{try{const ut=JSON.parse(nt.target?.result),ae=ut.setting||ut;y($e=>({...$e,...ae})),r("File imported")}catch{r("Invalid JSON","error")}},Xe.readAsText(rt)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[o==="common"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(a0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(b).filter(me=>me!=="inherits").length>0&&s.jsxs("button",{onClick:()=>q(!Y),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(cs,{className:"w-3 h-3"}),"Save as template"]})]}),Y&&s.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[s.jsx("input",{type:"text",value:Z,onChange:me=>re(me.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:ie,onChange:me=>U(me.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",onClick:Te,disabled:!Z.trim(),children:[s.jsx(cs,{className:"w-3 h-3"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>q(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>ee(!G),className:`flex items-center gap-1.5 text-xs transition-colors ${G?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[G?s.jsx(vf,{className:"w-3.5 h-3.5"}):s.jsx(T2,{className:"w-3.5 h-3.5"}),G?"Show in modals":"Hidden in modals"]})]})]}),ne&&s.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[s.jsx(ps,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",s.jsx("span",{className:"font-medium",children:ne})]}),s.jsx("button",{onClick:()=>se(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[ke.map(me=>s.jsxs("button",{onClick:()=>Q(me),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:me.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:me.description})]},me.id)),ke.length===0&&s.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:H.slice(0,10).map(me=>s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:me.label}),s.jsx("div",{className:"w-48",children:ht(me)})]},me.key))})]}),Object.keys(b).length>1&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(b).filter(([me])=>me!=="inherits").map(([me,rt])=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[me,": ",String(rt).slice(0,20),s.jsx("button",{onClick:()=>V(me,void 0),className:"hover:text-white",children:s.jsx(Ut,{className:"w-3 h-3"})})]},me))})]})]}),o==="fields"&&s.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:Re?`${H.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:k,onChange:me=>C(me.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[W.filter(me=>!(me.key in b)).map(me=>{const rt=Ie[me.key],Xe=We(rt);return s.jsxs("div",{onClick:()=>{y(nt=>({...nt,[me.key]:Xe||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white truncate",children:me.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:me.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Xe&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Xe,children:[Xe.slice(0,20),Xe.length>20?"...":""]}),s.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:s.jsx(qn,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},me.key)}),W.filter(me=>!(me.key in b)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:I?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:P,onChange:me=>F(me.target.value),onKeyDown:me=>me.key==="Enter"&&z(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx(Me,{size:"sm",onClick:z,disabled:!P.trim(),children:s.jsx(qn,{className:"w-4 h-4"})}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{X(!1),F("")},children:s.jsx(Ut,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>X(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(qn,{className:"w-4 h-4"}),"Add custom field"]})})]}),s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(b).filter(me=>me!=="inherits").length," fields"]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(b).filter(([me])=>me!=="inherits").map(([me,rt])=>{const Xe=H.find(nt=>nt.key===me);return s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:Xe?.label||me}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:me})]}),s.jsx("button",{onClick:()=>V(me,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),Xe?ht(Xe):s.jsx("input",{type:"text",value:String(rt),onChange:nt=>V(me,nt.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"})]},me)}),Object.keys(b).filter(me=>me!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(dz,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"No overrides yet"}),s.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(b).filter(me=>me!=="inherits").length>0&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsxs("button",{onClick:()=>{q(!0),l("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(cs,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[A&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(ea,{className:"w-4 h-4"}),A]}),s.jsx("textarea",{value:M,onChange:me=>Ae(me.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>ce.mutate(),disabled:ce.isPending||!d.trim()||!a&&!m||!!A,className:"flex-1",children:[ce.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(cs,{className:"w-4 h-4"}):s.jsx(qn,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function uKe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,o]=w.useState(""),[l,c]=w.useState("all"),[u,d]=w.useState("all"),[f,m]=w.useState("all"),[p,x]=w.useState("all"),[v,b]=w.useState("all"),[y,M]=w.useState("all"),[S,A]=w.useState(null),[E,k]=w.useState(!1),[C,R]=w.useState(!1),[T,P]=w.useState(null),[F,I]=w.useState(null),[X,D]=w.useState(null),[K,Y]=w.useState(!1),[q,Z]=w.useState([null,null]),[re,ie]=w.useState(!1),[U,G]=w.useState(null),ee=Qt(),ne=w.useMemo(()=>[...t.filament.map(W=>({...W,type:"filament"})),...t.printer.map(W=>({...W,type:"printer"})),...t.process.map(W=>({...W,type:"process"}))].map(W=>({...W,meta:jL(W.name)})),[t]),se=w.useMemo(()=>{const H=new Set,W=new Set,z=new Set;return ne.forEach(V=>{V.meta.nozzle&&H.add(V.meta.nozzle),V.meta.filamentType&&W.add(V.meta.filamentType),V.meta.layerHeight&&z.add(V.meta.layerHeight)}),{printers:i.map(V=>({id:V.id.toString(),name:V.name})),nozzles:Array.from(H).sort((V,Q)=>parseFloat(V)-parseFloat(Q)),filaments:Array.from(W).sort(),layerHeights:Array.from(z).sort((V,Q)=>parseFloat(V)-parseFloat(Q))}},[ne,i]),de=w.useMemo(()=>f==="all"?null:i.find(W=>W.id.toString()===f)?.model||null,[f,i]),he=w.useMemo(()=>ne.filter(H=>l==="all"||H.type===l).filter(H=>{if(u==="all")return!0;const W=W0(H.setting_id);return u==="custom"?W:!W}).filter(H=>{if(f==="all"||!de)return!0;const W=H.meta.printer?.toLowerCase()||"",z=de.toLowerCase();return W.includes(z)||z.includes(W)}).filter(H=>p==="all"||H.meta.nozzle===p).filter(H=>v==="all"||H.meta.filamentType===v).filter(H=>y==="all"||H.meta.layerHeight===y).filter(H=>a===""||H.name.toLowerCase().includes(a.toLowerCase())).sort((H,W)=>H.name.localeCompare(W.name)),[ne,l,u,f,de,p,v,y,a]),Ee=H=>{if(K){const W=q[0]?.setting_id===H.setting_id,z=q[1]?.setting_id===H.setting_id;if(W)Z([q[1],null]);else if(z)Z([q[0],null]);else if(!q[0])Z([H,null]);else if(q[1]){if(q[0].type!==H.type)return;Z([q[0],H])}else{if(q[0].type!==H.type)return;Z([q[0],H])}}else A(H)},ge=H=>{if(q[0]?.setting_id===H.setting_id)return 0;if(q[1]?.setting_id===H.setting_id)return 1},Ne=async H=>{try{const W=await pe.getCloudSettingDetail(H.setting_id),z=H.type==="process"?"print":H.type;P({type:z,name:H.name,base_id:W.base_id||"GFSA00",setting:W.setting||{}}),A(null)}catch(W){console.error("Failed to fetch preset details for duplication:",W)}},Re=async H=>{try{ee.removeQueries({queryKey:["cloudSettingDetail",H.setting_id]});const W=await pe.getCloudSettingDetail(H.setting_id),z=H.type==="process"?"print":H.type;I({type:z,name:H.name,base_id:W.base_id||"GFSA00",setting:W.setting||{},setting_id:H.setting_id}),A(null)}catch(W){console.error("Failed to fetch preset details for editing:",W)}},te=()=>{c("all"),d("all"),m("all"),x("all"),b("all"),M("all"),o("")},Je=l!=="all"||u!=="all"||f!=="all"||p!=="all"||v!=="all"||y!=="all"||a!=="",B=t.filament.length+t.printer.length+t.process.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-4 mb-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:a,onChange:H=>o(H.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:K?"primary":"secondary",onClick:()=>{K?(Y(!1),Z([null,null])):Y(!0)},children:[s.jsx(Rp,{className:"w-4 h-4"}),K?"Cancel":"Compare"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>R(!0),children:[s.jsx(a0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Me,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(yr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Me,{onClick:()=>k(!0),children:[s.jsx(qn,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(k2,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(xp,{label:"Type",value:l,options:[{value:"all",label:"All",count:B},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:H=>c(H)}),s.jsx(xp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:H=>d(H)}),se.printers.length>0&&s.jsx(xp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...se.printers.map(H=>({value:H.id,label:H.name}))],onChange:m}),se.nozzles.length>0&&s.jsx(xp,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...se.nozzles.map(H=>({value:H,label:H}))],onChange:x}),se.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(xp,{label:"Filament",value:v,options:[{value:"all",label:"All"},...se.filaments.map(H=>({value:H,label:H}))],onChange:b}),se.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(xp,{label:"Layer",value:y,options:[{value:"all",label:"All"},...se.layerHeights.map(H=>({value:H,label:H}))],onChange:M}),Je&&s.jsx("button",{onClick:te,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),K&&s.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(Rp,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),s.jsx("span",{className:"text-bambu-gray",children:q[0]?`Select another ${q[0].type} preset`:"Click two presets of the same type to compare"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${q[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:q[0]?q[0].name:"1. Select first"}),s.jsx(Ij,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${q[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:q[1]?q[1].name:"2. Select second"})]}),q[0]&&q[1]&&s.jsxs(Me,{size:"sm",onClick:async()=>{try{const[H,W]=await Promise.all([pe.getCloudSettingDetail(q[0].setting_id),pe.getCloudSettingDetail(q[1].setting_id)]);G([H.setting||{},W.setting||{}]),ie(!0)}catch{}},children:[s.jsx(Rp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Hn,{className:"w-3 h-3"}),"Last synced: ",iKe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",he.length," of ",B," presets"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),s.jsx("span",{children:"= My preset (editable)"})]})]}),he.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(tl,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Je&&s.jsx("button",{onClick:te,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(eD,{className:"w-4 h-4 text-amber-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",he.filter(H=>H.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[he.filter(H=>H.type==="filament").map(H=>s.jsx(bj,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>Ne(H),compareMode:K,isCompareSelected:ge(H)!==void 0,compareIndex:ge(H),compareDisabled:K&&!!q[0]&&q[0].type!==H.type},H.setting_id)),he.filter(H=>H.type==="filament").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Dd,{className:"w-4 h-4 text-blue-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",he.filter(H=>H.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[he.filter(H=>H.type==="process").map(H=>s.jsx(bj,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>Ne(H),compareMode:K,isCompareSelected:ge(H)!==void 0,compareIndex:ge(H),compareDisabled:K&&!!q[0]&&q[0].type!==H.type},H.setting_id)),he.filter(H=>H.type==="process").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Ir,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",he.filter(H=>H.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[he.filter(H=>H.type==="printer").map(H=>s.jsx(bj,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>Ne(H),compareMode:K,isCompareSelected:ge(H)!==void 0,compareIndex:ge(H),compareDisabled:K&&!!q[0]&&q[0].type!==H.type},H.setting_id)),he.filter(H=>H.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),S&&s.jsx(oKe,{setting:S,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>Ne(S),onEdit:()=>Re(S)}),(E||T||F||X)&&s.jsx(cKe,{onClose:()=>{k(!1),P(null),I(null),D(null)},initialData:F||T||(X?{type:X.type,name:"",base_id:"",setting:X.setting}:void 0),allPresets:t}),C&&s.jsx(lKe,{onClose:()=>R(!1),onApply:H=>{D({type:H.type,setting:H.settings}),R(!1)}}),re&&U&&q[0]&&q[1]&&s.jsx(hre,{onClose:()=>{ie(!1),G(null)},leftPreset:U[0],rightPreset:U[1],leftLabel:q[0].name,rightLabel:q[1].name})]})}function dKe(){const t=Qt(),{showToast:e}=Un(),[n,r]=w.useState("cloud"),[i,a]=w.useState(),{data:o,isLoading:l}=lt({queryKey:["cloudStatus"],queryFn:pe.getCloudStatus}),{data:c=[]}=lt({queryKey:["printers"],queryFn:pe.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=lt({queryKey:["cloudSettings"],queryFn:()=>pe.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&a(new Date(m))},[m]);const p=ft({mutationFn:pe.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-6 lg:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[s.jsxs("button",{onClick:()=>r("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(A2,{className:"w-4 h-4"}),"Cloud Profiles"]}),s.jsxs("button",{onClick:()=>r("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(j2,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&s.jsxs(s.Fragment,{children:[o?.is_authenticated&&s.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",s.jsx("span",{className:"text-white",children:o.email})]})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[s.jsx($j,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(uKe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),s.jsx(Me,{onClick:()=>f(),children:"Retry"})]}):s.jsx(aKe,{onSuccess:x})]}),n==="kprofiles"&&s.jsx(rKe,{}),s.jsx(sKe,{})]})}const Cb={Droplet:eD,Flame:due,Ruler:$de,Sparkles:a0,Square:Ol,Cable:lce,Wrench:Od,Calendar:Qr,Timer:md,Cog:Fce,Fan:HW,Zap:Sf,Wind:rq,Thermometer:U2,Layers:tl,Box:Rs,Target:JW,RefreshCw:yr,Settings:F2,Filter:k2,CircleDot:Nce};function Jb(t){return t&&Cb[t]||Od}function bp(t,e){if(e==="days")return t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<180?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`;{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const n=t/24;if(n<7)return`${n<2?n.toFixed(1):Math.round(n)}d`;const r=n/7;return r<12?`${r<2?r.toFixed(1):Math.round(r)}w`:`${Math.round(r/4)}mo`}}function yj(t,e){return e==="days"?t===1?"1 day":t===7?"1 week":t===14?"2 weeks":t===30?"1 month":t===60?"2 months":t===90?"3 months":t===180?"6 months":t===365?"1 year":`${t} days`:`${t}h`}function hKe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),a=n.includes("A1MINI"),o=n.includes("A1")&&!a,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,f=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":a||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":f?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":a||o||d||f?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":a||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function fKe({item:t,onPerform:e,onToggle:n}){const r=Jb(t.maintenance_type_icon),i=t.interval_type||"hours",o=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),l=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${bp(Math.abs(f),"days")}`:t.is_warning?`Due in ${bp(f,"days")}`:`${bp(f,"days")} left`}else return t.is_due?`Overdue by ${bp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${bp(t.hours_until_due,"hours")}`:`${bp(t.hours_until_due,"hours")} left`};return s.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[s.jsx(r,{className:`w-5 h-5 ${l()}`}),t.enabled&&(t.is_due||t.is_warning)&&s.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&s.jsx("span",{title:"Time-based interval",children:s.jsx(Qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||hKe(t.maintenance_type_name,t.printer_model);return f?s.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:"View documentation",onClick:m=>m.stopPropagation(),children:s.jsx(Lr,{className:"w-3.5 h-3.5"})}):null})()]}),s.jsx("div",{className:"mt-2 mb-1.5",children:s.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${o}%`}})})}),s.jsxs("div",{className:`text-xs flex items-center gap-1 ${l()}`,children:[t.is_due&&s.jsx(En,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(Hn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(ps,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx($n,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Me,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(Hf,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function mKe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=w.useState(!0),[o,l]=w.useState(!1),[c,u]=w.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,x)=>p.is_due&&!x.is_due?-1:!p.is_due&&x.is_due?1:p.is_warning&&!x.is_warning?-1:!p.is_warning&&x.is_warning?1:p.maintenance_type_id-x.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),m=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),l(!1))};return s.jsxs(wt,{className:"overflow-hidden",children:[s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&s.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(En,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&s.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(Hn,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&s.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(ps,{className:"w-3 h-3"}),"All good"]})]})]}),s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?s.jsx(Jc,{className:"w-4 h-4"}):s.jsx(Ji,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),s.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:s.jsx(md,{className:"w-4 h-4 text-bambu-gray"})}),o?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",value:c,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&m(),p.key==="Escape"&&l(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),s.jsx(Me,{size:"sm",onClick:m,children:"Save"}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):s.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[s.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.round(t.total_print_hours)," hours",s.jsx(_f,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const p=Jb(f.maintenance_type_icon);return s.jsx(p,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),s.jsxs("div",{children:[s.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),s.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&s.jsx(Mt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(p=>s.jsx(fKe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function pKe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l}){const[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState("hours"),[x,v]=w.useState(!1),[b,y]=w.useState(""),[M,S]=w.useState("100"),[A,E]=w.useState("hours"),[k,C]=w.useState("Wrench"),[R,T]=w.useState(""),[P,F]=w.useState(new Set),[I,X]=w.useState(null),D=w.useMemo(()=>t?t.map(z=>({id:z.printer_id,name:z.printer_name})):[],[t]),K=z=>t?t.filter(V=>V.maintenance_items.some(Q=>Q.maintenance_type_id===z)).map(V=>({printerId:V.printer_id,printerName:V.printer_name,itemId:V.maintenance_items.find(Q=>Q.maintenance_type_id===z)?.id})):[],Y=z=>{if(!t)return[];const V=new Set(K(z).map(Q=>Q.printerId));return D.filter(Q=>!V.has(Q.id))},[q,Z]=w.useState(null),[re,ie]=w.useState(""),[U,G]=w.useState(""),[ee,ne]=w.useState("hours"),[se,de]=w.useState("Wrench"),[he,Ee]=w.useState(""),ge=z=>{Z(z),ie(z.name),G(z.default_interval_hours.toString()),ne(z.interval_type||"hours"),de(z.icon||"Wrench"),Ee(z.wiki_url||"")},Ne=()=>{q&&re.trim()&&parseFloat(U)>0&&(i(q.id,{name:re.trim(),default_interval_hours:parseFloat(U),interval_type:ee,icon:se,wiki_url:he.trim()||null}),Z(null))},Re=(z,V,Q)=>{const Te=parseFloat(d);if(!isNaN(Te)&&Te>0){const ke=Math.abs(Te-V)<.01?null:Te;n(z,{custom_interval_hours:ke,custom_interval_type:m!==Q?m:null})}u(null)},te=z=>{z.preventDefault(),b.trim()&&parseFloat(M)>0&&P.size>0&&(r({name:b.trim(),default_interval_hours:parseFloat(M),interval_type:A,icon:k,wiki_url:R.trim()||null},Array.from(P)),y(""),S("100"),E("hours"),T(""),F(new Set),v(!1))},Je=z=>{F(V=>{const Q=new Set(V);return Q.has(z)?Q.delete(z):Q.add(z),Q})},B=t?.map(z=>({printerId:z.printer_id,printerName:z.printer_name,items:z.maintenance_items.sort((V,Q)=>V.maintenance_type_id-Q.maintenance_type_id)})).sort((z,V)=>z.printerName.localeCompare(V.printerName))||[],H=e.filter(z=>z.is_system),W=e.filter(z=>!z.is_system);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),s.jsxs(Me,{onClick:()=>v(!x),children:[s.jsx(qn,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&s.jsx(wt,{className:"mb-6",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("form",{onSubmit:te,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),s.jsx("input",{type:"text",value:b,onChange:z=>y(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),s.jsxs("select",{value:A,onChange:z=>{E(z.target.value),z.target.value==="days"?S("30"):S("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",A==="days"?"days":"hours",")"]}),s.jsx("input",{type:"number",value:M,onChange:z=>S(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),s.jsx("div",{className:"mt-4 flex items-end justify-between",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),s.jsx("div",{className:"flex gap-1",children:Object.keys(Cb).map(z=>{const V=Cb[z];return s.jsx("button",{type:"button",onClick:()=>C(z),className:`p-2 rounded-lg transition-colors ${k===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(V,{className:"w-4 h-4"})},z)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),s.jsx("input",{type:"url",value:R,onChange:z=>T(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(z=>s.jsx("button",{type:"button",onClick:()=>Je(z.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${P.has(z.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:z.name},z.id))}),P.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:()=>{v(!1),F(new Set)},children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!b.trim()||P.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[H.map(z=>{const V=Jb(z.icon),Q=z.interval_type||"hours";return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:s.jsx(V,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-white truncate",children:z.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[Q==="days"?s.jsx(Qr,{className:"w-3 h-3"}):s.jsx(md,{className:"w-3 h-3"}),yj(z.default_interval_hours,Q)]})]})]})},z.id)}),W.map(z=>{const V=Jb(z.icon),Q=z.interval_type||"hours";if(q?.id===z.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:re,onChange:L=>ie(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:ee,onChange:L=>ne(L.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:U,onChange:L=>G(L.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Cb).map(L=>{const oe=Cb[L];return s.jsx("button",{type:"button",onClick:()=>de(L),className:`p-1.5 rounded transition-colors ${se===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(oe,{className:"w-3.5 h-3.5"})},L)})}),s.jsx("input",{type:"url",value:he,onChange:L=>Ee(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Documentation link (optional)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{size:"sm",onClick:Ne,disabled:!re.trim(),children:"Save"}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>Z(null),children:"Cancel"})]})]})},z.id);const ke=K(z.id),Ae=Y(z.id),$=I===z.id;return s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:s.jsx(V,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-white truncate",children:z.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[Q==="days"?s.jsx(Qr,{className:"w-3 h-3"}):s.jsx(md,{className:"w-3 h-3"}),yj(z.default_interval_hours,Q)]})]}),s.jsxs("button",{onClick:()=>X($?null:z.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${ke.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:`${ke.length} printer(s) assigned - click to manage`,children:[s.jsx(Ir,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:ke.length}),s.jsx(Ji,{className:`w-3 h-3 transition-transform ${$?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>ge(z),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(_f,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(`Delete "${z.name}"?`)&&a(z.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Jt,{className:"w-4 h-4"})})]}),$&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),ke.length===0?s.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:ke.map(L=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[L.printerName,s.jsx("button",{onClick:()=>L.itemId&&l(L.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},L.printerId))}),Ae.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),Ae.map(L=>s.jsxs("button",{onClick:()=>o(L.id,z.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",L.name]},L.id))]})]})]},z.id)})]})]}),B.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),s.jsx("div",{className:"space-y-4",children:B.map(z=>s.jsx(wt,{children:s.jsxs(Mt,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:z.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:z.items.map(V=>{const Q=Jb(V.maintenance_type_icon),Te=e.find(oe=>oe.id===V.maintenance_type_id),ke=Te?.default_interval_hours||V.interval_hours,Ae=Te?.interval_type||"hours",$=V.interval_type||"hours",L=c===V.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(Q,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:V.maintenance_type_name}),L?s.jsxs("div",{className:"flex items-center gap-1",children:[m==="days"?s.jsx(Qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(md,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:m,onChange:oe=>p(oe.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:d,onChange:oe=>f(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&Re(V.id,ke,Ae),oe.key==="Escape"&&u(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),s.jsx(Me,{size:"sm",onClick:()=>Re(V.id,ke,Ae),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(V.id),f(V.interval_hours.toString()),p($)},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors flex items-center gap-1",children:[$==="days"?s.jsx(Qr,{className:"w-3 h-3"}):s.jsx(md,{className:"w-3 h-3"}),yj(V.interval_hours,$),s.jsx(_f,{className:"w-3 h-3 text-bambu-gray"})]})]},V.id)})})]})},z.printerId))})]}),B.length===0&&s.jsx(wt,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx(Hn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function gKe(){const t=Qt(),{showToast:e}=Un(),[n,r]=w.useState("status"),{data:i,isLoading:a}=lt({queryKey:["maintenanceOverview"],queryFn:pe.getMaintenanceOverview}),{data:o}=lt({queryKey:["maintenanceTypes"],queryFn:pe.getMaintenanceTypes}),l=ft({mutationFn:({id:S,notes:A})=>pe.performMaintenance(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:S=>{e(S.message,"error")}}),c=ft({mutationFn:({id:S,data:A})=>pe.updateMaintenanceItem(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:S=>{e(S.message,"error")}}),u=ft({mutationFn:({id:S,data:A})=>pe.updateMaintenanceType(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:S=>{e(S.message,"error")}}),d=ft({mutationFn:pe.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:S=>{e(S.message,"error")}}),f=ft({mutationFn:({printerId:S,hours:A})=>pe.setPrinterHours(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:S=>{e(S.message,"error")}}),m=ft({mutationFn:({printerId:S,typeId:A})=>pe.assignMaintenanceType(S,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:S=>{e(S.message,"error")}}),p=ft({mutationFn:pe.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:S=>{e(S.message,"error")}}),x=S=>{l.mutate({id:S})},v=(S,A)=>{c.mutate({id:S,data:{enabled:A}})},b=(S,A)=>{f.mutate({printerId:S,hours:A})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const y=i?.reduce((S,A)=>S+A.due_count,0)||0,M=i?.reduce((S,A)=>S+A.warning_count,0)||0;return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?s.jsxs(s.Fragment,{children:[y>0&&s.jsxs("span",{className:"text-red-400",children:[y," task",y!==1?"s":""," overdue"]}),y>0&&M>0&&" · ",M>0&&s.jsxs("span",{className:"text-amber-400",children:[M," due soon"]}),y===0&&M===0&&s.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>r("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),s.jsx("button",{onClick:()=>r("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?s.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((S,A)=>{const E=S.due_count*10+S.warning_count,k=A.due_count*10+A.warning_count;return E!==k?k-E:S.printer_name.localeCompare(A.printer_name)}).map(S=>s.jsx(mKe,{overview:S,onPerform:x,onToggle:v,onSetHours:b},S.printer_id)):s.jsx(wt,{children:s.jsxs(Mt,{className:"text-center py-16",children:[s.jsx(Od,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):s.jsx(pKe,{overview:i,types:o||[],onUpdateInterval:(S,A)=>c.mutate({id:S,data:A}),onAddType:async(S,A)=>{const E=await pe.createMaintenanceType(S);for(const k of A)await pe.assignMaintenanceType(k,E.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(S,A)=>u.mutate({id:S,data:A}),onDeleteType:S=>d.mutate(S),onAssignType:(S,A)=>m.mutate({printerId:S,typeId:A}),onRemoveItem:S=>p.mutate(S)})]})}const GG=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function fre({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=w.useState(t?.name||""),[o,l]=w.useState(t?.description||""),[c,u]=w.useState(t?.color||GG[0]),[d,f]=w.useState(t?.target_count?.toString()||""),[m,p]=w.useState(t?.target_parts_count?.toString()||""),[x,v]=w.useState(t?.status||"active"),[b,y]=w.useState(t?.tags||""),[M,S]=w.useState(t?.due_date?.split("T")[0]||""),[A,E]=w.useState(t?.priority||"normal"),k=C=>{C.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:b.trim()||void 0,due_date:M||void 0,priority:A,...t&&{status:x}})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),s.jsxs("form",{onSubmit:k,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),s.jsx("input",{type:"text",value:i,onChange:C=>a(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:"e.g., Voron 2.4 Build",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),s.jsx("textarea",{value:o,onChange:C=>l(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 resize-none",placeholder:"Optional description...",rows:2})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),s.jsx("div",{className:"flex gap-2 flex-wrap",children:GG.map(C=>s.jsx("button",{type:"button",onClick:()=>u(C),className:`w-8 h-8 rounded-full transition-transform ${c===C?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:C}},C))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Plates"}),s.jsx("input",{type:"number",value:d,onChange:C=>f(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:"e.g., 25",min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of print jobs"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Parts"}),s.jsx("input",{type:"number",value:m,onChange:C=>p(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:"e.g., 150",min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Total objects needed"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),s.jsx("input",{type:"text",value:b,onChange:C=>y(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:"e.g., voron, functional, gift"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),s.jsx("input",{type:"date",value:M,onChange:C=>S(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),s.jsxs("select",{value:A,onChange:C=>E(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"low",children:"Low"}),s.jsx("option",{value:"normal",children:"Normal"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),s.jsxs("select",{value:x,onChange:C=>v(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"active",children:"Active"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"archived",children:"Archived"})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function xKe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.target_count?Math.round(t.archive_count/t.target_count*100):0,a=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,o=t.status==="completed",l=t.status==="archived",[c,u]=w.useState(!1),f=o?{icon:E2,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:Is,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Hn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:xa,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return s.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[s.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),s.jsxs("div",{className:"p-5 pl-6",children:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg ${f.bg} flex-shrink-0`,children:s.jsx(f.icon,{className:`w-5 h-5 ${f.color}`})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${a>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," parts"]}):t.target_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${i>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," plates"]}):t.completed_count>0?s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," parts"]}):null,o&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),l&&s.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),t.description&&s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const m=t.archives.map(b=>b.filament_type).filter(Boolean).flatMap(b=>b.split(",").map(y=>y.trim())).filter(Boolean),p=[...new Set(m)],x=t.archives.map(b=>b.filament_color).filter(Boolean).flatMap(b=>b.split(",").map(y=>y.trim())).filter(b=>b.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(b)),v=[...new Set(x)];return p.length===0&&v.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[p.slice(0,3).map(b=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:b},b)),v.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(b=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:b.startsWith("#")?b:`#${b}`},title:b},b)),v.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:m=>m.stopPropagation(),children:[s.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>u(!c),children:s.jsx(wd,{className:"w-4 h-4"})}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!1)}),s.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[s.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{n(),u(!1)},children:[s.jsx(_f,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(),u(!1)},children:[s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?s.jsxs("div",{className:"space-y-3",children:[t.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Plates"}),s.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(i,100)}%`,background:i>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${i>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Parts"}),s.jsxs("span",{className:a>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(a,100)}%`,background:a>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${a>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&s.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," failed"]})]}):t.completed_count>0||t.failed_count>0?s.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Is,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.completed_count," completed"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[s.jsx(En,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.failed_count," failed"]})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[s.jsx(Hn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(m=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:m.print_name||"Unknown",children:[m.thumbnail_path?s.jsx("img",{src:pe.getArchiveThumbnail(m.id),alt:m.print_name||"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:s.jsx(Dl,{className:"w-6 h-6"})}),m.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(En,{className:"w-4 h-4 text-white"})})]},m.id))}),t.archive_count>4&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[s.jsxs("div",{className:"flex items-center gap-1.5",title:"Print jobs (plates)",children:[s.jsx(tl,{className:"w-3.5 h-3.5 text-blue-400"}),s.jsxs("span",{children:[t.archive_count," plates"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",title:"Parts printed",children:[s.jsx(Dl,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsxs("span",{children:[t.completed_count," parts"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:"Failed parts",children:[s.jsx(En,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:"In queue",children:[s.jsx(Bj,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Vs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function bKe(){const t=sl(),e=Qt(),{showToast:n}=Un(),[r,i]=w.useState(!1),[a,o]=w.useState(),[l,c]=w.useState("active"),[u,d]=w.useState(null),{data:f,isLoading:m}=lt({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>pe.getProjects(l==="all"?void 0:l)}),p=ft({mutationFn:k=>pe.createProject(k),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:k=>{n(k.message,"error")}}),x=ft({mutationFn:({id:k,data:C})=>pe.updateProject(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:k=>{n(k.message,"error")}}),v=ft({mutationFn:k=>pe.deleteProject(k),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:k=>{d(null),n(k.message,"error")}}),b=k=>{a?x.mutate({id:a.id,data:k}):p.mutate(k)},y=k=>{o(k),i(!0)},M=k=>{t(`/projects/${k.id}`)},S=k=>{d(k)},A=()=>{u!==null&&v.mutate(u)},E=f?.reduce((k,C)=>(k[C.status]=(k[C.status]||0)+1,k.all=(k.all||0)+1,k),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(xa,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),s.jsxs(Me,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(qn,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),s.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:Hn},{key:"completed",label:"Completed",icon:E2},{key:"archived",label:"Archived",icon:Is},{key:"all",label:"All",icon:xa}].map(({key:k,label:C,icon:R})=>s.jsxs("button",{onClick:()=>c(k),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===k?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(R,{className:"w-4 h-4"}),s.jsx("span",{children:C}),E[k]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===k?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:E[k]})]},k))}),m?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(xa,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:l==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${l} projects. Projects will appear here when their status changes.`}),l==="all"&&s.jsxs(Me,{onClick:()=>i(!0),children:[s.jsx(qn,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:f?.map(k=>s.jsx(xKe,{project:k,onClick:()=>M(k),onEdit:()=>y(k),onDelete:()=>S(k.id)},k.id))}),u!==null&&s.jsx(Rn,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:A,onCancel:()=>d(null)}),r&&s.jsx(fre,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:b,isLoading:p.isPending||x.isPending})]})}function yKe(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 vKe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function _Ke({status:t}){const e={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},n=e[t]||e.active;return s.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function WG({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(wt,{children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",title:i,children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function wKe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Dl,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No prints in this project yet"})]}):s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(e=>s.jsxs(as,{to:`/archives?search=${encodeURIComponent(e.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[e.thumbnail_path?s.jsx("img",{src:pe.getArchiveThumbnail(e.id),alt:e.print_name||"Print",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(Dl,{className:"w-8 h-8"})}),e.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(qi,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(kn,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx("p",{className:"text-xs text-white truncate",children:e.print_name||"Unknown"})})]},e.id))})}function SKe({priority:t}){const e={low:{color:"bg-gray-500/20 text-gray-400",label:"Low"},normal:{color:"bg-blue-500/20 text-blue-400",label:"Normal"},high:{color:"bg-orange-500/20 text-orange-400",label:"High"},urgent:{color:"bg-red-500/20 text-red-400",label:"Urgent"}},{color:n,label:r}=e[t]||e.normal;return s.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&s.jsx(En,{className:"w-3 h-3"}),r]})}function MKe(t){return t?Jp(t,{year:"numeric",month:"short",day:"numeric"}):""}function vj(t){if(!t)return null;const e=mi(t);if(!e)return null;const n=new Date,r=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return r<0?{color:"text-red-400",label:"Overdue"}:r===0?{color:"text-orange-400",label:"Due today"}:r<=3?{color:"text-yellow-400",label:`${r} days left`}:{color:"text-bambu-gray",label:`${r} days left`}}function NKe(){const{id:t}=HR(),e=sl(),n=Qt(),{showToast:r}=Un(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=parseInt(t||"0",10),{data:f,isLoading:m,error:p}=lt({queryKey:["project",d],queryFn:()=>pe.getProject(d),enabled:d>0}),{data:x,isLoading:v}=lt({queryKey:["project-archives",d],queryFn:()=>pe.getProjectArchives(d),enabled:d>0}),{data:b,isLoading:y}=lt({queryKey:["project-bom",d],queryFn:()=>pe.getProjectBOM(d),enabled:d>0}),{data:M,isLoading:S}=lt({queryKey:["project-timeline",d],queryFn:()=>pe.getProjectTimeline(d,20),enabled:d>0}),{data:A}=lt({queryKey:["settings"],queryFn:pe.getSettings}),{data:E}=lt({queryKey:["project-folders",d],queryFn:()=>pe.getLibraryFoldersByProject(d),enabled:d>0}),k=A?.currency||"$",C=A?.time_format||"system",R=ft({mutationFn:Q=>pe.updateProject(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:Q=>{r(Q.message,"error")}}),T=()=>{u(f?.notes||""),l(!0)},P=()=>{R.mutate({notes:c})},F=()=>{l(!1),u("")},[I,X]=w.useState(""),[D,K]=w.useState(1),[Y,q]=w.useState(""),[Z,re]=w.useState(""),[ie,U]=w.useState(""),[G,ee]=w.useState(!1),[ne,se]=w.useState(!1),[de,he]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Ee=ft({mutationFn:Q=>pe.createBOMItem(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),X(""),K(1),q(""),re(""),U(""),ee(!1),r("Part added","success")},onError:Q=>r(Q.message,"error")}),ge=ft({mutationFn:({itemId:Q,data:Te})=>pe.updateBOMItem(d,Q,Te),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]})},onError:Q=>r(Q.message,"error")}),Ne=ft({mutationFn:Q=>pe.deleteBOMItem(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:Q=>r(Q.message,"error")}),Re=Q=>{Q.preventDefault(),I.trim()&&Ee.mutate({name:I.trim(),quantity_needed:D,unit_price:Y?parseFloat(Y):void 0,sourcing_url:Z.trim()||void 0,remarks:ie.trim()||void 0})},te=Q=>{const Te=Q.is_complete?0:Q.quantity_needed;ge.mutate({itemId:Q.id,data:{quantity_acquired:Te}})},Je=(Q,Te)=>{he({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Te}"?`,onConfirm:()=>{he(ke=>({...ke,isOpen:!1})),Ne.mutate(Q)}})},B=ft({mutationFn:()=>pe.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:Q=>r(Q.message,"error")}),H=Q=>eg(Q,C,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(m)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(p||!f)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:p?`Error: ${p.message}`:"Project not found"}),s.jsx(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const W=f.stats,z=W?.progress_percent??0,V=W?.parts_progress_percent??0;return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(as,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Vs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:f.name})]}),s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:s.jsx(UW,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:f.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:f.name}),f.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:f.description})]})]}),s.jsx(_Ke,{status:f.status})]}),s.jsxs(Me,{onClick:()=>a(!0),children:[s.jsx(_f,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),(f.target_count||f.target_parts_count)&&s.jsx(wt,{children:s.jsxs(Mt,{className:"p-4 space-y-4",children:[f.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Plates Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[W?.total_archives||0," / ",f.target_count," print jobs"]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(z,100)}%`,backgroundColor:z>=100?"#22c55e":f.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[z.toFixed(0),"% complete"]}),W?.remaining_prints!=null&&W.remaining_prints>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[W.remaining_prints," remaining"]})]})]}),f.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Parts Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[W?.completed_prints||0," / ",f.target_parts_count," parts"]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(V,100)}%`,backgroundColor:V>=100?"#22c55e":f.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[V.toFixed(0),"% complete"]}),W?.remaining_parts!=null&&W.remaining_parts>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[W.remaining_parts," remaining"]})]})]})]})}),W&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(wt,{children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(Dl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Print Jobs"}),s.jsxs("p",{className:"text-xl font-semibold text-white",children:[W.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),W.failed_prints>0&&s.jsxs("p",{className:"text-sm text-red-400",children:[W.failed_prints," failed"]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[W.completed_prints," parts printed"]})]})]})})}),s.jsx(WG,{icon:Hn,label:"Print Time",value:yKe(W.total_print_time_hours),color:"text-yellow-400"}),s.jsx(WG,{icon:Ir,label:"Filament Used",value:vKe(W.total_filament_grams),color:"text-purple-400"})]}),W&&(W.estimated_cost>0||f.budget)&&s.jsx(wt,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[k,W.estimated_cost.toFixed(2)]})]}),W.total_energy_kwh>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[W.total_energy_kwh.toFixed(2)," kWh",W.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",k,W.total_energy_cost.toFixed(2),")"]})]})]}),f.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[k,f.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),s.jsxs("p",{className:`text-lg font-semibold ${f.budget-W.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[k,(f.budget-W.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&s.jsx(wt,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(xue,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:f.children.map(Q=>s.jsxs(as,{to:`/projects/${Q.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Q.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:Q.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Q.status==="completed"?"bg-bambu-green/20 text-bambu-green":Q.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Q.status})]}),Q.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[Q.progress_percent.toFixed(0),"%"]})]},Q.id))})]})}),f.parent_id&&f.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(as,{to:`/projects/${f.parent_id}`,className:"text-bambu-green hover:underline",children:f.parent_name})]}),(f.tags||f.due_date||f.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.priority&&f.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),s.jsx(SKe,{priority:f.priority})]}),f.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:MKe(f.due_date)}),vj(f.due_date)&&s.jsxs("span",{className:`text-xs ${vj(f.due_date).color}`,children:["(",vj(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zp,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((Q,Te)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Q.trim()},Te))})]})]}),s.jsx(wt,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ua,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:F,disabled:R.isPending,children:[s.jsx(Ut,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Me,{size:"sm",onClick:P,disabled:R.isPending,children:[R.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(cs,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:T,children:[s.jsx(_f,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(kR,{content:c,onChange:u,placeholder:"Add notes about this project..."}):f.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:f.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),s.jsx(wt,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(el,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(as,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),E&&E.length>0?s.jsx("div",{className:"space-y-2",children:E.map(Q=>s.jsxs(as,{to:`/files?folder=${Q.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(el,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:Q.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[Q.file_count," file",Q.file_count!==1?"s":""]})]})]}),s.jsx(Vs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Q.id))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No folders linked. Go to File Manager and link a folder to this project."})]})}),s.jsx(wt,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(QW,{className:"w-5 h-5"}),"Bill of Materials",W&&W.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.bom_completed_items,"/",W.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[b&&b.some(Q=>Q.is_complete)&&s.jsx("button",{onClick:()=>se(!ne),className:`text-xs px-2 py-1 rounded transition-colors ${ne?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:ne?"Show all":"Hide done"}),!G&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ee(!0),children:[s.jsx(qn,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),G&&s.jsxs("form",{onSubmit:Re,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:I,onChange:Q=>X(Q.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name (e.g., M3x8 screws)",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:D,onChange:Q=>K(parseInt(Q.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),s.jsx("input",{type:"number",step:"0.01",value:Y,onChange:Q=>q(Q.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${k})`})]})]}),s.jsx("input",{type:"url",value:Z,onChange:Q=>re(Q.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),s.jsx("input",{type:"text",value:ie,onChange:Q=>U(Q.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>ee(!1),children:"Cancel"}),s.jsx(Me,{type:"submit",size:"sm",disabled:!I.trim()||Ee.isPending,children:Ee.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),y?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):b&&b.length>0?s.jsxs("div",{className:"space-y-2",children:[b.filter(Q=>!ne||!Q.is_complete).map(Q=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${Q.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>te(Q),disabled:ge.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Q.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:Q.is_complete&&s.jsx(kn,{className:"w-3 h-3"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("p",{className:`text-sm font-medium ${Q.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Q.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Q.quantity_needed]})]}),Q.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[k,(Q.unit_price*Q.quantity_needed).toFixed(2)]})]}),s.jsx("button",{onClick:()=>Je(Q.id,Q.name),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0",title:"Delete",children:s.jsx(Jt,{className:"w-4 h-4"})})]}),Q.sourcing_url&&s.jsxs("a",{href:Q.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:Te=>Te.stopPropagation(),children:[s.jsx(Lr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Q.sourcing_url).hostname.replace("www.","")}catch{return Q.sourcing_url}})()})]}),Q.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Q.remarks})]})]})},Q.id)),b.some(Q=>Q.unit_price!==null)&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:"Total cost:"}),s.jsxs("span",{className:"text-white font-medium",children:[k,b.reduce((Q,Te)=>Q+(Te.unit_price||0)*Te.quantity_needed,0).toFixed(2)]})]})]}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."})]})}),s.jsx(wt,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(hw,{className:"w-5 h-5"}),"Activity Timeline"]})}),S?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):M&&M.length>0?s.jsx("div",{className:"space-y-3",children:M.slice(0,10).map((Q,Te)=>s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Q.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":Q.event_type==="print_failed"?"bg-red-500/20 text-red-400":Q.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Q.event_type==="print_completed"&&s.jsx(kn,{className:"w-4 h-4"}),Q.event_type==="print_failed"&&s.jsx(qi,{className:"w-4 h-4"}),Q.event_type==="print_started"&&s.jsx(Ir,{className:"w-4 h-4"}),Q.event_type==="queued"&&s.jsx(Bj,{className:"w-4 h-4"}),Q.event_type==="project_created"&&s.jsx(qn,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:Q.title}),Q.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Q.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:H(Q.timestamp)})]})]},Te))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!f.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>B.mutate(),disabled:B.isPending,children:[B.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Gs,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),W&&(W.queued_prints>0||W.in_progress_prints>0)&&s.jsx(wt,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Bj,{className:"w-5 h-5"}),"Queue"]}),s.jsx(as,{to:`/queue?project=${d}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[W.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[W.in_progress_prints," printing"]}),W.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[W.queued_prints," queued"]})]})]})}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-4",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Dl,{className:"w-5 h-5"}),"Prints (",x?.length||0,")"]})}),v?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(wKe,{archives:x||[]})]}),i&&s.jsx(fre,{project:{...f,archive_count:W?.total_archives||0,total_items:W?.total_items||0,completed_count:W?.completed_prints||0,failed_count:W?.failed_prints||0,queue_count:W?.queued_prints||0,progress_percent:W?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:Q=>R.mutate(Q),isLoading:R.isPending}),de.isOpen&&s.jsx(Rn,{title:de.title,message:de.message,confirmText:"Delete",variant:"danger",onConfirm:de.onConfirm,onCancel:()=>he(Q=>({...Q,isOpen:!1}))})]})}function Ep(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 EKe(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 AKe({parentId:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=w.useState(""),o=l=>{l.preventDefault(),n({name:i.trim(),parent_id:t})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"New Folder"})}),s.jsxs("form",{onSubmit:o,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Folder Name"}),s.jsx("input",{type:"text",value:i,onChange:l=>a(l.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Functional Parts",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function TKe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i}){const[a,o]=w.useState(e),l=c=>{c.preventDefault(),a.trim()&&a.trim()!==e&&r(a.trim())};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Rename ",t==="file"?"File":"Folder"]})}),s.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),s.jsx("input",{type:"text",value:a,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!a.trim()||a.trim()===e||i,children:i?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Rename"})]})]})]})})}function CKe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:a}){const[o,l]=w.useState(null),c=(d,f=0)=>{const m=[];for(const p of d)m.push({id:p.id,name:p.name,depth:f}),p.children.length>0&&m.push(...c(p.children,f+1));return m},u=[{id:null,name:"Root (No Folder)",depth:0},...c(t)];return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Move ",e.length," File(s)"]})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:u.map(d=>s.jsxs("button",{onClick:()=>l(d.id),disabled:d.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===d.id?"bg-bambu-green/20 text-bambu-green":d.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+d.depth*16}px`},children:[s.jsx(el,{className:"w-4 h-4"}),d.name,d.id===n&&s.jsx("span",{className:"text-xs text-bambu-gray ml-auto",children:"(current)"})]},d.id??"root"))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Me,{onClick:()=>i(o),disabled:a,children:a?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function kKe({folder:t,onClose:e,onLink:n,isLoading:r}){const[i,a]=w.useState("project"),[o,l]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&a("archive")});const{data:c}=lt({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:u}=lt({queryKey:["archives-for-link"],queryFn:()=>pe.getArchives(void 0,void 0,100)}),d=()=>{n(i==="project"?{project_id:o,archive_id:0}:{project_id:0,archive_id:o})},f=()=>{n({project_id:0,archive_id:0})},m=t.project_id||t.archive_id;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Cl,{className:"w-5 h-5 text-bambu-green"}),"Link Folder"]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:['Link "',s.jsx("span",{className:"text-white",children:t.name}),'" to a project or archive for quick access.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>{a("project"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(BW,{className:"w-4 h-4"}),"Project"]}),s.jsxs("button",{onClick:()=>{a("archive"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(Is,{className:"w-4 h-4"}),"Archive"]})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:i==="project"?c&&c.length>0?c.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:p.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:p.name})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(tf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:p.print_name||p.filename})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No archives found"})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&s.jsxs(Me,{variant:"danger",onClick:f,disabled:r,children:[s.jsx(aD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:d,disabled:!o||r,children:r?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function jKe({folderId:t,onClose:e,onUploadComplete:n}){const[r,i]=w.useState([]),[a,o]=w.useState(!1),[l,c]=w.useState(!1),u=w.useRef(null),d=E=>{E.preventDefault(),o(!0)},f=E=>{E.preventDefault(),o(!1)},m=E=>{E.preventDefault(),o(!1);const k=Array.from(E.dataTransfer.files);x(k)},p=E=>{E.target.files&&x(Array.from(E.target.files))},x=E=>{const k=E.map(C=>({file:C,status:"pending"}));i(C=>[...C,...k])},v=E=>{i(k=>k.filter((C,R)=>R!==E))},b=async()=>{if(r.length!==0){c(!0);for(let E=0;E<r.length;E++)if(r[E].status==="pending"){i(k=>k.map((C,R)=>R===E?{...C,status:"uploading"}:C));try{await pe.uploadLibraryFile(r[E].file,t),i(k=>k.map((C,R)=>R===E?{...C,status:"success"}:C))}catch(k){i(C=>C.map((R,T)=>T===E?{...R,status:"error",error:k instanceof Error?k.message:"Upload failed"}:R))}}c(!1),n(),e()}},y=r.filter(E=>E.status==="pending").length,M=r.filter(E=>E.status==="success").length,S=r.filter(E=>E.status==="error").length,A=r.length>0&&y===0&&!l;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Upload Files"}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:d,onDragLeave:f,onDrop:m,onClick:()=>u.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${a?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[s.jsx(bi,{className:`w-10 h-10 mx-auto mb-3 ${a?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("p",{className:"text-white font-medium",children:a?"Drop files here":"Drag & drop files here"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"or click to browse"})]}),s.jsx("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:p}),r.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((E,k)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[s.jsx(C2,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:E.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(E.file.size/1024/1024).toFixed(2)," MB"]})]}),E.status==="pending"&&s.jsx("button",{onClick:()=>v(k),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ut,{className:"w-4 h-4 text-bambu-gray"})}),E.status==="uploading"&&s.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"}),E.status==="success"&&s.jsx(kn,{className:"w-4 h-4 text-green-500"}),E.status==="error"&&s.jsx("span",{title:E.error,children:s.jsx(qi,{className:"w-4 h-4 text-red-500"})})]},k))}),A&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",M," succeeded",S>0&&s.jsxs("span",{className:"text-red-400",children:[", ",S," failed"]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:A?"Close":"Cancel"}),!A&&s.jsx(Me,{onClick:b,disabled:y===0||l,children:l?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bi,{className:"w-4 h-4 mr-2"}),"Upload ",y>0?`(${y})`:""]})})]})]})})}function mre({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0}){const[l,c]=w.useState(!0),[u,d]=w.useState(!1),f=t.children.length>0,m=t.project_id||t.archive_id;return s.jsxs("div",{children:[s.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[f?s.jsx("button",{onClick:p=>{p.stopPropagation(),c(!l)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Vs,{className:`w-3.5 h-3.5 transition-transform ${l?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(el,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm truncate flex-1",children:t.name}),m&&s.jsxs("button",{onClick:p=>{p.stopPropagation(),i(t)},className:"flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[s.jsx(Cl,{className:"w-3 h-3"}),t.project_name?s.jsx(BW,{className:"w-3 h-3"}):s.jsx(Is,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.file_count}),!m&&s.jsx("button",{onClick:p=>{p.stopPropagation(),i(t)},className:"p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:s.jsx(Cl,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:p=>p.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>d(!u),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(wd,{className:"w-3.5 h-3.5 text-bambu-gray"})}),u&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>d(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{a(t),d(!1)},children:[s.jsx(Ha,{className:"w-3.5 h-3.5"}),"Rename"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t),d(!1)},children:[s.jsx(Cl,{className:"w-3.5 h-3.5"}),m?"Change Link...":"Link to..."]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),d(!1)},children:[s.jsx(Jt,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),f&&l&&s.jsx("div",{children:t.children.map(p=>s.jsx(mre,{folder:p,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1},p.id))})]})}function FR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function PKe({file:t,isSelected:e,onSelect:n,onDelete:r,onDownload:i,onAddToQueue:a,onPrint:o,onRename:l}){const[c,u]=w.useState(!1);return s.jsxs("div",{className:`group relative bg-bambu-card rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>n(t.id),children:[s.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?s.jsx("img",{src:pe.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(tf,{className:"w-12 h-12 text-bambu-gray/30"}),t.duplicate_count>0&&s.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1 bg-amber-500/90 text-white text-xs px-1.5 py-0.5 rounded",children:[s.jsx(Gs,{className:"w-3 h-3"}),t.duplicate_count]}),s.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),s.jsxs("div",{className:"p-3",children:[s.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[s.jsx("span",{children:Ep(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Hn,{className:"w-3 h-3"}),EKe(t.print_time_seconds)]})]}),t.print_count>0&&s.jsxs("div",{className:"mt-1 text-xs text-bambu-green",children:["Printed ",t.print_count,"x"]})]}),s.jsxs("div",{className:"absolute bottom-2 right-2 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",onClick:d=>d.stopPropagation(),children:[s.jsx("button",{onClick:()=>u(!c),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:s.jsx(wd,{className:"w-4 h-4 text-bambu-gray"})}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!1)}),s.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[o&&FR(t.filename)&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-bambu-green hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{o(t),u(!1)},children:[s.jsx(Ir,{className:"w-3.5 h-3.5"}),"Print"]}),a&&FR(t.filename)&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{a(t.id),u(!1)},children:[s.jsx(Hn,{className:"w-3.5 h-3.5"}),"Add to Queue"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t.id),u(!1)},children:[s.jsx(Jr,{className:"w-3.5 h-3.5"}),"Download"]}),l&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{l(t),u(!1)},children:[s.jsx(Ha,{className:"w-3.5 h-3.5"}),"Rename"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),u(!1)},children:[s.jsx(Jt,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]}),s.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":"border-white/30 bg-black/30 opacity-100 md:opacity-0 md:group-hover:opacity-100"}`,children:e&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function RKe(){const t=Qt(),{showToast:e}=Un(),[n]=vW(),r=n.get("folder"),i=r?parseInt(r,10):null,[a,o]=w.useState(i),[l,c]=w.useState([]),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[v,b]=w.useState(null),[y,M]=w.useState(null),[S,A]=w.useState(null),[E,k]=w.useState(null),[C,R]=w.useState(null),[T,P]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[F,I]=w.useState(""),[X,D]=w.useState("all"),[K,Y]=w.useState("date"),[q,Z]=w.useState("desc");w.useEffect(()=>{const ce=n.get("folder");if(ce){const xe=parseInt(ce,10);o(xe)}},[n]);const{data:re}=lt({queryKey:["settings"],queryFn:()=>pe.getSettings()}),{data:ie,isLoading:U}=lt({queryKey:["library-folders"],queryFn:()=>pe.getLibraryFolders()}),{data:G,isLoading:ee}=lt({queryKey:["library-files",a],queryFn:()=>pe.getLibraryFiles(a,a===null)}),{data:ne}=lt({queryKey:["library-stats"],queryFn:()=>pe.getLibraryStats()}),se=w.useMemo(()=>{if(!G)return[];const ce=new Set(G.map(xe=>xe.file_type));return Array.from(ce).sort()},[G]),de=w.useMemo(()=>{if(!G)return[];let ce=[...G];if(F.trim()){const xe=F.toLowerCase();ce=ce.filter(ve=>ve.filename.toLowerCase().includes(xe)||ve.print_name&&ve.print_name.toLowerCase().includes(xe))}return X!=="all"&&(ce=ce.filter(xe=>xe.file_type===X)),ce.sort((xe,ve)=>{let _e=0;switch(K){case"name":_e=(xe.print_name||xe.filename).localeCompare(ve.print_name||ve.filename);break;case"date":_e=new Date(xe.created_at).getTime()-new Date(ve.created_at).getTime();break;case"size":_e=xe.file_size-ve.file_size;break;case"type":_e=xe.file_type.localeCompare(ve.file_type);break;case"prints":_e=xe.print_count-ve.print_count;break}return q==="asc"?_e:-_e}),ce},[G,F,X,K,q]),he=w.useMemo(()=>{if(!ne||!re)return!1;const ce=(re.library_disk_warning_gb||5)*1024*1024*1024;return ne.disk_free_bytes<ce},[ne,re]),Ee=ft({mutationFn:ce=>pe.createLibraryFolder(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:ce=>e(ce.message,"error")}),ge=ft({mutationFn:ce=>pe.deleteLibraryFolder(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),a===y?.id&&o(null),M(null),e("Folder deleted","success")},onError:ce=>{M(null),e(ce.message,"error")}}),Ne=ft({mutationFn:ce=>pe.deleteLibraryFile(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(ce=>ce.filter(xe=>xe!==y?.id)),M(null),e("File deleted","success")},onError:ce=>{M(null),e(ce.message,"error")}}),Re=ft({mutationFn:({fileIds:ce,folderId:xe})=>pe.moveLibraryFiles(ce,xe),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:ce=>e(ce.message,"error")}),te=ft({mutationFn:({id:ce,data:xe})=>pe.updateLibraryFolder(ce,xe),onSuccess:(ce,xe)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),b(null);const ve=xe.data.project_id===0&&xe.data.archive_id===0;e(ve?"Folder unlinked":"Folder linked","success")},onError:ce=>e(ce.message,"error")}),Je=ft({mutationFn:ce=>pe.addLibraryFilesToQueue(ce),onSuccess:ce=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),ce.added.length>0&&ce.errors.length===0?e(`Added ${ce.added.length} file${ce.added.length>1?"s":""} to queue`,"success"):ce.added.length>0&&ce.errors.length>0?e(`Added ${ce.added.length} file${ce.added.length>1?"s":""}, ${ce.errors.length} failed`,"success"):e(`Failed to add files: ${ce.errors[0]?.error||"Unknown error"}`,"error")},onError:ce=>e(ce.message,"error")}),B=ft({mutationFn:({id:ce,filename:xe})=>pe.updateLibraryFile(ce,{filename:xe}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),R(null),e("File renamed","success")},onError:ce=>{R(null),e(ce.message,"error")}}),H=ft({mutationFn:({id:ce,name:xe})=>pe.updateLibraryFolder(ce,{name:xe}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),R(null),e("Folder renamed","success")},onError:ce=>{R(null),e(ce.message,"error")}}),W=w.useCallback(ce=>{const xe=ce.toLowerCase();return xe.endsWith(".gcode")||xe.includes(".gcode.")},[]),z=w.useMemo(()=>G?G.filter(ce=>l.includes(ce.id)&&W(ce.filename)):[],[G,l,W]),V=w.useCallback(ce=>{c(xe=>xe.includes(ce)?xe.filter(ve=>ve!==ce):[...xe,ce])},[]),Q=w.useCallback(()=>{de.length>0&&c(de.map(ce=>ce.id))},[de]),Te=w.useCallback(()=>{c([])},[]),ke=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},Ae=ce=>{window.open(pe.getLibraryFileDownloadUrl(ce),"_blank")},$=()=>{y&&(y.type==="file"?Ne.mutate(y.id):y.type==="folder"?ge.mutate(y.id):y.type==="bulk"&&pe.bulkDeleteLibrary(l,[]).then(()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${l.length} files`,"success"),c([]),M(null)}).catch(ce=>{e(ce.message,"error"),M(null)}))},L=ce=>{P(ce),localStorage.setItem("library-view-mode",ce)},oe=U||ee;return s.jsxs("div",{className:"p-4 md:p-8 h-[calc(100vh-64px)] flex flex-col",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(el,{className:"w-6 h-6 text-bambu-green"})}),"File Manager"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and manage your print files"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[s.jsx("button",{onClick:()=>L("grid"),className:`p-1.5 rounded transition-colors ${T==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:s.jsx(D2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>L("list"),className:`p-1.5 rounded transition-colors ${T==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:s.jsx(O2,{className:"w-4 h-4"})})]}),s.jsxs(Me,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(pue,{className:"w-4 h-4 mr-2"}),"New Folder"]}),s.jsxs(Me,{onClick:()=>x(!0),children:[s.jsx(bi,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),he&&ne&&re&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[s.jsx(En,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-500 font-medium",children:"Low disk space warning"}),s.jsxs("p",{className:"text-xs text-amber-500/80",children:["Only ",Ep(ne.disk_free_bytes)," free of ",Ep(ne.disk_total_bytes)," total. Threshold is set to ",re.library_disk_warning_gb," GB in settings."]})]})]}),ne&&s.jsxs("div",{className:"flex items-center gap-6 mb-6 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(C2,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-bambu-gray",children:"Files:"}),s.jsx("span",{className:"text-white font-medium",children:ne.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(el,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Folders:"}),s.jsx("span",{className:"text-white font-medium",children:ne.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(P2,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Size:"}),s.jsx("span",{className:"text-white font-medium",children:Ep(ne.total_size_bytes)})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm ml-auto",children:[s.jsx("span",{className:"text-bambu-gray",children:"Free:"}),s.jsx("span",{className:`font-medium ${he?"text-amber-500":"text-white"}`,children:Ep(ne.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex gap-6 min-h-0",children:[s.jsxs("div",{className:"w-64 flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex flex-col",children:[s.jsx("div",{className:"p-3 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-sm font-medium text-white",children:"Folders"})}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[s.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${a===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>o(null),children:[s.jsx(tf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),ie?.map(ce=>s.jsx(mre,{folder:ce,selectedFolderId:a,onSelect:o,onDelete:xe=>M({type:"folder",id:xe}),onLink:b,onRename:xe=>R({type:"folder",id:xe.id,name:xe.name})},ce.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[G&&G.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(Ws,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search files...",value:F,onChange:ce=>I(ce.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(k2,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("select",{value:X,onChange:ce=>D(ce.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"all",children:"All types"}),se.map(ce=>s.jsx("option",{value:ce,children:ce.toUpperCase()},ce))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:K,onChange:ce=>Y(ce.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"date",children:"Date"}),s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"size",children:"Size"}),s.jsx("option",{value:"type",children:"Type"}),s.jsx("option",{value:"prints",children:"Prints"})]}),s.jsx("button",{onClick:()=>Z(ce=>ce==="asc"?"desc":"asc"),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:q==="asc"?"Ascending":"Descending",children:q==="asc"?s.jsx(Xle,{className:"w-4 h-4 text-white"}):s.jsx(Hle,{className:"w-4 h-4 text-white"})})]}),(F||X!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[de.length," of ",G.length," files"]})]}),de.length>0&&s.jsxs("div",{className:"flex items-center gap-2 mb-4 p-2 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[l.length===de.length&&l.length>0?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Te,children:[s.jsx(Ol,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Q,children:[s.jsx(eu,{className:"w-4 h-4 mr-1"}),"Select All"]}),l.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-bambu-gray ml-2",children:[l.length," selected"]}),s.jsx("div",{className:"flex-1"}),z.length===1&&s.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>k(z[0]),children:[s.jsx(nl,{className:"w-4 h-4 mr-1"}),"Print"]}),z.length>0&&s.jsxs(Me,{variant:z.length===1?"secondary":"primary",size:"sm",onClick:()=>Je.mutate(z.map(ce=>ce.id)),disabled:Je.isPending,children:[s.jsx(Hn,{className:"w-4 h-4 mr-1"}),Je.isPending?"Adding...":`Add to Queue${z.length<l.length?` (${z.length})`:""}`]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[s.jsx(wde,{className:"w-4 h-4 mr-1"}),"Move"]}),s.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{l.length===1?M({type:"file",id:l[0]}):M({type:"bulk",id:0,count:l.length})},children:[s.jsx(Jt,{className:"w-4 h-4 mr-1"}),"Delete"]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Te,children:"Clear"})]})]}),oe?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):G?.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(tf,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:a!==null?"Folder is empty":"No files yet"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:a!==null?"Upload files or move files into this folder to get started.":"Upload files to start organizing your print-related files."}),s.jsxs(Me,{onClick:()=>x(!0),children:[s.jsx(qn,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):de.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(Ws,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No matching files"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:"No files match your current search or filter criteria."}),s.jsx(Me,{variant:"secondary",onClick:()=>{I(""),D("all")},children:"Clear filters"})]}):T==="grid"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:de.map(ce=>s.jsx(PKe,{file:ce,isSelected:l.includes(ce.id),onSelect:V,onDelete:xe=>M({type:"file",id:xe}),onDownload:Ae,onAddToQueue:xe=>Je.mutate([xe]),onPrint:A,onRename:xe=>R({type:"file",id:xe.id,name:xe.filename})},ce.id))})}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[s.jsxs("div",{className:"grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"w-6"}),s.jsx("div",{children:"Name"}),s.jsx("div",{children:"Type"}),s.jsx("div",{children:"Size"}),s.jsx("div",{children:"Prints"}),s.jsx("div",{})]}),de.map(ce=>s.jsxs("div",{className:`grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${l.includes(ce.id)?"bg-bambu-green/10":""}`,onClick:()=>V(ce.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(ce.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(ce.id)&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative group/thumb",children:[s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:ce.thumbnail_path?s.jsx("img",{src:pe.getLibraryFileThumbnailUrl(ce.id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(tf,{className:"w-5 h-5 text-bambu-gray/50"})})}),ce.thumbnail_path&&s.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:s.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:s.jsx("img",{src:pe.getLibraryFileThumbnailUrl(ce.id),alt:ce.filename,className:"w-full h-full object-contain"})})})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm text-white truncate",children:ce.print_name||ce.filename}),ce.duplicate_count>0&&s.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-400",children:[s.jsx(Gs,{className:"w-3 h-3"}),ce.duplicate_count," duplicate(s)"]})]})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${ce.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":ce.file_type==="gcode"?"bg-blue-500/20 text-blue-400":ce.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:ce.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:Ep(ce.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:ce.print_count>0?`${ce.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:xe=>xe.stopPropagation(),children:[FR(ce.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>A(ce),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Print",children:s.jsx(Ir,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Je.mutate([ce.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Add to Queue",disabled:Je.isPending,children:s.jsx(Hn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>Ae(ce.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Download",children:s.jsx(Jr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>R({type:"file",id:ce.id,name:ce.filename}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename",children:s.jsx(Ha,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>M({type:"file",id:ce.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:s.jsx(Jt,{className:"w-4 h-4"})})]})]},ce.id))]})})]})]}),u&&s.jsx(AKe,{parentId:a,onClose:()=>d(!1),onSave:ce=>Ee.mutate(ce),isLoading:Ee.isPending}),f&&ie&&s.jsx(CKe,{folders:ie,selectedFiles:l,currentFolderId:a,onClose:()=>m(!1),onMove:ce=>Re.mutate({fileIds:l,folderId:ce}),isLoading:Re.isPending}),p&&s.jsx(jKe,{folderId:a,onClose:()=>x(!1),onUploadComplete:ke}),v&&s.jsx(kKe,{folder:v,onClose:()=>b(null),onLink:ce=>te.mutate({id:v.id,data:ce}),isLoading:te.isPending}),y&&s.jsx(Rn,{title:y.type==="folder"?"Delete Folder":y.type==="bulk"?`Delete ${y.count} Files`:"Delete File",message:y.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":y.type==="bulk"?`Are you sure you want to delete ${y.count} selected files? This action cannot be undone.`:"Are you sure you want to delete this file?",confirmText:"Delete",variant:"danger",onConfirm:$,onCancel:()=>M(null)}),S&&s.jsx(Wd,{mode:"reprint",libraryFileId:S.id,archiveName:S.print_name||S.filename,onClose:()=>A(null),onSuccess:()=>{A(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),E&&s.jsx(Wd,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>k(null),onSuccess:()=>{k(null),c([]),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),C&&s.jsx(TKe,{type:C.type,currentName:C.name,onClose:()=>R(null),onSave:ce=>{C.type==="file"?B.mutate({id:C.id,filename:ce}):H.mutate({id:C.id,name:ce})},isLoading:B.isPending||H.isPending})]})}const _j=5,DKe=2e3,OKe=3e4,LKe=5e3;function IKe(){const{printerId:t}=HR(),e=parseInt(t||"0",10),[n,r]=w.useState("stream"),[i,a]=w.useState(!1),[o,l]=w.useState(!0),[c,u]=w.useState(Date.now()),[d,f]=w.useState(!1),[m,p]=w.useState(!1),[x,v]=w.useState(0),[b,y]=w.useState(!1),[M,S]=w.useState(0),A=w.useRef(null),E=w.useRef(null),k=w.useRef(null),C=w.useRef(null),R=w.useRef(null),{data:T}=lt({queryKey:["printer",e],queryFn:()=>pe.getPrinter(e),enabled:e>0});w.useEffect(()=>(T&&(document.title=`${T.name} - Camera`),()=>{document.title="Bambuddy"}),[T]);const P=w.useRef(!1);w.useEffect(()=>{const ie=`/api/v1/printers/${e}/camera/stop`;P.current=!1;const U=()=>{e>0&&!P.current&&(P.current=!0,navigator.sendBeacon(ie))},G=()=>{U()};window.addEventListener("beforeunload",G);const ee=A.current;return()=>{window.removeEventListener("beforeunload",G),ee&&(ee.src=""),U()}},[e]),w.useEffect(()=>{if(o&&!d){const U=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(U)}},[n,o,c,d]),w.useEffect(()=>{const ie=()=>{const U=!!document.fullscreenElement;p(U),n==="stream"&&!d&&(A.current&&(A.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",ie),()=>document.removeEventListener("fullscreenchange",ie)},[n,d]),w.useEffect(()=>{let ie;const U=()=>{clearTimeout(ie),ie=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",U),()=>{clearTimeout(ie),window.removeEventListener("resize",U)}},[]),w.useEffect(()=>()=>{k.current&&clearTimeout(k.current),C.current&&clearInterval(C.current),R.current&&clearInterval(R.current)},[]);const F=w.useCallback(()=>{if(x>=_j){y(!1),a(!0);return}const ie=Math.min(DKe*Math.pow(2,x),OKe);y(!0),S(Math.ceil(ie/1e3)),C.current=setInterval(()=>{S(U=>U<=1?(C.current&&clearInterval(C.current),0):U-1)},1e3),k.current=setTimeout(()=>{v(U=>U+1),y(!1),l(!0),a(!1),A.current&&(A.current.src=""),u(Date.now())},ie)},[x]);w.useEffect(()=>{if(n!=="stream"||o||b||d){R.current&&(clearInterval(R.current),R.current=null);return}return R.current=setInterval(async()=>{try{const ie=await fetch(`/api/v1/printers/${e}/camera/status`);if(ie.ok){const U=await ie.json();(U.stalled||!U.active&&!i)&&(console.log(`Stream issue detected: stalled=${U.stalled}, active=${U.active}, reconnecting...`),R.current&&(clearInterval(R.current),R.current=null),l(!1),F())}}catch{}},LKe),()=>{R.current&&(clearInterval(R.current),R.current=null)}},[n,o,i,b,d,e,F]);const I=()=>{l(!1),n==="stream"&&x<_j?F():a(!0)},X=()=>{if(l(!1),a(!1),v(0),y(!1),k.current&&clearTimeout(k.current),C.current&&clearInterval(C.current),A.current&&!localStorage.getItem("cameraWindowState")){const ie=A.current,U=ie.naturalWidth,G=ie.naturalHeight;if(U>0&&G>0){const se=window.outerWidth-window.innerWidth,de=window.outerHeight-window.innerHeight,he=U+16+se,Ee=G+45+16+de;try{window.resizeTo(he,Ee)}catch{}}}},D=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},K=ie=>{n===ie||d||(f(!0),l(!0),a(!1),v(0),y(!1),k.current&&clearTimeout(k.current),C.current&&clearInterval(C.current),A.current&&(A.current.src=""),n==="stream"&&D(),setTimeout(()=>{r(ie),u(Date.now()),f(!1)},100))},Y=()=>{d||(f(!0),l(!0),a(!1),v(0),y(!1),k.current&&clearTimeout(k.current),C.current&&clearInterval(C.current),A.current&&(A.current.src=""),n==="stream"&&D(),setTimeout(()=>{u(Date.now()),f(!1)},100))},q=()=>{E.current&&(document.fullscreenElement?document.exitFullscreen():E.current.requestFullscreen())},Z=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,re=o||d||b;return e?s.jsxs("div",{ref:E,className:"min-h-screen bg-black flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[s.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(Xp,{className:"w-4 h-4"}),T?.name||`Printer ${e}`]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[s.jsx("button",{onClick:()=>K("stream"),disabled:re,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),s.jsx("button",{onClick:()=>K("snapshot"),disabled:re,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),s.jsx("button",{onClick:Y,disabled:re,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(yr,{className:`w-4 h-4 text-bambu-gray ${re?"animate-spin":""}`})}),s.jsx("button",{onClick:q,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?s.jsx(gde,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(cde,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(yr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Pg,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",M,"s... (attempt ",x+1,"/",_j,")"]}),s.jsx("button",{onClick:Y,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(En,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),s.jsx("button",{onClick:Y,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:A,src:Z,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:Z?I:void 0,onLoad:Z?X:void 0},c)]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function FKe(){const{id:t}=HR(),{mode:e}=Xd(),{data:n,isLoading:r,error:i}=lt({queryKey:["external-link",t],queryFn:()=>pe.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[s.jsx(En,{className:"w-12 h-12"}),s.jsx("p",{children:"Link not found"})]}):s.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const qG=["DEBUG","INFO","WARNING","ERROR"],wj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},UKe={DEBUG:N2,INFO:Rl,WARNING:En,ERROR:ea};function zKe(){const t=Qt(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[a,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[f,m]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:v,refetch:b}=lt({queryKey:["application-logs",l,a],queryFn:()=>Op.getLogs({limit:200,level:l==="ALL"?void 0:l,search:a||void 0}),refetchInterval:f?2e3:!1,enabled:u});w.useEffect(()=>{u||m(!1)},[u]);const y=ft({mutationFn:()=>Op.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const M=C=>{i(R=>{const T=new Set(R);return T.has(C)?T.delete(C):T.add(C),T})},S=C=>{const R=C.split(" ");return R.length>=2?R[1]:C},A=w.useMemo(()=>x?.entries??[],[x?.entries]),E=w.useMemo(()=>[...A].reverse(),[A]),k=({level:C})=>{const R=UKe[C]||Rl;return s.jsx(R,{className:`w-3.5 h-3.5 ${wj[C]||"text-gray-400"}`})};return s.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(N2,{className:"w-5 h-5"})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?s.jsx(Jc,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Ji,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f?s.jsxs("button",{onClick:C=>{C.stopPropagation(),m(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[s.jsx(Ol,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:C=>{C.stopPropagation(),m(!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:[s.jsx(nl,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>y.mutate(),disabled:y.isPending||A.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[s.jsx(Jt,{className:"w-4 h-4"}),"Clear"]}),s.jsx("button",{onClick:()=>b(),disabled:v,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:s.jsx(yr,{className:`w-4 h-4 ${v?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:C=>n(C.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ws,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:a,onChange:C=>o(C.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),a&&s.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Ut,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),qG.map((C,R)=>s.jsx("button",{onClick:()=>c(C),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${R===qG.length-1?"rounded-r":""} ${l===C?`${wj[C]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:C},C))]})]})]}),s.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:A.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No log entries found"}),s.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:E.map((C,R)=>{const T=r.has(R),P=C.message.includes(`
  8291. `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${T?"bg-bambu-dark-secondary/30":""}`,onClick:()=>P&&M(R),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:S(C.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(k,{level:C.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:C.logger_name,children:["[",C.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${wj[C.level]||"text-white/80"} ${!T&&P?"truncate":""}`,children:T?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:C.message}):C.message.split(`
  8292. `)[0]}),P&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:T?s.jsx(Jc,{className:"w-3.5 h-3.5"}):s.jsx(Ji,{className:"w-3.5 h-3.5"})})]})},R)})})}),s.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):s.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function BKe(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 qr({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return s.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function KG({percent:t,color:e="bg-bambu-green"}){return s.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function ed({title:t,icon:e,children:n}){return s.jsxs(wt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(e,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function $Ke(){const{t}=Tg(),e=Qt(),[n,r]=w.useState(null),[i,a]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=lt({queryKey:["systemInfo"],queryFn:pe.getSystemInfo,refetchInterval:3e4}),{data:m}=lt({queryKey:["debugLogging"],queryFn:Op.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=lt({queryKey:["settings"],queryFn:pe.getSettings}),{data:x}=lt({queryKey:["library-stats"],queryFn:pe.getLibraryStats}),v=p?.time_format||"system",b=async()=>{l(!0);try{const A=await Op.setDebugLogging(!m?.enabled);e.setQueryData(["debugLogging"],A)}catch(A){console.error("Failed to toggle debug logging:",A)}finally{l(!1)}},y=async()=>{r(null),a(!0);try{await Op.downloadSupportBundle()}catch(A){r(A instanceof Error?A.message:"Failed to download support bundle")}finally{a(!1)}};if(u)return s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return s.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const M=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",S=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),s.jsxs("button",{onClick:()=>d(),disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[s.jsx(yr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(ed,{title:t("system.application","Application"),icon:jh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(qr,{icon:jh,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(qr,{icon:Hn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(qr,{icon:jh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(ed,{title:t("support.title","Support & Troubleshooting"),icon:Pue,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${m?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(N2,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[m?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),m?.enabled&&m.duration_seconds!==null&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(m.duration_seconds/60),"m ",m.duration_seconds%60,"s)"]})]})]})]}),s.jsxs("button",{onClick:b,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${m?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&s.jsx(pt,{className:"w-4 h-4 animate-spin"}),m?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:s.jsx(Jr,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),s.jsxs("button",{onClick:y,disabled:i||!m?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:m?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&s.jsx(pt,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!m?.enabled&&s.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-bambu-gray",children:[s.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),s.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),s.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),s.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),s.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),s.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),s.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),s.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),s.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),s.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),s.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),s.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),s.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),s.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),s.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]}),s.jsx(zKe,{})]})}),s.jsxs(ed,{title:t("system.database","Database"),icon:Yp,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(qr,{icon:Is,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(qr,{icon:E2,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(qr,{icon:qi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(qr,{icon:pt,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(qr,{icon:Ir,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(qr,{icon:nD,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(qr,{icon:xa,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(qr,{icon:Fs,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[s.jsx(qr,{icon:Hn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(qr,{icon:Is,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(ed,{title:t("system.connectedPrinters","Connected Printers"),icon:Ir,children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),s.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?s.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(A=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),s.jsx("span",{className:"font-medium text-white",children:A.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:A.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${A.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":A.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:A.state})]})]},A.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(ed,{title:t("system.storage","Storage"),icon:P2,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),s.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),s.jsx(KG,{percent:c.storage.disk_percent_used,color:M}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(qr,{icon:Is,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(qr,{icon:Yp,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&s.jsx(qr,{icon:el,label:t("system.fileManagerStorage","File Manager"),value:BKe(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsx(ed,{title:t("system.memory","Memory"),icon:dde,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),s.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),s.jsx(KG,{percent:c.memory.percent_used,color:S}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(ed,{title:t("system.cpu","CPU"),icon:Xv,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(qr,{icon:Xv,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(qr,{icon:Xv,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(ed,{title:t("system.systemDetails","System Details"),icon:jh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(qr,{icon:jh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(qr,{icon:Xv,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(qr,{icon:jh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(qr,{icon:Hn,label:t("system.bootTime","Boot Time"),value:eg(c.system.boot_time,v)})]})})]})}function HKe(){const t=sl(),{login:e}=Vf(),{showToast:n}=Un(),{mode:r}=Xd(),[i,a]=w.useState(""),[o,l]=w.useState(""),c=ft({mutationFn:()=>e(i,o),onSuccess:()=>{n("Logged in successfully"),t("/")},onError:d=>{n(d.message||"Login failed","error")}}),u=d=>{if(d.preventDefault(),!i||!o){n("Please enter username and password","error");return}c.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Login"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Sign in to your account"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:u,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:"Username"}),s.jsx("input",{id:"username",type:"text",required:!0,value:i,onChange:d=>a(d.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:"Password"}),s.jsx("input",{id:"password",type:"password",required:!0,value:o,onChange:d=>l(d.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your password",autoComplete:"current-password"})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:c.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:c.isPending?"Logging in...":"Sign in"})})]})]})})}function VKe(){const t=sl(),{showToast:e}=Un(),{mode:n}=Xd(),[r,i]=w.useState(!1),[a,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(""),f=ft({mutationFn:()=>pe.setupAuth({auth_enabled:r,admin_username:r?a:void 0,admin_password:r?l:void 0}),onSuccess:p=>{p.auth_enabled&&p.admin_created?(e("Authentication enabled and admin user created"),t("/login")):(e("Setup completed"),t("/"))},onError:p=>{e(p.message,"error")}}),m=p=>{if(p.preventDefault(),r){if(!a||!l){e("Please enter admin username and password","error");return}if(l!==u){e("Passwords do not match","error");return}if(l.length<6){e("Password must be at least 6 characters","error");return}}f.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Setup"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Configure authentication for your Bambuddy instance"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:m,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("input",{id:"auth-enabled",type:"checkbox",checked:r,onChange:p=>i(p.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),s.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:"Enable Authentication"})]}),r&&s.jsxs("div",{className:"space-y-4 mt-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:"Admin Username"}),s.jsx("input",{id:"admin-username",type:"text",required:!0,value:a,onChange:p=>o(p.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:"Admin Password"}),s.jsx("input",{id:"admin-password",type:"password",required:!0,value:l,onChange:p=>c(p.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin password",minLength:6,autoComplete:"new-password"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),s.jsx("input",{id:"confirm-password",type:"password",required:!0,value:u,onChange:p=>d(p.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Confirm admin password",minLength:6,autoComplete:"new-password"})]})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:f.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:f.isPending?"Setting up...":"Complete Setup"})})]})]})})}function GKe(){const t=sl(),{user:e}=Vf(),{showToast:n}=Un(),r=Qt(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(null),[d,f]=w.useState({username:"",password:"",role:"user"});w.useEffect(()=>{const E=k=>{k.key==="Escape"&&i&&(a(!1),f({username:"",password:"",role:"user"}))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]);const{data:m=[],isLoading:p}=lt({queryKey:["users"],queryFn:()=>pe.getUsers()}),x=ft({mutationFn:E=>pe.createUser(E),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),a(!1),f({username:"",password:"",role:"user"}),n("User created successfully")},onError:E=>{n(E.message,"error")}}),v=ft({mutationFn:({id:E,data:k})=>pe.updateUser(E,k),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),l(null),f({username:"",password:"",role:"user"}),n("User updated successfully")},onError:E=>{n(E.message,"error")}}),b=ft({mutationFn:E=>pe.deleteUser(E),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),n("User deleted successfully")},onError:E=>{n(E.message,"error")}}),y=()=>{if(!d.username||!d.password){n("Please fill in all required fields","error");return}x.mutate(d)},M=E=>{const k={username:d.username||void 0,password:d.password||void 0,role:d.role};k.password||delete k.password,v.mutate({id:E,data:k})},S=E=>{u(E)},A=E=>{l(E.id),f({username:E.username,password:"",role:E.role})};return e?.role!=="admin"?s.jsx("div",{className:"p-6",children:s.jsx(wt,{children:s.jsx(Mt,{className:"py-6",children:s.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[s.jsx(P1,{className:"w-5 h-5"}),s.jsx("p",{className:"text-white",children:"You do not have permission to access this page."})]})})})}):s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>t("/settings?tab=users"),className:"p-2 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Back to Settings",children:s.jsx(UW,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Gh,{className:"w-6 h-6 text-bambu-green"}),"User Management"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Manage users and their access to your Bambuddy instance"})]})]}),s.jsxs(Me,{onClick:()=>{a(!0),f({username:"",password:"",role:"user"})},children:[s.jsx(qn,{className:"w-4 h-4"}),"Create User"]})]}),p?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsx(wt,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-bambu-dark-tertiary",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Username"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Role"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Status"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Actions"})]})}),s.jsx("tbody",{className:"divide-y divide-bambu-dark-tertiary",children:m.map(E=>s.jsxs("tr",{className:"hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-white",children:o===E.id?s.jsx("input",{type:"text",value:d.username,onChange:k=>f({...d,username:k.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green"}):E.username}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:o===E.id?s.jsxs("select",{value:d.role,onChange:k=>f({...d,role:k.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green",children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]}):s.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${E.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:E.role})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:s.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${E.is_active?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:E.is_active?"Active":"Inactive"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:o===E.id?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",onClick:()=>M(E.id),disabled:v.isPending,children:[v.isPending?s.jsx(pt,{className:"w-4 h-4 animate-spin"}):s.jsx(cs,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{l(null),f({username:"",password:"",role:"user"})},children:"Cancel"})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>A(E),children:[s.jsx(L2,{className:"w-4 h-4"}),"Edit"]}),E.id!==e?.id&&s.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>S(E.id),children:[s.jsx(Jt,{className:"w-4 h-4"}),"Delete"]})]})})]},E.id))})]})})}),i&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsxs(wt,{className:"w-full max-w-md",onClick:E=>E.stopPropagation(),children:[s.jsx(mr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Gh,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsx(Ut,{className:"w-5 h-5"})})]})}),s.jsxs(Mt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Username"}),s.jsx("input",{type:"text",value:d.username,onChange:E=>f({...d,username:E.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Password"}),s.jsx("input",{type:"password",value:d.password,onChange:E=>f({...d,password:E.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter password",autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Role"}),s.jsxs("select",{value:d.role,onChange:E=>f({...d,role:E.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:"Cancel"}),s.jsx(Me,{onClick:y,disabled:x.isPending||!d.username||!d.password,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(qn,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),c!==null&&s.jsx(Rn,{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirmText:"Delete User",variant:"danger",onConfirm:()=>{b.mutate(c),u(null)},onCancel:()=>u(null)})]})}function WKe(){const t=w.useRef(null),e=w.useRef(null),n=Qt(),[r,i]=w.useState(!1),a=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),f=w.useRef(()=>{}),m=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const M=()=>{const S=u.current.shift();S?requestAnimationFrame(()=>{f.current(S),u.current.length>0?setTimeout(M,16):d.current=!1}):d.current=!1};M()},[]),p=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const S=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,A=new WebSocket(S);let E=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),E=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=k=>{try{const C=JSON.parse(k.data);C.type==="printer_status"&&C.printer_id!==void 0&&C.data?f.current(C):(u.current.push(C),m())}catch{}},A.onclose=k=>{console.log("[WebSocket] Closed",k.code,k.reason),E&&(clearInterval(E),E=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},A.onerror=k=>{console.error("[WebSocket] Error",k),A.close()},t.current=A},[m]),x=w.useCallback((M,S)=>{const A=l.current.get(M)||{};l.current.set(M,{...A,...S}),c.current||(c.current=window.setTimeout(()=>{const E=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{E.forEach((k,C)=>{n.setQueryData(["printerStatus",C],R=>{const T={...R,...k};return T.wifi_signal==null&&R?.wifi_signal!=null&&(T.wifi_signal=R.wifi_signal),T})})})},100))},[n]),v=w.useCallback(M=>{a.current.add(M),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const S=Array.from(a.current);a.current.clear(),o.current=null;let A=0;S.forEach(E=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[E]})})},A),A+=500})},3e3)},[n]),b=w.useCallback(M=>{switch(M.type){case"printer_status":M.printer_id!==void 0&&M.data&&x(M.printer_id,M.data);break;case"print_start":M.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",M.printer_id]});break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break}},[n,v,x]);w.useEffect(()=>{f.current=b},[b]),w.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const y=w.useCallback(M=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(M))},[]);return{isConnected:r,sendMessage:y}}const qKe=new Tle({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function KKe({children:t}){return WKe(),s.jsx(s.Fragment,{children:t})}function XKe({children:t}){const{authEnabled:e,loading:n,user:r}=Vf();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(ow,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function YKe({children:t}){const{authEnabled:e,loading:n,user:r}=Vf();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?s.jsx(ow,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:t}):s.jsx(ow,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function QKe({children:t}){const{authEnabled:e,loading:n}=Vf();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(ow,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function ZKe(){return s.jsx(Yhe,{children:s.jsx(cfe,{children:s.jsx(Cle,{client:qKe,children:s.jsx(tfe,{children:s.jsx(Xoe,{children:s.jsxs(Noe,{children:[s.jsx($i,{path:"/setup",element:s.jsx(QKe,{children:s.jsx(VKe,{})})}),s.jsx($i,{path:"/login",element:s.jsx(HKe,{})}),s.jsx($i,{path:"/camera/:printerId",element:s.jsx(IKe,{})}),s.jsxs($i,{element:s.jsx(XKe,{children:s.jsx(KKe,{children:s.jsx(afe,{})})}),children:[s.jsx($i,{index:!0,element:s.jsx(Vke,{})}),s.jsx($i,{path:"archives",element:s.jsx(PGe,{})}),s.jsx($i,{path:"queue",element:s.jsx(gqe,{})}),s.jsx($i,{path:"stats",element:s.jsx(kqe,{})}),s.jsx($i,{path:"profiles",element:s.jsx(dKe,{})}),s.jsx($i,{path:"maintenance",element:s.jsx(gKe,{})}),s.jsx($i,{path:"projects",element:s.jsx(bKe,{})}),s.jsx($i,{path:"projects/:id",element:s.jsx(NKe,{})}),s.jsx($i,{path:"files",element:s.jsx(RKe,{})}),s.jsx($i,{path:"settings",element:s.jsx(YKe,{children:s.jsx(eKe,{})})}),s.jsx($i,{path:"users",element:s.jsx(GKe,{})}),s.jsx($i,{path:"system",element:s.jsx($Ke,{})}),s.jsx($i,{path:"external/:id",element:s.jsx(FKe,{})})]})]})})})})})})}Cae.createRoot(document.getElementById("root")).render(s.jsx(w.StrictMode,{children:s.jsx(ZKe,{})}));